How to apply effects to only one AudioTransportSource in a multi-transport app?

Hi Arif,

Thanks for your response. The link you sent certainly pointed me in the right direction. It got me to look more closely at the AudioMixerSource Class.

I have A solution but am not confident its THE solution.

I took the idea of having a temp buffer from the AudioMixerSource class and have solved the problem.

First, I declared an AudioBuffer tempBuffer; in my header file;

AudioBuffer<float> tempBuffer;

Then, I replaced the above getNextAudioBlock() code with the below:

void SelectTrackComponent::getNextAudioBlock(const AudioSourceChannelInfo& bufferToFill)
{
    //mAudioMixer.getNextAudioBlock(bufferToFill);
    
    //Setup the temporary buffer with same number of channels and num of samples as the main buffer (bufferToFill)
    tempBuffer.setSize(jmax(1, bufferToFill.buffer->getNumChannels()), bufferToFill.buffer->getNumSamples());
    AudioSourceChannelInfo tempInfo(&tempBuffer, 0, bufferToFill.numSamples);

    //Populate that buffer with audio from AudioSource 1  
    mTransportSourceVocals.getNextAudioBlock(tempInfo);

    //Add the temp buffer to the main buffer using buffer->addFrom()
    for (int chan = 0; chan < bufferToFill.buffer->getNumChannels(); ++chan)
    {
        bufferToFill.buffer->addFrom(chan, bufferToFill.startSample, tempBuffer, chan, 0, bufferToFill.numSamples);
    }

    //At this point, the main buffer only has the samples from the first AudioTransportSource (mTransportSourceVocals)
    //Apply your effects / DSP - I've just tested this with a simple volume change of the vocals
    for (auto channel = 0; channel < bufferToFill.buffer->getNumChannels(); ++channel)
    {
       auto* inBuffer = bufferToFill.buffer->getReadPointer(channel, bufferToFill.startSample);
       auto* outBuffer = bufferToFill.buffer->getWritePointer(channel, bufferToFill.startSample);

       for (auto sample = 0; sample < bufferToFill.numSamples; ++sample)
       {
           outBuffer[sample] = inBuffer[sample] * mVocalVolSlider.getValue();
       }
    }

    //Repeat the process for each additional audio input source but skip the adding effects
    mTransportSourceMusic.getNextAudioBlock(tempInfo);
    for (int chan = 0; chan < bufferToFill.buffer->getNumChannels(); ++chan)
    {
        bufferToFill.buffer->addFrom(chan, bufferToFill.startSample, tempBuffer, chan, 0, bufferToFill.numSamples);
    }

    mAudioVisualiser.pushBuffer(bufferToFill);
}

Good news is that it works. Bad news is that now am bypassing built the MixerAudioSource. Ideas for improvements:

  1. Create a custom MixerAudioSource class object that inherits from MixerAudioSource, and override its getNextAudioBlock() function
  2. Create a custom AudioTransportSource class object that inherits from AudioTransportSource and override its getNextAudioBlock() function

Anyone have any thoughts on improvements? Please do share.