Skip to content

Sound programming notes

damiannz edited this page Oct 2, 2012 · 57 revisions

subclassing ofBaseSoundStream

  • ofSoundStream's isSetup() calls getNumInputChannels() and getNumOutputChannels() to determine if the system is setup or not. Make sure your subclass returns 0 for these immediately after construction.

subclassing ofBaseSoundOut

ofSoundMixer

  • move instance out of ofBasicSoundPlayer, make singleton
  • deal with singleton/root ofSoundStream instance: need some way of selecting the output at startup

audioOut

  • audioOut is called on the sound card's rendering thread, not the main thread. Make sure your audioOut is threadsafe but DON'T do this by using standard mutexes etc. Don't block! Don't do file I/O! If you need to do a lot of work, do it in a different thread that writes to a lock-free FIFO and read from this FIFO in audioOut. See Ross Bencina's guide for tips.
  • audioOut's float* output comes pre-cleared: audioOut does not need to set to 0 if it doesn't render anything
  • always assert that the input bufferSize and nChannels are what it expects. be smart enough to render multiple times

Clone this wiki locally