Audio plugin host https://kx.studio/carla
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.

376 lines
16KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2016 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of the ISC license
  6. http://www.isc.org/downloads/software-support-policy/isc-license/
  7. Permission to use, copy, modify, and/or distribute this software for any
  8. purpose with or without fee is hereby granted, provided that the above
  9. copyright notice and this permission notice appear in all copies.
  10. THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
  11. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  12. FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
  13. OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  14. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  16. OF THIS SOFTWARE.
  17. -----------------------------------------------------------------------------
  18. To release a closed-source product which uses other parts of JUCE not
  19. licensed under the ISC terms, commercial licenses are available: visit
  20. www.juce.com for more information.
  21. ==============================================================================
  22. */
  23. #ifndef JUCE_AUDIOCHANNELSET_H_INCLUDED
  24. #define JUCE_AUDIOCHANNELSET_H_INCLUDED
  25. //==============================================================================
  26. /**
  27. Represents a set of audio channel types.
  28. For example, you might have a set of left + right channels, which is a stereo
  29. channel set. It is a collection of values from the AudioChannelSet::ChannelType
  30. enum, where each type may only occur once within the set.
  31. The documentation below lists which AudioChannelSet corresponds to which native
  32. layouts used by AAX, VST2/VST3 and CoreAudio/AU. The layout tags in CoreAudio
  33. are particularly confusing. For example, the layout which is labeled as "7.1 SDDS"
  34. in Logic Pro, corresponds to CoreAudio/AU's kAudioChannelLayoutTag_DTS_7_0 tag, whereas
  35. AAX's DTS 7.1 Layout corresponds to CoreAudio/AU's
  36. kAudioChannelLayoutTag_MPEG_7_1_A format, etc. Please do not use the CoreAudio tag
  37. as an indication to the actual layout of the speakers.
  38. @see Bus
  39. */
  40. class JUCE_API AudioChannelSet
  41. {
  42. public:
  43. /** Creates an empty channel set.
  44. You can call addChannel to add channels to the set.
  45. */
  46. AudioChannelSet() noexcept {}
  47. /** Creates a zero-channel set which can be used to indicate that a
  48. bus is disabled. */
  49. static AudioChannelSet disabled();
  50. //==============================================================================
  51. /** Creates a one-channel mono set (centre).
  52. Is equivalent to: kMonoAAX (VST), AAX_eStemFormat_Mono (AAX), kAudioChannelLayoutTag_Mono (CoreAudio)
  53. */
  54. static AudioChannelSet mono();
  55. /** Creates a set containing a stereo set (left, right).
  56. Is equivalent to: kStereo (VST), AAX_eStemFormat_Stereo (AAX), kAudioChannelLayoutTag_Stereo (CoreAudio)
  57. */
  58. static AudioChannelSet stereo();
  59. //==============================================================================
  60. /** Creates a set containing an LCR set (left, right, centre).
  61. Is equivalent to: k30Cine (VST), AAX_eStemFormat_LCR (AAX), kAudioChannelLayoutTag_MPEG_3_0_A (CoreAudio)
  62. This format is referred to as "LRC" in Cubase.
  63. This format is referred to as "LCR" in Pro Tools.
  64. */
  65. static AudioChannelSet createLCR();
  66. /** Creates a set containing an LRS set (left, right, surround).
  67. Is equivalent to: k30Music (VST), n/a (AAX), kAudioChannelLayoutTag_ITU_2_1 (CoreAudio)
  68. This format is referred to as "LRS" in Cubase.
  69. */
  70. static AudioChannelSet createLRS();
  71. /** Creates a set containing an LCRS set (left, right, centre, surround).
  72. Is equivalent to: k40Cine (VST), AAX_eStemFormat_LCRS (AAX), kAudioChannelLayoutTag_MPEG_4_0_A (CoreAudio)
  73. This format is referred to as "LCRS (Pro Logic)" in Logic Pro.
  74. This format is referred to as "LRCS" in Cubase.
  75. This format is referred to as "LCRS" in Pro Tools.
  76. */
  77. static AudioChannelSet createLCRS();
  78. //==============================================================================
  79. /** Creates a set for a 5.0 surround setup (left, right, centre, leftSurround, rightSurround).
  80. Is equivalent to: k50 (VST), AAX_eStemFormat_5_0 (AAX), kAudioChannelLayoutTag_MPEG_5_0_A (CoreAudio)
  81. This format is referred to as "5.0" in Cubase.
  82. This format is referred to as "5.0" in Pro Tools.
  83. */
  84. static AudioChannelSet create5point0();
  85. /** Creates a set for a 5.1 surround setup (left, right, centre, leftSurround, rightSurround, LFE).
  86. Is equivalent to: k51 (VST), AAX_eStemFormat_5_1 (AAX), kAudioChannelLayoutTag_MPEG_5_1_A (CoreAudio)
  87. This format is referred to as "5.1 (ITU 775)" in Logic Pro.
  88. This format is referred to as "5.1" in Cubase.
  89. This format is referred to as "5.1" in Pro Tools.
  90. */
  91. static AudioChannelSet create5point1();
  92. /** Creates a set for a 6.0 Cine surround setup (left, right, centre, leftSurround, rightSurround, centreSurround).
  93. Is equivalent to: k60Cine (VST), AAX_eStemFormat_6_0 (AAX), kAudioChannelLayoutTag_AudioUnit_6_0 (CoreAudio)
  94. Logic Pro incorrectly uses this for the surround format labeled "6.1 (ES/EX)".
  95. This format is referred to as "6.0 Cine" in Cubase.
  96. This format is referred to as "6.0" in Pro Tools.
  97. */
  98. static AudioChannelSet create6point0();
  99. /** Creates a set for a 6.1 Cine surround setup (left, right, centre, leftSurround, rightSurround, centreSurround, LFE).
  100. Is equivalent to: k61Cine (VST), AAX_eStemFormat_6_1 (AAX), kAudioChannelLayoutTag_MPEG_6_1_A (CoreAudio)
  101. This format is referred to as "6.1" in Pro Tools.
  102. */
  103. static AudioChannelSet create6point1();
  104. /** Creates a set for a 6.0 Music surround setup (left, right, leftSurround, rightSurround, leftSurroundSide, rightSurroundSide).
  105. Is equivalent to: k60Music (VST), n/a (AAX), kAudioChannelLayoutTag_DTS_6_0_A (CoreAudio)
  106. This format is referred to as "6.0 Music" in Cubase.
  107. */
  108. static AudioChannelSet create6point0Music();
  109. /** Creates a set for a 6.0 Music surround setup (left, right, leftSurround, rightSurround, leftSurroundSide, rightSurroundSide, LFE).
  110. Is equivalent to: k61Music (VST), n/a (AAX), kAudioChannelLayoutTag_DTS_6_1_A (CoreAudio)
  111. */
  112. static AudioChannelSet create6point1Music();
  113. /** Creates a set for a DTS 7.0 surround setup (left, right, centre, leftSurroundSide, rightSurroundSide, leftSurroundRear, rightSurroundRear).
  114. Is equivalent to: k70Music (VST), AAX_eStemFormat_7_0_DTS (AAX), kAudioChannelLayoutTag_AudioUnit_7_0 (CoreAudio)
  115. This format is referred to as "7.0" in Pro Tools.
  116. */
  117. static AudioChannelSet create7point0();
  118. /** Creates a set for a SDDS 7.0 surround setup (left, right, centre, leftSurround, rightSurround, leftCentre, rightCentre).
  119. Is equivalent to: k70Cine (VST), AAX_eStemFormat_7_0_SDDS (AAX), kAudioChannelLayoutTag_AudioUnit_7_0_Front (CoreAudio)
  120. This format is referred to as "7.0 SDDS" in Pro Tools.
  121. */
  122. static AudioChannelSet create7point0SDDS();
  123. /** Creates a set for a DTS 7.1 surround setup (left, right, centre, leftSurroundSide, rightSurroundSide, leftSurroundRear, rightSurroundRear, LFE).
  124. Is equivalent to: k71CineSideFill (VST), AAX_eStemFormat_7_1_DTS (AAX), kAudioChannelLayoutTag_MPEG_7_1_C/kAudioChannelLayoutTag_ITU_3_4_1 (CoreAudio)
  125. This format is referred to as "7.1 (3/4.1)" in Logic Pro.
  126. This format is referred to as "7.1" in Pro Tools.
  127. */
  128. static AudioChannelSet create7point1();
  129. /** Creates a set for a 7.1 surround setup (left, right, centre, leftSurround, rightSurround, leftCentre, rightCentre, LFE).
  130. Is equivalent to: k71Cine (VST), AAX_eStemFormat_7_1_SDDS (AAX), kAudioChannelLayoutTag_MPEG_7_1_A (CoreAudio)
  131. This format is referred to as "7.1 (SDDS)" in Logic Pro.
  132. This format is referred to as "7.1 SDDS" in Pro Tools.
  133. */
  134. static AudioChannelSet create7point1SDDS();
  135. //==============================================================================
  136. /** Creates a set for ambisonic surround setups (ambisonicW, ambisonicX, ambisonicY, ambisonicZ).
  137. Is equivalent to: kBFormat (VST), n/a (AAX), kAudioChannelLayoutTag_Ambisonic_B_Format (CoreAudio)
  138. */
  139. static AudioChannelSet ambisonic();
  140. /** Creates a set for quadraphonic surround setup (left, right, leftSurround, rightSurround)
  141. Is equivalent to: k40Music (VST), AAX_eStemFormat_Quad (AAX), kAudioChannelLayoutTag_Quadraphonic (CoreAudio)
  142. This format is referred to as "Quadraphonic" in Logic Pro.
  143. This format is referred to as "Quadro" in Cubase.
  144. This format is referred to as "Quad" in Pro Tools.
  145. */
  146. static AudioChannelSet quadraphonic();
  147. /** Creates a set for pentagonal surround setup (left, right, centre, leftSurroundRear, rightSurroundRear).
  148. Is equivalent to: n/a (VST), n/a (AAX), kAudioChannelLayoutTag_Pentagonal (CoreAudio)
  149. */
  150. static AudioChannelSet pentagonal();
  151. /** Creates a set for hexagonal surround setup (left, right, leftSurroundRear, rightSurroundRear, centre, surroundCentre).
  152. Is equivalent to: n/a (VST), n/a (AAX), kAudioChannelLayoutTag_Hexagonal (CoreAudio)
  153. */
  154. static AudioChannelSet hexagonal();
  155. /** Creates a set for octagonal surround setup (left, right, leftSurround, rightSurround, centre, centreSurround, wideLeft, wideRight).
  156. Is equivalent to: n/a (VST), n/a (AAX), kAudioChannelLayoutTag_Octagonal (CoreAudio)
  157. */
  158. static AudioChannelSet octagonal();
  159. //==============================================================================
  160. /** Creates a set of untyped discrete channels. */
  161. static AudioChannelSet discreteChannels (int numChannels);
  162. /** Create a canonical channel set for a given number of channels.
  163. For example, numChannels = 1 will return mono, numChannels = 2 will return stereo, etc. */
  164. static AudioChannelSet canonicalChannelSet (int numChannels);
  165. /** Create a channel set for a given number of channels which is non-discrete.
  166. If numChannels is larger than the number of channels of the surround format
  167. with the maximum amount of channels (currently 7.1 Surround), then this
  168. function returns an empty set.*/
  169. static AudioChannelSet namedChannelSet (int numChannels);
  170. /** Return an array of channel sets which have a given number of channels */
  171. static Array<AudioChannelSet> channelSetsWithNumberOfChannels (int numChannels);
  172. //==============================================================================
  173. /** Represents different audio channel types. */
  174. enum ChannelType
  175. {
  176. unknown = 0,
  177. left = 1, // L
  178. right = 2, // R
  179. centre = 3, // C (sometimes M for mono)
  180. LFE = 4,
  181. leftSurround = 5, // Ls
  182. rightSurround = 6, // Rs
  183. leftCentre = 7, // Lc (AAX/VST), Lc used as Lss in AU for most layouts
  184. rightCentre = 8, // Rc (AAX/VST), Rc used as Rss in AU for most layouts
  185. centreSurround = 9, // Cs/S
  186. surround = centreSurround, // Cs/S
  187. leftSurroundSide = 10, // Lss (AXX), Side Left "Sl" (VST), Left Centre "LC" (AU)
  188. rightSurroundSide = 11, // Rss (AXX), Side right "Sr" (VST), Right Centre "Rc" (AU)
  189. topMiddle = 12,
  190. topFrontLeft = 13,
  191. topFrontCentre = 14,
  192. topFrontRight = 15,
  193. topRearLeft = 16,
  194. topRearCentre = 17,
  195. topRearRight = 18,
  196. LFE2 = 19,
  197. leftSurroundRear = 20, // Lsr (AAX), Lcs (VST), Rls (AU)
  198. rightSurroundRear = 21, // Rsr (AAX), Rcs (VST), Rrs (AU)
  199. wideLeft = 22,
  200. wideRight = 23,
  201. ambisonicW = 24,
  202. ambisonicX = 25,
  203. ambisonicY = 26,
  204. ambisonicZ = 27,
  205. discreteChannel0 = 64 /**< Non-typed individual channels are indexed upwards from this value. */
  206. };
  207. /** Returns the name of a given channel type. For example, this method may return "Surround Left". */
  208. static String getChannelTypeName (ChannelType);
  209. /** Returns the abbreviated name of a channel type. For example, this method may return "Ls". */
  210. static String getAbbreviatedChannelTypeName (ChannelType);
  211. /** Returns the channel type from an abbreviated name. */
  212. static ChannelType getChannelTypeFromAbbreviation (const String& abbreviation);
  213. //==============================================================================
  214. enum
  215. {
  216. maxChannelsOfNamedLayout = 8
  217. };
  218. /** Adds a channel to the set. */
  219. void addChannel (ChannelType newChannelType);
  220. /** Removes a channel from the set. */
  221. void removeChannel (ChannelType newChannelType);
  222. /** Returns the number of channels in the set. */
  223. int size() const noexcept;
  224. /** Returns true if there are no channels in the set. */
  225. bool isDisabled() const noexcept { return size() == 0; }
  226. /** Returns an array of all the types in this channel set. */
  227. Array<ChannelType> getChannelTypes() const;
  228. /** Returns the type of one of the channels in the set, by index. */
  229. ChannelType getTypeOfChannel (int channelIndex) const noexcept;
  230. /** Returns the index for a particular channel-type.
  231. Will return -1 if the this set does not contain a channel of this type. */
  232. int getChannelIndexForType (ChannelType type) const noexcept;
  233. /** Returns a string containing a whitespace-separated list of speaker types
  234. corresponding to each channel. For example in a 5.1 arrangement,
  235. the string may be "L R C Lfe Ls Rs". If the speaker arrangement is unknown,
  236. the returned string will be empty.*/
  237. String getSpeakerArrangementAsString() const;
  238. /** Returns an AudioChannelSet from a string returned by getSpeakerArrangementAsString
  239. @see getSpeakerArrangementAsString */
  240. static AudioChannelSet fromAbbreviatedString (const String& set);
  241. /** Returns the description of the current layout. For example, this method may return
  242. "Quadraphonic". Note that the returned string may not be unique. */
  243. String getDescription() const;
  244. /** Returns if this is a channel layout made-up of discrete channels. */
  245. bool isDiscreteLayout() const noexcept;
  246. /** Intersect two channel layouts. */
  247. void intersect (const AudioChannelSet& other) { channels &= other.channels; }
  248. //==============================================================================
  249. bool operator== (const AudioChannelSet&) const noexcept;
  250. bool operator!= (const AudioChannelSet&) const noexcept;
  251. bool operator< (const AudioChannelSet&) const noexcept;
  252. private:
  253. BigInteger channels;
  254. explicit AudioChannelSet (uint32);
  255. };
  256. #endif // JUCE_AUDIOCHANNELSET_H_INCLUDED