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

Hi all,

The Tutorials and the Forum has been really helpful as a new JUCE and C++ programmer – thanks heaps.

So I have a standalone audioapp inheriting from AudioAppComponent with two AudioTransportSources – one for vocals and one for music, and a mixer to play them in sync.

std::unique_ptr<AudioFormatReaderSource> mVocalSource;
std::unique_ptr<AudioFormatReaderSource> mMusicSource;
AudioTransportSource mTransportSourceVocals;
AudioTransportSource mTransportSourceMusic;
MixerAudioSource mAudioMixer;
//Load file into transport
    auto* musicFileReader = mFormatManager.createReaderFor(File(filePath));
    if (musicFileReader != nullptr)
        std::unique_ptr<AudioFormatReaderSource> newMusicSource(new AudioFormatReaderSource(musicFileReader, true));
        mTransportSourceMusic.setSource(newMusicSource.get(), 0, nullptr, musicFileReader->sampleRate);
        mAudioMixer.addInputSource(&mTransportSourceMusic, false);

    //Load vocals
    AudioFormatReader* vocalFileReader = nullptr;
        auto* vocalFileReader = mFormatManager.createReaderFor(File("C:/Users/aman_/Music/Beats/Beat01.wav"));
    if (vocalFileReader != nullptr)
        std::unique_ptr<AudioFormatReaderSource> newVocalSource(new AudioFormatReaderSource(vocalFileReader, true));
        mTransportSourceVocals.setSource(newVocalSource.get(), 0, nullptr, vocalFileReader->sampleRate);
        mAudioMixer.addInputSource(&mTransportSourceVocals, false);
    //Rewind both tracks to the start and play


Then in the getNextAudioBlock, I play the mixer:

void SelectTrackComponent::prepareToPlay(int samplesPerBlockExpected, double sampleRate)
    mSamplesPerBlockExpected = samplesPerBlockExpected;
    mSampleRate = sampleRate;

    // This function will be called when the audio device is started, or when its settings (i.e. sample rate, block size, etc) are changed.
    //mAudioMixer.prepareToPlay(samplesPerBlockExpected, int(mSampleRate / mSampleRateXRatio
    mAudioMixer.prepareToPlay(samplesPerBlockExpected, int(mSampleRate / mSampleRateXRatio));

void SelectTrackComponent::getNextAudioBlock(const AudioSourceChannelInfo& bufferToFill)
    // Your audio-processing code goes here!

This all works. Except I now want to add effects to ONLY ONE AudioTransportSource / track / audiosource (mTransportSourceVocals). All the tutorials and forum entries I’ve seen only seem to cover manipulating the entire buffer (see

How do I apply effects / do signal processing for only 1 AudioTransportSource?

Hey man,

Got your ping in the other thread :wink: It’s been a while since I’ve tinkered with JUCE now, but if I understand your problem correctly, the first half, presented by Fabian Renn-Giles solves your issue: