Advice about using the audio thread


#1

I have read a number of posts which recommend doing certain actions on the audio thread. In particular, I’m thinking of using the audio thread as a ‘master clock’ for sending midi messages to graphs of VST plugins. Can you tell me if I’ve got the right idea about this?

  1. AudioDeviceManager::addAudioCallback()
    Is this the right function to call to get access to the audio thread? I guess that the callback is called (at a high frequency?) on the audio thread.

  2. Is it OK to use the audio-callback just for timing?
    I don’t want to use the audio-callback to modify the audio stream. I just want to use it for timing. So is this still the right thing to use? Should I just set the audio-stream output data to zeros in my callback? Or should I be doing the timing of midi updates a different way?

  3. Can I send midi updates from the audio-thread?
    I have different ‘tracks’ each of which plays a different stream of midi messages via an audio-processor-graph of VST instruments and effects. Can I use a single audio callback as a ‘master clock’ to check whether it is time to update midi data? If it is, I would then send the midi updates by calling AudioProcessorPlayer::getMidiMessageCollector().addMessageToQueue()

If I’ve got this all wrong, could you point me in the right direction of what I should be doing? (If I’ve got it right, it would be good to have some confirmation of this. So don’t hold back from posting if the answers are Yes!)

thanks,
Richard