OpenShot Audio Library | OpenShotAudio  0.3.2
juce_AudioChannelSet.h
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2017 - ROLI Ltd.
6 
7  JUCE is an open source library subject to commercial or open-source
8  licensing.
9 
10  The code included in this file is provided under the terms of the ISC license
11  http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12  To use, copy, modify, and/or distribute this software for any purpose with or
13  without fee is hereby granted provided that the above copyright notice and
14  this permission notice appear in all copies.
15 
16  JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17  EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18  DISCLAIMED.
19 
20  ==============================================================================
21 */
22 
23 namespace juce
24 {
25 
26 //==============================================================================
46 class JUCE_API AudioChannelSet
47 {
48 public:
52  AudioChannelSet() = default;
53 
56  static AudioChannelSet JUCE_CALLTYPE disabled();
57 
58  //==============================================================================
63  static AudioChannelSet JUCE_CALLTYPE mono();
64 
65 
70  static AudioChannelSet JUCE_CALLTYPE stereo();
71 
72 
73  //==============================================================================
81  static AudioChannelSet JUCE_CALLTYPE createLCR();
82 
83 
90  static AudioChannelSet JUCE_CALLTYPE createLRS();
91 
92 
101  static AudioChannelSet JUCE_CALLTYPE createLCRS();
102 
103 
104  //==============================================================================
112  static AudioChannelSet JUCE_CALLTYPE create5point0();
113 
114 
123  static AudioChannelSet JUCE_CALLTYPE create5point1();
124 
125 
134  static AudioChannelSet JUCE_CALLTYPE create6point0();
135 
136 
143  static AudioChannelSet JUCE_CALLTYPE create6point1();
144 
145 
152  static AudioChannelSet JUCE_CALLTYPE create6point0Music();
153 
154 
159  static AudioChannelSet JUCE_CALLTYPE create6point1Music();
160 
161 
168  static AudioChannelSet JUCE_CALLTYPE create7point0();
169 
170 
177  static AudioChannelSet JUCE_CALLTYPE create7point0SDDS();
178 
179 
187  static AudioChannelSet JUCE_CALLTYPE create7point1();
188 
189 
197  static AudioChannelSet JUCE_CALLTYPE create7point1SDDS();
198 
203  static AudioChannelSet JUCE_CALLTYPE create7point0point2();
204 
209  static AudioChannelSet JUCE_CALLTYPE create7point1point2();
210 
211 
212  //==============================================================================
221  static AudioChannelSet JUCE_CALLTYPE quadraphonic();
222 
223 
228  static AudioChannelSet JUCE_CALLTYPE pentagonal();
229 
230 
235  static AudioChannelSet JUCE_CALLTYPE hexagonal();
236 
237 
242  static AudioChannelSet JUCE_CALLTYPE octagonal();
243 
244  //==============================================================================
249  static AudioChannelSet JUCE_CALLTYPE ambisonic (int order = 1);
250 
254  int getAmbisonicOrder() const;
255 
256  //==============================================================================
258  static AudioChannelSet JUCE_CALLTYPE discreteChannels (int numChannels);
259 
262  static AudioChannelSet JUCE_CALLTYPE canonicalChannelSet (int numChannels);
263 
268  static AudioChannelSet JUCE_CALLTYPE namedChannelSet (int numChannels);
269 
271  static Array<AudioChannelSet> JUCE_CALLTYPE channelSetsWithNumberOfChannels (int numChannels);
272 
273  //==============================================================================
276  {
277  unknown = 0,
279  //==============================================================================
280  left = 1,
281  right = 2,
282  centre = 3,
284  //==============================================================================
285  LFE = 4,
286  leftSurround = 5,
287  rightSurround = 6,
288  leftCentre = 7,
289  rightCentre = 8,
290  centreSurround = 9,
291  surround = centreSurround,
292  leftSurroundSide = 10,
293  rightSurroundSide = 11,
294  topMiddle = 12,
295  topFrontLeft = 13,
296  topFrontCentre = 14,
297  topFrontRight = 15,
298  topRearLeft = 16,
299  topRearCentre = 17,
300  topRearRight = 18,
301  LFE2 = 19,
302  leftSurroundRear = 20,
303  rightSurroundRear = 21,
304  wideLeft = 22,
305  wideRight = 23,
307  //==============================================================================
308  // Used by Dolby Atmos 7.0.2 and 7.1.2
309  topSideLeft = 28,
310  topSideRight = 29,
312  //==============================================================================
313  // Ambisonic ACN formats - all channels are SN3D normalised
314 
315  // zero-th and first-order ambisonic ACN
316  ambisonicACN0 = 24,
317  ambisonicACN1 = 25,
318  ambisonicACN2 = 26,
319  ambisonicACN3 = 27,
321  // second-order ambisonic
322  ambisonicACN4 = 30,
323  ambisonicACN5 = 31,
324  ambisonicACN6 = 32,
325  ambisonicACN7 = 33,
326  ambisonicACN8 = 34,
328  // third-order ambisonic
329  ambisonicACN9 = 35,
330  ambisonicACN10 = 36,
331  ambisonicACN11 = 37,
332  ambisonicACN12 = 38,
333  ambisonicACN13 = 39,
334  ambisonicACN14 = 40,
335  ambisonicACN15 = 41,
337  // fourth-order ambisonic
338  ambisonicACN16 = 42,
339  ambisonicACN17 = 43,
340  ambisonicACN18 = 44,
341  ambisonicACN19 = 45,
342  ambisonicACN20 = 46,
343  ambisonicACN21 = 47,
344  ambisonicACN22 = 48,
345  ambisonicACN23 = 49,
346  ambisonicACN24 = 50,
348  // fifth-order ambisonic
349  ambisonicACN25 = 51,
350  ambisonicACN26 = 52,
351  ambisonicACN27 = 53,
352  ambisonicACN28 = 54,
353  ambisonicACN29 = 55,
354  ambisonicACN30 = 56,
355  ambisonicACN31 = 57,
356  ambisonicACN32 = 58,
357  ambisonicACN33 = 59,
358  ambisonicACN34 = 60,
359  ambisonicACN35 = 61,
361  //==============================================================================
362  ambisonicW = ambisonicACN0,
363  ambisonicX = ambisonicACN3,
364  ambisonicY = ambisonicACN1,
365  ambisonicZ = ambisonicACN2,
367  //==============================================================================
368  bottomFrontLeft = 62,
369  bottomFrontCentre = 63,
370  bottomFrontRight = 64,
372  proxymityLeft = 65,
373  proximityRight = 66,
375  bottomSideLeft = 67,
376  bottomSideRight = 68,
377  bottomRearLeft = 69,
378  bottomRearCentre = 70,
379  bottomRearRight = 71,
381  //==============================================================================
382  discreteChannel0 = 128
383  };
384 
386  static String JUCE_CALLTYPE getChannelTypeName (ChannelType);
387 
389  static String JUCE_CALLTYPE getAbbreviatedChannelTypeName (ChannelType);
390 
392  static ChannelType JUCE_CALLTYPE getChannelTypeFromAbbreviation (const String& abbreviation);
393 
394  //==============================================================================
395  enum
396  {
397  maxChannelsOfNamedLayout = 36
398  };
399 
401  void addChannel (ChannelType newChannelType);
402 
404  void removeChannel (ChannelType newChannelType);
405 
407  int size() const noexcept;
408 
410  bool isDisabled() const noexcept { return size() == 0; }
411 
413  Array<ChannelType> getChannelTypes() const;
414 
416  ChannelType getTypeOfChannel (int channelIndex) const noexcept;
417 
420  int getChannelIndexForType (ChannelType type) const noexcept;
421 
426  String getSpeakerArrangementAsString() const;
427 
431  static AudioChannelSet fromAbbreviatedString (const String& set);
432 
435  String getDescription() const;
436 
438  bool isDiscreteLayout() const noexcept;
439 
441  void intersect (const AudioChannelSet& other) { channels &= other.channels; }
442 
450  static AudioChannelSet JUCE_CALLTYPE channelSetWithChannels (const Array<ChannelType>&);
451 
452  //==============================================================================
453  // Conversion between wave and juce channel layout identifiers
454 
457  static AudioChannelSet JUCE_CALLTYPE fromWaveChannelMask (int32 dwChannelMask);
458 
465  int32 getWaveChannelMask() const noexcept;
466 
467  //==============================================================================
468  bool operator== (const AudioChannelSet&) const noexcept;
469  bool operator!= (const AudioChannelSet&) const noexcept;
470  bool operator< (const AudioChannelSet&) const noexcept;
471 
472 private:
473  //==============================================================================
474  BigInteger channels;
475 
476  //==============================================================================
477  explicit AudioChannelSet (uint32);
478  explicit AudioChannelSet (const Array<ChannelType>&);
479 
480  //==============================================================================
481  static int JUCE_CALLTYPE getAmbisonicOrderForNumChannels (int);
482 };
483 
484 } // namespace juce