AudioChannelSet Intersection (w/ code submission)


#1

Hi, I’m in a situation where I need to find out what channels are shared between two AudioChannelSets, i.e. if one AudioChannelSet is LCR (left, right, center) and another is LRS (left, right, surround), then the intersection would produce stereo (left, right). I looked through the implementation of AudioChannelSet and since the layout is stored as a BigInteger mask it’s extremely easy to add via an and operation on the two BigIntegers. This would be the function:

juce_AudioChannelSet.h: class JUCE_API AudioChannelSet { public: ... void intersect (const AudioChannelSet& other) { channels &= other.channels; } ... }

Thanks!


#2

Any feedback on this? Another option is to add a raw getter/setter/constructor to the underlying channel mask so it can be manipulated manually, i.e.

void AudioChannelSets (BigInteger mask) : channels (mask) {}
BigInteger getChannelMask() const { return channels; }
void setChannelMask (BigInteger mask) { channels = mask; }

since the ChannelType enum layout is public, this is still sensical data for users outside of the class.


#3

I think you will need to have a little patience, according to what is being posted here in the forum, it seems that some relevant bugs appeared in ver. 4.2 and I believe most of the current attention of JUCE team is towards fixing those.
Once the dust has settled, I’m sure they’ll read and reply to this topic, too.


#4

Indeed, there definitely seems to be a number of bugs with 4.2 and that is a priority. Just don’t want to see this get buried since AFAIK posting here is the only way to request changes/features.


#5

Looks like a great feature. I’ll add it. Thanks!


#6

Thank you fabian!!


#7

The intersect method is on the latest tip of develop now.