The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

217 lines
7.9KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_AUDIOCHANNELSET_H_INCLUDED
  18. #define JUCE_AUDIOCHANNELSET_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. Represents a set of audio channel types.
  22. For example, you might have a set of left + right channels, which is a stereo
  23. channel set. It is a collection of values from the AudioChannelSet::ChannelType
  24. enum, where each type may only occur once within the set.
  25. @see AudioProcessorBus
  26. */
  27. class JUCE_API AudioChannelSet
  28. {
  29. public:
  30. /** Creates an empty channel set.
  31. You can call addChannel to add channels to the set.
  32. */
  33. AudioChannelSet() noexcept {}
  34. /** Creates a zero-channel set which can be used to indicate that a
  35. bus is disabled. */
  36. static AudioChannelSet disabled();
  37. /** Creates a one-channel mono set. */
  38. static AudioChannelSet mono();
  39. /** Creates a set containing a left and right channel. */
  40. static AudioChannelSet stereo();
  41. /** Creates a set containing a left, right and centre channels. */
  42. static AudioChannelSet createLCR();
  43. /** Creates a set containing a left, right and centre channels. */
  44. static AudioChannelSet createLRS();
  45. /** Creates a set containing a left, right, centre and surround channels. */
  46. static AudioChannelSet createLCRS();
  47. /** Creates a set for quadraphonic surround setup. */
  48. static AudioChannelSet quadraphonic();
  49. /** Creates a set for pentagonal surround setup. */
  50. static AudioChannelSet pentagonal();
  51. /** Creates a set for hexagonal surround setup. */
  52. static AudioChannelSet hexagonal();
  53. /** Creates a set for octagonal surround setup. */
  54. static AudioChannelSet octagonal();
  55. /** Creates a set for ambisonic surround setups. */
  56. static AudioChannelSet ambisonic();
  57. /** Creates a set for a 5.0 surround setup. */
  58. static AudioChannelSet create5point0();
  59. /** Creates a set for a 5.1 surround setup. */
  60. static AudioChannelSet create5point1();
  61. /** Creates a set for a 6.0 Cine surround setup. */
  62. static AudioChannelSet create6point0();
  63. /** Creates a set for a 6.0 Music surround setup. */
  64. static AudioChannelSet create6point0Music();
  65. /** Creates a set for a 6.1 surround setup. */
  66. static AudioChannelSet create6point1();
  67. /** Creates a set for a 7.0 surround setup. */
  68. static AudioChannelSet create7point0();
  69. /** Creates a set for a 7.1 surround setup. */
  70. static AudioChannelSet create7point1();
  71. /** Creates a set for a 7.1 AC3 C surround setup. */
  72. static AudioChannelSet create7point1AC3();
  73. /** Creates a set for a 7.0 surround setup (with side instead of rear speakers). */
  74. static AudioChannelSet createFront7point0();
  75. /** Creates a set for a 7.1 surround setup (with side instead of rear speakers). */
  76. static AudioChannelSet createFront7point1();
  77. /** Creates a set of untyped discrete channels. */
  78. static AudioChannelSet discreteChannels (int numChannels);
  79. /** Create a canonical channel set for a given number of channels.
  80. For example, numChannels = 1 will return mono, numChannels = 2 will return stereo, etc. */
  81. static AudioChannelSet canonicalChannelSet (int numChannels);
  82. //==============================================================================
  83. /** Represents different audio channel types. */
  84. enum ChannelType
  85. {
  86. unknown = 0,
  87. left = 1,
  88. right = 2,
  89. centre = 3,
  90. subbass = 4,
  91. leftSurround = 5,
  92. rightSurround = 6,
  93. leftCentre = 7,
  94. rightCentre = 8,
  95. surround = 9,
  96. leftSurroundDirect = 10, // also known as "side left"
  97. rightSurroundDirect = 11, // also known as "side right"
  98. topMiddle = 12,
  99. topFrontLeft = 13,
  100. topFrontCentre = 14,
  101. topFrontRight = 15,
  102. topRearLeft = 16,
  103. topRearCentre = 17,
  104. topRearRight = 18,
  105. subbass2 = 19,
  106. leftRearSurround = 20,
  107. rightRearSurround = 21,
  108. wideLeft = 22,
  109. wideRight = 23,
  110. ambisonicW = 24,
  111. ambisonicX = 25,
  112. ambisonicY = 26,
  113. ambisonicZ = 27,
  114. discreteChannel0 = 64 /**< Non-typed individual channels are indexed upwards from this value. */
  115. };
  116. /** Returns the name of a given channel type. For example, this method may return "Surround Left". */
  117. static String getChannelTypeName (ChannelType);
  118. /** Returns the abbreviated name of a channel type. For example, this method may return "Ls". */
  119. static String getAbbreviatedChannelTypeName (ChannelType);
  120. //==============================================================================
  121. /** Adds a channel to the set. */
  122. void addChannel (ChannelType newChannelType);
  123. /** Removes a channel from the set. */
  124. void removeChannel (ChannelType newChannelType);
  125. /** Returns the number of channels in the set. */
  126. int size() const noexcept;
  127. /** Returns true if there are no channels in the set. */
  128. bool isDisabled() const noexcept { return size() == 0; }
  129. /** Returns an array of all the types in this channel set. */
  130. Array<ChannelType> getChannelTypes() const;
  131. /** Returns the type of one of the channels in the set, by index. */
  132. ChannelType getTypeOfChannel (int channelIndex) const noexcept;
  133. /** Returns the index for a particular channel-type.
  134. Will return -1 if the this set does not contain a channel of this type. */
  135. int getChannelIndexForType (ChannelType type) const noexcept;
  136. /** Returns a string containing a whitespace-separated list of speaker types
  137. corresponding to each channel. For example in a 5.1 arrangement,
  138. the string may be "L R C Lfe Ls Rs". If the speaker arrangement is unknown,
  139. the returned string will be empty.*/
  140. String getSpeakerArrangementAsString() const;
  141. /** Returns the description of the current layout. For example, this method may return
  142. "Quadraphonic". Note that the returned string may not be unique. */
  143. String getDescription() const;
  144. /** Returns if this is a channel layout made-up of discrete channels. */
  145. bool isDiscreteLayout() const noexcept;
  146. /** Intersect two channel layouts. */
  147. void intersect (const AudioChannelSet& other) { channels &= other.channels; }
  148. //==============================================================================
  149. bool operator== (const AudioChannelSet&) const noexcept;
  150. bool operator!= (const AudioChannelSet&) const noexcept;
  151. bool operator< (const AudioChannelSet&) const noexcept;
  152. private:
  153. BigInteger channels;
  154. explicit AudioChannelSet (uint32);
  155. };
  156. #endif // JUCE_AUDIOCHANNELSET_H_INCLUDED