# Surround channels misplaced on AU but they are ok on AAX

**URL:** <https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906>\
**Category:** Audio Plugins\
**Created:** [October 31, 2017, 2:55pm UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906 "2017-10-31T14:55:06Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![karolos](https://avatars.discourse-cdn.com/v4/letter/k/ccd318/32.png) [@karolos](https://forum.juce.com/u/karolos)\
**Post date:** [October 31, 2017, 2:55pm UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/1 "2017-10-31T14:55:06Z")

</div>

Hi, I’m stuck on a problem a long time now and I don’t seem to find the reason on any similar topic.  
On a multichannel (5.1 surround) pluggin I get misplaced output channels on AU. It seems to have L|R|Ls|Rs|C|LFE outputs order. Printing getCurrentLayout().getSpeakerArrangementAsString() I get t L R C Lfe Ls Rs  
When I’m building for Pro tools it seems to be everything in the right order.  
I tried to follow the Surround plugin example, which it works fine, but I don’t know what I’m missing.  
Maybe I should use different process block for different DAWs?

---

<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:** [October 31, 2017, 3:29pm UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/2 "2017-10-31T15:29:23Z")

</div>

Best use the helper functions and never assume a certain order of the channels:

```
auto* bus = getBus (false, 0); // returns main output bus
const auto& layout = bus->getCurrentLayout(); // returns the AudioChannelSet
int index = layout.getChannelIndexForType (AudioChannelSet::left); // index in the channel set
int pIndex = getChannelIndexInProcessBlockBuffer (false, 0 index); // finally index in your buffer in processBlock

```

Every time you have more than 2 channels it is worth to go the long route to be safe…

Good luck

---

<div class="post-metadata">

**Author:** ![karolos](https://avatars.discourse-cdn.com/v4/letter/k/ccd318/32.png) [@karolos](https://forum.juce.com/u/karolos)\
**Post date:** [November 1, 2017, 2:40pm UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/3 "2017-11-01T14:40:53Z")

</div>

Thanks for the fast reply. Those functions are great indeed 🙂 but in this case I got the same results  
pinting  
Left channel index – 0|| process block – 0  
Right channel index – 1|| process block – 1  
Center channel index – 2|| process block – 2  
LFE channel index – 3|| process block – 3  
LeftSr channel index – 4|| process block – 4  
RightSr channel index – 5|| process block – 5

and the outputs I got from logic are in L R Ls Rs C LFE order

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [November 2, 2017, 10:30am UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/4 "2017-11-02T10:30:29Z")

</div>

JUCE always uses the same channel order internally no matter if the native AU/VST/AAX layout has a different order. JUCE’s plug-in backend will always re-order the channels for you. The “JUCE channel order” is always in the order in which the channels appear in the `ChannelType` enum list [here](https://github.com/WeAreROLI/JUCE/blob/fae4cf656710eec695a080670ac9c94224b0e6d0/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h#L268).

So for 5.1 surround sound, the channel order of the buffer in your `processBlock` callback is always: L R C Lfe Ls Rs - regardless of DAW or plug-in type.

If you are getting an incorrect layout in some DAW then this is likely to be a JUCE bug (or DAW bug). I’ve just tested 5.1 Surround in Logic Pro and the channel ordering seems to be working fine.

---

<div class="post-metadata">

**Author:** ![karolos](https://avatars.discourse-cdn.com/v4/letter/k/ccd318/32.png) [@karolos](https://forum.juce.com/u/karolos)\
**Post date:** [November 2, 2017, 10:44am UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/5 "2017-11-02T10:44:58Z")

</div>

Yes indeed, with the Surround example found in example folder seemed to work fine, so no bug for juce. I don’t know why my write buffer is reordering the channels in logic, without doing enything fancy, just passing some values to test the channels

---

<div class="post-metadata">

**Author:** ![goodhertz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/goodhertz/32/74_2.png) [@goodhertz](https://forum.juce.com/u/goodhertz)\
**Post date:** [January 23, 2018, 9:39pm UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/6 "2018-01-23T21:39:44Z")

</div>

Were you able to solve your problem? We are experiencing the same issue and haven’t been able to find a solution. Since the Surround example plugin works correctly, we have been searching for a difference but haven’t been able to find anything.

The error is not our buffer copying, because the channels are already out of order in `JuceAU::Render()` before `processBlock()` has been called.

We have verified that the following things are the same between the Surround project and our plugin:

- `channelInfo` returned by `AudioUnitHelpers::getAUChannelInfo()`
- number of input and output buses, and the number of channels in each
- mapping of `chIdx` to `outLayoutMap[ch]` and `inLayoutMap[ch]` used when setting buffer pointers
- channel mapping and variables used in `CoreAudioBufferList::push()` when copying input
- default `BusesProperties` used upon initial construction of `AudioProcessor`

It seems like there must be some setting or assumption that is different between the example plugin and ours, but we haven’t been able to find it. The only difference we’re seeing is the order of the channels.

Any help or ideas to look into would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![goodhertz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/goodhertz/32/74_2.png) [@goodhertz](https://forum.juce.com/u/goodhertz)\
**Post date:** [February 5, 2018, 8:37pm UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/7 "2018-02-05T20:37:01Z")

</div>

Hey @fabian, do you have any thoughts on this?

---

<div class="post-metadata">

**Author:** ![karolos](https://avatars.discourse-cdn.com/v4/letter/k/ccd318/32.png) [@karolos](https://forum.juce.com/u/karolos)\
**Post date:** [February 5, 2018, 9:06pm UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/8 "2018-02-05T21:06:24Z")

</div>

Hey, sorry for the delayed answer, I remember solving it by installing an updated version and re-initiating my project.  
I hope this helps,  
Karolos

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [February 6, 2018, 9:05am UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/9 "2018-02-06T09:05:21Z")

</div>

Not really sure what could be causing this problem. Do you have some minimal code which reproduces the problem? Also note that if you are seeing this problem within Apple’s `auval` then have a look at [this thread](https://forum.juce.com/t/audiounit-synth-wrong-channel-layouts-reported-by-auval-when-using-isbuseslayoutsupported/23734/5?u=fabian) which was a bug in `auval` which was only recently fixed in 10.13.3.

---

<div class="post-metadata">

**Author:** ![goodhertz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/goodhertz/32/74_2.png) [@goodhertz](https://forum.juce.com/u/goodhertz)\
**Post date:** [February 9, 2018, 7:18pm UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/10 "2018-02-09T19:18:36Z")

</div>

I think we’ve found the discrepancy in our surround project: we needed to explicitly check `!isDiscreteLayout()` on both the input and the output in `isBusesLayoutSupported()`. Additionally, the AU cache must be cleared / rescanned for any changes in this function to be picked up by Logic.

Would it be possible to make `isDiscreteLayout()`'s purpose a little clearer in the documentation? It’s pretty sparse at the moment. Also, does it make sense that we’d need `!isDiscreteLayout()` for the surround channels to be correctly identified?

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [February 12, 2018, 10:04am UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/11 "2018-02-12T10:04:25Z")

</div>

> [@hguthertz](#):
>
> Also, does it make sense that we’d need !isDiscreteLayout() for the surround channels to be correctly identified?

Yes, that makes complete sense. I’ll update the documentation.

---

<div class="post-metadata">

**Author:** ![goodhertz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/goodhertz/32/74_2.png) [@goodhertz](https://forum.juce.com/u/goodhertz)\
**Post date:** [February 12, 2018, 5:01pm UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/12 "2018-02-12T17:01:05Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![audiogaming](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@audiogaming](https://forum.juce.com/u/audiogaming)\
**Post date:** [April 18, 2018, 8:29am UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/13 "2018-04-18T08:29:43Z")

</div>

The documentation of [create5point1](https://docs.juce.com/master/classAudioChannelSet.html#a8c0c22c3be59ca79cbf65dac2c729573) states a channel order (L R C Ls Rs Lfe) different than you mentioned (L R C Lfe Ls Rs). Which one is correct ?

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [April 18, 2018, 9:02am UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/14 "2018-04-18T09:02:59Z")

</div>

That latter one is correct. I’ll fix the documentation as well.

---

<div class="post-metadata">

**Author:** ![audiogaming](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@audiogaming](https://forum.juce.com/u/audiogaming)\
**Post date:** [April 18, 2018, 9:08am UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/15 "2018-04-18T09:08:24Z")

</div>

The AAX format seems to be different:  
AAX\_eStemFormat\_5\_1, { AudioChannelSet::left, AudioChannelSet::centre, AudioChannelSet::right, AudioChannelSet::leftSurround, AudioChannelSet::rightSurround, AudioChannelSet::LFE, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown } }

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [April 18, 2018, 9:09am UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/16 "2018-04-18T09:09:54Z")

</div>

No. That’s the channel order in AAX, but not the JUCE channel order. The explanation in this post is correct:

> [@Surround channels misplaced on AU but they are ok on AAX](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/4):
>
> JUCE always uses the same channel order internally no matter if the native AU/VST/AAX layout has a different order. JUCE’s plug-in backend will always re-order the channels for you. The “JUCE channel order” is always in the order in which the channels appear in the ChannelType enum list [here](https://github.com/WeAreROLI/JUCE/blob/fae4cf656710eec695a080670ac9c94224b0e6d0/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h#L268). So for 5.1 surround sound, the channel order of the buffer in your processBlock callback is always: L R C Lfe Ls Rs - regardless of DAW or plug-in type. If you are getting an incorrect layout in some DAW …

---

<div class="post-metadata">

**Author:** ![audiogaming](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@audiogaming](https://forum.juce.com/u/audiogaming)\
**Post date:** [April 18, 2018, 9:16am UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/17 "2018-04-18T09:16:02Z")

</div>

The AAX wrapper uses create5point1 but I don’t see where the order is handled differently.

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [April 18, 2018, 9:20am UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/18 "2018-04-18T09:20:46Z")

</div>

I don’t quite see what your issue is. The AAX wrapper (as all the other wrappers) take care of re-ordering the channels to JUCE channel order. What is the specific problem you are having?

For example, in AAX, the re-ordering is happening [here](https://github.com/WeAreROLI/JUCE/blob/c7c26fa9f033c196c48e743deb6ae16e524ff29a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp#L1066) and [here](https://github.com/WeAreROLI/JUCE/blob/c7c26fa9f033c196c48e743deb6ae16e524ff29a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp#L1641). But as I said, in my [post above](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/4?u=fabian), you needn’t worry about that the internal AAX/AU/VST/VST3 channel order, as the channel order that your audio processor sees, will always be in the same order as the AudioChannelSet enums are defined.

---

<div class="post-metadata">

**Author:** ![audiogaming](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@audiogaming](https://forum.juce.com/u/audiogaming)\
**Post date:** [April 18, 2018, 9:23am UTC](https://forum.juce.com/t/surround-channels-misplaced-on-au-but-they-are-ok-on-aax/24906/19 "2018-04-18T09:23:05Z")

</div>

Right, just found that in the wrapper, thanks !
