Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Real-Time Audio Loop Switching for iPhone

I'm trying to find the best way to play a seamless loop of audio, that the user can switch out for another at the shortest possible notice, with a decent number (30-150) of very short loops being available. Will OpenAL be sufficient for this, or do I need to delve into Audio Units? The Apple Documentation says that for real-time feedback like an instrument, Audio Units is the right choice.

I just want to get the community's opinion on this, and any links and sample projects would be greatly appreciated.

like image 600
DanF Avatar asked Feb 15 '11 19:02

DanF


2 Answers

You can use AVAudioPlayer to seamlessly loop a compressed audio file (numberOfLoops = -1). I suggest using IMA4-encoded CAF files, as these are rumored to benefit from hardware decompression (saving CPU cycles for other things).

To keep file size down, you can lower the bit rate (try 96 kbps) and/or use mono.

Note that AVAudioPlayer does not allow you to change the tempo or frequency of playback.

like image 192
Glenn Barnett Avatar answered Sep 27 '22 17:09

Glenn Barnett


this probably doesn't really answer your question, but have you ever looked at Finch? Just looking at the source might provide some pointers.

  • Johannes
like image 34
Johannes Fahrenkrug Avatar answered Sep 27 '22 18:09

Johannes Fahrenkrug