AudioFormat.pas 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. {!
  2. @file AudioFormat.h
  3. @framework AudioToolbox.framework
  4. @copyright (c) 1985-2015 by Apple, Inc., all rights reserved.
  5. @abstract API for finding things out about audio formats.
  6. }
  7. {
  8. Modified for use with Free Pascal
  9. Version 308
  10. Please report any bugs to <[email protected]>
  11. }
  12. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  13. {$mode macpas}
  14. {$modeswitch cblocks}
  15. {$packenum 1}
  16. {$macro on}
  17. {$inline on}
  18. {$calling mwpascal}
  19. unit AudioFormat;
  20. interface
  21. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  22. {$setc GAP_INTERFACES_VERSION := $0308}
  23. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  24. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  25. {$endc}
  26. {$ifc defined CPUPOWERPC and defined CPUI386}
  27. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  28. {$endc}
  29. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  30. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  31. {$endc}
  32. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  33. {$setc __ppc__ := 1}
  34. {$elsec}
  35. {$setc __ppc__ := 0}
  36. {$endc}
  37. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  38. {$setc __ppc64__ := 1}
  39. {$elsec}
  40. {$setc __ppc64__ := 0}
  41. {$endc}
  42. {$ifc not defined __i386__ and defined CPUI386}
  43. {$setc __i386__ := 1}
  44. {$elsec}
  45. {$setc __i386__ := 0}
  46. {$endc}
  47. {$ifc not defined __x86_64__ and defined CPUX86_64}
  48. {$setc __x86_64__ := 1}
  49. {$elsec}
  50. {$setc __x86_64__ := 0}
  51. {$endc}
  52. {$ifc not defined __arm__ and defined CPUARM}
  53. {$setc __arm__ := 1}
  54. {$elsec}
  55. {$setc __arm__ := 0}
  56. {$endc}
  57. {$ifc not defined __arm64__ and defined CPUAARCH64}
  58. {$setc __arm64__ := 1}
  59. {$elsec}
  60. {$setc __arm64__ := 0}
  61. {$endc}
  62. {$ifc defined cpu64}
  63. {$setc __LP64__ := 1}
  64. {$elsec}
  65. {$setc __LP64__ := 0}
  66. {$endc}
  67. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  68. {$error Conflicting definitions for __ppc__ and __i386__}
  69. {$endc}
  70. {$ifc defined __ppc__ and __ppc__}
  71. {$setc TARGET_CPU_PPC := TRUE}
  72. {$setc TARGET_CPU_PPC64 := FALSE}
  73. {$setc TARGET_CPU_X86 := FALSE}
  74. {$setc TARGET_CPU_X86_64 := FALSE}
  75. {$setc TARGET_CPU_ARM := FALSE}
  76. {$setc TARGET_CPU_ARM64 := FALSE}
  77. {$setc TARGET_OS_MAC := TRUE}
  78. {$setc TARGET_OS_IPHONE := FALSE}
  79. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  80. {$setc TARGET_OS_EMBEDDED := FALSE}
  81. {$elifc defined __ppc64__ and __ppc64__}
  82. {$setc TARGET_CPU_PPC := FALSE}
  83. {$setc TARGET_CPU_PPC64 := TRUE}
  84. {$setc TARGET_CPU_X86 := FALSE}
  85. {$setc TARGET_CPU_X86_64 := FALSE}
  86. {$setc TARGET_CPU_ARM := FALSE}
  87. {$setc TARGET_CPU_ARM64 := FALSE}
  88. {$setc TARGET_OS_MAC := TRUE}
  89. {$setc TARGET_OS_IPHONE := FALSE}
  90. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  91. {$setc TARGET_OS_EMBEDDED := FALSE}
  92. {$elifc defined __i386__ and __i386__}
  93. {$setc TARGET_CPU_PPC := FALSE}
  94. {$setc TARGET_CPU_PPC64 := FALSE}
  95. {$setc TARGET_CPU_X86 := TRUE}
  96. {$setc TARGET_CPU_X86_64 := FALSE}
  97. {$setc TARGET_CPU_ARM := FALSE}
  98. {$setc TARGET_CPU_ARM64 := FALSE}
  99. {$ifc defined(iphonesim)}
  100. {$setc TARGET_OS_MAC := FALSE}
  101. {$setc TARGET_OS_IPHONE := TRUE}
  102. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  103. {$elsec}
  104. {$setc TARGET_OS_MAC := TRUE}
  105. {$setc TARGET_OS_IPHONE := FALSE}
  106. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  107. {$endc}
  108. {$setc TARGET_OS_EMBEDDED := FALSE}
  109. {$elifc defined __x86_64__ and __x86_64__}
  110. {$setc TARGET_CPU_PPC := FALSE}
  111. {$setc TARGET_CPU_PPC64 := FALSE}
  112. {$setc TARGET_CPU_X86 := FALSE}
  113. {$setc TARGET_CPU_X86_64 := TRUE}
  114. {$setc TARGET_CPU_ARM := FALSE}
  115. {$setc TARGET_CPU_ARM64 := FALSE}
  116. {$ifc defined(iphonesim)}
  117. {$setc TARGET_OS_MAC := FALSE}
  118. {$setc TARGET_OS_IPHONE := TRUE}
  119. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  120. {$elsec}
  121. {$setc TARGET_OS_MAC := TRUE}
  122. {$setc TARGET_OS_IPHONE := FALSE}
  123. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  124. {$endc}
  125. {$setc TARGET_OS_EMBEDDED := FALSE}
  126. {$elifc defined __arm__ and __arm__}
  127. {$setc TARGET_CPU_PPC := FALSE}
  128. {$setc TARGET_CPU_PPC64 := FALSE}
  129. {$setc TARGET_CPU_X86 := FALSE}
  130. {$setc TARGET_CPU_X86_64 := FALSE}
  131. {$setc TARGET_CPU_ARM := TRUE}
  132. {$setc TARGET_CPU_ARM64 := FALSE}
  133. { will require compiler define when/if other Apple devices with ARM cpus ship }
  134. {$setc TARGET_OS_MAC := FALSE}
  135. {$setc TARGET_OS_IPHONE := TRUE}
  136. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  137. {$setc TARGET_OS_EMBEDDED := TRUE}
  138. {$elifc defined __arm64__ and __arm64__}
  139. {$setc TARGET_CPU_PPC := FALSE}
  140. {$setc TARGET_CPU_PPC64 := FALSE}
  141. {$setc TARGET_CPU_X86 := FALSE}
  142. {$setc TARGET_CPU_X86_64 := FALSE}
  143. {$setc TARGET_CPU_ARM := FALSE}
  144. {$setc TARGET_CPU_ARM64 := TRUE}
  145. { will require compiler define when/if other Apple devices with ARM cpus ship }
  146. {$setc TARGET_OS_MAC := FALSE}
  147. {$setc TARGET_OS_IPHONE := TRUE}
  148. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  149. {$setc TARGET_OS_EMBEDDED := TRUE}
  150. {$elsec}
  151. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  152. {$endc}
  153. {$ifc defined __LP64__ and __LP64__ }
  154. {$setc TARGET_CPU_64 := TRUE}
  155. {$elsec}
  156. {$setc TARGET_CPU_64 := FALSE}
  157. {$endc}
  158. {$ifc defined FPC_BIG_ENDIAN}
  159. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  160. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  161. {$elifc defined FPC_LITTLE_ENDIAN}
  162. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  163. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  164. {$elsec}
  165. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  166. {$endc}
  167. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  168. {$setc CALL_NOT_IN_CARBON := FALSE}
  169. {$setc OLDROUTINENAMES := FALSE}
  170. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  171. {$setc OPAQUE_UPP_TYPES := TRUE}
  172. {$setc OTCARBONAPPLICATION := TRUE}
  173. {$setc OTKERNEL := FALSE}
  174. {$setc PM_USE_SESSION_APIS := TRUE}
  175. {$setc TARGET_API_MAC_CARBON := TRUE}
  176. {$setc TARGET_API_MAC_OS8 := FALSE}
  177. {$setc TARGET_API_MAC_OSX := TRUE}
  178. {$setc TARGET_CARBON := TRUE}
  179. {$setc TARGET_CPU_68K := FALSE}
  180. {$setc TARGET_CPU_MIPS := FALSE}
  181. {$setc TARGET_CPU_SPARC := FALSE}
  182. {$setc TARGET_OS_UNIX := FALSE}
  183. {$setc TARGET_OS_WIN32 := FALSE}
  184. {$setc TARGET_RT_MAC_68881 := FALSE}
  185. {$setc TARGET_RT_MAC_CFM := FALSE}
  186. {$setc TARGET_RT_MAC_MACHO := TRUE}
  187. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  188. {$setc TYPE_BOOL := FALSE}
  189. {$setc TYPE_EXTENDED := FALSE}
  190. {$setc TYPE_LONGLONG := TRUE}
  191. {$endc} {not MACOSALLINCLUDE}
  192. { Pascal Translation: Jonas Maebe <[email protected]>, July 2019 }
  193. uses MacTypes,CoreAudioTypes;
  194. {$ALIGN POWER}
  195. //=============================================================================
  196. // Includes
  197. //=============================================================================
  198. // System Includes
  199. //CF_ASSUME_NONNULL_BEGIN
  200. //=============================================================================
  201. // Types
  202. //=============================================================================
  203. {!
  204. @typedef AudioFormatPropertyID
  205. @abstract A type for four char codes for property IDs
  206. }
  207. type
  208. AudioFormatPropertyID = UInt32;
  209. AudioFormatPropertyIDPtr = ^AudioFormatPropertyID;
  210. {!
  211. @enum PanningMode
  212. @abstract Different panning algorithms.
  213. @constant kPanningMode_SoundField
  214. Sound field panning algorithm
  215. @constant kPanningMode_VectorBasedPanning
  216. Vector based panning algorithm
  217. }
  218. type
  219. AudioPanningMode = UInt32;
  220. AudioPanningModePtr = ^AudioPanningMode;
  221. const
  222. kPanningMode_SoundField = 3;
  223. kPanningMode_VectorBasedPanning = 4;
  224. {!
  225. @struct AudioPanningInfo
  226. @abstract This struct is for use with kAudioFormatProperty_PanningMatrix.
  227. @field mPanningMode the PanningMode to be used for the pan
  228. @field mCoordinateFlags the coordinates are specified as in the AudioChannelDescription struct in CoreAudioTypes.h
  229. @field mCoordinates the coordinates are specified as in the AudioChannelDescription struct in CoreAudioTypes.h
  230. @field mGainScale
  231. mGainScale is used to multiply the panning values.
  232. In typical usage you are applying an existing volume.
  233. value in 0 -> 1 (where 1 is unity gain) to the panned values.
  234. 1 would give you panning at unity.
  235. 0 would give you back a matrix of zeroes.
  236. @field mOutputChannelMap
  237. This is the channel map that is going to be used to determine channel volumes for this pan.
  238. }
  239. type
  240. AudioPanningInfo = record
  241. mPanningMode: AudioPanningMode;
  242. mCoordinateFlags: UInt32;
  243. mCoordinates: array [0..3-1] of Float32;
  244. mGainScale: Float32;
  245. mOutputChannelMap: {const} AudioChannelLayoutPtr;
  246. end;
  247. AudioPanningInfoPtr = ^AudioPanningInfo;
  248. {!
  249. @enum AudioBalanceFadeType
  250. @abstract used for mType field of AudioBalanceFade struct
  251. @constant kAudioBalanceFadeType_MaxUnityGain
  252. the gain value never exceeds 1.0, the opposite channel fades out.
  253. This can reduce overall loudness when the balance or fade is not in the center.
  254. @constant kAudioBalanceFadeType_EqualPower
  255. The overall loudness remains constant, but gain can exceed 1.0.
  256. the gain value is 1.0 when the balance and fade are in the center.
  257. From there they can increase to +3dB (1.414) and decrease to -inf dB (0.0).
  258. }
  259. type
  260. AudioBalanceFadeType = UInt32;
  261. AudioBalanceFadeTypePtr = ^AudioBalanceFadeType;
  262. const
  263. kAudioBalanceFadeType_MaxUnityGain = 0;
  264. kAudioBalanceFadeType_EqualPower = 1;
  265. {!
  266. @struct AudioBalanceFade
  267. @abstract this struct is used with kAudioFormatProperty_BalanceFade
  268. @field mLeftRightBalance
  269. -1 is full left, 0 is center, +1 is full right
  270. @field mBackFrontFade
  271. -1 is full rear, 0 is center, +1 is full front
  272. @field mType
  273. an AudioBalanceFadeType constant
  274. @field mChannelLayout
  275. a pointer to an AudioChannelLayout
  276. }
  277. type
  278. AudioBalanceFade = record
  279. mLeftRightBalance: Float32; // -1 is full left, 0 is center, +1 is full right
  280. mBackFrontFade: Float32; // -1 is full rear, 0 is center, +1 is full front
  281. mType: AudioBalanceFadeType; // max unity gain, or equal power.
  282. mChannelLayout: {const} AudioChannelLayoutPtr;
  283. end;
  284. AudioBalanceFadePtr = ^AudioBalanceFade;
  285. {!
  286. @struct AudioFormatInfo
  287. @abstract this struct is used as a specifier for the kAudioFormatProperty_FormatList property
  288. @field mASBD
  289. an AudioStreamBasicDescription
  290. @field mMagicCookie
  291. a pointer to the decompression info for the data described in mASBD
  292. @field mMagicCookieSize
  293. the size in bytes of mMagicCookie
  294. }
  295. type
  296. AudioFormatInfo = record
  297. mASBD: AudioStreamBasicDescription;
  298. mMagicCookie: {const} UnivPtr;
  299. mMagicCookieSize: UInt32;
  300. end;
  301. AudioFormatInfoPtr = ^AudioFormatInfo;
  302. {!
  303. @struct ExtendedAudioFormatInfo
  304. @abstract this struct is used as a specifier for the kAudioFormatProperty_FormatList property
  305. @field mASBD
  306. an AudioStreamBasicDescription
  307. @field mMagicCookie
  308. a pointer to the decompression info for the data described in mASBD
  309. @field mMagicCookieSize
  310. the size in bytes of mMagicCookie
  311. @field mClassDescription
  312. an AudioClassDescription specifying the codec to be used in answering the question.
  313. }
  314. type
  315. ExtendedAudioFormatInfo = record
  316. mASBD: AudioStreamBasicDescription;
  317. mMagicCookie: {const} UnivPtr {__nullable};
  318. mMagicCookieSize: UInt32;
  319. mClassDescription: AudioClassDescription;
  320. end;
  321. ExtendedAudioFormatInfoPtr = ^ExtendedAudioFormatInfo;
  322. {!
  323. @struct AudioFormatListItem
  324. @abstract this struct is used as output from the kAudioFormatProperty_FormatList property
  325. @field mASBD
  326. an AudioStreamBasicDescription
  327. @field mChannelLayoutTag
  328. an AudioChannelLayoutTag
  329. }
  330. type
  331. AudioFormatListItem = record
  332. mASBD: AudioStreamBasicDescription;
  333. mChannelLayoutTag: AudioChannelLayoutTag;
  334. end;
  335. AudioFormatListItemPtr = ^AudioFormatListItem;
  336. //=============================================================================
  337. // Properties - for various format structures.
  338. //=============================================================================
  339. {!
  340. @enum AudioFormatProperty constants
  341. @abstract constants for use with AudioFormatGetPropertyInfo and AudioFormatGetProperty.
  342. @constant kAudioFormatProperty_FormatInfo
  343. Retrieves general information about a format. The specifier is a
  344. magic cookie, or NULL.
  345. On input, the property value is an AudioStreamBasicDescription which
  346. should have at least the mFormatID filled out. On output it will be filled out
  347. as much as possible given the information known about the format
  348. and the contents of the magic cookie (if any is given).
  349. If multiple formats can be described by the AudioStreamBasicDescription and the associated magic cookie,
  350. this property will return the base level format.
  351. @constant kAudioFormatProperty_FormatIsVBR
  352. Returns whether or not a format has a variable number of bytes per
  353. packet. The specifier is an AudioStreamBasicDescription describing
  354. the format to ask about. The value is a UInt32 where non-zero means
  355. the format is variable bytes per packet.
  356. @constant kAudioFormatProperty_FormatIsExternallyFramed
  357. Returns whether or not a format requires external framing information,
  358. i.e. AudioStreamPacketDescriptions.
  359. The specifier is an AudioStreamBasicDescription describing
  360. the format to ask about. The value is a UInt32 where non-zero means
  361. the format is externally framed. Any format which has variable byte sized packets
  362. requires AudioStreamPacketDescriptions.
  363. @constant kAudioFormatProperty_FormatIsEncrypted
  364. Returns whether or not a format is encrypted. The specifier is a UInt32 format ID.
  365. The value is a UInt32 where non-zero means the format is encrypted.
  366. @constant kAudioFormatProperty_EncodeFormatIDs
  367. No specifier needed. Must be set to NULL.
  368. Returns an array of UInt32 format IDs for formats that are valid output formats
  369. for a converter.
  370. @constant kAudioFormatProperty_DecodeFormatIDs
  371. No specifier needed. Must be set to NULL.
  372. Returns an array of UInt32 format IDs for formats that are valid input formats
  373. for a converter.
  374. @constant kAudioFormatProperty_Encoders
  375. The specifier is the format that you are interested in, e.g. 'aac '
  376. Returns an array of AudioClassDescriptions for all installed encoders for the given format
  377. @constant kAudioFormatProperty_Decoders
  378. The specifier is the format that you are interested in, e.g. 'aac '
  379. Returns an array of AudioClassDescriptions for all installed decoders for the given format
  380. @constant kAudioFormatProperty_AvailableEncodeBitRates
  381. The specifier is a UInt32 format ID.
  382. The property value is an array of AudioValueRange describing all available bit rates.
  383. @constant kAudioFormatProperty_AvailableEncodeSampleRates
  384. The specifier is a UInt32 format ID.
  385. The property value is an array of AudioValueRange describing all available sample rates.
  386. @constant kAudioFormatProperty_AvailableEncodeChannelLayoutTags
  387. The specifier is an AudioStreamBasicDescription with at least the mFormatID
  388. and mChannelsPerFrame fields set.
  389. The property value is an array of AudioChannelLayoutTags for the format and number of
  390. channels specified. If mChannelsPerFrame is zero, then all layouts supported by
  391. the format are returned.
  392. @constant kAudioFormatProperty_AvailableEncodeNumberChannels
  393. The specifier is an AudioStreamBasicDescription with at least the mFormatID field set.
  394. The property value is an array of UInt32 indicating the number of channels that can be encoded.
  395. A value of 0xFFFFFFFF indicates that any number of channels may be encoded.
  396. @constant kAudioFormatProperty_FormatName
  397. Returns a name for a given format. The specifier is an
  398. AudioStreamBasicDescription describing the format to ask about.
  399. The value is a CFStringRef. The caller is responsible for releasing the
  400. returned string. For some formats (eg, Linear PCM) you will get back a
  401. descriptive string (e.g. 16-bit, interleaved, etc...)
  402. @constant kAudioFormatProperty_ASBDFromESDS
  403. Returns an audio stream description for a given ESDS. The specifier is an ESDS.
  404. The value is a AudioStreamBasicDescription. If multiple formats can be described
  405. by the ESDS this property will return the base level format.
  406. @constant kAudioFormatProperty_ChannelLayoutFromESDS
  407. Returns an audio channel layout for a given ESDS. The specifier is an
  408. ESDS. The value is a AudioChannelLayout.
  409. @constant kAudioFormatProperty_ASBDFromMPEGPacket
  410. Returns an audio stream description for a given MPEG Packet. The specifier is an MPEG Packet.
  411. The value is a AudioStreamBasicDescription.
  412. @constant kAudioFormatProperty_FormatList
  413. Returns a list of AudioFormatListItem structs describing the audio formats contained within the compressed bit stream
  414. as described by the magic cookie. The specifier is an AudioFormatInfo struct. The mFormatID member of the
  415. ASBD struct must filled in. Formats are returned in order from the most to least 'rich', with
  416. channel count taking the highest precedence followed by sample rate. The kAudioFormatProperty_FormatList property
  417. is the preferred method for discovering format information of the audio data. If the audio data can only be described
  418. by a single AudioFormatListItem, this property would be equivalent to using the kAudioFormatProperty_FormatInfo property,
  419. which should be used by the application as a fallback case, to ensure backward compatibility with existing systems
  420. when kAudioFormatProperty_FormatList is not present on the running system.
  421. @constant kAudioFormatProperty_OutputFormatList
  422. Returns a list of AudioFormatListItem structs describing the audio formats which may be obtained by decoding the format
  423. described by the specifier.
  424. The specifier is an AudioFormatInfo struct. At a minimum formatID member of the ASBD struct must filled in. Other fields
  425. may be filled in. If there is no magic cookie, then the number of channels and sample rate should be filled in.
  426. @constant kAudioFormatProperty_FirstPlayableFormatFromList
  427. The specifier is a list of 1 or more AudioFormatListItem. Generally it is the list of these items returned from kAudioFormatProperty_FormatList. The property value retrieved is an UInt32 that specifies an index into that list. The list that the caller provides is generally sorted with the first item as the best format (most number of channels, highest sample rate), and the returned index represents the first item in that list that can be played by the system.
  428. Thus, the property is typically used to determine the best playable format for a given (layered) audio stream
  429. @constant kAudioFormatProperty_ValidateChannelLayout
  430. The specifier is an AudioChannelLayout. The property value and size are not used and must be set to NULL.
  431. This property validates an AudioChannelLayout. This is useful if the layout has come from an untrusted source such as a file.
  432. It returns noErr if the AudioChannelLayout is OK, kAudio_ParamError if there is a structural problem with the layout,
  433. or kAudioFormatUnknownFormatError for unrecognized layout tags or channel labels.
  434. @constant kAudioFormatProperty_ChannelLayoutForTag
  435. Returns the channel descriptions for a standard channel layout.
  436. The specifier is a AudioChannelLayoutTag (the mChannelLayoutTag field
  437. of the AudioChannelLayout struct) containing the layout constant.
  438. The value is an AudioChannelLayout structure. In typical use a AudioChannelLayout
  439. can be valid with just a defined AudioChannelLayoutTag (ie, those layouts
  440. have predefined speaker locations and orderings).
  441. Returns an error if the tag is kAudioChannelLayoutTag_UseChannelBitmap
  442. @constant kAudioFormatProperty_TagForChannelLayout
  443. Returns an AudioChannelLayoutTag for a layout, if there is one.
  444. The specifier is an AudioChannelLayout containing the layout description.
  445. The value is an AudioChannelLayoutTag.
  446. This can be used to reduce a layout specified by kAudioChannelLayoutTag_UseChannelDescriptions
  447. or kAudioChannelLayoutTag_UseChannelBitmap to a known AudioChannelLayoutTag.
  448. @constant kAudioFormatProperty_ChannelLayoutForBitmap
  449. Returns the channel descriptions for a standard channel layout.
  450. The specifier is a UInt32 (the mChannelBitmap field
  451. of the AudioChannelLayout struct) containing the layout bitmap. The value
  452. is an AudioChannelLayout structure. In some uses, an AudioChannelLayout can be
  453. valid with the layoutTag set to "use bitmap" and the bitmap set appropriately.
  454. @constant kAudioFormatProperty_BitmapForLayoutTag
  455. Returns a bitmap for an AudioChannelLayoutTag, if there is one.
  456. The specifier is a AudioChannelLayoutTag containing the layout tag.
  457. The value is an UInt32 bitmap. The bits are as defined in CoreAudioTypes.h.
  458. To go in the other direction, i.e. get a layout tag for a bitmap,
  459. use kAudioFormatProperty_TagForChannelLayout where your layout tag
  460. is kAudioChannelLayoutTag_UseChannelBitmap and the bitmap is filled in.
  461. @constant kAudioFormatProperty_ChannelLayoutName
  462. Returns the a name for a particular channel layout. The specifier is
  463. an AudioChannelLayout containing the layout description. The value
  464. is a CFStringRef. The caller is responsible for releasing the
  465. returned string.
  466. @constant kAudioFormatProperty_ChannelLayoutSimpleName
  467. Returns the a simpler name for a channel layout than does kAudioFormatProperty_ChannelLayoutName.
  468. It omits the channel labels from the name. The specifier is
  469. an AudioChannelLayout containing the layout description. The value
  470. is a CFStringRef. The caller is responsible for releasing the
  471. returned string.
  472. @constant kAudioFormatProperty_ChannelName
  473. Returns the name for a particular channel. The specifier is an
  474. AudioChannelDescription which has the mChannelLabel field set. The value
  475. is a CFStringRef. The caller is responsible for releasing the
  476. returned string.
  477. @constant kAudioFormatProperty_ChannelShortName
  478. Returns an abbreviated name for a particular channel. The specifier is an
  479. AudioChannelDescription which has the mChannelLabel field set. The value
  480. is a CFStringRef. The caller is responsible for releasing the
  481. returned string.
  482. @constant kAudioFormatProperty_MatrixMixMap
  483. Returns a matrix of scaling coefficients for converting audio from one channel map
  484. to another in a standard way, if one is known. Otherwise an error is returned.
  485. The specifier is an array of two pointers to AudioChannelLayout structures.
  486. The first points to the input layout, the second to the output layout.
  487. The value is a two dimensional array of Float32 where the first dimension (rows)
  488. is the input channel and the second dimension (columns) is the output channel.
  489. @constant kAudioFormatProperty_ChannelMap
  490. Returns an array of SInt32 for reordering input channels.
  491. The specifier is an array of two pointers to AudioChannelLayout structures.
  492. The first points to the input layout, the second to the output layout.
  493. The length of the output array is equal to the number of output channels.
  494. @constant kAudioFormatProperty_NumberOfChannelsForLayout
  495. This is a general call for parsing a AudioChannelLayout provided as the specifier,
  496. to determine the number of valid channels that are represented. So, if the
  497. LayoutTag is specified, it returns the number of channels for that layout. If
  498. the bitmap is specified, it returns the number of channels represented by that bitmap.
  499. If the layout tag is 'kAudioChannelLayoutTag_UseChannelDescriptions' it returns
  500. the number of channel descriptions.
  501. @constant kAudioFormatProperty_AreChannelLayoutsEquivalent
  502. Returns a UInt32 which is 1 if two layouts are equivalent and 0 if they are not equivalent.
  503. In order to be equivalent, the layouts must describe the same channels in the same order.
  504. Whether the layout is represented by a bitmap, channel descriptions or a channel layout tag is not significant.
  505. The channel coordinates are only significant if the channel label is kAudioChannelLabel_UseCoordinates.
  506. The specifier is an array of two pointers to AudioChannelLayout structures.
  507. The value is a pointer to the UInt32 result.
  508. @constant kAudioFormatProperty_ChannelLayoutHash
  509. Returns a UInt32 which represents the hash of the provided channel layout.
  510. The specifier is a pointer to an AudioChannelLayout structure.
  511. The value is a pointer to the UInt32 result.
  512. @constant kAudioFormatProperty_TagsForNumberOfChannels
  513. returns an array of AudioChannelLayoutTags for the number of channels specified.
  514. The specifier is a UInt32 number of channels.
  515. @constant kAudioFormatProperty_PanningMatrix
  516. This call will pass in an AudioPanningInfo struct that specifies one of the
  517. kPanningMode_ constants for the panning algorithm and an AudioChannelLayout
  518. to describe the destination channel layout. As in kAudioFormatProperty_MatrixMixMap
  519. the return value is an array of Float32 values of the number of channels
  520. represented by this specified channel layout. It is presumed that the source
  521. being panned is mono (thus for a quad channel layout, 4 Float32 values are returned).
  522. The intention of this API is to provide support for panning operations that are
  523. strictly manipulating the respective volumes of the channels. Thus, more
  524. complex panners (like HRTF, distance filtering etc,) will not be represented
  525. by this API. The resultant volume scalars can then be applied to a mixer
  526. or some other processing code to adapt the individual volumes of the mixed
  527. output.
  528. The volume values will typically be presented within a 0->1 range (where 1 is unity gain)
  529. For stereo formats, vector based panning is equivalent to the equal-power pan mode.
  530. @constant kAudioFormatProperty_BalanceFade
  531. get an array of coefficients for applying left/right balance and front/back fade.
  532. The specifier is an AudioBalanceFade struct.
  533. the return value is an array of Float32 values of the number of channels
  534. represented by this specified channel layout.
  535. The volume values will typically be presented within a 0->1 range (where 1 is unity gain)
  536. @constant kAudioFormatProperty_ID3TagSize
  537. Returns a UInt32 indicating the ID3 tag size.
  538. The specifier must begin with the ID3 tag header and be at least 10 bytes in length
  539. @constant kAudioFormatProperty_ID3TagToDictionary
  540. Returns a CFDictionary containing key/value pairs for the frames in the ID3 tag
  541. The specifier is the entire ID3 tag
  542. Caller must call CFRelease for the returned dictionary
  543. }
  544. const
  545. //=============================================================================
  546. // The following properties are concerned with the AudioStreamBasicDescription
  547. //=============================================================================
  548. kAudioFormatProperty_FormatInfo = FourCharCode('fmti');
  549. kAudioFormatProperty_FormatName = FourCharCode('fnam');
  550. kAudioFormatProperty_EncodeFormatIDs = FourCharCode('acof');
  551. kAudioFormatProperty_DecodeFormatIDs = FourCharCode('acif');
  552. kAudioFormatProperty_FormatList = FourCharCode('flst');
  553. kAudioFormatProperty_ASBDFromESDS = FourCharCode('essd');
  554. kAudioFormatProperty_ChannelLayoutFromESDS = FourCharCode('escl');
  555. kAudioFormatProperty_OutputFormatList = FourCharCode('ofls');
  556. kAudioFormatProperty_FirstPlayableFormatFromList = FourCharCode('fpfl');
  557. kAudioFormatProperty_FormatIsVBR = FourCharCode('fvbr');
  558. kAudioFormatProperty_FormatIsExternallyFramed = FourCharCode('fexf');
  559. kAudioFormatProperty_FormatIsEncrypted = FourCharCode('cryp');
  560. kAudioFormatProperty_Encoders = FourCharCode('aven');
  561. kAudioFormatProperty_Decoders = FourCharCode('avde');
  562. kAudioFormatProperty_AvailableEncodeBitRates = FourCharCode('aebr');
  563. kAudioFormatProperty_AvailableEncodeSampleRates = FourCharCode('aesr');
  564. kAudioFormatProperty_AvailableEncodeChannelLayoutTags = FourCharCode('aecl');
  565. kAudioFormatProperty_AvailableEncodeNumberChannels = FourCharCode('avnc');
  566. kAudioFormatProperty_ASBDFromMPEGPacket = FourCharCode('admp');
  567. //=============================================================================
  568. // The following properties concern the AudioChannelLayout struct (speaker layouts)
  569. //=============================================================================
  570. kAudioFormatProperty_BitmapForLayoutTag = FourCharCode('bmtg');
  571. kAudioFormatProperty_MatrixMixMap = FourCharCode('mmap');
  572. kAudioFormatProperty_ChannelMap = FourCharCode('chmp');
  573. kAudioFormatProperty_NumberOfChannelsForLayout = FourCharCode('nchm');
  574. kAudioFormatProperty_AreChannelLayoutsEquivalent = FourCharCode('cheq');
  575. kAudioFormatProperty_ChannelLayoutHash = FourCharCode('chha');
  576. kAudioFormatProperty_ValidateChannelLayout = FourCharCode('vacl');
  577. kAudioFormatProperty_ChannelLayoutForTag = FourCharCode('cmpl');
  578. kAudioFormatProperty_TagForChannelLayout = FourCharCode('cmpt');
  579. kAudioFormatProperty_ChannelLayoutName = FourCharCode('lonm');
  580. kAudioFormatProperty_ChannelLayoutSimpleName = FourCharCode('lsnm');
  581. kAudioFormatProperty_ChannelLayoutForBitmap = FourCharCode('cmpb');
  582. kAudioFormatProperty_ChannelName = FourCharCode('cnam');
  583. kAudioFormatProperty_ChannelShortName = FourCharCode('csnm');
  584. kAudioFormatProperty_TagsForNumberOfChannels = FourCharCode('tagc');
  585. kAudioFormatProperty_PanningMatrix = FourCharCode('panm');
  586. kAudioFormatProperty_BalanceFade = FourCharCode('balf');
  587. //=============================================================================
  588. // The following properties concern the ID3 Tags
  589. //=============================================================================
  590. kAudioFormatProperty_ID3TagSize = FourCharCode('id3s');
  591. kAudioFormatProperty_ID3TagToDictionary = FourCharCode('id3d');
  592. //=============================================================================
  593. // Routines
  594. //=============================================================================
  595. {!
  596. @function AudioFormatGetPropertyInfo
  597. @abstract Retrieve information about the given property
  598. @param inPropertyID an AudioFormatPropertyID constant.
  599. @param inSpecifierSize The size of the specifier data.
  600. @param inSpecifier A specifier is a buffer of data used as an input argument to some of the properties.
  601. @param outPropertyDataSize The size in bytes of the current value of the property. In order to get the property value,
  602. you will need a buffer of this size.
  603. @result returns noErr if successful.
  604. }
  605. function AudioFormatGetPropertyInfo( inPropertyID: AudioFormatPropertyID; inSpecifierSize: UInt32; {const} inSpecifier: UnivPtr {__nullable}; var outPropertyDataSize: UInt32 ): OSStatus; external name '_AudioFormatGetPropertyInfo';
  606. (* API_AVAILABLE(macos(10.3), ios(2.0), watchos(2.0), tvos(9.0)) *)
  607. {!
  608. @function AudioFormatGetProperty
  609. @abstract Retrieve the indicated property data
  610. @param inPropertyID an AudioFormatPropertyID constant.
  611. @param inSpecifierSize The size of the specifier data.
  612. @param inSpecifier A specifier is a buffer of data used as an input argument to some of the properties.
  613. @param ioPropertyDataSize on input the size of the outPropertyData buffer. On output the number of bytes written to the buffer.
  614. @param outPropertyData the buffer in which to write the property data. If outPropertyData is NULL and ioPropertyDataSize is
  615. not, the amount that would have been written will be reported.
  616. @result returns noErr if successful.
  617. }
  618. function AudioFormatGetProperty( inPropertyID: AudioFormatPropertyID; inSpecifierSize: UInt32; {const} inSpecifier: UnivPtr {__nullable}; ioPropertyDataSize: UInt32Ptr {* __nullable}; outPropertyData: UnivPtr {__nullable} ): OSStatus; external name '_AudioFormatGetProperty';
  619. (* API_AVAILABLE(macos(10.3), ios(2.0), watchos(2.0), tvos(9.0)) *)
  620. //-----------------------------------------------------------------------------
  621. // AudioFormat Error Codes
  622. //-----------------------------------------------------------------------------
  623. const
  624. kAudioFormatUnspecifiedError = FourCharCode('what'); // 0x77686174, 2003329396
  625. kAudioFormatUnsupportedPropertyError = FourCharCode('prop'); // 0x70726F70, 1886547824
  626. kAudioFormatBadPropertySizeError = FourCharCode('!siz'); // 0x2173697A, 561211770
  627. kAudioFormatBadSpecifierSizeError = FourCharCode('!spc'); // 0x21737063, 561213539
  628. kAudioFormatUnsupportedDataFormatError = FourCharCode('fmt?'); // 0x666D743F, 1718449215
  629. kAudioFormatUnknownFormatError = FourCharCode('!fmt'); // 0x21666D74, 560360820
  630. //CF_ASSUME_NONNULL_END
  631. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  632. end.
  633. {$endc} {not MACOSALLINCLUDE}