Pump AudioSampleBuffer from processBlock() to audioDeviceIOCallback()


#1

I'm trying to do something cheeky with my vst plugin. I've created a global AudioDeviceManager inside my plugin, and I want to pass the processed audio from my plugin to the AudioDeviceIOCallback function and have that processed audio hit the audio device (Different device than what the DAW is using)

I've gotten as far as copying the AudioSampleBuffer to a scratch buffer that is visible to the AudioDeviceManager:

void processBlock(AudioSampleBuffer& buffer, MidiBuffer& midiMessages) {
  ...
                copiedBuffer.makeCopyOf(buffer);
  ...
}

But I'm not sure how to route that buffer to the AudioDeviceIOCallback function. I tried doing something like the below, but I'm not hearing any audio:

void audioDeviceIOCallback(const float **inputChannelData, int numInputChannels, float **outputChannelData, int numOutputChannels, int numSamples) {

    outputChannelData = copiedBuffer.getArrayOfWritePointers();

}

I have a feeling that I'm missing something here. Any pointers?

 

PS: See y'all at NAMM!


#2

Unless the other device is actually the same device as the DAW is using, and unless they are synchronized with word clock, you also need to resample your audio in either of the ends. The clocks will differ! Check out the JUCE LagrangeInterpolator class for example.


#3

Ok cool, thanks.

I think then maybe I should start small. Let's say that I'm trying to hit the same device that the DAW is using - would I still have to use the LagrangeInterpolator class? And would the inputSamples and outputSamples parameters correspond to only one channel in the output buffer?


#4

Alright, i actually got it to work! Just changed the audioDeviceIOCallback to this:

void audioDeviceIOCallback(const float **inputChannelData, int numInputChannels, float **outputChannelData, int numOutputChannels, int numSamples) {
    AudioSampleBuffer outputBuffer(outputChannelData, numOutputChannels, numSamples);
    outputBuffer.makeCopyOf(copiedBuffer);
}

But this introduces some artifacts to the audio, clicking and such - would the interpolation thing fix that?