I'm porting my game to iOS using MonoTouch, and I'm having some trouble getting sound output to work. SystemSound/AVAudioPlayer is way too simple for my needs (I need looping and multiple simultaneous sounds), and OpenTK is not trivial to get working, in addition for it not supporting audio decoding by itself.

So I've settled with CoreAudio, which seems to do the trick. I've downloaded some samples, and gotten it to play and loop some sounds. Now I want it to play multiple sounds at the same time.

I noticed that it was trivial to get multiple sounds by creating multiple AudioUnits, each one separately connected to RemoteIO, but this doesn't seem to be very efficient. You can also mix multiple sounds by creating a graph and mixing everything on a MultiChannelMixer connected to RemoteIO which seems to be the right way to do it.

But I'm basing my decisions on pure assumptions (and in my short iOS experience, I've seen my assumptions are usually wrong when it comes to iOS, like some kind of inverse Principle of Least Astonishment), so I would like to ask the CoreAudio gurus over here if there is a real difference between these two approaches, or if there is a "more correct" approach to do what I want.

  • \$\begingroup\$ Not an answer - but seeing as you've posted on the game dev site and are using MonoTouch, have you considered using either MonoGame (OpenAL, I think) or ExEn (AudioQueue)? Even if you don't want the whole library - I imagine the audio components are fairly easy to extract and use stand-alone. \$\endgroup\$ – Andrew Russell Feb 6 '13 at 14:48
  • \$\begingroup\$ @AndrewRussell I tried OpenAL, as it readily has bindings to MonoTouch, but it lacks a decoder, so I'm limited to WAV files. I tried NVorbis for ogg decoding, but it is simply too slow for playback. I don't know about AudioQueue, but so far I've gotten Core Audio to somewhat work. It seems more difficult than what it actually is (hopefully). \$\endgroup\$ – Panda Pajama Feb 6 '13 at 15:37
  • \$\begingroup\$ Don't think this qualifies as an answer to your problem, but I've recently bound cocosDenshion to monotouch github.com/mono/monotouch-bindings/pull/91 and both SimpleAudioEngine and CDAudioManager works. You can use that without cocos2d, and it should cover your needs (background sounds, effects) \$\endgroup\$ – Stephane Delcroix Feb 20 '13 at 6:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.