27#if JUCE_MAC || JUCE_IOS
29#include "../../juce_audio_basics/native/juce_mac_CoreAudioLayouts.h"
37 const char*
const coreAudioFormatName =
"CoreAudio supported file";
39 StringArray findFileExtensionsForCoreAudioCodecs()
41 StringArray extensionsArray;
42 CFArrayRef extensions =
nullptr;
43 UInt32 sizeOfArray =
sizeof (extensions);
45 if (AudioFileGetGlobalInfo (kAudioFileGlobalInfo_AllExtensions, 0,
nullptr, &sizeOfArray, &extensions) == noErr)
47 auto numValues = CFArrayGetCount (extensions);
49 for (CFIndex i = 0; i < numValues; ++i)
50 extensionsArray.add (
"." +
String::fromCFString ((CFStringRef) CFArrayGetValueAtIndex (extensions, i)));
52 CFRelease (extensions);
55 return extensionsArray;
115 uint32 bytesPerPacket;
116 uint32 framesPerPacket;
117 uint32 channelsPerFrame;
118 uint32 bitsPerChannel;
128 input.
read (uuid,
sizeof (uuid));
130 if (memcmp (uuid,
"\x29\x81\x92\x73\xB5\xBF\x4A\xEF\xB7\x8D\x62\xD1\xEF\x90\xBB\x2C", 16) == 0)
134 for (uint32 i = 0; i < numEntries && input.
getPosition() < originalPosition + size; ++i)
146 static StringPairArray parseMidiChunk (InputStream& input, int64 size)
148 auto originalPosition = input.getPosition();
150 MemoryBlock midiBlock;
151 input.readIntoMemoryBlock (midiBlock, (ssize_t) size);
152 MemoryInputStream midiInputStream (midiBlock,
false);
154 StringPairArray midiMetadata;
157 if (midiFile.readFrom (midiInputStream))
161 findTempoEvents (midiFile, midiMetadata);
162 findTimeSigEvents (midiFile, midiMetadata);
163 findKeySigEvents (midiFile, midiMetadata);
166 input.setPosition (originalPosition + size);
170 static void findTempoEvents (MidiFile& midiFile, StringPairArray& midiMetadata)
172 MidiMessageSequence tempoEvents;
173 midiFile.findAllTempoEvents (tempoEvents);
175 auto numTempoEvents = tempoEvents.getNumEvents();
176 MemoryOutputStream tempoSequence;
178 for (
int i = 0; i < numTempoEvents; ++i)
180 auto tempo = getTempoFromTempoMetaEvent (tempoEvents.getEventPointer (i));
187 if (numTempoEvents > 1)
188 tempoSequence << String (tempo) <<
',' << tempoEvents.getEventTime (i) <<
';';
192 if (tempoSequence.getDataSize() > 0)
193 midiMetadata.set (
"tempo sequence", tempoSequence.toUTF8());
196 static double getTempoFromTempoMetaEvent (MidiMessageSequence::MidiEventHolder* holder)
198 if (holder !=
nullptr)
200 auto& midiMessage = holder->message;
202 if (midiMessage.isTempoMetaEvent())
204 auto tempoSecondsPerQuarterNote = midiMessage.getTempoSecondsPerQuarterNote();
206 if (tempoSecondsPerQuarterNote > 0.0)
207 return 60.0 / tempoSecondsPerQuarterNote;
214 static void findTimeSigEvents (MidiFile& midiFile, StringPairArray& midiMetadata)
216 MidiMessageSequence timeSigEvents;
217 midiFile.findAllTimeSigEvents (timeSigEvents);
218 auto numTimeSigEvents = timeSigEvents.getNumEvents();
220 MemoryOutputStream timeSigSequence;
222 for (
int i = 0; i < numTimeSigEvents; ++i)
224 int numerator, denominator;
225 timeSigEvents.getEventPointer(i)->message.getTimeSignatureInfo (numerator, denominator);
227 String timeSigString;
228 timeSigString << numerator <<
'/' << denominator;
233 if (numTimeSigEvents > 1)
234 timeSigSequence << timeSigString <<
',' << timeSigEvents.getEventTime (i) <<
';';
237 if (timeSigSequence.getDataSize() > 0)
238 midiMetadata.set (
"time signature sequence", timeSigSequence.toUTF8());
241 static void findKeySigEvents (MidiFile& midiFile, StringPairArray& midiMetadata)
243 MidiMessageSequence keySigEvents;
244 midiFile.findAllKeySigEvents (keySigEvents);
245 auto numKeySigEvents = keySigEvents.getNumEvents();
247 MemoryOutputStream keySigSequence;
249 for (
int i = 0; i < numKeySigEvents; ++i)
251 auto& message (keySigEvents.getEventPointer (i)->message);
252 auto key = jlimit (0, 14, message.getKeySignatureNumberOfSharpsOrFlats() + 7);
253 bool isMajor = message.isKeySignatureMajorKey();
255 static const char* majorKeys[] = {
"Cb",
"Gb",
"Db",
"Ab",
"Eb",
"Bb",
"F",
"C",
"G",
"D",
"A",
"E",
"B",
"F#",
"C#" };
256 static const char* minorKeys[] = {
"Ab",
"Eb",
"Bb",
"F",
"C",
"G",
"D",
"A",
"E",
"B",
"F#",
"C#",
"G#",
"D#",
"A#" };
258 String keySigString (isMajor ? majorKeys[key]
267 if (numKeySigEvents > 1)
268 keySigSequence << keySigString <<
',' << keySigEvents.getEventTime (i) <<
';';
271 if (keySigSequence.getDataSize() > 0)
272 midiMetadata.set (
"key signature sequence", keySigSequence.toUTF8());
276 static StringPairArray parseInformationChunk (InputStream& input)
278 StringPairArray infoStrings;
279 auto numEntries = (uint32) input.readIntBigEndian();
281 for (uint32 i = 0; i < numEntries; ++i)
282 infoStrings.
set (input.readString(), input.readString());
288 static bool read (InputStream& input, StringPairArray& metadataValues)
290 auto originalPos = input.getPosition();
292 const FileHeader cafFileHeader (input);
293 const bool isCafFile = cafFileHeader.fileType == chunkName (
"caff");
297 while (! input.isExhausted())
299 const ChunkHeader chunkHeader (input);
301 if (chunkHeader.chunkType == chunkName (
"desc"))
303 AudioDescriptionChunk audioDescriptionChunk (input);
305 else if (chunkHeader.chunkType == chunkName (
"uuid"))
307 metadataValues.addArray (parseUserDefinedChunk (input, chunkHeader.chunkSize));
309 else if (chunkHeader.chunkType == chunkName (
"data"))
314 if (chunkHeader.chunkSize == -1)
317 input.setPosition (input.getPosition() + chunkHeader.chunkSize);
319 else if (chunkHeader.chunkType == chunkName (
"midi"))
321 metadataValues.addArray (parseMidiChunk (input, chunkHeader.chunkSize));
323 else if (chunkHeader.chunkType == chunkName (
"info"))
325 metadataValues.addArray (parseInformationChunk (input));
330 input.setPosition (input.getPosition() + chunkHeader.chunkSize);
335 input.setPosition (originalPos);
350 if (
input !=
nullptr)
353 auto status = AudioFileOpenWithCallbacks (
this,
362 status = ExtAudioFileWrapAudioFileID (audioFileID,
false, &audioFileRef);
366 AudioStreamBasicDescription sourceAudioFormat;
367 UInt32 audioStreamBasicDescriptionSize =
sizeof (AudioStreamBasicDescription);
368 ExtAudioFileGetProperty (audioFileRef,
369 kExtAudioFileProperty_FileDataFormat,
370 &audioStreamBasicDescriptionSize,
376 UInt32 sizeOfLengthProperty =
sizeof (int64);
377 ExtAudioFileGetProperty (audioFileRef,
378 kExtAudioFileProperty_FileLengthFrames,
379 &sizeOfLengthProperty,
383 bool hasLayout =
false;
384 UInt32 sizeOfLayout = 0, isWritable = 0;
386 status = AudioFileGetPropertyInfo (audioFileID, kAudioFilePropertyChannelLayout, &sizeOfLayout, &isWritable);
388 if (status == noErr && sizeOfLayout >= (
sizeof (AudioChannelLayout) -
sizeof (AudioChannelDescription)))
390 caLayout.
malloc (1,
static_cast<size_t> (sizeOfLayout));
392 status = AudioFileGetProperty (audioFileID, kAudioFilePropertyChannelLayout,
393 &sizeOfLayout, caLayout.
get());
397 auto fileLayout = CoreAudioLayouts::fromCoreAudio (*caLayout.
get());
399 if (fileLayout.size() ==
static_cast<int> (
numChannels))
402 channelSet = fileLayout;
407 destinationAudioFormat.mSampleRate =
sampleRate;
408 destinationAudioFormat.mFormatID = kAudioFormatLinearPCM;
409 destinationAudioFormat.mFormatFlags = kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsNonInterleaved | kAudioFormatFlagsNativeEndian;
410 destinationAudioFormat.mBitsPerChannel =
sizeof (float) * 8;
411 destinationAudioFormat.mChannelsPerFrame =
numChannels;
412 destinationAudioFormat.mBytesPerFrame =
sizeof (float);
413 destinationAudioFormat.mFramesPerPacket = 1;
414 destinationAudioFormat.mBytesPerPacket = destinationAudioFormat.mFramesPerPacket * destinationAudioFormat.mBytesPerFrame;
416 status = ExtAudioFileSetProperty (audioFileRef,
417 kExtAudioFileProperty_ClientDataFormat,
418 sizeof (AudioStreamBasicDescription),
419 &destinationAudioFormat);
422 bufferList.
malloc (1,
sizeof (AudioBufferList) +
numChannels *
sizeof (::AudioBuffer));
426 if (hasLayout && caLayout !=
nullptr)
428 auto caOrder = CoreAudioLayouts::getCoreAudioLayoutChannels (*caLayout);
430 for (
int i = 0; i < static_cast<int> (
numChannels); ++i)
433 jassert (isPositiveAndBelow (idx,
static_cast<int> (
numChannels)));
440 for (
int i = 0; i < static_cast<int> (
numChannels); ++i)
452 ExtAudioFileDispose (audioFileRef);
453 AudioFileClose (audioFileID);
457 bool readSamples (
int** destSamples,
int numDestChannels,
int startOffsetInDestBuffer,
458 int64 startSampleInFile,
int numSamples)
override
466 if (lastReadPosition != startSampleInFile)
468 OSStatus status = ExtAudioFileSeek (audioFileRef, startSampleInFile);
472 lastReadPosition = startSampleInFile;
475 while (numSamples > 0)
477 auto numThisTime = jmin (8192, numSamples);
478 auto numBytes = (size_t) numThisTime *
sizeof (
float);
481 auto* data =
static_cast<float*
> (audioDataBlock.
getData());
485 bufferList->mBuffers[j].mNumberChannels = 1;
486 bufferList->mBuffers[j].mDataByteSize = (UInt32) numBytes;
487 bufferList->mBuffers[j].mData = data;
491 auto numFramesToRead = (UInt32) numThisTime;
492 auto status = ExtAudioFileRead (audioFileRef, &numFramesToRead, bufferList);
497 if (numFramesToRead == 0)
500 if ((
int) numFramesToRead < numThisTime)
502 numThisTime = (int) numFramesToRead;
503 numBytes = (size_t) numThisTime *
sizeof (
float);
506 for (
int i = numDestChannels; --i >= 0;)
508 auto* dest = destSamples[(i < (int)
numChannels ? channelMap[i] : i)];
513 memcpy (dest + startOffsetInDestBuffer, bufferList->mBuffers[i].mData, numBytes);
515 zeromem (dest + startOffsetInDestBuffer, numBytes);
519 startOffsetInDestBuffer += numThisTime;
520 numSamples -= numThisTime;
521 lastReadPosition += numThisTime;
538 AudioFileID audioFileID;
539 ExtAudioFileRef audioFileRef;
541 AudioStreamBasicDescription destinationAudioFormat;
544 int64 lastReadPosition = 0;
547 static SInt64 getSizeCallback (
void* inClientData)
552 static OSStatus readCallback (
void* inClientData, SInt64 inPosition, UInt32 requestCount,
553 void* buffer, UInt32* actualCount)
555 auto* reader =
static_cast<CoreAudioReader*
> (inClientData);
556 reader->input->setPosition (inPosition);
557 *actualCount = (UInt32) reader->input->read (buffer, (
int) requestCount);
561 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CoreAudioReader)
566 :
AudioFormat (coreAudioFormatName, findFileExtensionsForCoreAudioCodecs())
580 bool deleteStreamIfOpeningFails)
582 std::unique_ptr<CoreAudioReader> r (
new CoreAudioReader (sourceStream));
587 if (! deleteStreamIfOpeningFails)
609#define DEFINE_CHANNEL_LAYOUT_DFL_ENTRY(x) CoreAudioChannelLayoutTag { x, #x, AudioChannelSet() }
610#define DEFINE_CHANNEL_LAYOUT_TAG_ENTRY(x, y) CoreAudioChannelLayoutTag { x, #x, y }
612class CoreAudioLayoutsUnitTest :
public UnitTest
615 CoreAudioLayoutsUnitTest()
616 :
UnitTest (
"Core Audio Layout <-> JUCE channel layout conversion", UnitTestCategories::audio)
622 kAudioChannelLayoutTag_HOA_ACN_SN3D_0Order = (190U<<16) | 1,
623 kAudioChannelLayoutTag_HOA_ACN_SN3D_1Order = (190U<<16) | 4,
624 kAudioChannelLayoutTag_HOA_ACN_SN3D_2Order = (190U<<16) | 9,
625 kAudioChannelLayoutTag_HOA_ACN_SN3D_3Order = (190U<<16) | 16,
626 kAudioChannelLayoutTag_HOA_ACN_SN3D_4Order = (190U<<16) | 25,
627 kAudioChannelLayoutTag_HOA_ACN_SN3D_5Order = (190U<<16) | 36
630 void runTest()
override
632 auto& knownTags = getAllKnownLayoutTags();
638 beginTest (
"All CA tags handled");
640 for (
auto tagEntry : knownTags)
642 auto labels = CoreAudioLayouts::fromCoreAudio (tagEntry.tag);
644 expect (! labels.isDiscreteLayout(),
"Tag \"" + String (tagEntry.name) +
"\" is not handled by JUCE");
649 beginTest (
"Number of speakers");
651 for (
auto tagEntry : knownTags)
653 auto labels = CoreAudioLayouts::getSpeakerLayoutForCoreAudioTag (tagEntry.tag);
655 expect (labels.size() == (tagEntry.tag & 0xffff),
"Tag \"" + String (tagEntry.name) +
"\" has incorrect channel count");
660 beginTest (
"No duplicate speaker");
662 for (
auto tagEntry : knownTags)
664 auto labels = CoreAudioLayouts::getSpeakerLayoutForCoreAudioTag (tagEntry.tag);
667 for (
int i = 0; i < (labels.size() - 1); ++i)
668 expect (labels.getReference (i) != labels.getReference (i + 1),
669 "Tag \"" + String (tagEntry.name) +
"\" has the same speaker twice");
674 beginTest (
"CA speaker list and juce layouts are consistent");
676 for (
auto tagEntry : knownTags)
678 == CoreAudioLayouts::fromCoreAudio (tagEntry.tag),
679 "Tag \"" + String (tagEntry.name) +
"\" is not converted consistently by JUCE");
683 beginTest (
"AudioChannelSet documentation is correct");
685 for (
auto tagEntry : knownTags)
687 if (tagEntry.equivalentChannelSet.isDisabled())
690 expect (CoreAudioLayouts::fromCoreAudio (tagEntry.tag) == tagEntry.equivalentChannelSet,
691 "Documentation for tag \"" + String (tagEntry.name) +
"\" is incorrect");
696 beginTest (
"CA tag reverse conversion");
698 for (
auto tagEntry : knownTags)
700 if (tagEntry.equivalentChannelSet.isDisabled())
703 expect (CoreAudioLayouts::toCoreAudio (tagEntry.equivalentChannelSet) == tagEntry.tag,
704 "Incorrect reverse conversion for tag \"" + String (tagEntry.name) +
"\"");
710 struct CoreAudioChannelLayoutTag
712 AudioChannelLayoutTag tag;
714 AudioChannelSet equivalentChannelSet;
718 const Array<CoreAudioChannelLayoutTag>& getAllKnownLayoutTags()
const
720 static CoreAudioChannelLayoutTag tags[] = {
723 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_StereoHeadphones),
724 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_MatrixStereo),
725 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_MidSide),
726 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_XY),
727 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_Binaural),
728 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_Ambisonic_B_Format),
733 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_Cube),
734 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_MPEG_1_0),
735 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_MPEG_2_0),
737 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_MPEG_3_0_B),
739 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_MPEG_4_0_B),
741 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_MPEG_5_0_B),
742 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_MPEG_5_0_C),
743 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_MPEG_5_0_D),
745 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_MPEG_5_1_B),
746 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_MPEG_5_1_C),
747 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_MPEG_5_1_D),
750 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_MPEG_7_1_B),
752 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_Emagic_Default_7_1),
753 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_SMPTE_DTV),
754 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_ITU_1_0),
755 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_ITU_2_0),
757 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_ITU_2_2),
758 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_ITU_3_0),
759 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_ITU_3_1),
760 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_ITU_3_2),
761 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_ITU_3_2_1),
762 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_ITU_3_4_1),
763 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_0),
764 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_1),
765 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_2),
766 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_3),
767 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_4),
768 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_5),
769 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_6),
770 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_7),
771 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_8),
772 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_9),
773 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_10),
774 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_11),
775 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_12),
776 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_13),
777 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_14),
778 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_15),
779 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_16),
780 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_17),
781 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_18),
782 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_19),
783 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DVD_20),
784 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AudioUnit_4),
785 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AudioUnit_5),
786 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AudioUnit_6),
787 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AudioUnit_8),
788 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AudioUnit_5_0),
792 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AudioUnit_5_1),
793 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AudioUnit_6_1),
794 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AudioUnit_7_1),
795 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AudioUnit_7_1_Front),
796 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AAC_3_0),
797 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AAC_Quadraphonic),
798 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AAC_4_0),
799 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AAC_5_0),
800 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AAC_5_1),
801 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AAC_6_0),
802 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AAC_6_1),
803 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AAC_7_0),
804 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AAC_7_1),
805 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AAC_7_1_B),
806 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AAC_7_1_C),
807 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AAC_Octagonal),
808 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_TMH_10_2_std),
810 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AC3_1_0_1),
811 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AC3_3_0),
812 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AC3_3_1),
813 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AC3_3_0_1),
814 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AC3_2_1_1),
815 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_AC3_3_1_1),
816 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_EAC_6_0_A),
817 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_EAC_7_0_A),
818 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_EAC3_6_1_A),
819 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_EAC3_6_1_B),
820 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_EAC3_6_1_C),
821 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_EAC3_7_1_A),
822 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_EAC3_7_1_B),
823 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_EAC3_7_1_C),
824 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_EAC3_7_1_D),
825 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_EAC3_7_1_E),
826 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_EAC3_7_1_F),
827 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_EAC3_7_1_G),
828 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_EAC3_7_1_H),
829 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_3_1),
830 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_4_1),
832 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_6_0_B),
833 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_6_0_C),
835 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_6_1_B),
836 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_6_1_C),
837 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_7_0),
838 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_7_1),
839 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_8_0_A),
840 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_8_0_B),
841 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_8_1_A),
842 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_8_1_B),
843 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_6_1_D),
844 DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_6_1_D),
852 static Array<CoreAudioChannelLayoutTag> knownTags (tags,
sizeof (tags) /
sizeof (CoreAudioChannelLayoutTag));
858static CoreAudioLayoutsUnitTest coreAudioLayoutsUnitTest;
Represents a set of audio channel types.
static AudioChannelSet JUCE_CALLTYPE create7point1()
Creates a set for a DTS 7.1 surround setup (left, right, centre, leftSurroundSide,...
static AudioChannelSet JUCE_CALLTYPE quadraphonic()
Creates a set for quadraphonic surround setup (left, right, leftSurround, rightSurround)
static AudioChannelSet JUCE_CALLTYPE create5point0()
Creates a set for a 5.0 surround setup (left, right, centre, leftSurround, rightSurround).
int size() const noexcept
Returns the number of channels in the set.
static AudioChannelSet JUCE_CALLTYPE create6point0()
Creates a set for a 6.0 Cine surround setup (left, right, centre, leftSurround, rightSurround,...
static AudioChannelSet JUCE_CALLTYPE create6point1Music()
Creates a set for a 6.0 Music surround setup (left, right, leftSurround, rightSurround,...
static AudioChannelSet JUCE_CALLTYPE hexagonal()
Creates a set for hexagonal surround setup (left, right, leftSurroundRear, rightSurroundRear,...
static AudioChannelSet JUCE_CALLTYPE mono()
Creates a one-channel mono set (centre).
static AudioChannelSet JUCE_CALLTYPE createLRS()
Creates a set containing an LRS set (left, right, surround).
static AudioChannelSet JUCE_CALLTYPE stereo()
Creates a set containing a stereo set (left, right).
static AudioChannelSet JUCE_CALLTYPE octagonal()
Creates a set for octagonal surround setup (left, right, leftSurround, rightSurround,...
static AudioChannelSet JUCE_CALLTYPE create6point1()
Creates a set for a 6.1 Cine surround setup (left, right, centre, leftSurround, rightSurround,...
static AudioChannelSet JUCE_CALLTYPE create5point1()
Creates a set for a 5.1 surround setup (left, right, centre, leftSurround, rightSurround,...
static AudioChannelSet JUCE_CALLTYPE create7point0SDDS()
Creates a set for a SDDS 7.0 surround setup (left, right, centre, leftSurround, rightSurround,...
static AudioChannelSet JUCE_CALLTYPE create6point0Music()
Creates a set for a 6.0 Music surround setup (left, right, leftSurround, rightSurround,...
static AudioChannelSet JUCE_CALLTYPE create7point1SDDS()
Creates a set for a 7.1 surround setup (left, right, centre, leftSurround, rightSurround,...
static AudioChannelSet JUCE_CALLTYPE create7point0()
Creates a set for a DTS 7.0 surround setup (left, right, centre, leftSurroundSide,...
static AudioChannelSet JUCE_CALLTYPE channelSetWithChannels(const Array< ChannelType > &)
Creates a channel set for a list of channel types.
static AudioChannelSet JUCE_CALLTYPE ambisonic(int order=1)
Creates a set for ACN, SN3D normalised ambisonic surround setups with a given order.
static AudioChannelSet JUCE_CALLTYPE createLCRS()
Creates a set containing an LCRS set (left, right, centre, surround).
static AudioChannelSet JUCE_CALLTYPE createLCR()
Creates a set containing an LCR set (left, right, centre).
static AudioChannelSet JUCE_CALLTYPE pentagonal()
Creates a set for pentagonal surround setup (left, right, centre, leftSurroundRear,...
int getChannelIndexForType(ChannelType type) const noexcept
Returns the index for a particular channel-type.
static JUCE_CONSTEXPR uint32 bigEndianInt(const void *bytes) noexcept
Turns 4 bytes into a big-endian integer.
AudioChannelSet getChannelLayout() override
Get the channel layout of the audio stream.
bool readSamples(int **destSamples, int numDestChannels, int startOffsetInDestBuffer, int64 startSampleInFile, int numSamples) override
Subclasses must implement this method to perform the low-level read operation.
Very simple container class to hold a pointer to some data on the heap.
void malloc(SizeType newNumElements, size_t elementSize=sizeof(ElementType))
Allocates a specified amount of memory.
ElementType * get() const noexcept
Returns a raw pointer to the allocated data.
A class to hold a resizable block of raw data.
void ensureSize(const size_t minimumSize, bool initialiseNewSpaceToZero=false)
Increases the block's size only if it's smaller than a given size.
void * getData() noexcept
Returns a void pointer to the data.
The base class for streams that write data to some kind of destination.
A container for holding a set of strings which are keyed by another string.
void set(const String &key, const String &value)
Adds or amends a key/value pair.
static String fromCFString(CFStringRef cfString)
OSX ONLY - Creates a String from an OSX CFString.
This is a base class for classes that perform a unit test.