# Specify channel output for mono audio file

**URL:** <https://forum.juce.com/t/specify-channel-output-for-mono-audio-file/14168>\
**Category:** Audio Plugins\
**Created:** [January 13, 2015, 10:06am UTC](https://forum.juce.com/t/specify-channel-output-for-mono-audio-file/14168 "2015-01-13T10:06:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![csw](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@csw](https://forum.juce.com/u/csw)\
**Post date:** [January 13, 2015, 10:06am UTC](https://forum.juce.com/t/specify-channel-output-for-mono-audio-file/14168/1 "2015-01-13T10:06:18Z")

</div>

Hi,

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?

&nbsp;

Thanks!

&nbsp;

**EDIT:**

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.

&nbsp;

```
//create the players

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

        MediaPlayer *player = new MediaPlayer();

        // Connect the source player to the audio device.

        deviceManager.addAudioCallback(player);

        players.push_back(player);

    }

    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){

        players[i]->playFromStart();

    }
```

&nbsp;

MediaPlayer looks like this:

```
MediaPlayer::MediaPlayer()

{

    //CoInitialize(0);

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

    formatManager.registerBasicFormats();

    // Connect the transport source to the remapping source

    remappingSource = new ChannelRemappingAudioSource(&transportSource, true);

    // Connect the remapping source to the source player.

    sourcePlayer.setSource(remappingSource);

    // Listen for changes

    transportSource.addChangeListener(this);

    

}

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);

    transportSource.setSource(readerSource);

    remappingSource->clearAllMappings();

    remappingSource->setOutputChannelMapping(0, channel);

}
```

---

<div class="post-metadata">

**Author:** ![csw](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@csw](https://forum.juce.com/u/csw)\
**Post date:** [January 14, 2015, 10:52am UTC](https://forum.juce.com/t/specify-channel-output-for-mono-audio-file/14168/2 "2015-01-14T10:52:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![csw](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@csw](https://forum.juce.com/u/csw)\
**Post date:** [January 14, 2015, 4:00pm UTC](https://forum.juce.com/t/specify-channel-output-for-mono-audio-file/14168/3 "2015-01-14T16:00:19Z")

</div>

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

Output:

- Speakers (MOTU AVB USB Audio)
- Digital Audio

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [January 14, 2015, 4:13pm UTC](https://forum.juce.com/t/specify-channel-output-for-mono-audio-file/14168/4 "2015-01-14T16:13:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![csw](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@csw](https://forum.juce.com/u/csw)\
**Post date:** [January 14, 2015, 4:49pm UTC](https://forum.juce.com/t/specify-channel-output-for-mono-audio-file/14168/5 "2015-01-14T16:49:33Z")

</div>

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());
    types[i]->scanForDevices();
    StringArray deviceNames (types[i]->getDeviceNames());
    for (int j = 0; j < deviceNames.size(); ++j)
    {
        AudioIODevice* device = types[i]->createDevice (deviceNames [j]);
        devices.add(device);
    }
}

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:&nbsp;Speakers (MOTU AVB USB Audio)
- type: ASIO. device: MOTU AVB USB ASIO

However, when I try to initialise the MOTU AVB USB ASIO device&nbsp;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");

if(error.isNotEmpty()){

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

}
```

&nbsp;

---

<div class="post-metadata">

**Author:** ![csw](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@csw](https://forum.juce.com/u/csw)\
**Post date:** [January 14, 2015, 6:11pm UTC](https://forum.juce.com/t/specify-channel-output-for-mono-audio-file/14168/6 "2015-01-14T18:11:50Z")

</div>

Figured it out!

Just needed to add:

```
audioDeviceManager.setCurrentAudioDeviceType("ASIO", true);
```

After initialising the audioDeviceManager.
