iTGB 1.2 and MP3
by Americo Amorim · in iTorque 2D · 05/12/2009 (1:55 pm) · 18 replies
Hey Guys,
I am developing a kind of rhythm game, this way it plays a lot of audio content, and I need a very fast response from the audio system.
I was very excited when I received the news about mp3 audio feature at iTGB 1.2, since my game size in disk would reduce a lot. However, when I tried to play mp3 audio, I got very disappointed. There is a considerable delay (about 500ms) between the moment the play command is called and the moment the audio is actually played.
I planned changing the engine, in order to preload the mp3 content before the game level is started (during game loading). However, it seems that the engine only allows only one file loaded at a time. Is that right?
Making a long story short, I would be very glad if someone answer the questions below:
Can I preload the mp3 audio files, and play them after, when I need them (not necessary simultaneously)? Is there other way to avoid the delay?
Can I play two mp3 songs simultaneously?
And finally, Can I pause the audio stream?
I really appreciate your answer,
Americo
I am developing a kind of rhythm game, this way it plays a lot of audio content, and I need a very fast response from the audio system.
I was very excited when I received the news about mp3 audio feature at iTGB 1.2, since my game size in disk would reduce a lot. However, when I tried to play mp3 audio, I got very disappointed. There is a considerable delay (about 500ms) between the moment the play command is called and the moment the audio is actually played.
I planned changing the engine, in order to preload the mp3 content before the game level is started (during game loading). However, it seems that the engine only allows only one file loaded at a time. Is that right?
Making a long story short, I would be very glad if someone answer the questions below:
Can I preload the mp3 audio files, and play them after, when I need them (not necessary simultaneously)? Is there other way to avoid the delay?
Can I play two mp3 songs simultaneously?
And finally, Can I pause the audio stream?
I really appreciate your answer,
Americo
#2
Only one hardware-supported compressed stream at a time is the basic rule (MP3, AAC mainly).
05/12/2009 (7:38 pm)
Definitely no mixing on the MP3 hardware. Because of the different bus bandwidth on 2nd gen. iPod touch and all the other devices, that device may also trick you into thinking you can mix more than you should if you get it working.Only one hardware-supported compressed stream at a time is the basic rule (MP3, AAC mainly).
#3
Maybe I'm lacking in my MP3 knowledge there and there's no longer any fee... that would be quite awesome if true. :)
05/12/2009 (9:52 pm)
Maybe I'm a bit behind on the "What Is MP3" times, but doesn't using MP3 require paying a rather hefty license to the owners of of the format? I thought that was why everyone switched to .OGG?Maybe I'm lacking in my MP3 knowledge there and there's no longer any fee... that would be quite awesome if true. :)
#4
MP3 may not represent all sound as well as some other lossy formats, but it is damn fast to decode. With the dedicated decoder (either a chip or part of the processor in the iPhone/touch) it's the best option for game music.
05/12/2009 (9:58 pm)
Licence fees still exist, but being an iPhone developer means it's covered by Apple :)MP3 may not represent all sound as well as some other lossy formats, but it is damn fast to decode. With the dedicated decoder (either a chip or part of the processor in the iPhone/touch) it's the best option for game music.
#5
UPDATE: Okay, was easy to fix. Just add a count:
05/12/2009 (10:05 pm)
I'm getting a random stoppage of my MP3 music. Anyone else encountering this or know a workaround?UPDATE: Okay, was easy to fix. Just add a count:
startiPhoneAudioStream($musicStreamFile,500);
#6
05/13/2009 (9:35 am)
@Ronny: Well then! No MP3 fees means I'll be using MP3s in our iPhone games! (Time to convert things over from WAV now, heh...)
#7
Right now I´m confussed and I don´t know what to do to play mp3 music in my game since preloading the mp3 files as usual with OGG files doesn´t works:
If I use below code I just get a horrible sound instead of the music. And I get the following message:
What can I do to play the mp3 music?
Thanks,
Mike
05/14/2009 (4:44 pm)
Hello,Right now I´m confussed and I don´t know what to do to play mp3 music in my game since preloading the mp3 files as usual with OGG files doesn´t works:
new AudioProfile(melodia1Audio)
{
filename = "~/data/audio/SSBGM1.mp3";";
description = "AudioLooping";
preload = true;
};If I use below code I just get a horrible sound instead of the music. And I get the following message:
ResourceObject::construct: NULL resource create function for 'SSBGM1.mp3'
What can I do to play the mp3 music?
Thanks,
Mike
#8
To stop music:
You'll only hear it on your iPhone/iPod.
05/14/2009 (5:24 pm)
To start music:$musicStreamHandle = startiPhoneAudioStream($musicStreamFile,500);
To stop music:
stopiPhoneAudioStream($musicStreamHandle);
You'll only hear it on your iPhone/iPod.
#9
Thanks for your answer. So the startiPhoneAudioStream and stopiPhoneAudioStream commands works only on the iPhone/iPod? I will play on them once I get the Apple license :)
;ike
05/14/2009 (6:34 pm)
Chris,Thanks for your answer. So the startiPhoneAudioStream and stopiPhoneAudioStream commands works only on the iPhone/iPod? I will play on them once I get the Apple license :)
;ike
#10
05/14/2009 (7:58 pm)
Not a problem. Correct, it will only play on an iphone or ipod.
#11
Is the MP3 support as rudimentary as start and stop?
07/09/2009 (3:42 pm)
Is there any way to control the volume of an MP3? I realized that I had to manually drop the volume of all my MP3 files by 65% in order to match the volume of the WAV files playing over them. It was quite a time-consuming process that would have been easier if there's a way to simply set the volume before or during playback (I would appreciate a fade feature!)Is the MP3 support as rudimentary as start and stop?
#12
When you say 'it will only play on an iphone or ipod' - do you mean it wont play when you test the game in a TGBGame environment, and will only work when you build and run the app on your iphone device???
I can't get it to work anywhere!
Thanks
07/12/2009 (3:11 am)
@ Chris JorgensenWhen you say 'it will only play on an iphone or ipod' - do you mean it wont play when you test the game in a TGBGame environment, and will only work when you build and run the app on your iphone device???
I can't get it to work anywhere!
Thanks
#13
07/12/2009 (5:57 am)
The *iPhoneAudioStream commands will only work on devices, yes. The simulator won't even play it. They call specific commands that use the MP3 decoder chip on the devices.
#14
thats a very bad idea.
The decompression happens on cpu so every additional mp3 is a good way to kill the performance.
If the decoder was used, it would be restricted to a single mp3 at a time. But as iTGB uses OpenAL you are always on cpu
07/12/2009 (8:55 am)
Quote:@Ronny: Well then! No MP3 fees means I'll be using MP3s in our iPhone games! (Time to convert things over from WAV now, heh...)
thats a very bad idea.
The decompression happens on cpu so every additional mp3 is a good way to kill the performance.
If the decoder was used, it would be restricted to a single mp3 at a time. But as iTGB uses OpenAL you are always on cpu
#15
Yes. And replace my "500" with "true". I think that's really how you're supposed to do it. Someone can verify that though.
07/13/2009 (10:05 am)
Quote:
When you say 'it will only play on an iphone or ipod' - do you mean it wont play when you test the game in a TGBGame environment, and will only work when you build and run the app on your iphone device???
Yes. And replace my "500" with "true". I think that's really how you're supposed to do it. Someone can verify that though.
#16
Plays once:
07/13/2009 (12:32 pm)
Yes, the second argument is a boolean value for looping.Plays once:
startiPhoneAudioStream($musicStreamFile,false);
#17
What are the chances someone could write a patch into itgb that reads this command and issues another to play the mp3 on the computer when tested?
This way at least we could make sure it is firing the command ok when we want it and that all filepaths are correct without having to build it onto a device??? Or is licensing a problem?
07/13/2009 (3:10 pm)
Got it working thanks, but as Marc says, with some detriment to the performance.What are the chances someone could write a patch into itgb that reads this command and issues another to play the mp3 on the computer when tested?
This way at least we could make sure it is firing the command ok when we want it and that all filepaths are correct without having to build it onto a device??? Or is licensing a problem?
#18
07/13/2009 (3:18 pm)
you can just write it like (for example with above code)if( $platform $= "iphone) startiPhoneAudioStream($musicStreamFile,false);
Torque Owner Bret Patterson
You'll need to use regular .wav files for mixing and just deal with the file sizes.