Help with simple Audio Output on iOS

Hello guys, I am new around here, so please be patient.

I am developing a game with Cocos2d-x, and I need to produce sounds, actualy, single notes, but with different tunes and I wouldn't like to import  a bunch of .mp3 inside of my project. I've searched on the Juce Demos, and the Synthetizer tab is what I need (i guess). I;ve tried to understand how it works with breakpoints during execution, but just couldn't figure out. 

There is a synthetizer tutorial? Or can someone explain me what classes should I use to get a simple output function?


I don't do much synth stuff so there might be something better, but the basic building blocks would typically include


  • gives you access to the device audio stream.


  • create a subclass of this and put your synthesizer in it. Take a look at juce_Synthesizer for docs on how the synth works, there are 3 classes in there
  • You will have to override the methods from AudioSource in your sublcass.  In your implementation of "getNextAudioBlock", call "renderNextBlock" on the synth.  Take a look at the docs for each method to see how it works.  Note that getNextAudioBlock is driven by the audio system, so you don't call it yourself.


  • this allows you to conveniently connect your AudioSource to the AudioDeviceManager.
  • Call "setSource" and pass in your audio source subclass.
  • Connect to the device manager by calling "addAudioCallback" and pass in the AudioSourcePlayer.

Once all setup, the device manager should call the proper methods on the player which in turn will call the proper methods on the audio source which in turn gets the audio from the synth.  So it all works in a chain like that.  Keep in mind that all that activity happens on the audio thread and your app is generally working from the message thread.  If you need to change things on the synth you may need to do some level of synchronization to ensure the changes between the two threads are clean.