# Play multi audio files at the same time

**URL:** <https://forum.juce.com/t/play-multi-audio-files-at-the-same-time/15388>\
**Category:** General JUCE discussion\
**Created:** [August 22, 2015, 12:57pm UTC](https://forum.juce.com/t/play-multi-audio-files-at-the-same-time/15388 "2015-08-22T12:57:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChrisNilson](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@ChrisNilson](https://forum.juce.com/u/ChrisNilson)\
**Post date:** [August 22, 2015, 12:57pm UTC](https://forum.juce.com/t/play-multi-audio-files-at-the-same-time/15388/1 "2015-08-22T12:57:23Z")

</div>

Hi Juce community!

&nbsp;

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&nbsp;MixerAudioSource?

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

&nbsp;

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

---

<div class="post-metadata">

**Author:** ![patulski](https://avatars.discourse-cdn.com/v4/letter/p/90ced4/32.png) [@patulski](https://forum.juce.com/u/patulski)\
**Post date:** [January 17, 2017, 8:00pm UTC](https://forum.juce.com/t/play-multi-audio-files-at-the-same-time/15388/2 "2017-01-17T20:00:32Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![ed95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ed95/32/7635_2.png) [@ed95](https://forum.juce.com/u/ed95)\
**Post date:** [January 18, 2017, 11:45am UTC](https://forum.juce.com/t/play-multi-audio-files-at-the-same-time/15388/3 "2017-01-18T11:45:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![patulski](https://avatars.discourse-cdn.com/v4/letter/p/90ced4/32.png) [@patulski](https://forum.juce.com/u/patulski)\
**Post date:** [January 18, 2017, 6:31pm UTC](https://forum.juce.com/t/play-multi-audio-files-at-the-same-time/15388/4 "2017-01-18T18:31:31Z")

</div>

Thanks for response. My code now is:

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

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.

---

<div class="post-metadata">

**Author:** ![patulski](https://avatars.discourse-cdn.com/v4/letter/p/90ced4/32.png) [@patulski](https://forum.juce.com/u/patulski)\
**Post date:** [January 18, 2017, 6:41pm UTC](https://forum.juce.com/t/play-multi-audio-files-at-the-same-time/15388/5 "2017-01-18T18:41:23Z")

</div>

> [@patulski](#):
>
> audioTransportSource

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