Associate AudioTransportSource to mono/stereo channel of ASIO device


#1

Hi,

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.

 

Thanks.


#2

Maybe use a couple of ChannelRemappingAudioSources and mix them together?


#3

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.


#4

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


#5

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?


#6

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.


#7

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?

 

 

 

 


#8

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.


#9

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

 

Cheers.