Associate AudioTransportSource to mono/stereo channel of ASIO device


I would like to play different files to different channels of the ASIO device. I was able to create

        AudioSourcePlayer audioSourcePlayer;
        AudioTransportSource transportSource;
        audioDeviceManager.addAudioCallback (&audioSourcePlayer);
        audioSourcePlayer.setSource (&transportSource);

        AudioFormatReader *audioReader = formatManager.createReaderFor (File("C:\\p1.wav"));
        AudioFormatReaderSource * currentAudioFileSource =  new AudioFormatReaderSource (audioReader, true);

        transportSource.setSource (currentAudioFileSource, 0, nullptr, audioReader->sampleRate);

transportSource as above but dont know how to associate it to a single channel (mono) or two channels (stereo) for playing.


I have also set proper bits in config.outputChannels.


This is working for direct play of a single audio to all the set channels, but i would like to play different files on different channels simultaneously.



Maybe use a couple of ChannelRemappingAudioSources and mix them together?

I dont want to change the already set channels, I just want to map different audiosource audio files to be played in different asio output channels simultaneously on start.

Huh? You can just map the channels of each source onto whatever channels you want it to come out of.

Hmmm. Is there an AudioSource class already existing which can make this mapping or do I need to write my own AudioSource class inheriting from 'AudioSource' just to enable this feature?

Like I said, look at ChannelRemappingAudioSource. As the name suggests, it remaps input channels to output channels, which AFAICT is exactly what you're trying to do.

Hi Jules,

Yea got the idea that to map the respective input to the output channels to set different audio source to different channels.

I took Juce::Demo as reference and started developing this module, I created as below

AudioFormatReaderSource * currentAudioFileSource =  new AudioFormatReaderSource(audioReader, true);

AudioSourcePlayer audioSourcePlayer;

AudioTransportSource transportSource;

transportSource.setSource (currentAudioFileSource, 0, nullptr, audioReader->sampleRate);

audioSourcePlayer.setSource (&transportSource);

while introducing ChannelRemappingAudioSource, I created

ChannelRemappingAudioSource remappingSource (&transportSource, true);

and changed the source of audioSourcePlayer to point to channelremapping source

audioSourcePlayer.setSource (&remappingSource);


But it doesnt look like working. Can you please help me with the usage of ChannelRemappingAudioSource?





Can you please help me with the usage of ChannelRemappingAudioSource?

I don't think I can tell you anything that isn't already explained in its docs. If you have any specific questions, or think that any of the class's methods need better comments, then please ask.

Thanks a lot Jules, figured out how to use ChannelRemappingSource :)