Query how Juce reorders channels

Hi everyone,

is there a way to query how juce internally reorders the input and output channel to convert from the internal speaker layout to those used in the hosts, like Logic for example?

I want to check this to actually have my meters move on channel 1 when the hosts meter also moves on channel 1 etc. It is also important for me to know this because I want to provide the user a channel assignment feature for the inputs which of course must reflect the incoming channels.

Best,

Thomas

1 Like

JUCE channels are ordered using AudioChannelSet. You can query the AudioChannelSet for each bus from the AudioProcessor, and use AudioChannelSet::getTypeOfChannel(int) to find the kind of channel at a specific index in the bus.

Hi reuk,

hm, let me give you an example. In Logic pro the Quadro channel set is ordered from 1-4 like this:
LS, L, R, RS. In Juce however the order is L, R, LS, RS and juce then converts back and forth.

I need the info about what is converted to what as int. That means, what juce internal channel nr. corresponds to which channel nr. in Logic?

Is that available in AudioChannelSet?

Thanks.

I don’t think it necessarily makes sense to think about the ‘channel number’ in Logic. Instead, you should probably use the ‘channel type’ to differentiate channels. You can query the channel type of a particular channel using getTypeOfChannel, or find the index of a particular channel type using getChannelIndexForType.

In my case it makes sense. Otherwise I would not ask.

In the example I gave in my previous post, how could I implement multichannel metering which moves in the same way as the multichannel metering on the logic channel? Meaning, if channel 1 moves in the plugin it should also be channel 1 in Logic, etc…

And metering is just an example.

By trying to take off the burden of thinking about channel order of the Juce user through this channel reordering abstraction layer, this problem now arises. Except I could switch off the reordering or get the info about which channel nr. in Juce is mapped to which channel nr. in Logic/Protools/etc…

1 Like

Another problem is also that in certain layouts the azimuth values of L and R are 30° or -30°, while in others 45° and -45°. The channel type is not telling me anything about that. So I need to create a solution for that by myself to have correct rendering.

1 Like

There’s no way to do this. The channel order that Logic displays in its UI does not correspond to the channel order that is passed to the plugin’s processing callback, and there’s no way to query the order in which channels are displayed in the host UI.

Instead, a better approach is to pick a channel order that you want to use in your plugin (e.g. LS L C R RS LFE) and then to use getChannelIndexForType to find the index of the channel with a particular type. As long as the channel meters are labelled clearly, the channel ordering will be obvious to the user.

I checked out a couple of 5.1 AU plugins in Logic. FabFilter ProQ 3 displays the channels in the order L C R LS RS LFE, and Izotope Neutron 3 uses L R C LS RS LFE. Both of these layouts differ from Logic’s built-in Level Meter, which uses LS L C R RS LFE. In all cases, the interface is easy to understand because the meters are clearly labelled.

Unfortunately I don’t think there’s a way to query the speaker locations/angles using the current JUCE API.

So if i understand this correctly, Logic/AU is not communicating to Juce any kind of channel numbers associated with channel types, such as left, right etc.?

I know that I currently have no way of knowing anything about what Logic does from within the process callback or any other part of my PluginProcessor implementation. Thats why I ask. I also have the problem on the input side. On the input side the user of my plugin can choose what to do with each input channel, by number, not by name…

1 Like

AU hosts pass the channels in an order specified by a channel tag, e.g. kAudioChannelLayoutTag_MPEG_5_1_A (L R C LFE LS RS). This channel layout is not guaranteed to match the layout displayed in the host’s UI. As far as I’m aware, there’s no way to query the channel number/order that a host uses in its UI.

Ok, got it. Now, for 5.1 Juce uses left, right, centre, LFE, leftSurround, rightSurround. Is there a way to query this conversion?

And, is this kind of conversion host specific or plugin format specific (VST3, AU, AAX)?

Yes; look at the documentation for AudioChannelSet. You can use getChannelTypes to find the types of the channels in the set, and their orders. You can also use getTypeOfChannel to find the type of a channel at a particular index; and getChannelIndexForType to find the index of a channel with a particular type.

The ordering is consistent across hosts and plugin formats. A 5.1 layout will always use the order L R C LFE LS RS.

