Take the 2-minute tour ×

I'm a Unity dev and need to help out colleagues with doing this natively in Obj-C. In Unity it's no big deal :

1)samples are stored in memory as a List of float[]

2)A helper function returns float[] of n size for any given sample, at any given offset

3)Another helper function fades the data if needed

4)An AudioClip object is created with the right size to accomodate all cut samples, and is then filled at appropriate offsets.

5)The AudioClip is assigned to a player component(AudioSource).

6)AudioSource.Play(ulong offsetInSamples), plays at a sample accurate time in the future. Looping is also just a matter of setting the AudioSource object's loop parameter.

I would very much appreciate if someone could point me towards the right classes to achieve similar results in Obj-C, for iOS devices. I'm pretty sure a lot of iOS audio newbies would be intersted too. Many thanks in advance!


share|improve this question

1 Answer 1

up vote 2 down vote accepted

A good overview of the relevant audio APIs available in iOs is here

The highest level framework that makes sense for patching together audio clips, setting their volume levels, and playing them back in your case is probably AVFoundation.

It will involve creating AVAssets, adding them to AVPlayerItems, possibly putting them into AVMutableCompositions to merge multiple items together and adjust their volumes (audioMix), and them playing them back with AVPlayer.

AVFoundation works with AVAsset, for converting between relevant formats and lower level bytes you'll want to have a look at AudioToolbox (I can't post more than two links yet).

For an somewhat simpler API with less control have a look at AVAudioPlayer. If you need greater control (eg: games - real time / low latency) you might need to use OpenAL for playback.

share|improve this answer
Many thanks for the detailed reply. I've had a look at AVAudioPlayer, which seems to give enough control to achieve what my colleagues are trying to : it can be initialized with NSData instead of an audio file. So know, all I need to know is how to convert a wav's data in a NSData object. Is there a ready made method to avoid manually parsing the file, removing header data and retaining only audio data? Many thanks, Gregzo –  Gregzo Jan 20 '13 at 15:29
Ha, it seems AudioFileReadPackets should do the trick. –  Gregzo Jan 20 '13 at 16:03

Your Answer


