Specify channel output for mono audio file


I cannot seem to figure out how to specify the output channel I want an audio file to playback on. I've looked at using MixerAudioSource but it doesn't look like I can specify a channel number.

Can someone point me in the right direction?





This thread is getting quite long so I've removed some of my last edits.

It seems I'm still having trouble with this. With the following code I can map channels 1 and 2 but nothing higher. I'd like to have 24 separate channel outputs.


//create the players

    for (int i = 0; i < 24; ++i){

        MediaPlayer *player = new MediaPlayer();

        // Connect the source player to the audio device.




    String error = deviceManager.initialise(0, 24, nullptr, true);

    if (error.isNotEmpty())


        std::cout << error << std::endl;


    //load files

    for (int i = 0; i < players.size(); ++i){

        String num = String(i + 1);

        String file = "C:/Library/" + num + "_test.wav";

        players[i]->setFile(file, i);


    //lock to ensure sync

    ScopedLock lock(deviceManager.getAudioCallbackLock());

    //playback files

    for (int i = 0; i < players.size(); ++i){




MediaPlayer looks like this:




    // Configure the format manager to read common audio file types.


    // Connect the transport source to the remapping source

    remappingSource = new ChannelRemappingAudioSource(&transportSource, true);

    // Connect the remapping source to the source player.


    // Listen for changes




void MediaPlayer::setFile(String filename, int channel)


    File audioFile = File(filename);

    // Create a reader from the selected file.

    readerSource = new AudioFormatReaderSource(formatManager.createReaderFor(audioFile), true);



    remappingSource->setOutputChannelMapping(0, channel);


Sorry to bump this but really need help with this one!

It looks like this could be a different issue where JUCE can only see 2 channels from the soundcard. I've hooked up a quick demo in max/MSP and can get that to output to each of the 24 channels.

max/MSP gives me the following audio driver options:

  • None
  • as_asio MOTU AVN USB ASIO (this is the one that gives me 24 channels)
  • ad_directsound
  • ad_mme
  • NonRealTime
  • ad_portaudio MME
  • ad_portaudio Windows DirectSound
  • ad_portaudio ASIO
  • ad_portaudio Windows WASAPI
  • ad_rewire
  • Live

When I run the audio settings demo I get the following options:

Audio Device Type:

  • Windows Audio
  • DirectSound


  • Speakers (MOTU AVB USB Audio)
  • Digital Audio

Try building juce with ASIO enabled, and you'll get access to the ASIO device.

Thanks for the reply. That has got me a step closer!

Using the following code I see a list of devices:

OwnedArray<AudioIODeviceType> types;
myAudioDeviceManager.createAudioDeviceTypes (types);

OwnedArray<AudioIODevice> devices;

for (int i = 0; i < types.size(); ++i)
    String typeName (types[i]->getTypeName());
    StringArray deviceNames (types[i]->getDeviceNames());
    for (int j = 0; j < deviceNames.size(); ++j)
        AudioIODevice* device = types[i]->createDevice (deviceNames [j]);

for(int i=0; i< devices.size(); ++i)
    String type = devices[i]->getTypeName();
    String name = devices[i]->getName();
    std::cout << "type: " << type << ". device: " << name << std::endl;

From that I see:

  • type: Windows Audio. device: Speakers (MOTU AVB USB Audio)
  • type: DirectSound. device: Speakers (MOTU AVB USB Audio)
  • type: ASIO. device: MOTU AVB USB ASIO

However, when I try to initialise the MOTU AVB USB ASIO device I get the following error:

No such device: MOTU AVB USB ASIO

I am trying to initialise like so:

String error = audioDeviceManager.initialise(0, 24, 0, false, "MOTU AVB USB ASIO");


    std::cout << error << std::endl;



Figured it out!

Just needed to add:

audioDeviceManager.setCurrentAudioDeviceType("ASIO", true);

After initialising the audioDeviceManager.

1 Like