Play multi audio files at the same time

Hi Juce community!


I'm looking for to play more than one file at the same time and do some stuff with their buffer (like changing the gain). But I don't know how to do it.

What is the method to do it ?

1°) Do I have to use N-AudioTransportSource to play N tracks? Or do I have to use MixerAudioSource?

2°) When the AudioTransportSource will start, the getNextAudioBlock() method will be called. How do I manage to know where buffer belong to a particular AudioTransportSource?


I'm totally lost, so if you could give a little exemple it will be nice.

1 Like

Hi. I have the same problem, may someone know solution ? Especially how to get in: void getNextAudioBlock(const AudioSourceChannelInfo& bufferToFill) access to each channel from mixer to be able manipulate each in separate way. For example to change volume…

If you are using AudioTransportSource objects with a MixerAudioSource you can use the AudioTransportSource::setGain() method to change the volume of a source whilst it is being mixed. However if you’re using a custom AudioSource object then you should do your processing in its getNextAudioBlock() method as MixerAudioSource just iterates over each of its AudioSources and calls this.

Thanks for response. My code now is:

audioTransportSource = new AudioTransportSource;
audioTransportSource->setSource(new AudioFormatReaderSource(audioFormatReader, true));
audioMixer.addInputSource(audioTransportSource, true);

But I have somewhere error in my conception because it doesn’t work.

Previously was only:

audioMixer.addInputSource(new AudioFormatReaderSource(audioFormatReader, true), true);

and worked.

I forget about: audioTransportSource->start();
So now works, thank you for help ! :slight_smile:

1 Like