I’m messing with an instance of AudioAppComponent - sort of following the audioPlayer tutorial example. However I wanted to introduce a processBlock
I got getNextAudioBlock creating an audioBuffer and passing it to the processBlock and then, after processing, I thought I needed to pass the buffer back to AudioTransportSource via AudioSourceChannelInfo.
It works, it just doesn’t play the processed audio but the unprocessed audio.
Can someone point out my misunderstanding please?
void getNextAudioBlock(const AudioSourceChannelInfo& bufferToFill) override
{
if (readerSource.get() == nullptr)
{
bufferToFill.clearActiveBufferRegion();
return;
}
/* coment out next line, is used at the end of the processBlock*/
//transportSource.getNextAudioBlock(bufferToFill);
AudioBuffer<float> procBuf(bufferToFill.buffer->getArrayOfWritePointers(),
bufferToFill.buffer->getNumChannels(),
bufferToFill.startSample,
bufferToFill.numSamples);
MidiBuffer midi;
processBlock(procBuf, midi);
}
void processBlock(AudioBuffer<float>& buffer, MidiBuffer& midiMessages) {
ScopedNoDenormals noDenormals;
auto* device = deviceManager.getCurrentAudioDevice();
auto totalNumInputChannels = device->getActiveInputChannels().getHighestBit() + 1;
auto totalNumOutputChannels = device->getActiveOutputChannels().getHighestBit() + 1;
for (int sampleIndex = 0; sampleIndex < buffer.getNumSamples(); ++sampleIndex) {
for (int channel = 0; channel < totalNumInputChannels; ++channel) {
/* does some processing here - code removed for brevity*/
}
/* does some more processing here - code removed for brevity */
for (int i = 0; i < totalNumOutputChannels; i++)
{
auto* channelData = buffer.getWritePointer(i);
channelData[sampleIndex] = myProcessor.getProcessedSamlpe(sampleIndex, i);
}
}
// my guess is my misunderstanding is here
AudioSourceChannelInfo cinfo(buffer);
transportSource.getNextAudioBlock(cinfo);
}
