mp3 Sounds Playing on simulator but not on Device (Audio BeatBox)
I Have a really serious Problem on my end:
Im Making an Audio Synchronized BEATBOX with 16 different sounds playing at the same time.
In Order to Implement the TIME-SYNC of the mp3 files we gave up on the AVAudioPlayer and included the AUGraph Method of:
MixerHostAudio.m and MixerHostAudio.h
which I Downloaded at the Developer Resources form Apple.
The Impleme开发者_开发百科ntation worked fine for the Simulator, but not on Device, which CRASHED after loading the 4th file...
we Were Loading the Files as kAudioFormatLinearPCM format.
We Changed it to: kAudioFormatMPEGLayer3
being out files all .mp3 we thought that would be the required format.
The APP Did manage to load the Resources, but we got an Error on startAUGraph method.
The APP Didnt crashed on Device, but it PLAYS NO SOUNDS, nor in Device, nor in Simulator.
we tried changin the bit Rate from 32 to 16 and it seems to have helped.. but NO SOund Still.. HELP!
SOLVED:
There is Apparently NO WAY to load a Compressed Audio File into the AUGraph or the AudioBuffer on iOS, there HAS to be a conversion to linearPCM, therefore:
the 29 second .mp3 files which were 500KB each turned into 5 MB files when converted to linearPCM.
the iPhone 3G allows about 20 MB of RAM memory for each application, which explains why the APP Crashed after loading the 4th file ( 4 * 5 = 20 :p )
The ideal Solution would be to implement a Buffering Algorithm that loads only a fraction of the file every time (for example, 1 second).
This Solution was a bit over my head at the time, and hence the Actual Solution was loading shorter Files for the Loop to make it able to load on 3G and 3GS Devices. iPhone4 will load the Full Original Loop.
Thanks for all the replies.
Hernan
精彩评论