Sorry, but you just wrote that kAudioChannelLayoutTag_MPEG_5_1_A (L R C LFE LS RS).

This order is different from the Juce order. I need to query this conversion between this order and the Juce internal order.

getChannelTypes, getTypeOfChannel and getChannelIndexForType only refer to the Juce internal order, as far as i understand and this i already use. Or am i getting something totally wrong?

There’s no way to query the host’s original layout. It’s only possible to query the JUCE layout.

Can you give some more details about what you’re trying to achieve? At the moment, I don’t understand why you would need to query the host’s channel layout.

In case it wasn’t clear, the order in which the host passes channels to the plugin’s processing callback is likely to be different from the order in which the host displays those channels in its UI.

There cannot be an answer, since the user can even change the displayed order of the channels:

(Sorry for the German, I thought I had my system set to English UK…)
Kanalreihenfolge == Channel order

1 Like

@reuk Ok, got it. Well originally i wanted to make everything line up correctly, metering, input selection and output format. Since that idea just fell apart with the Logic meters having nothing to do with the actual channels I have to look for another way to do what I want without knowing the external format. But thanks for digging into this.

@daniel Danke für diese Info, kein Problem. :wink:

Kein Problem :slight_smile:

I would go the same route and offer the user those choices, so they can select their preferred order.
Just save it in a PropertiesFile rather than in the plugin instance, so it becomes a global setting for your plugin.

1 Like

Nah, since this only makes sense for Logic, not worth the effort. Other DAWs don’t care about this or do it another way so I do not want to create too much dependency on DAW specifics. The plugin I am developing is already complex.

@reuk Ok, so i am doing some further testing with Logic and hell, things seem to be wrong. Here it comes:

LCRS in Logic is identified as Quadraphonic
6.1 (ES/EX) in Logic is identified as 7.0 Surround
7.1 (SDDS) in Logic is identified as 7.1 Surround
5.1.2 in Logic is identified as 7.1 Surround
5.1.4 in Logic is identified as Discrete #10
7.1.2 in Logic is identified as Discrete #10
7.1.4 in Logic is identified as Discrete #12

Logic 10.7.2 and Juce master 6.1.5

See also:

sorry to resurrect this but I still am confused with the implementation of this and why this cannot be achieved

to give an example i know that in PT on a 7.1 bus the index is expected as:

[0] = juce::AudioChannelSet::ChannelType::left;
[1] = juce::AudioChannelSet::ChannelType::centre;
[2] = juce::AudioChannelSet::ChannelType::right;
[3] = juce::AudioChannelSet::ChannelType::leftSurroundSide;
[4] = juce::AudioChannelSet::ChannelType::rightSurroundSide;
[5] = juce::AudioChannelSet::ChannelType::leftSurroundRear;
[6] = juce::AudioChannelSet::ChannelType::rightSurroundRear;
[7] = juce::AudioChannelSet::ChannelType::LFE;

however when checking for non-discrete channel layouts via the suggested getTypeOfChannel(int index) I get this returned:

[0]	juce::AudioChannelSet::ChannelType::left
[1]	juce::AudioChannelSet::ChannelType::right
[2]	juce::AudioChannelSet::ChannelType::centre
[3]	juce::AudioChannelSet::ChannelType::LFE
[4]	juce::AudioChannelSet::ChannelType::leftSurroundSide
[5]	juce::AudioChannelSet::ChannelType::rightSurroundSide
[6]	juce::AudioChannelSet::ChannelType::leftSurroundRear
[7]	juce::AudioChannelSet::ChannelType::rightSurroundRear

previously i had to maintain an ever growing list of what each DAW expects the order of each channel layout for non-discrete multichannel formats and I dont understand why this cant be maintained in JUCE since thats what some of the functions in AudioChannelSet led me to believe was possible, happy to hear more of a picture outside of this case but ultimately im not sure i understand what the purpose of getTypeOfChannel(int) is if it can report back an incorrect order

also I understand that some host settings can change the channel order outside the scope/view of the plugin SDK, but at the very least in PT (as an example) the order that function returns is never correct as far as I can see and I don’t see why it cant at least capture the default known layout order and let this become a function needed from the AAX SDK side