AudioConverter.pas 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
  1. {!
  2. @file AudioConverter.h
  3. @framework AudioToolbox.framework
  4. @copyright (c) 1985-2015 by Apple, Inc., all rights reserved.
  5. @abstract API's to perform audio format conversions.
  6. @discussion
  7. AudioConverters convert between various linear PCM and compressed
  8. audio formats. Supported transformations include:
  9. - PCM float/integer/bit depth conversions
  10. - PCM sample rate conversion
  11. - PCM interleaving and deinterleaving
  12. - encoding PCM to compressed formats
  13. - decoding compressed formats to PCM
  14. A single AudioConverter may perform more than one
  15. of the above transformations.
  16. }
  17. { Pascal Translation: Jonas Maebe <[email protected]>, July 2019 }
  18. {
  19. Modified for use with Free Pascal
  20. Version 308
  21. Please report any bugs to <[email protected]>
  22. }
  23. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  24. {$mode macpas}
  25. {$modeswitch cblocks}
  26. {$packenum 1}
  27. {$macro on}
  28. {$inline on}
  29. {$calling mwpascal}
  30. {$IFNDEF FPC_DOTTEDUNITS}
  31. unit AudioConverter;
  32. {$ENDIF FPC_DOTTEDUNITS}
  33. interface
  34. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  35. {$setc GAP_INTERFACES_VERSION := $0308}
  36. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  37. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  38. {$endc}
  39. {$ifc defined CPUPOWERPC and defined CPUI386}
  40. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  41. {$endc}
  42. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  43. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  44. {$endc}
  45. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  46. {$setc __ppc__ := 1}
  47. {$elsec}
  48. {$setc __ppc__ := 0}
  49. {$endc}
  50. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  51. {$setc __ppc64__ := 1}
  52. {$elsec}
  53. {$setc __ppc64__ := 0}
  54. {$endc}
  55. {$ifc not defined __i386__ and defined CPUI386}
  56. {$setc __i386__ := 1}
  57. {$elsec}
  58. {$setc __i386__ := 0}
  59. {$endc}
  60. {$ifc not defined __x86_64__ and defined CPUX86_64}
  61. {$setc __x86_64__ := 1}
  62. {$elsec}
  63. {$setc __x86_64__ := 0}
  64. {$endc}
  65. {$ifc not defined __arm__ and defined CPUARM}
  66. {$setc __arm__ := 1}
  67. {$elsec}
  68. {$setc __arm__ := 0}
  69. {$endc}
  70. {$ifc not defined __arm64__ and defined CPUAARCH64}
  71. {$setc __arm64__ := 1}
  72. {$elsec}
  73. {$setc __arm64__ := 0}
  74. {$endc}
  75. {$ifc defined cpu64}
  76. {$setc __LP64__ := 1}
  77. {$elsec}
  78. {$setc __LP64__ := 0}
  79. {$endc}
  80. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  81. {$error Conflicting definitions for __ppc__ and __i386__}
  82. {$endc}
  83. {$ifc defined __ppc__ and __ppc__}
  84. {$setc TARGET_CPU_PPC := TRUE}
  85. {$setc TARGET_CPU_PPC64 := FALSE}
  86. {$setc TARGET_CPU_X86 := FALSE}
  87. {$setc TARGET_CPU_X86_64 := FALSE}
  88. {$setc TARGET_CPU_ARM := FALSE}
  89. {$setc TARGET_CPU_ARM64 := FALSE}
  90. {$setc TARGET_OS_MAC := TRUE}
  91. {$setc TARGET_OS_IPHONE := FALSE}
  92. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  93. {$setc TARGET_OS_EMBEDDED := FALSE}
  94. {$elifc defined __ppc64__ and __ppc64__}
  95. {$setc TARGET_CPU_PPC := FALSE}
  96. {$setc TARGET_CPU_PPC64 := TRUE}
  97. {$setc TARGET_CPU_X86 := FALSE}
  98. {$setc TARGET_CPU_X86_64 := FALSE}
  99. {$setc TARGET_CPU_ARM := FALSE}
  100. {$setc TARGET_CPU_ARM64 := FALSE}
  101. {$setc TARGET_OS_MAC := TRUE}
  102. {$setc TARGET_OS_IPHONE := FALSE}
  103. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  104. {$setc TARGET_OS_EMBEDDED := FALSE}
  105. {$elifc defined __i386__ and __i386__}
  106. {$setc TARGET_CPU_PPC := FALSE}
  107. {$setc TARGET_CPU_PPC64 := FALSE}
  108. {$setc TARGET_CPU_X86 := TRUE}
  109. {$setc TARGET_CPU_X86_64 := FALSE}
  110. {$setc TARGET_CPU_ARM := FALSE}
  111. {$setc TARGET_CPU_ARM64 := FALSE}
  112. {$ifc defined iphonesim}
  113. {$setc TARGET_OS_MAC := FALSE}
  114. {$setc TARGET_OS_IPHONE := TRUE}
  115. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  116. {$elsec}
  117. {$setc TARGET_OS_MAC := TRUE}
  118. {$setc TARGET_OS_IPHONE := FALSE}
  119. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  120. {$endc}
  121. {$setc TARGET_OS_EMBEDDED := FALSE}
  122. {$elifc defined __x86_64__ and __x86_64__}
  123. {$setc TARGET_CPU_PPC := FALSE}
  124. {$setc TARGET_CPU_PPC64 := FALSE}
  125. {$setc TARGET_CPU_X86 := FALSE}
  126. {$setc TARGET_CPU_X86_64 := TRUE}
  127. {$setc TARGET_CPU_ARM := FALSE}
  128. {$setc TARGET_CPU_ARM64 := FALSE}
  129. {$ifc defined iphonesim}
  130. {$setc TARGET_OS_MAC := FALSE}
  131. {$setc TARGET_OS_IPHONE := TRUE}
  132. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  133. {$elsec}
  134. {$setc TARGET_OS_MAC := TRUE}
  135. {$setc TARGET_OS_IPHONE := FALSE}
  136. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  137. {$endc}
  138. {$setc TARGET_OS_EMBEDDED := FALSE}
  139. {$elifc defined __arm__ and __arm__}
  140. {$setc TARGET_CPU_PPC := FALSE}
  141. {$setc TARGET_CPU_PPC64 := FALSE}
  142. {$setc TARGET_CPU_X86 := FALSE}
  143. {$setc TARGET_CPU_X86_64 := FALSE}
  144. {$setc TARGET_CPU_ARM := TRUE}
  145. {$setc TARGET_CPU_ARM64 := FALSE}
  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. {$elifc defined __arm64__ and __arm64__}
  151. {$setc TARGET_CPU_PPC := FALSE}
  152. {$setc TARGET_CPU_PPC64 := FALSE}
  153. {$setc TARGET_CPU_X86 := FALSE}
  154. {$setc TARGET_CPU_X86_64 := FALSE}
  155. {$setc TARGET_CPU_ARM := FALSE}
  156. {$setc TARGET_CPU_ARM64 := TRUE}
  157. {$ifc defined ios}
  158. {$setc TARGET_OS_MAC := FALSE}
  159. {$setc TARGET_OS_IPHONE := TRUE}
  160. {$setc TARGET_OS_EMBEDDED := TRUE}
  161. {$elsec}
  162. {$setc TARGET_OS_MAC := TRUE}
  163. {$setc TARGET_OS_IPHONE := FALSE}
  164. {$setc TARGET_OS_EMBEDDED := FALSE}
  165. {$endc}
  166. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  167. {$elsec}
  168. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  169. {$endc}
  170. {$ifc defined __LP64__ and __LP64__ }
  171. {$setc TARGET_CPU_64 := TRUE}
  172. {$elsec}
  173. {$setc TARGET_CPU_64 := FALSE}
  174. {$endc}
  175. {$ifc defined FPC_BIG_ENDIAN}
  176. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  177. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  178. {$elifc defined FPC_LITTLE_ENDIAN}
  179. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  180. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  181. {$elsec}
  182. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  183. {$endc}
  184. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  185. {$setc CALL_NOT_IN_CARBON := FALSE}
  186. {$setc OLDROUTINENAMES := FALSE}
  187. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  188. {$setc OPAQUE_UPP_TYPES := TRUE}
  189. {$setc OTCARBONAPPLICATION := TRUE}
  190. {$setc OTKERNEL := FALSE}
  191. {$setc PM_USE_SESSION_APIS := TRUE}
  192. {$setc TARGET_API_MAC_CARBON := TRUE}
  193. {$setc TARGET_API_MAC_OS8 := FALSE}
  194. {$setc TARGET_API_MAC_OSX := TRUE}
  195. {$setc TARGET_CARBON := TRUE}
  196. {$setc TARGET_CPU_68K := FALSE}
  197. {$setc TARGET_CPU_MIPS := FALSE}
  198. {$setc TARGET_CPU_SPARC := FALSE}
  199. {$setc TARGET_OS_UNIX := FALSE}
  200. {$setc TARGET_OS_WIN32 := FALSE}
  201. {$setc TARGET_RT_MAC_68881 := FALSE}
  202. {$setc TARGET_RT_MAC_CFM := FALSE}
  203. {$setc TARGET_RT_MAC_MACHO := TRUE}
  204. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  205. {$setc TYPE_BOOL := FALSE}
  206. {$setc TYPE_EXTENDED := FALSE}
  207. {$setc TYPE_LONGLONG := TRUE}
  208. {$IFDEF FPC_DOTTEDUNITS}
  209. uses MacOsApi.MacTypes,MacOsApi.CoreAudioTypes;
  210. {$ELSE FPC_DOTTEDUNITS}
  211. uses MacTypes,CoreAudioTypes;
  212. {$ENDIF FPC_DOTTEDUNITS}
  213. {$endc} {not MACOSALLINCLUDE}
  214. {$ALIGN POWER}
  215. //==================================================================================================
  216. {!
  217. @header AudioConverter.h
  218. }
  219. //=============================================================================
  220. // Includes
  221. //=============================================================================
  222. //CF_ASSUME_NONNULL_BEGIN
  223. //=============================================================================
  224. // Theory of Operation
  225. //=============================================================================
  226. //=============================================================================
  227. // Types specific to the Audio Converter API
  228. //=============================================================================
  229. {!
  230. @typedef AudioConverterRef
  231. @abstract A reference to an AudioConverter object.
  232. }
  233. type
  234. AudioConverterRef = ^OpaqueAudioConverter; { an opaque type }
  235. OpaqueAudioConverter = record end;
  236. type
  237. AudioConverterPropertyID = UInt32;
  238. //=============================================================================
  239. // Standard Properties
  240. //=============================================================================
  241. {!
  242. @enum AudioConverterPropertyID
  243. @abstract The properties of an AudioConverter, accessible via AudioConverterGetProperty()
  244. and AudioConverterSetProperty().
  245. @constant kAudioConverterPropertyMinimumInputBufferSize
  246. a UInt32 that indicates the size in bytes of the smallest buffer of input
  247. data that can be supplied via the AudioConverterInputProc or as the input to
  248. AudioConverterConvertBuffer
  249. @constant kAudioConverterPropertyMinimumOutputBufferSize
  250. a UInt32 that indicates the size in bytes of the smallest buffer of output
  251. data that can be supplied to AudioConverterFillComplexBuffer or as the output to
  252. AudioConverterConvertBuffer
  253. @constant kAudioConverterPropertyMaximumInputBufferSize
  254. DEPRECATED. The AudioConverter input proc may be passed any number of packets of data.
  255. If fewer are packets are returned than required, then the input proc will be called again.
  256. If more packets are passed than required, they will remain in the client's buffer and be
  257. consumed as needed.
  258. @constant kAudioConverterPropertyMaximumInputPacketSize
  259. a UInt32 that indicates the size in bytes of the largest single packet of
  260. data in the input format. This is mostly useful for variable bit rate
  261. compressed data (decoders).
  262. @constant kAudioConverterPropertyMaximumOutputPacketSize
  263. a UInt32 that indicates the size in bytes of the largest single packet of
  264. data in the output format. This is mostly useful for variable bit rate
  265. compressed data (encoders).
  266. @constant kAudioConverterPropertyCalculateInputBufferSize
  267. a UInt32 that on input holds a size in bytes that is desired for the output
  268. data. On output, it will hold the size in bytes of the input buffer required
  269. to generate that much output data. Note that some converters cannot do this
  270. calculation.
  271. @constant kAudioConverterPropertyCalculateOutputBufferSize
  272. a UInt32 that on input holds a size in bytes that is desired for the input
  273. data. On output, it will hold the size in bytes of the output buffer
  274. required to hold the output data that will be generated. Note that some
  275. converters cannot do this calculation.
  276. @constant kAudioConverterPropertyInputCodecParameters
  277. The value of this property varies from format to format and is considered
  278. private to the format. It is treated as a buffer of untyped data.
  279. @constant kAudioConverterPropertyOutputCodecParameters
  280. The value of this property varies from format to format and is considered
  281. private to the format. It is treated as a buffer of untyped data.
  282. @constant kAudioConverterSampleRateConverterAlgorithm
  283. DEPRECATED: please use kAudioConverterSampleRateConverterComplexity instead
  284. @constant kAudioConverterSampleRateConverterComplexity
  285. An OSType that specifies the sample rate converter algorithm to use (as defined in
  286. AudioToolbox/AudioUnitProperties.h)
  287. @constant kAudioConverterSampleRateConverterQuality
  288. A UInt32 that specifies rendering quality of the sample rate converter (see
  289. enum constants below)
  290. @constant kAudioConverterSampleRateConverterInitialPhase
  291. A Float64 with value 0.0 <= x < 1.0 giving the initial subsample position of the
  292. sample rate converter.
  293. @constant kAudioConverterCodecQuality
  294. A UInt32 that specifies rendering quality of a codec (see enum constants
  295. below)
  296. @constant kAudioConverterPrimeMethod
  297. a UInt32 specifying priming method (usually for sample-rate converter) see
  298. explanation for struct AudioConverterPrimeInfo below along with enum
  299. constants
  300. @constant kAudioConverterPrimeInfo
  301. A pointer to AudioConverterPrimeInfo (see explanation for struct
  302. AudioConverterPrimeInfo below)
  303. @constant kAudioConverterChannelMap
  304. An array of SInt32's. The size of the array is the number of output
  305. channels, and each element specifies which input channel's data is routed to
  306. that output channel (using a 0-based index of the input channels), or -1 if
  307. no input channel is to be routed to that output channel. The default
  308. behavior is as follows. I = number of input channels, O = number of output
  309. channels. When I > O, the first O inputs are routed to the first O outputs,
  310. and the remaining puts discarded. When O > I, the first I inputs are routed
  311. to the first O outputs, and the remaining outputs are zeroed.
  312. A simple example for splitting mono input to stereo output (instead of routing
  313. the input to only the first output channel):
  314. <pre>
  315. // this should be as large as the number of output channels:
  316. SInt32 channelMap[2] = ( 0, 0 );
  317. AudioConverterSetProperty(theConverter, kAudioConverterChannelMap,
  318. sizeof(channelMap), channelMap);
  319. </pre>
  320. @constant kAudioConverterDecompressionMagicCookie
  321. A void * pointing to memory set up by the caller. Required by some formats
  322. in order to decompress the input data.
  323. @constant kAudioConverterCompressionMagicCookie
  324. A void * pointing to memory set up by the caller. Returned by the converter
  325. so that it may be stored along with the output data. It can then be passed
  326. back to the converter for decompression at a later time.
  327. @constant kAudioConverterEncodeBitRate
  328. A UInt32 containing the number of bits per second to aim for when encoding
  329. data. Some decoders will also allow you to get this property to discover the bit rate.
  330. @constant kAudioConverterEncodeAdjustableSampleRate
  331. For encoders where the AudioConverter was created with an output sample rate
  332. of zero, and the codec can do rate conversion on its input, this provides a
  333. way to set the output sample rate. The property value is a Float64.
  334. @constant kAudioConverterInputChannelLayout
  335. The property value is an AudioChannelLayout.
  336. @constant kAudioConverterOutputChannelLayout
  337. The property value is an AudioChannelLayout.
  338. @constant kAudioConverterApplicableEncodeBitRates
  339. The property value is an array of AudioValueRange describing applicable bit
  340. rates based on current settings.
  341. @constant kAudioConverterAvailableEncodeBitRates
  342. The property value is an array of AudioValueRange describing available bit
  343. rates based on the input format. You can get all available bit rates from
  344. the AudioFormat API.
  345. @constant kAudioConverterApplicableEncodeSampleRates
  346. The property value is an array of AudioValueRange describing applicable
  347. sample rates based on current settings.
  348. @constant kAudioConverterAvailableEncodeSampleRates
  349. The property value is an array of AudioValueRange describing available
  350. sample rates based on the input format. You can get all available sample
  351. rates from the AudioFormat API.
  352. @constant kAudioConverterAvailableEncodeChannelLayoutTags
  353. The property value is an array of AudioChannelLayoutTags for the format and
  354. number of channels specified in the input format going to the encoder.
  355. @constant kAudioConverterCurrentOutputStreamDescription
  356. Returns the current completely specified output AudioStreamBasicDescription.
  357. For example when encoding to AAC, your original output stream description
  358. will not have been completely filled out.
  359. @constant kAudioConverterCurrentInputStreamDescription
  360. Returns the current completely specified input AudioStreamBasicDescription.
  361. @constant kAudioConverterPropertySettings
  362. Returns the a CFArray of property settings for converters.
  363. @constant kAudioConverterPropertyBitDepthHint
  364. An SInt32 of the source bit depth to preserve. This is a hint to some
  365. encoders like lossless about how many bits to preserve in the input. The
  366. converter usually tries to preserve as many as possible, but a lossless
  367. encoder will do poorly if more bits are supplied than are desired in the
  368. output. The bit depth is expressed as a negative number if the source was floating point,
  369. e.g. -32 for float, -64 for double.
  370. @constant kAudioConverterPropertyFormatList
  371. An array of AudioFormatListItem structs describing all the data formats produced by the
  372. encoder end of the AudioConverter. If the ioPropertyDataSize parameter indicates that
  373. outPropertyData is sizeof(AudioFormatListItem), then only the best format is returned.
  374. This property may be used for example to discover all the data formats produced by the AAC_HE2
  375. (AAC High Efficiency vers. 2) encoder.
  376. }
  377. const
  378. kAudioConverterPropertyMinimumInputBufferSize = FourCharCode('mibs');
  379. kAudioConverterPropertyMinimumOutputBufferSize = FourCharCode('mobs');
  380. kAudioConverterPropertyMaximumInputBufferSize = FourCharCode('xibs');
  381. kAudioConverterPropertyMaximumInputPacketSize = FourCharCode('xips');
  382. kAudioConverterPropertyMaximumOutputPacketSize = FourCharCode('xops');
  383. kAudioConverterPropertyCalculateInputBufferSize = FourCharCode('cibs');
  384. kAudioConverterPropertyCalculateOutputBufferSize = FourCharCode('cobs');
  385. kAudioConverterPropertyInputCodecParameters = FourCharCode('icdp');
  386. kAudioConverterPropertyOutputCodecParameters = FourCharCode('ocdp');
  387. kAudioConverterSampleRateConverterAlgorithm = FourCharCode('srci');
  388. kAudioConverterSampleRateConverterComplexity = FourCharCode('srca');
  389. kAudioConverterSampleRateConverterQuality = FourCharCode('srcq');
  390. kAudioConverterSampleRateConverterInitialPhase = FourCharCode('srcp');
  391. kAudioConverterCodecQuality = FourCharCode('cdqu');
  392. kAudioConverterPrimeMethod = FourCharCode('prmm');
  393. kAudioConverterPrimeInfo = FourCharCode('prim');
  394. kAudioConverterChannelMap = FourCharCode('chmp');
  395. kAudioConverterDecompressionMagicCookie = FourCharCode('dmgc');
  396. kAudioConverterCompressionMagicCookie = FourCharCode('cmgc');
  397. kAudioConverterEncodeBitRate = FourCharCode('brat');
  398. kAudioConverterEncodeAdjustableSampleRate = FourCharCode('ajsr');
  399. kAudioConverterInputChannelLayout = FourCharCode('icl ');
  400. kAudioConverterOutputChannelLayout = FourCharCode('ocl ');
  401. kAudioConverterApplicableEncodeBitRates = FourCharCode('aebr');
  402. kAudioConverterAvailableEncodeBitRates = FourCharCode('vebr');
  403. kAudioConverterApplicableEncodeSampleRates = FourCharCode('aesr');
  404. kAudioConverterAvailableEncodeSampleRates = FourCharCode('vesr');
  405. kAudioConverterAvailableEncodeChannelLayoutTags = FourCharCode('aecl');
  406. kAudioConverterCurrentOutputStreamDescription = FourCharCode('acod');
  407. kAudioConverterCurrentInputStreamDescription = FourCharCode('acid');
  408. kAudioConverterPropertySettings = FourCharCode('acps');
  409. kAudioConverterPropertyBitDepthHint = FourCharCode('acbd');
  410. kAudioConverterPropertyFormatList = FourCharCode('flst');
  411. //=============================================================================
  412. //
  413. //=============================================================================
  414. {!
  415. @enum Mac OS X AudioConverter Properties
  416. @constant kAudioConverterPropertyDithering
  417. A UInt32. Set to a value from the enum of dithering algorithms below.
  418. Zero means no dithering and is the default. (Mac OS X only.)
  419. @constant kAudioConverterPropertyDitherBitDepth
  420. A UInt32. Dither is applied at this bit depth. (Mac OS X only.)
  421. }
  422. const
  423. kAudioConverterPropertyDithering = FourCharCode('dith');
  424. kAudioConverterPropertyDitherBitDepth = FourCharCode('dbit');
  425. {!
  426. @enum Dithering algorithms
  427. @abstract Constants to be used as the value for kAudioConverterPropertyDithering.
  428. @constant kDitherAlgorithm_TPDF Dither signal is generated by a white noise source with a triangular probability density function
  429. @constant kDitherAlgorithm_NoiseShaping Use a static, perceptually weighted noise shaped dither
  430. }
  431. const
  432. kDitherAlgorithm_TPDF = 1;
  433. kDitherAlgorithm_NoiseShaping = 2;
  434. {!
  435. @enum Quality constants
  436. @abstract Constants to be used with kAudioConverterSampleRateConverterQuality.
  437. @constant kAudioConverterQuality_Max maximum quality
  438. @constant kAudioConverterQuality_High high quality
  439. @constant kAudioConverterQuality_Medium medium quality
  440. @constant kAudioConverterQuality_Low low quality
  441. @constant kAudioConverterQuality_Min minimum quality
  442. }
  443. const
  444. kAudioConverterQuality_Max = $7F;
  445. kAudioConverterQuality_High = $60;
  446. kAudioConverterQuality_Medium = $40;
  447. kAudioConverterQuality_Low = $20;
  448. kAudioConverterQuality_Min = 0;
  449. {!
  450. @enum Sample Rate Converter Complexity
  451. @constant kAudioConverterSampleRateConverterComplexity_Linear
  452. @discussion Linear interpolation. lowest quality, cheapest.
  453. InitialPhase and PrimeMethod properties are not operative with this mode.
  454. @constant kAudioConverterSampleRateConverterComplexity_Normal
  455. @discussion Normal quality sample rate conversion.
  456. @constant kAudioConverterSampleRateConverterComplexity_Mastering
  457. @discussion Mastering quality sample rate conversion. More expensive.
  458. @constant kAudioConverterSampleRateConverterComplexity_MinimumPhase
  459. @discussion Minimum phase impulse response. Stopband attenuation varies with quality setting.
  460. The InitialPhase and PrimeMethod properties are not operative with this mode.
  461. There are three levels of quality provided.
  462. kAudioConverterQuality_Low (or Min) : noise floor to -96 dB
  463. kAudioConverterQuality_Medium : noise floor to -144 dB
  464. kAudioConverterQuality_High (or Max) : noise floor to -160 dB (this uses double precision internally)
  465. Quality equivalences to the other complexity modes are very roughly as follows:
  466. MinimumPhase Low is somewhat better than Normal Medium.
  467. MinimumPhase Medium is similar to Normal Max.
  468. MinimumPhase High is similar to Mastering Low.
  469. In general, MinimumPhase performs better than Normal and Mastering for the equivalent qualities listed above.
  470. MinimumPhase High is several times faster than Mastering Low.
  471. }
  472. const
  473. kAudioConverterSampleRateConverterComplexity_Linear = FourCharCode('line'); // linear interpolation
  474. kAudioConverterSampleRateConverterComplexity_Normal = FourCharCode('norm'); // normal quality range, the default
  475. kAudioConverterSampleRateConverterComplexity_Mastering = FourCharCode('bats'); // higher quality range, more expensive
  476. kAudioConverterSampleRateConverterComplexity_MinimumPhase = FourCharCode('minp'); // minimum phase impulse response.
  477. {!
  478. @enum Prime method constants
  479. @abstract Constants to be used with kAudioConverterPrimeMethod.
  480. @constant kConverterPrimeMethod_Pre
  481. Primes with leading + trailing input frames.
  482. @constant kConverterPrimeMethod_Normal
  483. Only primes with trailing (zero latency). Leading frames are assumed to be
  484. silence.
  485. @constant kConverterPrimeMethod_None
  486. Acts in "latency" mode. Both leading and trailing frames assumed to be
  487. silence.
  488. }
  489. const
  490. kConverterPrimeMethod_Pre = 0;
  491. kConverterPrimeMethod_Normal = 1;
  492. kConverterPrimeMethod_None = 2;
  493. {!
  494. @struct AudioConverterPrimeInfo
  495. @abstract Specifies priming information.
  496. @field leadingFrames
  497. Specifies the number of leading (previous) input frames, relative to the normal/desired
  498. start input frame, required by the converter to perform a high quality conversion. If
  499. using kConverterPrimeMethod_Pre, the client should "pre-seek" the input stream provided
  500. through the input proc by leadingFrames. If no frames are available previous to the
  501. desired input start frame (because, for example, the desired start frame is at the very
  502. beginning of available audio), then provide "leadingFrames" worth of initial zero frames
  503. in the input proc. Do not "pre-seek" in the default case of
  504. kConverterPrimeMethod_Normal or when using kConverterPrimeMethod_None.
  505. @field trailingFrames
  506. Specifies the number of trailing input frames (past the normal/expected end input frame)
  507. required by the converter to perform a high quality conversion. The client should be
  508. prepared to provide this number of additional input frames except when using
  509. kConverterPrimeMethod_None. If no more frames of input are available in the input stream
  510. (because, for example, the desired end frame is at the end of an audio file), then zero
  511. (silent) trailing frames will be synthesized for the client.
  512. @discussion
  513. When using AudioConverterFillComplexBuffer() (either a single call or a series of calls), some
  514. conversions, particularly involving sample-rate conversion, ideally require a certain
  515. number of input frames previous to the normal start input frame and beyond the end of
  516. the last expected input frame in order to yield high-quality results.
  517. These are expressed in the leadingFrames and trailingFrames members of the structure.
  518. The very first call to AudioConverterFillComplexBuffer(), or first call after
  519. AudioConverterReset(), will request additional input frames beyond those normally
  520. expected in the input proc callback to fulfill this first AudioConverterFillComplexBuffer()
  521. request. The number of additional frames requested, depending on the prime method, will
  522. be approximately:
  523. <pre>
  524. kConverterPrimeMethod_Pre leadingFrames + trailingFrames
  525. kConverterPrimeMethod_Normal trailingFrames
  526. kConverterPrimeMethod_None 0
  527. </pre>
  528. Thus, in effect, the first input proc callback(s) may provide not only the leading
  529. frames, but also may "read ahead" by an additional number of trailing frames depending
  530. on the prime method.
  531. kConverterPrimeMethod_None is useful in a real-time application processing live input,
  532. in which case trailingFrames (relative to input sample rate) of through latency will be
  533. seen at the beginning of the output of the AudioConverter. In other real-time
  534. applications such as DAW systems, it may be possible to provide these initial extra
  535. audio frames since they are stored on disk or in memory somewhere and
  536. kConverterPrimeMethod_Pre may be preferable. The default method is
  537. kConverterPrimeMethod_Normal, which requires no pre-seeking of the input stream and
  538. generates no latency at the output.
  539. }
  540. type
  541. AudioConverterPrimeInfo = record
  542. leadingFrames: UInt32;
  543. trailingFrames: UInt32;
  544. end;
  545. AudioConverterPrimeInfoPtr = ^AudioConverterPrimeInfo;
  546. //=============================================================================
  547. // Errors
  548. //=============================================================================
  549. const
  550. kAudioConverterErr_FormatNotSupported = FourCharCode('fmt?');
  551. kAudioConverterErr_OperationNotSupported = $6F703F3F; // 'op??', integer used because of trigraph
  552. kAudioConverterErr_PropertyNotSupported = FourCharCode('prop');
  553. kAudioConverterErr_InvalidInputSize = FourCharCode('insz');
  554. kAudioConverterErr_InvalidOutputSize = FourCharCode('otsz');
  555. // e.g. byte size is not a multiple of the frame size
  556. kAudioConverterErr_UnspecifiedError = FourCharCode('what');
  557. kAudioConverterErr_BadPropertySizeError = FourCharCode('!siz');
  558. kAudioConverterErr_RequiresPacketDescriptionsError = FourCharCode('!pkd');
  559. kAudioConverterErr_InputSampleRateOutOfRange = FourCharCode('!isr');
  560. kAudioConverterErr_OutputSampleRateOutOfRange = FourCharCode('!osr');
  561. //=============================================================================
  562. // Routines
  563. //=============================================================================
  564. //-----------------------------------------------------------------------------
  565. {!
  566. @function AudioConverterNew
  567. @abstract Create a new AudioConverter.
  568. @param inSourceFormat
  569. The format of the source audio to be converted.
  570. @param inDestinationFormat
  571. The destination format to which the audio is to be converted.
  572. @param outAudioConverter
  573. On successful return, points to a new AudioConverter instance.
  574. @result An OSStatus result code.
  575. @discussion
  576. For a pair of linear PCM formats, the following conversions
  577. are supported:
  578. <ul>
  579. <li>addition and removal of channels, when the stream descriptions'
  580. mChannelsPerFrame does not match. Channels may also be reordered and removed
  581. using the kAudioConverterChannelMap property.</li>
  582. <li>sample rate conversion</li>
  583. <li>interleaving/deinterleaving, when the stream descriptions' (mFormatFlags &
  584. kAudioFormatFlagIsNonInterleaved) does not match.</li>
  585. <li>conversion between any pair of the following formats:</li>
  586. <ul>
  587. <li>8 bit integer, signed or unsigned</li>
  588. <li>16, 24, or 32-bit integer, big- or little-endian. Other integral
  589. bit depths, if high-aligned and non-packed, are also supported</li>
  590. <li>32 and 64-bit float, big- or little-endian.</li>
  591. </ul>
  592. </ul>
  593. Also, encoding and decoding between linear PCM and compressed formats is
  594. supported. Functions in AudioToolbox/AudioFormat.h return information about the
  595. supported formats. When using a codec, you can use any supported PCM format (as
  596. above); the converter will perform any necessary additional conversion between
  597. your PCM format and the one created or consumed by the codec.
  598. }
  599. function AudioConverterNew( const (*var*) inSourceFormat: AudioStreamBasicDescription; const (*var*) inDestinationFormat: AudioStreamBasicDescription; var outAudioConverter: AudioConverterRef {__nullable * __nonnull} ): OSStatus; external name '_AudioConverterNew';
  600. (* API_AVAILABLE(macos(10.1), ios(2.0), watchos(2.0), tvos(9.0)) *)
  601. //-----------------------------------------------------------------------------
  602. {!
  603. @function AudioConverterNewSpecific
  604. @abstract Create a new AudioConverter using specific codecs.
  605. @param inSourceFormat
  606. The format of the source audio to be converted.
  607. @param inDestinationFormat
  608. The destination format to which the audio is to be converted.
  609. @param inNumberClassDescriptions
  610. The number of class descriptions.
  611. @param inClassDescriptions
  612. AudioClassDescriptions specifiying the codec to instantiate.
  613. @param outAudioConverter
  614. On successful return, points to a new AudioConverter instance.
  615. @result An OSStatus result code.
  616. @discussion
  617. This function is identical to AudioConverterNew(), except that the client may
  618. explicitly choose which codec to instantiate if there is more than one choice.
  619. }
  620. function AudioConverterNewSpecific( const (*var*) inSourceFormat: AudioStreamBasicDescription; const (*var*) inDestinationFormat: AudioStreamBasicDescription; inNumberClassDescriptions: UInt32; const (*var*) inClassDescriptions: AudioClassDescription; var outAudioConverter: AudioConverterRef {__nullable * __nonnull} ): OSStatus; external name '_AudioConverterNewSpecific';
  621. (* API_AVAILABLE(macos(10.4), ios(2.0), watchos(2.0), tvos(9.0)) *)
  622. //-----------------------------------------------------------------------------
  623. {!
  624. @function AudioConverterDispose
  625. @abstract Destroy an AudioConverter.
  626. @param inAudioConverter
  627. The AudioConverter to dispose.
  628. @result An OSStatus result code.
  629. }
  630. function AudioConverterDispose( inAudioConverter: AudioConverterRef ): OSStatus; external name '_AudioConverterDispose';
  631. (* API_AVAILABLE(macos(10.1), ios(2.0), watchos(2.0), tvos(9.0)) *)
  632. //-----------------------------------------------------------------------------
  633. {!
  634. @function AudioConverterReset
  635. @abstract Reset an AudioConverter
  636. @param inAudioConverter
  637. The AudioConverter to reset.
  638. @result An OSStatus result code.
  639. @discussion
  640. Should be called whenever there is a discontinuity in the source audio stream
  641. being provided to the converter. This will flush any internal buffers in the
  642. converter.
  643. }
  644. function AudioConverterReset( inAudioConverter: AudioConverterRef ): OSStatus; external name '_AudioConverterReset';
  645. (* API_AVAILABLE(macos(10.1), ios(2.0), watchos(2.0), tvos(9.0)) *)
  646. //-----------------------------------------------------------------------------
  647. {!
  648. @function AudioConverterGetPropertyInfo
  649. @abstract Returns information about an AudioConverter property.
  650. @param inAudioConverter
  651. The AudioConverter to query.
  652. @param inPropertyID
  653. The property to query.
  654. @param outSize
  655. If non-null, on exit, the maximum size of the property value in bytes.
  656. @param outWritable
  657. If non-null, on exit, indicates whether the property value is writable.
  658. @result An OSStatus result code.
  659. }
  660. function AudioConverterGetPropertyInfo( inAudioConverter: AudioConverterRef; inPropertyID: AudioConverterPropertyID; outSize: UInt32Ptr {* __nullable}; outWritable: BooleanPtr {* __nullable} ): OSStatus; external name '_AudioConverterGetPropertyInfo';
  661. (* API_AVAILABLE(macos(10.1), ios(2.0), watchos(2.0), tvos(9.0)) *)
  662. //-----------------------------------------------------------------------------
  663. {!
  664. @function AudioConverterGetProperty
  665. @abstract Returns an AudioConverter property value.
  666. @param inAudioConverter
  667. The AudioConverter to query.
  668. @param inPropertyID
  669. The property to fetch.
  670. @param ioPropertyDataSize
  671. On entry, the size of the memory pointed to by outPropertyData. On
  672. successful exit, the size of the property value.
  673. @param outPropertyData
  674. On exit, the property value.
  675. @result An OSStatus result code.
  676. }
  677. function AudioConverterGetProperty( inAudioConverter: AudioConverterRef; inPropertyID: AudioConverterPropertyID; var ioPropertyDataSize: UInt32; outPropertyData: UnivPtr ): OSStatus; external name '_AudioConverterGetProperty';
  678. (* API_AVAILABLE(macos(10.1), ios(2.0), watchos(2.0), tvos(9.0)) *)
  679. //-----------------------------------------------------------------------------
  680. {!
  681. @function AudioConverterSetProperty
  682. @abstract Sets an AudioConverter property value.
  683. @param inAudioConverter
  684. The AudioConverter to modify.
  685. @param inPropertyID
  686. The property to set.
  687. @param inPropertyDataSize
  688. The size in bytes of the property value.
  689. @param inPropertyData
  690. Points to the new property value.
  691. @result An OSStatus result code.
  692. }
  693. function AudioConverterSetProperty( inAudioConverter: AudioConverterRef; inPropertyID: AudioConverterPropertyID; inPropertyDataSize: UInt32; inPropertyData: {const} UnivPtr ): OSStatus; external name '_AudioConverterSetProperty';
  694. (* API_AVAILABLE(macos(10.1), ios(2.0), watchos(2.0), tvos(9.0)) *)
  695. //-----------------------------------------------------------------------------
  696. {!
  697. @typedef AudioConverterInputDataProc
  698. @abstract Callback function for supplying input data to AudioConverterFillBuffer.
  699. @param inAudioConverter
  700. The AudioConverter requesting input.
  701. @param ioDataSize
  702. On entry, the minimum number of bytes of audio data the converter
  703. would like in order to fulfill its current FillBuffer request.
  704. On exit, the number of bytes of audio data actually being provided
  705. for input, or 0 if there is no more input.
  706. @param outData
  707. On exit, *outData should point to the audio data being provided
  708. for input.
  709. @param inUserData
  710. The inInputDataProcUserData parameter passed to AudioConverterFillBuffer().
  711. @result An OSStatus result code.
  712. @discussion
  713. <b>NOTE:</b> This API is now deprecated,
  714. use AudioConverterFillComplexBuffer instead.
  715. This callback function supplies input to AudioConverterFillBuffer.
  716. The AudioConverter requests a minimum amount of data (*ioDataSize). The callback
  717. may return any amount of data. If it is less than than the minimum, the callback
  718. will simply be called again in the near future.
  719. The callback supplies a pointer to a buffer of audio data. The callback is
  720. responsible for not freeing or altering this buffer until it is called again.
  721. If the callback returns an error, it must return zero bytes of data.
  722. AudioConverterFillBuffer will stop producing output and return whatever output
  723. has already been produced to its caller, along with the error code. This
  724. mechanism can be used when an input proc has temporarily run out of data, but
  725. has not yet reached end of stream.
  726. }
  727. type
  728. AudioConverterInputDataProc = function( inAudioConverter: AudioConverterRef; var ioDataSize: UInt32; var outData: UnivPtr {__nonnull * __nonnull}; inUserData: UnivPtr {__nullable} ): OSStatus;
  729. //-----------------------------------------------------------------------------
  730. (*
  731. {!
  732. @function AudioConverterFillBuffer
  733. @abstract Converts data supplied by an input callback function.
  734. @param inAudioConverter
  735. The AudioConverter to use.
  736. @param inInputDataProc
  737. A callback function which supplies the input data.
  738. @param inInputDataProcUserData
  739. A value for the use of the callback function.
  740. @param ioOutputDataSize
  741. On entry, the size of the buffer pointed to by outOutputData.
  742. On exit, the number of bytes written to outOutputData
  743. @param outOutputData
  744. The buffer into which the converted data is written.
  745. @result An OSStatus result code.
  746. @discussion
  747. <b>NOTE:</b> This API is now deprecated,
  748. use AudioConverterFillComplexBuffer instead.
  749. Produces a buffer of output data from an AudioConverter. The supplied input
  750. callback function is called whenever necessary.
  751. }
  752. extern OSStatus
  753. AudioConverterFillBuffer( AudioConverterRef inAudioConverter,
  754. AudioConverterInputDataProc inInputDataProc,
  755. void * __nullable inInputDataProcUserData,
  756. UInt32 * ioOutputDataSize,
  757. void * outOutputData)
  758. API_DEPRECATED("no longer supported", macos(10.1, 10.5)) API_UNAVAILABLE(ios, watchos, tvos);
  759. *)
  760. //-----------------------------------------------------------------------------
  761. {!
  762. @function AudioConverterConvertBuffer
  763. @abstract Converts data from an input buffer to an output buffer.
  764. @param inAudioConverter
  765. The AudioConverter to use.
  766. @param inInputDataSize
  767. The size of the buffer inInputData.
  768. @param inInputData
  769. The input audio data buffer.
  770. @param ioOutputDataSize
  771. On entry, the size of the buffer outOutputData. On exit, the number of bytes
  772. written to outOutputData.
  773. @param outOutputData
  774. The output data buffer.
  775. @result
  776. Produces a buffer of output data from an AudioConverter, using the supplied
  777. input buffer.
  778. @discussion
  779. <b>WARNING:</b> this function will fail for any conversion where there is a
  780. variable relationship between the input and output data buffer sizes. This
  781. includes sample rate conversions and most compressed formats. In these cases,
  782. use AudioConverterFillComplexBuffer. Generally this function is only appropriate for
  783. PCM-to-PCM conversions where there is no sample rate conversion.
  784. }
  785. function AudioConverterConvertBuffer( inAudioConverter: AudioConverterRef; inInputDataSize: UInt32; inInputData: {const} UnivPtr; var ioOutputDataSize: UInt32; outOutputData: UnivPtr ): OSStatus; external name '_AudioConverterConvertBuffer';
  786. (* API_AVAILABLE(macos(10.1), ios(2.0), watchos(2.0), tvos(9.0)) *)
  787. //-----------------------------------------------------------------------------
  788. {!
  789. @typedef AudioConverterComplexInputDataProc
  790. @abstract Callback function for supplying input data to AudioConverterFillComplexBuffer.
  791. @param inAudioConverter
  792. The AudioConverter requesting input.
  793. @param ioNumberDataPackets
  794. On entry, the minimum number of packets of input audio data the converter
  795. would like in order to fulfill its current FillBuffer request. On exit, the
  796. number of packets of audio data actually being provided for input, or 0 if
  797. there is no more input.
  798. @param ioData
  799. On exit, the members of ioData should be set to point to the audio data
  800. being provided for input.
  801. @param outDataPacketDescription
  802. If non-null, on exit, the callback is expected to fill this in with
  803. an AudioStreamPacketDescription for each packet of input data being provided.
  804. @param inUserData
  805. The inInputDataProcUserData parameter passed to AudioConverterFillComplexBuffer().
  806. @result An OSStatus result code.
  807. @discussion
  808. This callback function supplies input to AudioConverterFillComplexBuffer.
  809. The AudioConverter requests a minimum number of packets (*ioNumberDataPackets).
  810. The callback may return one or more packets. If this is less than the minimum,
  811. the callback will simply be called again in the near future.
  812. The callback manipulates the members of ioData to point to one or more buffers
  813. of audio data (multiple buffers are used with non-interleaved PCM data). The
  814. callback is responsible for not freeing or altering this buffer until it is
  815. called again.
  816. If the callback returns an error, it must return zero packets of data.
  817. AudioConverterFillComplexBuffer will stop producing output and return whatever
  818. output has already been produced to its caller, along with the error code. This
  819. mechanism can be used when an input proc has temporarily run out of data, but
  820. has not yet reached end of stream.
  821. }
  822. type
  823. AudioConverterComplexInputDataProc = function( inAudioConverter: AudioConverterRef; var ioNumberDataPackets: UInt32; var ioData: AudioBufferList; outDataPacketDescription: AudioStreamPacketDescriptionPtrPtr {* __nullable * __nullable}; inUserData: UnivPtr {__nullable} ): OSStatus;
  824. //-----------------------------------------------------------------------------
  825. {!
  826. @function AudioConverterFillComplexBuffer
  827. @abstract Converts data supplied by an input callback function, supporting non-interleaved
  828. and packetized formats.
  829. @param inAudioConverter
  830. The AudioConverter to use.
  831. @param inInputDataProc
  832. A callback function which supplies the input data.
  833. @param inInputDataProcUserData
  834. A value for the use of the callback function.
  835. @param ioOutputDataPacketSize
  836. On entry, the capacity of outOutputData expressed in packets in the
  837. converter's output format. On exit, the number of packets of converted
  838. data that were written to outOutputData.
  839. @param outOutputData
  840. The converted output data is written to this buffer.
  841. @param outPacketDescription
  842. If non-null, and the converter's output uses packet descriptions, then
  843. packet descriptions are written to this array. It must point to a memory
  844. block capable of holding *ioOutputDataPacketSize packet descriptions.
  845. (See AudioFormat.h for ways to determine whether an audio format
  846. uses packet descriptions).
  847. @result An OSStatus result code.
  848. @discussion
  849. Produces a buffer list of output data from an AudioConverter. The supplied input
  850. callback function is called whenever necessary.
  851. }
  852. function AudioConverterFillComplexBuffer( inAudioConverter: AudioConverterRef; inInputDataProc: AudioConverterComplexInputDataProc; inInputDataProcUserData: UnivPtr {__nullable}; var ioOutputDataPacketSize: UInt32; var outOutputData: AudioBufferList; outPacketDescription: AudioStreamPacketDescriptionPtr {* __nullable} ): OSStatus; external name '_AudioConverterFillComplexBuffer';
  853. (* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
  854. //-----------------------------------------------------------------------------
  855. {!
  856. @function AudioConverterConvertComplexBuffer
  857. @abstract Converts PCM data from an input buffer list to an output buffer list.
  858. @param inAudioConverter
  859. The AudioConverter to use.
  860. @param inNumberPCMFrames
  861. The number of PCM frames to convert.
  862. @param inInputData
  863. The source audio buffer list.
  864. @param outOutputData
  865. The converted output data is written to this buffer list.
  866. @result An OSStatus result code.
  867. @discussion
  868. <b>WARNING:</b> this function will fail for any conversion where there is a
  869. variable relationship between the input and output data buffer sizes. This
  870. includes sample rate conversions and most compressed formats. In these cases,
  871. use AudioConverterFillComplexBuffer. Generally this function is only appropriate for
  872. PCM-to-PCM conversions where there is no sample rate conversion.
  873. }
  874. function AudioConverterConvertComplexBuffer( inAudioConverter: AudioConverterRef; inNumberPCMFrames: UInt32; const (*var*) inInputData: AudioBufferList; var outOutputData: AudioBufferList ): OSStatus; external name '_AudioConverterConvertComplexBuffer';
  875. (* API_AVAILABLE(macos(10.7), ios(5.0), watchos(2.0), tvos(9.0)) *)
  876. //CF_ASSUME_NONNULL_END
  877. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  878. end.
  879. {$endc} {not MACOSALLINCLUDE}