Multitrack audio player ... recipes?


Hi :slight_smile:

i am completely new to Juce, so pls forgive me if I didnt see an obvious solution to my problem…

What i am up to is to develop some audio apps (win/mac/ios) which all base on a certain idea:
Take several audio tracks (wav files), apply gain and mute, mix them together and be able to playback the sum, including start/stop/positioning/looping capabilities (and of course, all tracks synchronously in time). These apps would maybe go commercial, not sure though…
Honestly, due to lack of documentation I dont find any recipes for what i am up to. Sure, I was able to write myself an app that plays back a wave file, or stick together some AudioTransportSources into a MixerAudioSource (not sample synchronous).
I tried krakkens PositionalMixerAudioSource, which i could attach to a AudioTransportSource and control playback synchronously, but it wont play with AudioTransportSources as inputs, so no chance to apply gain…
I’ve struggeled for 2 days now and was not able to show up a solution… every time i thought i find one there appears a new problem…

In fact… IS there a solution without having to code new Juce classes ? (i hoped to avoid exactly this by using a framework, and i think what i want to do is really basic stuff…)

Thanks :slight_smile:


OK, did it.
With the PositionalAudioMixerSource and a modified AudioFormatReaderSource (added gain and mute) this seems to do well.

Still, two question, hope that somebody can answer this.

Does AudioFormatReaderSource resp. AudioFormatReader stream audio files (directly) from disk ? I mean, NOT loading the entire audio into memory, but accessing disk while playback ? (In fact, this is very important for my application)

Assumed that it IS “direct from disk” streaming… there’s this chain: AudioFormatReaderSource->PositionalAudioMixerSource->AudioTransportSource-> (to Output)
When i call AudioTransportSource.SetPosition(…) (in order to play a loop) …i guess audio data will get “preloaded”/buffered earliest when i make the call to SetPosition(). Assumed that i have to playback 30+ audio files synchronously I’d say this is going to cause problems (stuttering).
Any opinions on this ?

Thanks :slight_smile:


AudioFormatReaderSource just reads the file direct from disc. If you want to buffer it, you’ll need to put it through a BufferingAudioSource.

BTW you might have got a quicker answer by just looking inside AudioFormatReaderSource.cpp… it’s < 100 lines of code, and pretty obvious to see what it’s doing in there.


Hi Jules :slight_smile:
thanks for the answer. I was hoping its direct from disc.

Its not that easy to just look into the sources. I code in c++ but often enough i dont know what exactly happens in lower layers… and so is this…AudioFormatReaderSource uses a AudioFormatReader uses a FileInputStream uses some read functions that ive never seen …

However, I found a class named AudioSubSectionReader … this could be a good (and cheaper) way to realize loops, right ?


I’ve tried to make all my code as clear as possible, so unlike a lot of libraries, I’d like to think that it’s not too scary to delve inside and see how it works!

AudioSubSectionReader just does what it says on the tin: it reads a subsection of another reader… If that’s what you need, then great.