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.

188 lines
6.6KB

  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, centre and surround channels. */
  44. static AudioChannelSet createLCRS();
  45. /** Creates a set for quadraphonic surround setup. */
  46. static AudioChannelSet quadraphonic();
  47. /** Creates a set for pentagonal surround setup. */
  48. static AudioChannelSet pentagonal();
  49. /** Creates a set for hexagonal surround setup. */
  50. static AudioChannelSet hexagonal();
  51. /** Creates a set for octagonal surround setup. */
  52. static AudioChannelSet octagonal();
  53. /** Creates a set for ambisonic surround setups. */
  54. static AudioChannelSet ambisonic();
  55. /** Creates a set for a 5.0 surround setup. */
  56. static AudioChannelSet create5point0();
  57. /** Creates a set for a 5.1 surround setup. */
  58. static AudioChannelSet create5point1();
  59. /** Creates a set for a 6.0 surround setup. */
  60. static AudioChannelSet create6point0();
  61. /** Creates a set for a 6.1 surround setup. */
  62. static AudioChannelSet create6point1();
  63. /** Creates a set for a 7.0 surround setup. */
  64. static AudioChannelSet create7point0();
  65. /** Creates a set for a 7.1 surround setup. */
  66. static AudioChannelSet create7point1();
  67. /** Creates a set for a 7.0 surround setup (with side instead of rear speakers). */
  68. static AudioChannelSet createFront7point0();
  69. /** Creates a set for a 7.1 surround setup (with side instead of rear speakers). */
  70. static AudioChannelSet createFront7point1();
  71. /** Creates a set of untyped discrete channels. */
  72. static AudioChannelSet discreteChannels (int numChannels);
  73. /** Create a canonical channel set for a given number of channels.
  74. For example, numChannels = 1 will return mono, numChannels = 2 will return stereo, etc. */
  75. static AudioChannelSet canonicalChannelSet (int numChannels);
  76. //==============================================================================
  77. /** Represents different audio channel types. */
  78. enum ChannelType
  79. {
  80. unknown = 0,
  81. left = 1,
  82. right = 2,
  83. centre = 3,
  84. subbass = 4,
  85. surroundLeft = 5,
  86. surroundRight = 6,
  87. centreLeft = 7,
  88. centreRight = 8,
  89. surround = 9,
  90. sideLeft = 10,
  91. sideRight = 11,
  92. topMiddle = 12,
  93. topFrontLeft = 13,
  94. topFrontCentre = 14,
  95. topFrontRight = 15,
  96. topRearLeft = 16,
  97. topRearCentre = 17,
  98. topRearRight = 18,
  99. wideLeft = 19,
  100. wideRight = 20,
  101. subbass2 = 21,
  102. ambisonicW = 22,
  103. ambisonicX = 23,
  104. ambisonicY = 24,
  105. ambisonicZ = 25,
  106. discreteChannel0 = 64 /**< Non-typed individual channels are indexed upwards from this value. */
  107. };
  108. /** Returns the name of a given channel type. For example, this method may return "Surround Left". */
  109. static const char* getChannelTypeName (ChannelType) noexcept;
  110. /** Returns the abbreviated name of a channel type. For example, this method may return "Ls". */
  111. static const char* getAbbreviatedChannelTypeName (ChannelType) noexcept;
  112. //==============================================================================
  113. /** Adds a channel to the set. */
  114. void addChannel (ChannelType newChannelType);
  115. /** Returns the number of channels in the set. */
  116. int size() const noexcept;
  117. /** Returns the number of channels in the set. */
  118. bool isDisabled() const noexcept { return size() == 0; }
  119. /** Returns an array of all the types in this channel set. */
  120. Array<ChannelType> getChannelTypes() const;
  121. /** Returns the type of one of the channels in the set, by index. */
  122. ChannelType getTypeOfChannel (int channelIndex) const noexcept;
  123. /** Returns a string containing a whitespace-separated list of speaker types
  124. corresponding to each channel. For example in a 5.1 arrangement,
  125. the string may be "L R C Lfe Ls Rs". If the speaker arrangement is unknown,
  126. the returned string will be empty.*/
  127. String getSpeakerArrangementAsString() const;
  128. //==============================================================================
  129. bool operator== (const AudioChannelSet&) const noexcept;
  130. bool operator!= (const AudioChannelSet&) const noexcept;
  131. bool operator< (const AudioChannelSet&) const noexcept;
  132. private:
  133. BigInteger channels;
  134. explicit AudioChannelSet (uint32);
  135. };
  136. #endif // JUCE_AUDIOCHANNELSET_H_INCLUDED