Browse Source

Add getChannelIndexForType to AudioChannelSet class

tags/2021-05-28
hogliux 9 years ago
parent
commit
7ee4c800a9
2 changed files with 18 additions and 0 deletions
  1. +14
    -0
      modules/juce_audio_processors/processors/juce_AudioChannelSet.cpp
  2. +4
    -0
      modules/juce_audio_processors/processors/juce_AudioChannelSet.h

+ 14
- 0
modules/juce_audio_processors/processors/juce_AudioChannelSet.cpp View File

@@ -135,6 +135,20 @@ AudioChannelSet::ChannelType AudioChannelSet::getTypeOfChannel (int index) const
return static_cast<ChannelType> (bit);
}
int AudioChannelSet::getChannelIndexForType (AudioChannelSet::ChannelType type) const noexcept
{
int idx = 0;
for (int bit = channels.findNextSetBit (0); bit >= 0; bit = channels.findNextSetBit (bit + 1))
{
if (static_cast<ChannelType> (bit) == type)
return idx;
idx++;
}
return -1;
}
Array<AudioChannelSet::ChannelType> AudioChannelSet::getChannelTypes() const
{
Array<ChannelType> result;


+ 4
- 0
modules/juce_audio_processors/processors/juce_AudioChannelSet.h View File

@@ -166,6 +166,10 @@ public:
/** Returns the type of one of the channels in the set, by index. */
ChannelType getTypeOfChannel (int channelIndex) const noexcept;
/** Returns the index for a particular channel-type.
Will return -1 if the this set does not contain a channel of this type. */
int getChannelIndexForType (ChannelType type) const noexcept;
/** Returns a string containing a whitespace-separated list of speaker types
corresponding to each channel. For example in a 5.1 arrangement,
the string may be "L R C Lfe Ls Rs". If the speaker arrangement is unknown,


Loading…
Cancel
Save