# Trouble finding index corresponding to Nth channel of AAX output in processBlock()

**URL:** <https://forum.juce.com/t/trouble-finding-index-corresponding-to-nth-channel-of-aax-output-in-processblock/56363>\
**Category:** Audio Plugins\
**Created:** [May 24, 2023, 2:52am UTC](https://forum.juce.com/t/trouble-finding-index-corresponding-to-nth-channel-of-aax-output-in-processblock/56363 "2023-05-24T02:52:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hij1234](https://avatars.discourse-cdn.com/v4/letter/h/8e7dd6/32.png) [@hij1234](https://forum.juce.com/u/hij1234)\
**Post date:** [May 24, 2023, 2:52am UTC](https://forum.juce.com/t/trouble-finding-index-corresponding-to-nth-channel-of-aax-output-in-processblock/56363/1 "2023-05-24T02:52:19Z")

</div>

Hi all,  
I’m working on an AAX plugin that’s capable of outputting a number of layouts with a number of different channel widths. I’ve noticed that the nth channel in the processBlock array doesn’t necessarily correspond to the nth channel of the output in pro tools, so I’m in search of a method that will let me get the process block array index corresponding to the Nth channel of the plugin’s output. I thought I may have found this in `getChannelIndexInProcessBlockBuffer`, but I’m finding this difficult to use (perhaps because I’m using it wrong). Since there’s only one output bus, I tried `getChannelIndexInProcessBlockBuffer(false, 0, n)` to get the process block buffer index corresponding to the nth output channel, but I find that I always get n back though even when this is not the case (in LCR, for example, the channel corresponding to the “1” index in processBlock is the third channel of the output; I can provide an example if necessary).

I’d be surprised if there isn’t a method to do what I need already around – can anyone here point me in the right direction?

---

<div class="post-metadata">

**Author:** ![railjonrogut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/railjonrogut/32/505_2.png) [@railjonrogut](https://forum.juce.com/u/railjonrogut)\
**Post date:** [May 24, 2023, 6:22pm UTC](https://forum.juce.com/t/trouble-finding-index-corresponding-to-nth-channel-of-aax-output-in-processblock/56363/2 "2023-05-24T18:22:07Z")

</div>

The AAX wrapper reorders the channels in the AudioBuffer to the JUCE order which is different to the AAX order… so you would process your AudioBuffer in the JUCE order… if you need to know the original AAX channel order you’ll have to deal with that yourself… JUCE has no mechanism currently to get that. the AAXClasses aren’t available publicly…

I recently started a thread which discussed some of this:

> [@AAX Channel order](https://forum.juce.com/t/aax-channel-order/56181/3):
>
> Okay… It appears that the AudioBuffer is sorted in the AAX wrapper to match the JUCE order: 0 2 1 7 3 4 5 6 8 9 So I guess I have to re-order the meter and channels in the UI to display them in the expected AAX order… but it would help if there were some methods in the AudioChannelSet class to get the native channel order. Rail

I created a separate utility with copies of some of the AAXClasses’ code in a new namespace with this:

```auto
static StringArray getAAXSpeakerArrangementAsString (AAX_EStemFormat aaxStemFormat)
{
    StringArray speakerTypes;
    
    int layoutIndex;
    
    for (layoutIndex = 0; aaxChannelOrder[layoutIndex].aaxStemFormat != aaxStemFormat; ++layoutIndex)
        if (aaxChannelOrder[layoutIndex].aaxStemFormat == 0) return {};

    auto& channelOrder = aaxChannelOrder[layoutIndex];
    const auto& speakerOrder = channelOrder.speakerOrder;
    
    for (auto spker : speakerOrder)
        {        
        String szChannel = AudioChannelSet::getAbbreviatedChannelTypeName (spker);
        
        speakerTypes.add (szChannel);
        }
    
    return speakerTypes;
}

```

I actually was gonna contact the JUCE devs to ask them to reformat the AAX wrapper slightly which would help us not have to duplicate the AAXClasses AAX\_EStemFormat and AAXChannel\_StreamOrder…

Have them rename the juce\_audio\_plugin\_client\_AAX.cpp file to a header and add a #pragma once at the top… and in juce\_audio\_plugin\_client\_AAX.cpp just include the juce\_audio\_plugin\_client\_AAX.h

I had to do this for adding the AAX DSP mods as well since they also need to use the AAXClasses externally so I needed to include the juce\_audio\_plugin\_client\_AAX.h

Cheers!

Rail

---

<div class="post-metadata">

**Author:** ![hij1234](https://avatars.discourse-cdn.com/v4/letter/h/8e7dd6/32.png) [@hij1234](https://forum.juce.com/u/hij1234)\
**Post date:** [May 26, 2023, 11:12pm UTC](https://forum.juce.com/t/trouble-finding-index-corresponding-to-nth-channel-of-aax-output-in-processblock/56363/3 "2023-05-26T23:12:09Z")

</div>

Thanks Rail, I appreciate the response! This makes sense, I’ll look into making some tweaks to the AAX layer in our juce fork.  
Best,  
Isaac
