Mono vs stereo detection

Hello,

I think it’s a pretty simple question, but what is the best practice for this?
So my Editor needs to know if the plugin opened on Mono or Stereo track. Because the size of editor will be different for each versions.

Could you tell me how to detect what version is launched and in what part of processor it’s better to do?

Thank you

I would store an atomic book in the processor that the editor can query. You can set this in various places in the processor, like from channelLayoutsChanged (or whatever that callback is called), or you could just set it from process block, depending on if the buffer you get sent has 1 or 2 channels.

1 Like

prepareToPlay is the right place for that. You get the input channelset with getMainInputChannelSet() or if you are just interested in the number of channels, call getMainInputChannels().

3 Likes

The plugin host can open your editor without ever having told your plugin whether it wants stereo or mono. It also might change while the editor is already open. Better be prepared for the edge cases and test with things like PT Audiosuite and Cubases offline processing.

That’s it. Thank you!

The only detail that the method is getTotalNumInputChannels().

It depends, if you have one or more input buses. If there is only one input bus, getTotalNumInputChannels() and getMainBusNumInputChannels() should yield the same result.
So using the method I posted will be more robust.

EDIT, I see the typo in my answer, it is not called getMainInputChannels, but the name I wrote now, sorry about that.

2 Likes

Be careful, IIRC in some DAWs (reaper comes to mind) you will always receive a stereo signal, even if the original content is mono. In the case of mono you’ll just have two channels of audio both with exactly the same content. If you need to know if it’s one channel or two the answers above are probably correct, but if you actually want to know if you are dealing with a mono signal or not, then I’m not sure there is any way to be absolutely sure about this, other than maybe analysing the signal but that has it’s own potential issues. This was an issue for a plugin at a company I worked at in the past. We needed to apply different processing for a mono or stereo signal. I think we went for two plugins and the user chooses which one they want. The mono version could be inserted on mono or stereo tracks, where-as the stereo one could only be inserted on stereo tracks. Anything we tried more clever than that always turned back to bite us later.

3 Likes