A virtual music player for TGE
by Robert Geiman · 12/28/2005 (2:47 pm) · 8 comments
First, let me say, "Wohoo, my first blog ever"! I've stayed away from doing blogs in the past, as I didn't want to write anything unless I truely had something interesting to say. I'm hoping this is the case today. ;)
My current game has stalled as both people involved, myself and a friend, haven't had the free time needed to keep the project moving forward (haven't we all heard that before). I had only been working with TGE for 2 months, but since my current game project was stalled I decided to take the time and give back to a community who has been so helpful (and patient) with me when I was trying to wrap my head around the beast that is TGE.
Despite my limited time working with Torque I wrote a few resources that, while relatively simple, were quite well received (one of them even found its way into Marble Blast Ultra):
Auto Scrolling Container Control
Generic Bar Hud Control
Add pausing and seeking of audio
Now that I have a few resources under my belt, I decided I'm familiar and confident enough with TGE to write a more advanced resource. While I'm a fairly good programmer I'm not near familar enough with 3D engines yet to make anything groundbreaking, ala John Kabus. However, with the work I've done on my game, as well as on my resources, I've gotten somewhat familar with the audio code in TGE, and I realized something: default support for music in TGE is fairly minimal, to say the least. It consists of playing, stopping, looping, and volume control. While this suffices for most sounds in a game, we all know it just doesn't cut it for music. We've all had to manually implement features commonly used for playing music in games, such as fading, transitioning between songs, randomly playing songs, etc. Too much time has been duplicated in implementing these features for games using TGE. So I've decided to change that.
For the past week I've been working on a new resource I plan on releasing soon. It's tentively called VMPlayer (Virtual Music Player). Simply put, it's a script only resource that adds some advanced music playing capabilities to the Torque Gaming Engine. To be more precise, think of it as a media player with no GUI, that's made specifically for playing music in your games.
The reason I'm posting this blog is to not only gauge the interest in this resource, but to also see if anyone has any other features they would like to add before it's released. Here's the feature list that VMPlayer currently consists of:
Common music player features - VMPlayer includes the commonly used features you would expect from any music player, such as play, pause, stop, rewind, fastforward, skip tracks, etc.
Playlists - Create multiple playlists and add as many songs as you like to each playlist. Playlists are perfect for grouping similar songs together, whether they are grouped based on game level/map, grouped by the mood of the songs, etc. For instance, an RPG could load and play an "eerie" playlist when the player enters a dungeon and an "upbeat" playlist when the user enters a town.
Random - Randomly play tracks in your playlist. A great way to mix things up.
Repeat - Repeat the same song infinately or repeat entire playlists.
Fading - VMPlayer can automatically fade songs in when they start and fade them out as they end. No more abrupt music stoppages that make a game sound unprofessional.
Transitioning - Transitioning allows you to smoothly transition from one song to another by fading out the current song while simultaneously fading in the next song. This is perfect for those games where you want the background music to dynamically change based when what is currently happening in your game.
Modify song lengths - This handy feature allows you to modify the playing length of any song in your playlist. This is useful for those songs which have that extra 5 seconds of white noise at the end which you don't want to hear. This feature can also be used to ADD silence to the end of your song to ensure there is a sufficient pause between track changes.
Synchronize your game with your music - Ever notice how background music in movies perfectly match events in the movie? VMPlayer gives the programmer this same ability by automatically calling user-specified functions at user-defined points in a song. This could allow you to flash a bolt of lightning in front of the player exactly when your background music hits its cresendo, or spawn a monster directly behind the player when your music is especially scary.
Let the player control the music - Imagine being able to enable players of your FPS game to modify and create their OWN playlists and play their OWN music in your game while they play. VMPlayer is built with all the features you need to do this, including saving/reading of custom playlists to/from disk. All you need to do is develop the user interface for the user!
Easy to use - Despite all the features of VMPlayer, it's actually very easy to use. In fact, it's faster to add new songs to your game and play them using VMPlayer than it is to do so using TGE without VMPlayer. It's literally as simple as placing the new song file in your data directory and calling VMPlayer.PlaySong(filename). No need to ever create AudioProfiles or AudioDescriptions, as VMPlayer handles that for you.
The feature list is actually slightly larger, but the list above covers all the major features. As of today, I actually have implemented every single one of the features listed above, with the sole exception of transitions. Transitions themselves are easy enough to implement, but I've realized I need to tweak the design of VMPlayer slightly to add transitioning without using aweful hacks to shoe-horn it in.
As it is, I could complete this resource in another 2 or 3 days, at which point I'd need to take a few days to run some unit tests to verify everything is working and to fix any bugs that may have slipped past me the first time. But I'll be on a business trip all next week so won't be releasing this resource 'till after I get back the week after.
Since it'll be another two weeks before I will be releasing this, there's plenty of time too add any other features you guys think may be useful. So if you have any additional features you'd like me to include please post them below. Or feel free to give a shout if you think this resource may be useful to you. Or you can just tell me to shut the hell up if I just wasted 10 minutes of your lives. ;)
Rob Geiman
My current game has stalled as both people involved, myself and a friend, haven't had the free time needed to keep the project moving forward (haven't we all heard that before). I had only been working with TGE for 2 months, but since my current game project was stalled I decided to take the time and give back to a community who has been so helpful (and patient) with me when I was trying to wrap my head around the beast that is TGE.
Despite my limited time working with Torque I wrote a few resources that, while relatively simple, were quite well received (one of them even found its way into Marble Blast Ultra):
Auto Scrolling Container Control
Generic Bar Hud Control
Add pausing and seeking of audio
Now that I have a few resources under my belt, I decided I'm familiar and confident enough with TGE to write a more advanced resource. While I'm a fairly good programmer I'm not near familar enough with 3D engines yet to make anything groundbreaking, ala John Kabus. However, with the work I've done on my game, as well as on my resources, I've gotten somewhat familar with the audio code in TGE, and I realized something: default support for music in TGE is fairly minimal, to say the least. It consists of playing, stopping, looping, and volume control. While this suffices for most sounds in a game, we all know it just doesn't cut it for music. We've all had to manually implement features commonly used for playing music in games, such as fading, transitioning between songs, randomly playing songs, etc. Too much time has been duplicated in implementing these features for games using TGE. So I've decided to change that.
For the past week I've been working on a new resource I plan on releasing soon. It's tentively called VMPlayer (Virtual Music Player). Simply put, it's a script only resource that adds some advanced music playing capabilities to the Torque Gaming Engine. To be more precise, think of it as a media player with no GUI, that's made specifically for playing music in your games.
The reason I'm posting this blog is to not only gauge the interest in this resource, but to also see if anyone has any other features they would like to add before it's released. Here's the feature list that VMPlayer currently consists of:
Common music player features - VMPlayer includes the commonly used features you would expect from any music player, such as play, pause, stop, rewind, fastforward, skip tracks, etc.
Playlists - Create multiple playlists and add as many songs as you like to each playlist. Playlists are perfect for grouping similar songs together, whether they are grouped based on game level/map, grouped by the mood of the songs, etc. For instance, an RPG could load and play an "eerie" playlist when the player enters a dungeon and an "upbeat" playlist when the user enters a town.
Random - Randomly play tracks in your playlist. A great way to mix things up.
Repeat - Repeat the same song infinately or repeat entire playlists.
Fading - VMPlayer can automatically fade songs in when they start and fade them out as they end. No more abrupt music stoppages that make a game sound unprofessional.
Transitioning - Transitioning allows you to smoothly transition from one song to another by fading out the current song while simultaneously fading in the next song. This is perfect for those games where you want the background music to dynamically change based when what is currently happening in your game.
Modify song lengths - This handy feature allows you to modify the playing length of any song in your playlist. This is useful for those songs which have that extra 5 seconds of white noise at the end which you don't want to hear. This feature can also be used to ADD silence to the end of your song to ensure there is a sufficient pause between track changes.
Synchronize your game with your music - Ever notice how background music in movies perfectly match events in the movie? VMPlayer gives the programmer this same ability by automatically calling user-specified functions at user-defined points in a song. This could allow you to flash a bolt of lightning in front of the player exactly when your background music hits its cresendo, or spawn a monster directly behind the player when your music is especially scary.
Let the player control the music - Imagine being able to enable players of your FPS game to modify and create their OWN playlists and play their OWN music in your game while they play. VMPlayer is built with all the features you need to do this, including saving/reading of custom playlists to/from disk. All you need to do is develop the user interface for the user!
Easy to use - Despite all the features of VMPlayer, it's actually very easy to use. In fact, it's faster to add new songs to your game and play them using VMPlayer than it is to do so using TGE without VMPlayer. It's literally as simple as placing the new song file in your data directory and calling VMPlayer.PlaySong(filename). No need to ever create AudioProfiles or AudioDescriptions, as VMPlayer handles that for you.
The feature list is actually slightly larger, but the list above covers all the major features. As of today, I actually have implemented every single one of the features listed above, with the sole exception of transitions. Transitions themselves are easy enough to implement, but I've realized I need to tweak the design of VMPlayer slightly to add transitioning without using aweful hacks to shoe-horn it in.
As it is, I could complete this resource in another 2 or 3 days, at which point I'd need to take a few days to run some unit tests to verify everything is working and to fix any bugs that may have slipped past me the first time. But I'll be on a business trip all next week so won't be releasing this resource 'till after I get back the week after.
Since it'll be another two weeks before I will be releasing this, there's plenty of time too add any other features you guys think may be useful. So if you have any additional features you'd like me to include please post them below. Or feel free to give a shout if you think this resource may be useful to you. Or you can just tell me to shut the hell up if I just wasted 10 minutes of your lives. ;)
Rob Geiman
#2
12/28/2005 (3:45 pm)
sounds really nice... Looking forward to get it in our project and start making hard beta-tests of this.
#3
12/28/2005 (5:42 pm)
Sounds like a good resource - I'm interested. About the repeating of songs - can you have a song that loops back to a point in the middle of a song (for skipping intros). Or perhaps a playlist that is two songs long, and the second one repeats (not the whole list)?
#4
So to do what you want, you would have a playlist that contains one song that plays completely and is set to repeat. You could then tell VMPlayer to execute a user-defined function when the end of the song gets played. This function would simply tell VMPlayer to change the starting point of that song to the 38 second mark. This way whenever it repeats it will skip that 38 second intro.
Thanks for the suggestion, I'll make sure VMPlayer allows user-defined starting points so you can do what you described above.
12/28/2005 (8:50 pm)
Jaimi, that's not a bad idea. Currently VMPlayer allows you to choose a different ending time, but not a different starting time. If I added the ability to choose a different starting time, then you could add a song but have VMPlayer only play a user-defined section of that song.So to do what you want, you would have a playlist that contains one song that plays completely and is set to repeat. You could then tell VMPlayer to execute a user-defined function when the end of the song gets played. This function would simply tell VMPlayer to change the starting point of that song to the 38 second mark. This way whenever it repeats it will skip that 38 second intro.
Thanks for the suggestion, I'll make sure VMPlayer allows user-defined starting points so you can do what you described above.
#5
I'd love to talk with you about improving Torque's music playback functionality. Can you drop me an e-mail? beng AT garagegames DOT com.
Ben
12/29/2005 (12:22 am)
Robert,I'd love to talk with you about improving Torque's music playback functionality. Can you drop me an e-mail? beng AT garagegames DOT com.
Ben
#6
I've yet to add the full basic details.
Toby.
12/29/2005 (1:39 am)
I started the audio section on TDN, but if you want to help out, then please go ahead! :PI've yet to add the full basic details.
Toby.
#7
12/29/2005 (3:09 am)
Fanastic. This is a feature always missing in TGE.
#8
I appreciate your efforts, if you decide to release your work.
Thanks, John.
12/29/2005 (11:46 am)
Music if very important to immersion. Being that I am fairly new, Im surprised this hasnt been done in the 4 or so years of people making games.I appreciate your efforts, if you decide to release your work.
Thanks, John.
Torque 3D Owner Rubes