# Audio output channel mapping

**URL:** <https://forum.juce.com/t/audio-output-channel-mapping/23607>\
**Category:** General JUCE discussion\
**Created:** [August 4, 2017, 6:54am UTC](https://forum.juce.com/t/audio-output-channel-mapping/23607 "2017-08-04T06:54:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikolas-k](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/nikolas-k/32/2307_2.png) [@nikolas-k](https://forum.juce.com/u/nikolas-k)\
**Post date:** [August 4, 2017, 6:54am UTC](https://forum.juce.com/t/audio-output-channel-mapping/23607/1 "2017-08-04T06:54:44Z")

</div>

Hi all,

Can anyone enlighten me if there is a way to easily re-map input/output audio channels?  
I have an app that uses a stereo output, what I am trying to achieve is to have a `ComboBox` for each of my “output channels” to set what physical output to use (Something like MaxMSP has at its “Audio Status”-?“IO Mappings”).

I found a post that suggested, in a similar issue, to do the mapping manually using another `AudioSampleBuffer`,  
but I was wondering if there is a way to get this done via the `AudioDevideManager` or something like that, without messing with the `processBlock()` ?

-N

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [August 4, 2017, 7:23am UTC](https://forum.juce.com/t/audio-output-channel-mapping/23607/2 "2017-08-04T07:23:55Z")

</div>

Hi @Nikolas_K,

the DeviceManager is only responsible for AudioDevices and MidiConfiguration. It is not involved in anything in AudioProcessors, because they are meant to be hosted plug-ins. So in processBlock you are on your own.

But Standalone apps are not driven in processBlock calls but rather getNextAudioBlock (like [AudioSource](https://juce.com/doc/classAudioSource) and it’s descentants). So here you can use [ChannelRemappingAudioSource](https://juce.com/doc/classChannelRemappingAudioSource) for instance.

HTH, Daniel

---

<div class="post-metadata">

**Author:** ![nikolas-k](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/nikolas-k/32/2307_2.png) [@nikolas-k](https://forum.juce.com/u/nikolas-k)\
**Post date:** [August 4, 2017, 7:37am UTC](https://forum.juce.com/t/audio-output-channel-mapping/23607/3 "2017-08-04T07:37:51Z")

</div>

Hello @Daniel,

Thank you for your answer, I found an older of your posts about the `ChannelRemappingAudioSource`.  
I started the project as a GUI application, so it just inherits “JUCEApplication”. I add the AudioCallback manually via the AudioDeviceManager.  
By `processBlock`, I mean any “audio callback” method that is used in that case, sorry for not clarifing it.

The current problem is that in order to add the AudioCallback, my DSP handling class, needs to inherit from `AudioIODeviceCallback`, but the `ChannelRemappingAudioSource` needs an `AudioSource`, which is not that handy!

What whould a correct approach be, keeping in mind that my project is just a `JUCEApplication`?

-N

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [August 4, 2017, 7:44am UTC](https://forum.juce.com/t/audio-output-channel-mapping/23607/4 "2017-08-04T07:44:55Z")

</div>

Wanted just to edit my post, when I realised, that it might not be that straight forward with your use case, but wanted to double check for syntax. I had this idea as alternative:

```
float* const pointers[2] = {
    bufferToFill.buffer->getWritePointer(0),
    bufferToFill.buffer->getWritePointer(1),
};
AudioBuffer<float> stem (pointers, 2, bufferToFill.startSample, bufferToFill.numSamples);

// either for channel Source
const AudioSourceChannelInfo stemBufferToFill (&stem, bufferToFill.startSample, bufferToFill.numSamples);
yourSource.getNextAudioBlock (stemBufferToFill);

// or processBlock:
yourProcessor.processBlock (stem, midi);

```

Maybe that adds some flexibility…

---

<div class="post-metadata">

**Author:** ![nikolas-k](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/nikolas-k/32/2307_2.png) [@nikolas-k](https://forum.juce.com/u/nikolas-k)\
**Post date:** [August 4, 2017, 8:02am UTC](https://forum.juce.com/t/audio-output-channel-mapping/23607/5 "2017-08-04T08:02:21Z")

</div>

I am not sure I follow your example’s aim, but If I understand correctly you suggest,getting the channel pointers and handle the mapping manualy?

Could I just inherit both from [AudioSource](https://www.juce.com/doc/classAudioSource) and [AudioIODeviceCallback](https://www.juce.com/doc/classAudioIODeviceCallback) to do the channel mapping with the [ChannelRemappingAudioSource](https://juce.com/doc/classChannelRemappingAudioSource) or is that “too much” ?

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [August 4, 2017, 9:22am UTC](https://forum.juce.com/t/audio-output-channel-mapping/23607/6 "2017-08-04T09:22:56Z")

</div>

Sorry, that was written in a bit of a hurry.

I wanted to point out, that you can use an AudioBuffer without allocating samples. In this case you have a fully functional AudioBuffer, which just refers to audio data. You can use this buffer in either function, processBlock or getNextAudioBlock.

For your last question, I tend to use the juce made players, that ARE actually AudioIODeviceCallbacks. Have a look at the inheritance diagram of AudioIODeviceCallback, there are:

- [AudioProcessorPlayer](https://www.juce.com/doc/classAudioProcessorPlayer) - give it a processor that will be played back
- [AudioSourcePlayer](https://www.juce.com/doc/classAudioSourcePlayer) - give it an AudioSource, that is played back (AudioTransportSource is a perfect match)
- [SoundPlayer](https://www.juce.com/doc/classSoundPlayer) - probably not what you want
- [StandalonePluginHolder](https://www.juce.com/doc/classStandalonePluginHolder) - most certainly not what you want

You can inherit one of these, if you want to play back a juce style processor or source. But you can roll your own and get inspiration in juce’s code, that’s up to you.

HTH

---

<div class="post-metadata">

**Author:** ![nikolas-k](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/nikolas-k/32/2307_2.png) [@nikolas-k](https://forum.juce.com/u/nikolas-k)\
**Post date:** [August 4, 2017, 1:37pm UTC](https://forum.juce.com/t/audio-output-channel-mapping/23607/7 "2017-08-04T13:37:58Z")

</div>

The [AudioSourcePlayer](https://www.juce.com/doc/classAudioSourcePlayer) seems very helpfull in my situation.  
Thank you very much @daniel for your time and answers!

-N
