1 {!
2 @file AudioFile.h
3 @framework AudioToolbox.framework
4 @copyright (c) 1985-2015 by Apple, Inc., all rights reserved.
5 @abstract API's to read and write audio files in the filesystem or in memory.
6 }
7 { Pascal Translation: Jonas Maebe <jonas@freepascal.org>, July 2019 }
8 {
9 Modified for use with Free Pascal
10 Version 308
11 Please report any bugs to <gpc@microbizz.nl>
12 }
13
14 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
15 {$mode macpas}
16 {$modeswitch cblocks}
17 {$packenum 1}
18 {$macro on}
19 {$inline on}
20 {$calling mwpascal}
21
22 unit AudioFile;
23 interface
24 {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
25 {$setc GAP_INTERFACES_VERSION := $0308}
26
27 {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
28 {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
29 {$endc}
30
31 {$ifc defined CPUPOWERPC and defined CPUI386}
32 {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
33 {$endc}
34 {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
35 {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
36 {$endc}
37
38 {$ifc not defined __ppc__ and defined CPUPOWERPC32}
39 {$setc __ppc__ := 1}
40 {$elsec}
41 {$setc __ppc__ := 0}
42 {$endc}
43 {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
44 {$setc __ppc64__ := 1}
45 {$elsec}
46 {$setc __ppc64__ := 0}
47 {$endc}
48 {$ifc not defined __i386__ and defined CPUI386}
49 {$setc __i386__ := 1}
50 {$elsec}
51 {$setc __i386__ := 0}
52 {$endc}
53 {$ifc not defined __x86_64__ and defined CPUX86_64}
54 {$setc __x86_64__ := 1}
55 {$elsec}
56 {$setc __x86_64__ := 0}
57 {$endc}
58 {$ifc not defined __arm__ and defined CPUARM}
59 {$setc __arm__ := 1}
60 {$elsec}
61 {$setc __arm__ := 0}
62 {$endc}
63 {$ifc not defined __arm64__ and defined CPUAARCH64}
64 {$setc __arm64__ := 1}
65 {$elsec}
66 {$setc __arm64__ := 0}
67 {$endc}
68
69 {$ifc defined cpu64}
70 {$setc __LP64__ := 1}
71 {$elsec}
72 {$setc __LP64__ := 0}
73 {$endc}
74
75
76 {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
77 {$error Conflicting definitions for __ppc__ and __i386__}
78 {$endc}
79
80 {$ifc defined __ppc__ and __ppc__}
81 {$setc TARGET_CPU_PPC := TRUE}
82 {$setc TARGET_CPU_PPC64 := FALSE}
83 {$setc TARGET_CPU_X86 := FALSE}
84 {$setc TARGET_CPU_X86_64 := FALSE}
85 {$setc TARGET_CPU_ARM := FALSE}
86 {$setc TARGET_CPU_ARM64 := FALSE}
87 {$setc TARGET_OS_MAC := TRUE}
88 {$setc TARGET_OS_IPHONE := FALSE}
89 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
90 {$setc TARGET_OS_EMBEDDED := FALSE}
91 {$elifc defined __ppc64__ and __ppc64__}
92 {$setc TARGET_CPU_PPC := FALSE}
93 {$setc TARGET_CPU_PPC64 := TRUE}
94 {$setc TARGET_CPU_X86 := FALSE}
95 {$setc TARGET_CPU_X86_64 := FALSE}
96 {$setc TARGET_CPU_ARM := FALSE}
97 {$setc TARGET_CPU_ARM64 := FALSE}
98 {$setc TARGET_OS_MAC := TRUE}
99 {$setc TARGET_OS_IPHONE := FALSE}
100 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
101 {$setc TARGET_OS_EMBEDDED := FALSE}
102 {$elifc defined __i386__ and __i386__}
103 {$setc TARGET_CPU_PPC := FALSE}
104 {$setc TARGET_CPU_PPC64 := FALSE}
105 {$setc TARGET_CPU_X86 := TRUE}
106 {$setc TARGET_CPU_X86_64 := FALSE}
107 {$setc TARGET_CPU_ARM := FALSE}
108 {$setc TARGET_CPU_ARM64 := FALSE}
109 {$ifc defined iphonesim}
110 {$setc TARGET_OS_MAC := FALSE}
111 {$setc TARGET_OS_IPHONE := TRUE}
112 {$setc TARGET_IPHONE_SIMULATOR := TRUE}
113 {$elsec}
114 {$setc TARGET_OS_MAC := TRUE}
115 {$setc TARGET_OS_IPHONE := FALSE}
116 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
117 {$endc}
118 {$setc TARGET_OS_EMBEDDED := FALSE}
119 {$elifc defined __x86_64__ and __x86_64__}
120 {$setc TARGET_CPU_PPC := FALSE}
121 {$setc TARGET_CPU_PPC64 := FALSE}
122 {$setc TARGET_CPU_X86 := FALSE}
123 {$setc TARGET_CPU_X86_64 := TRUE}
124 {$setc TARGET_CPU_ARM := FALSE}
125 {$setc TARGET_CPU_ARM64 := FALSE}
126 {$ifc defined iphonesim}
127 {$setc TARGET_OS_MAC := FALSE}
128 {$setc TARGET_OS_IPHONE := TRUE}
129 {$setc TARGET_IPHONE_SIMULATOR := TRUE}
130 {$elsec}
131 {$setc TARGET_OS_MAC := TRUE}
132 {$setc TARGET_OS_IPHONE := FALSE}
133 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
134 {$endc}
135 {$setc TARGET_OS_EMBEDDED := FALSE}
136 {$elifc defined __arm__ and __arm__}
137 {$setc TARGET_CPU_PPC := FALSE}
138 {$setc TARGET_CPU_PPC64 := FALSE}
139 {$setc TARGET_CPU_X86 := FALSE}
140 {$setc TARGET_CPU_X86_64 := FALSE}
141 {$setc TARGET_CPU_ARM := TRUE}
142 {$setc TARGET_CPU_ARM64 := FALSE}
143 {$setc TARGET_OS_MAC := FALSE}
144 {$setc TARGET_OS_IPHONE := TRUE}
145 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
146 {$setc TARGET_OS_EMBEDDED := TRUE}
147 {$elifc defined __arm64__ and __arm64__}
148 {$setc TARGET_CPU_PPC := FALSE}
149 {$setc TARGET_CPU_PPC64 := FALSE}
150 {$setc TARGET_CPU_X86 := FALSE}
151 {$setc TARGET_CPU_X86_64 := FALSE}
152 {$setc TARGET_CPU_ARM := FALSE}
153 {$setc TARGET_CPU_ARM64 := TRUE}
154 {$ifc defined ios}
155 {$setc TARGET_OS_MAC := FALSE}
156 {$setc TARGET_OS_IPHONE := TRUE}
157 {$setc TARGET_OS_EMBEDDED := TRUE}
158 {$elsec}
159 {$setc TARGET_OS_MAC := TRUE}
160 {$setc TARGET_OS_IPHONE := FALSE}
161 {$setc TARGET_OS_EMBEDDED := FALSE}
162 {$endc}
163 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
164 {$elsec}
165 {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
166 {$endc}
167
168 {$ifc defined __LP64__ and __LP64__ }
169 {$setc TARGET_CPU_64 := TRUE}
170 {$elsec}
171 {$setc TARGET_CPU_64 := FALSE}
172 {$endc}
173
174 {$ifc defined FPC_BIG_ENDIAN}
175 {$setc TARGET_RT_BIG_ENDIAN := TRUE}
176 {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
177 {$elifc defined FPC_LITTLE_ENDIAN}
178 {$setc TARGET_RT_BIG_ENDIAN := FALSE}
179 {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
180 {$elsec}
181 {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
182 {$endc}
183 {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
184 {$setc CALL_NOT_IN_CARBON := FALSE}
185 {$setc OLDROUTINENAMES := FALSE}
186 {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
187 {$setc OPAQUE_UPP_TYPES := TRUE}
188 {$setc OTCARBONAPPLICATION := TRUE}
189 {$setc OTKERNEL := FALSE}
190 {$setc PM_USE_SESSION_APIS := TRUE}
191 {$setc TARGET_API_MAC_CARBON := TRUE}
192 {$setc TARGET_API_MAC_OS8 := FALSE}
193 {$setc TARGET_API_MAC_OSX := TRUE}
194 {$setc TARGET_CARBON := TRUE}
195 {$setc TARGET_CPU_68K := FALSE}
196 {$setc TARGET_CPU_MIPS := FALSE}
197 {$setc TARGET_CPU_SPARC := FALSE}
198 {$setc TARGET_OS_UNIX := FALSE}
199 {$setc TARGET_OS_WIN32 := FALSE}
200 {$setc TARGET_RT_MAC_68881 := FALSE}
201 {$setc TARGET_RT_MAC_CFM := FALSE}
202 {$setc TARGET_RT_MAC_MACHO := TRUE}
203 {$setc TYPED_FUNCTION_POINTERS := TRUE}
204 {$setc TYPE_BOOL := FALSE}
205 {$setc TYPE_EXTENDED := FALSE}
206 {$setc TYPE_LONGLONG := TRUE}
207 uses MacTypes,CFBase,CoreAudioTypes,CoreFoundation;
208 {$endc} {not MACOSALLINCLUDE}
209
210 {$ALIGN POWER}
211
212
213 //=============================================================================
214 // Includes
215 //=============================================================================
216
217
218 //CF_ASSUME_NONNULL_BEGIN
219
220
221 {!
222 @typedef AudioFileTypeID
223 @abstract Identifier for an audio file type.
224 }
225 type
226 AudioFileTypeID = UInt32;
227
228 {!
229 @enum Audio File Types
230 @abstract Constants for the built-in audio file types.
231 @discussion These constants are used to indicate the type of file to be written, or as a hint to
232 what type of file to expect from data provided.
233 @constant kAudioFileAIFFType
234 Audio Interchange File Format (AIFF)
235 @constant kAudioFileAIFCType
236 Audio Interchange File Format Compressed (AIFF-C)
237 @constant kAudioFileWAVEType
238 Microsoft WAVE
239 @constant kAudioFileRF64Type
240 File Format specified in EBU Tech 3306
241 @constant kAudioFileSoundDesigner2Type
242 Sound Designer II
243 @constant kAudioFileNextType
244 NeXT / Sun
245 @constant kAudioFileMP3Type
246 MPEG Audio Layer 3 (.mp3)
247 @constant kAudioFileMP2Type
248 MPEG Audio Layer 2 (.mp2)
249 @constant kAudioFileMP1Type
250 MPEG Audio Layer 1 (.mp1)
251 @constant kAudioFileAC3Type
252 AC-3
253 @constant kAudioFileAAC_ADTSType
254 Advanced Audio Coding (AAC) Audio Data Transport Stream (ADTS)
255 @constant kAudioFileMPEG4Type
256 @constant kAudioFileM4AType
257 @constant kAudioFileM4BType
258 @constant kAudioFileCAFType
259 CoreAudio File Format
260 @constant kAudioFile3GPType
261 @constant kAudioFile3GP2Type
262 @constant kAudioFileAMRType
263 @constant kAudioFileFLACType
264 Free Lossless Audio Codec
265 }
266 const
267 kAudioFileAIFFType = FourCharCode('AIFF');
268 kAudioFileAIFCType = FourCharCode('AIFC');
269 kAudioFileWAVEType = FourCharCode('WAVE');
270 kAudioFileRF64Type = FourCharCode('RF64');
271 kAudioFileSoundDesigner2Type = FourCharCode('Sd2f');
272 kAudioFileNextType = FourCharCode('NeXT');
273 kAudioFileMP3Type = FourCharCode('MPG3'); // mpeg layer 3
274 kAudioFileMP2Type = FourCharCode('MPG2'); // mpeg layer 2
275 kAudioFileMP1Type = FourCharCode('MPG1'); // mpeg layer 1
276 kAudioFileAC3Type = FourCharCode('ac-3');
277 kAudioFileAAC_ADTSType = FourCharCode('adts');
278 kAudioFileMPEG4Type = FourCharCode('mp4f');
279 kAudioFileM4AType = FourCharCode('m4af');
280 kAudioFileM4BType = FourCharCode('m4bf');
281 kAudioFileCAFType = FourCharCode('caff');
282 kAudioFile3GPType = FourCharCode('3gpp');
283 kAudioFile3GP2Type = FourCharCode('3gp2');
284 kAudioFileAMRType = FourCharCode('amrf');
285 kAudioFileFLACType = FourCharCode('flac');
286
287 {!
288 @enum AudioFile error codes
289 @abstract These are the error codes returned from the AudioFile API.
290 @constant kAudioFileUnspecifiedError
291 An unspecified error has occurred.
292 @constant kAudioFileUnsupportedFileTypeError
293 The file type is not supported.
294 @constant kAudioFileUnsupportedDataFormatError
295 The data format is not supported by this file type.
296 @constant kAudioFileUnsupportedPropertyError
297 The property is not supported.
298 @constant kAudioFileBadPropertySizeError
299 The size of the property data was not correct.
300 @constant kAudioFilePermissionsError
301 The operation violated the file permissions. For example, trying to write to a file opened with kAudioFileReadPermission.
302 @constant kAudioFileNotOptimizedError
303 There are chunks following the audio data chunk that prevent extending the audio data chunk.
304 The file must be optimized in order to write more audio data.
305 @constant kAudioFileInvalidChunkError
306 The chunk does not exist in the file or is not supported by the file.
307 @constant kAudioFileDoesNotAllow64BitDataSizeError
308 The a file offset was too large for the file type. AIFF and WAVE have a 32 bit file size limit.
309 @constant kAudioFileInvalidPacketOffsetError
310 A packet offset was past the end of the file, or not at the end of the file when writing a VBR format,
311 or a corrupt packet size was read when building the packet table.
312 @constant kAudioFileInvalidFileError
313 The file is malformed, or otherwise not a valid instance of an audio file of its type.
314 @constant kAudioFileOperationNotSupportedError
315 The operation cannot be performed. For example, setting kAudioFilePropertyAudioDataByteCount to increase
316 the size of the audio data in a file is not a supported operation. Write the data instead.
317 @constant kAudioFileNotOpenError
318 The file is closed.
319 @constant kAudioFileEndOfFileError
320 End of file.
321 @constant kAudioFilePositionError
322 Invalid file position.
323 @constant kAudioFileFileNotFoundError
324 File not found.
325 }
326 const
327 kAudioFileUnspecifiedError = FourCharCode('wht?'); // 0x7768743F, 2003334207
328 kAudioFileUnsupportedFileTypeError = FourCharCode('typ?'); // 0x7479703F, 1954115647
329 kAudioFileUnsupportedDataFormatError = FourCharCode('fmt?'); // 0x666D743F, 1718449215
330 kAudioFileUnsupportedPropertyError = FourCharCode('pty?'); // 0x7074793F, 1886681407
331 kAudioFileBadPropertySizeError = FourCharCode('!siz'); // 0x2173697A, 561211770
332 kAudioFilePermissionsError = FourCharCode('prm?'); // 0x70726D3F, 1886547263
333 kAudioFileNotOptimizedError = FourCharCode('optm'); // 0x6F70746D, 1869640813
334 // file format specific error codes
335 kAudioFileInvalidChunkError = FourCharCode('chk?'); // 0x63686B3F, 1667787583
336 kAudioFileDoesNotAllow64BitDataSizeError = FourCharCode('off?'); // 0x6F66663F, 1868981823
337 kAudioFileInvalidPacketOffsetError = FourCharCode('pck?'); // 0x70636B3F, 1885563711
338 kAudioFileInvalidFileError = FourCharCode('dta?'); // 0x6474613F, 1685348671
339 kAudioFileOperationNotSupportedError = $6F703F3F; // 'op??', integer used because of trigraph
340 // general file error codes
341 kAudioFileNotOpenError = -38;
342 kAudioFileEndOfFileError = -39;
343 kAudioFilePositionError = -40;
344 kAudioFileFileNotFoundError = -43;
345
346 {!
347 @enum AudioFileFlags
348 @abstract These are flags that can be used with the CreateURL API call
349 @constant kAudioFileFlags_EraseFile
350 If set, then the CreateURL call will erase the contents of an existing file
351 If not set, then the CreateURL call will fail if the file already exists
352 @constant kAudioFileFlags_DontPageAlignAudioData
353 Normally, newly created and optimized files will have padding added in order to page align
354 the data to 4KB boundaries. This makes reading the data more efficient.
355 When disk space is a concern, this flag can be set so that the padding will not be added.
356 }
357 type
358 AudioFileFlags = UInt32;
359 const
360 kAudioFileFlags_EraseFile = 1;
361 kAudioFileFlags_DontPageAlignAudioData = 2;
362
363 type
364 AudioFilePermissions = SInt8;
365 const
366 kAudioFileReadPermission = $01;
367 kAudioFileWritePermission = $02;
368 kAudioFileReadWritePermission = $03;
369
370 //=============================================================================
371 // Types specific to the Audio File API
372 //=============================================================================
373
374 {!
375 @typedef AudioFileID
376 @abstract An opaque reference to an AudioFile object.
377 }
378 type
379 OpaqueAudioFileID = record end;
380 AudioFileID = ^OpaqueAudioFileID;
381 {!
382 @typedef AudioFilePropertyID
383 @abstract A constant for an AudioFile property.
384 }
385 type
386 AudioFilePropertyID = UInt32;
387
388 {!
389 @enum AudioFileLoopDirection
390 @abstract These constants describe the playback direction of a looped segment of a file.
391 @constant kAudioFileLoopDirection_NoLooping
392 The segment is not looped.
393 @constant kAudioFileLoopDirection_Forward
394 play segment forward.
395 @constant kAudioFileLoopDirection_Backward
396 play segment backward.
397 @constant kAudioFileLoopDirection_ForwardAndBackward
398 play segment forward and backward.
399 }
400 const
401 kAudioFileLoopDirection_NoLooping = 0;
402 kAudioFileLoopDirection_Forward = 1;
403 kAudioFileLoopDirection_ForwardAndBackward = 2;
404 kAudioFileLoopDirection_Backward = 3;
405
406 //=============================================================================
407 // Markers, Regions
408 //=============================================================================
409
410
411 {!
412 @struct AudioFile_SMPTE_Time
413 @abstract A struct for describing a SMPTE time.
414 @field mHours The hours.
415 @field mMinutes The minutes.
416 @field mSeconds The seconds.
417 @field mFrames The frames.
418 @field mSubFrameSampleOffset The sample offset within a frame.
419 }
420 type
421 AudioFile_SMPTE_Time = record
422 mHours: SInt8;
423 mMinutes: UInt8;
424 mSeconds: UInt8;
425 mFrames: UInt8;
426 mSubFrameSampleOffset: UInt32;
427 end;
428
429
430 {!
431 @enum AudioFileMarkerType
432 @abstract constants for types of markers within a file. Used in the mType field of AudioFileMarker.
433 @constant kAudioFileMarkerType_Generic A generic marker. See CAFFile.h for marker types specific to CAF files.
434 }
435 const
436 kAudioFileMarkerType_Generic = 0;
437
438
439 {!
440 @struct AudioFileMarker
441 @abstract A marker annotates a position in an audio file with additional information.
442 @discussion (description)
443 @field mFramePosition The frame in the file counting from the start of the audio data.
444 @field mName The name of this marker.
445 @field mMarkerID A unique ID for this marker.
446 @field mSMPTETime The SMPTE time for this marker.
447 @field mType The marker type.
448 @field mReserved A reserved field. Set to zero.
449 @field mChannel The channel number that the marker refers to. Set to zero if marker applies to all channels.
450 }
451 type
452 AudioFileMarker = record
453 mFramePosition: Float64;
454
455 mName: CFStringRef {__nullable};
456 mMarkerID: SInt32;
457
458 mSMPTETime: AudioFile_SMPTE_Time;
459 mType: UInt32;
460 mReserved: UInt16;
461 mChannel: UInt16;
462 end;
463 AudioFileMarkerPtr = ^AudioFileMarker;
464
465 {!
466 @struct AudioFileMarkerList
467 @abstract A list of AudioFileMarker.
468 @field mSMPTE_TimeType
469 This defines the SMPTE timing scheme used in the marker list. See CAFFile.h for the values used here.
470 @field mNumberMarkers
471 The number of markers in the mMarkers list.
472 @field mMarkers
473 A list of AudioFileMarker.
474 }
475 type
476 AudioFileMarkerList = record
477 mSMPTE_TimeType: UInt32;
478 mNumberMarkers: UInt32;
479 mMarkers: array [0..1-1] of AudioFileMarker; // this is a variable length array of mNumberMarkers elements
480 end;
481 AudioFileMarkerListPtr = ^AudioFileMarkerList;
482
483 {!
484 @function NumBytesToNumAudioFileMarkers
485 @abstract Converts a size in bytes to the number of AudioFileMarkers that can be contained in that number of bytes.
486 @discussion This can be used for the kAudioFilePropertyMarkerList property when calculating the number of
487 markers that will be returned.
488 @param inNumBytes
489 a number of bytes.
490 @result the number of AudioFileMarkers that can be contained in that number of bytes.
491 }
492
NumBytesToNumAudioFileMarkersnull493 function NumBytesToNumAudioFileMarkers(inNumBytes: size_t): size_t;
494 {FPC-ONLY-START}
495 inline;
496 {FPC-ONLY-END}
497
498 {!
499 @function NumAudioFileMarkersToNumBytes
500 @abstract Converts a number of AudioFileMarkers to a size in bytes.
501 @discussion This can be used for the kAudioFilePropertyMarkerList property when calculating the size required to
502 contain a number of AudioFileMarkers.
503 @param inNumMarkers
504 a number of AudioFileMarkers.
505 @result the size in bytes required to contain that number of AudioFileMarkers.
506 }
507
NumAudioFileMarkersToNumBytesnull508 function NumAudioFileMarkersToNumBytes(inNumMarkers: size_t): size_t;
509 {FPC-ONLY-START}
510 inline;
511 {FPC-ONLY-END}
512
513 {!
514 @enum AudioFileRegionFlags
515 @abstract These are flags for an AudioFileRegion that specify a playback direction.
516 @discussion One or multiple of these flags can be set. For example, if both kAudioFileRegionFlag_LoopEnable and
517 kAudioFileRegionFlag_PlayForward are set, then the region will play as a forward loop. If only
518 kAudioFileRegionFlag_PlayForward is set, then the region will be played forward once.
519 @constant kAudioFileRegionFlag_LoopEnable
520 If this flag is set, the region will be looped. One or both of the following must also be set.
521 @constant kAudioFileRegionFlag_PlayForward
522 If this flag is set, the region will be played forward.
523 @constant kAudioFileRegionFlag_PlayBackward
524 If this flag is set, the region will be played backward.
525 }
526 type
527 AudioFileRegionFlags = UInt32;
528 const
529 kAudioFileRegionFlag_LoopEnable = 1;
530 kAudioFileRegionFlag_PlayForward = 2;
531 kAudioFileRegionFlag_PlayBackward = 4;
532
533 {!
534 @struct AudioFileRegion
535 @abstract An AudioFileRegion specifies a segment of audio data.
536 @discussion Generally a region consists of at least two markers marking the beginning and end of the segment.
537 There may also be other markers defining other meta information such as sync point.
538 @field mRegionID
539 each region must have a unique ID.
540 @field mName
541 The name of the region.
542 @field mFlags
543 AudioFileRegionFlags.
544 @field mNumberMarkers
545 The number of markers in the mMarkers array.
546 @field mMarkers
547 A variable length array of AudioFileMarkers.
548 }
549 type
550 AudioFileRegion = record
551 mRegionID: UInt32;
552 mName: CFStringRef;
553 mFlags: AudioFileRegionFlags;
554 mNumberMarkers: UInt32;
555 mMarkers: array [0..1-1] of AudioFileMarker; // this is a variable length array of mNumberMarkers elements
556 end;
557 AudioFileRegionPtr = ^AudioFileRegion;
558
559
560 {!
561 @struct AudioFileRegionList
562 @abstract A list of the AudioFileRegions in a file.
563 @discussion This is the struct used by the kAudioFilePropertyRegionList property.
564 @field mSMPTE_TimeType
565 This defines the SMPTE timing scheme used in the file. See CAFFile.h for the values used here.
566 @field mNumberRegions
567 The number of regions in the mRegions list.
568 @field mRegions
569 A list of AudioFileRegions. Note that AudioFileMarkers are variable length, so this list cannot
570 be accessed as an array. Use the NextAudioFileRegion macro for traversing the list instead.
571 }
572 type
573 AudioFileRegionList = record
574 mSMPTE_TimeType: UInt32;
575 mNumberRegions: UInt32;
576 mRegions: array [0..1-1] of AudioFileRegion; // this is a variable length array of mNumberRegions elements
577 end;
578 AudioFileRegionListPtr = ^AudioFileRegionList;
579
580 {!
581 @function NextAudioFileRegion
582 @abstract convenience macro for traversing the region list.
583 @discussion because AudioFileRegions are variable length, you cannot access them as an array. Use NextAudioFileRegion
584 to walk the list.
585 @param inAFRegionPtr
586 a pointer to the current region.
587 @result a pointer to the region after the current region. This does not protect you from walking off the end of the list,
588 so obey mNumberRegions.
589 }
590
NextAudioFileRegionnull591 function NextAudioFileRegion(const {var} inAFRegionPtr: AudioFileRegion): AudioFileRegionPtr;
592 {FPC-ONLY-START}
593 inline;
594 {FPC-ONLY-END}
595
596 {!
597 @struct AudioFramePacketTranslation
598 @abstract used for properties kAudioFilePropertyPacketToFrame and kAudioFilePropertyFrameToPacket
599 @discussion See description of kAudioFilePropertyPacketToFrame and kAudioFilePropertyFrameToPacket
600 @field mFrame a frame number.
601 @field mPacket a packet number.
602 @field mFrameOffsetInPacket a frame offset in a packet.
603 }
604 type
605 AudioFramePacketTranslation = record
606 mFrame: SInt64;
607 mPacket: SInt64;
608 mFrameOffsetInPacket: UInt32;
609 end;
610 AudioFramePacketTranslationPtr = ^AudioFramePacketTranslation;
611
612
613 {!
614 @enum AudioBytePacketTranslation Flags
615
616 @abstract flags for the AudioBytePacketTranslation mFlags field
617 @discussion There is currently only one flag.
618
619 @constant kBytePacketTranslationFlag_IsEstimate
620 If the set then the result value is an estimate.
621 }
622 type
623 AudioBytePacketTranslationFlags = UInt32;
624 const
625 kBytePacketTranslationFlag_IsEstimate = 1;
626
627 {!
628 @struct AudioBytePacketTranslation
629 @abstract used for properties kAudioFileByteToPacket and kAudioFilePacketToByte
630 @discussion See description of kAudioFileByteToPacket and kAudioFilePacketToByte
631 @field mByte a byte number.
632 @field mPacket a packet number.
633 @field mByteOffsetInPacket a byte offset in a packet.
634 @field mFlags if kBytePacketTranslationFlag_IsEstimate is set, then the value is an estimate.
635 }
636 type
637 AudioBytePacketTranslation = record
638 mByte: SInt64;
639 mPacket: SInt64;
640 mByteOffsetInPacket: UInt32;
641 mFlags: AudioBytePacketTranslationFlags;
642 end;
643 AudioBytePacketTranslationPtr = ^AudioBytePacketTranslation;
644
645
646 {!
647 @struct AudioFilePacketTableInfo
648 @abstract This contains information about the number of valid frames in a file and where they begin and end.
649 @discussion Some data formats may have packets whose contents are not completely valid, but represent priming or remainder
650 frames that are not meant to be played. For example a file with 100 packets of AAC is nominally 1024 * 100 = 102400 frames
651 of data. However the first 2112 frames of that may be priming frames and there may be some
652 number of remainder frames added to pad out to a full packet of 1024 frames. The priming and remainder frames should be
653 discarded. The total number of packets in the file times the frames per packet (or counting each packet's frames
654 individually for a variable frames per packet format) minus mPrimingFrames, minus mRemainderFrames, should
655 equal mNumberValidFrames.
656 @field mNumberValidFrames the number of valid frames in the file.
657 @field mPrimingFrames the number of invalid frames at the beginning of the file.
658 @field mRemainderFrames the number of invalid frames at the end of the file.
659 }
660 type
661 AudioFilePacketTableInfo = record
662 mNumberValidFrames: SInt64;
663 mPrimingFrames: SInt32;
664 mRemainderFrames: SInt32;
665 end;
666 AudioFilePacketTableInfoPtr = ^AudioFilePacketTableInfo;
667
668 //=============================================================================
669 // Info String Keys
670 //=============================================================================
671
672 // Get key values from the InfoDictionary by making CFStrings from the following constants
673
674 const
675 kAFInfoDictionary_Album = 'album';
676 const
677 kAFInfoDictionary_ApproximateDurationInSeconds = 'approximate duration in seconds';
678 const
679 kAFInfoDictionary_Artist = 'artist';
680 const
681 kAFInfoDictionary_ChannelLayout = 'channel layout';
682 const
683 kAFInfoDictionary_Comments = 'comments';
684 const
685 kAFInfoDictionary_Composer = 'composer';
686 const
687 kAFInfoDictionary_Copyright = 'copyright';
688 const
689 kAFInfoDictionary_EncodingApplication = 'encoding application';
690 const
691 kAFInfoDictionary_Genre = 'genre';
692 const
693 kAFInfoDictionary_ISRC = 'ISRC'; // International Standard Recording Code
694 const
695 kAFInfoDictionary_KeySignature = 'key signature';
696 const
697 kAFInfoDictionary_Lyricist = 'lyricist';
698 const
699 kAFInfoDictionary_NominalBitRate = 'nominal bit rate';
700 const
701 kAFInfoDictionary_RecordedDate = 'recorded date';
702 const
703 kAFInfoDictionary_SourceBitDepth = 'source bit depth';
704 const
705 kAFInfoDictionary_SourceEncoder = 'source encoder';
706 const
707 kAFInfoDictionary_SubTitle = 'subtitle';
708 const
709 kAFInfoDictionary_Tempo = 'tempo';
710 const
711 kAFInfoDictionary_TimeSignature = 'time signature';
712 const
713 kAFInfoDictionary_Title = 'title';
714 const
715 kAFInfoDictionary_TrackNumber = 'track number';
716 const
717 kAFInfoDictionary_Year = 'year';
718
719 //=============================================================================
720 // Routines
721 //=============================================================================
722
723 {!
724 @function AudioFileCreateWithURL
725 @abstract creates a new audio file (or initialises an existing file)
726 @discussion creates a new (or initialises an existing) audio file specified by the URL.
727 Upon success, an AudioFileID is returned which can be used for subsequent calls
728 to the AudioFile APIs.
729 @param inFileRef an CFURLRef fully specifying the path of the file to create/initialise
730 @param inFileType an AudioFileTypeID indicating the type of audio file to create.
731 @param inFormat an AudioStreamBasicDescription describing the data format that will be
732 added to the audio file.
733 @param inFlags relevant flags for creating/opening the file.
734 if kAudioFileFlags_EraseFile is set, it will erase an existing file
735 if not set, then the Create call will fail if the URL is an existing file
736 @param outAudioFile if successful, an AudioFileID that can be used for subsequent AudioFile calls.
737 @result returns noErr if successful.
738 }
AudioFileCreateWithURLnull739 function AudioFileCreateWithURL( inFileRef: CFURLRef; inFileType: AudioFileTypeID; const (*var*) inFormat: AudioStreamBasicDescription; inFlags: AudioFileFlags; var outAudioFile: AudioFileID {__nullable * __nonnull} ): OSStatus; external name '_AudioFileCreateWithURL';
740 (* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
741
742 {!
743 @function AudioFileOpenURL
744 @abstract Open an existing audio file.
745 @discussion Open an existing audio file for reading or reading and writing.
746 @param inFileRef the CFURLRef of an existing audio file.
747 @param inPermissions use the permission constants
748 @param inFileTypeHint For files which have no filename extension and whose type cannot be easily or
749 uniquely determined from the data (ADTS,AC3), this hint can be used to indicate the file type.
750 Otherwise you can pass zero for this. The hint is only used on OS versions 10.3.1 or greater.
751 For OS versions prior to that, opening files of the above description will fail.
752 @param outAudioFile upon success, an AudioFileID that can be used for subsequent
753 AudioFile calls.
754 @result returns noErr if successful.
755 }
AudioFileOpenURLnull756 function AudioFileOpenURL( inFileRef: CFURLRef; inPermissions: AudioFilePermissions; inFileTypeHint: AudioFileTypeID; var outAudioFile: AudioFileID {__nullable * __nonnull} ): OSStatus; external name '_AudioFileOpenURL';
757 (* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
758
759 {!
760 @typedef AudioFile_ReadProc
761 @abstract A callback for reading data. used with AudioFileOpenWithCallbacks or AudioFileInitializeWithCallbacks.
762 @discussion a function that will be called when AudioFile needs to read data.
763 @param inClientData A pointer to the client data as set in the inClientData parameter to AudioFileXXXWithCallbacks.
764 @param inPosition An offset into the data from which to read.
765 @param requestCount The number of bytes to read.
766 @param buffer The buffer in which to put the data read.
767 @param actualCount The callback should set this to the number of bytes successfully read.
768 @result The callback should return noErr on success, or an appropriate error code on failure.
769 }
770 type
inClientDatanull771 AudioFile_ReadProc = function( inClientData: UnivPtr; inPosition: SInt64; requestCount: UInt32; buffer: UnivPtr; var actualCount: UInt32 ): OSStatus;
772
773 {!
774 @typedef AudioFile_WriteProc
775 @abstract A callback for writing data. used with AudioFileOpenWithCallbacks or AudioFileInitializeWithCallbacks.
776 @discussion a function that will be called when AudioFile needs to write data.
777 @param inClientData A pointer to the client data as set in the inClientData parameter to AudioFileXXXWithCallbacks.
778 @param inPosition An offset into the data from which to read.
779 @param requestCount The number of bytes to write.
780 @param buffer The buffer containing the data to write.
781 @param actualCount The callback should set this to the number of bytes successfully written.
782 @result The callback should return noErr on success, or an appropriate error code on failure.
783 }
784 type
inClientDatanull785 AudioFile_WriteProc = function( inClientData: UnivPtr; inPosition: SInt64; requestCount: UInt32; buffer: {const} UnivPtr; var actualCount: UInt32 ): OSStatus;
786
787 {!
788 @typedef AudioFile_GetSizeProc
789 @abstract A callback for getting the size of the file data. used with AudioFileOpenWithCallbacks or AudioFileInitializeWithCallbacks.
790 @discussion a function that will be called when AudioFile needs to determine the size of the file data. This size is for all of the
791 data in the file, not just the audio data.
792 @param inClientData A pointer to the client data as set in the inClientData parameter to AudioFileXXXWithCallbacks.
793 @result The callback should return the size of the data.
794 }
795 type
inClientDatanull796 AudioFile_GetSizeProc = function( inClientData: UnivPtr ): SInt64;
797
798 {!
799 @typedef AudioFile_SetSizeProc
800 @abstract A callback for setting the size of the file data. used with AudioFileOpenWithCallbacks or AudioFileInitializeWithCallbacks.
801 @discussion a function that will be called when AudioFile needs to set the size of the file data. This size is for all of the
802 data in the file, not just the audio data. This will only be called if the file is written to.
803 @param inClientData A pointer to the client data as set in the inClientData parameter to AudioFileXXXWithCallbacks.
804 @result The callback should return the size of the data.
805 }
806 type
inClientDatanull807 AudioFile_SetSizeProc = function( inClientData: UnivPtr; inSize: SInt64 ): OSStatus;
808
809 {!
810 @function AudioFileInitializeWithCallbacks
811 @abstract Wipe clean an existing file. You provide callbacks that the AudioFile API
812 will use to get the data.
813 @param inClientData a constant that will be passed to your callbacks.
814 @param inReadFunc a function that will be called when AudioFile needs to read data.
815 @param inWriteFunc a function that will be called when AudioFile needs to write data.
816 @param inGetSizeFunc a function that will be called when AudioFile needs to know the file size.
817 @param inSetSizeFunc a function that will be called when AudioFile needs to set the file size.
818
819 @param inFileType an AudioFileTypeID indicating the type of audio file to which to initialize the file.
820 @param inFormat an AudioStreamBasicDescription describing the data format that will be
821 added to the audio file.
822 @param inFlags flags for creating/opening the file. Currently zero.
823 @param outAudioFile upon success, an AudioFileID that can be used for subsequent
824 AudioFile calls.
825 @result returns noErr if successful.
826 }
AudioFileInitializeWithCallbacksnull827 function AudioFileInitializeWithCallbacks( inClientData: UnivPtr; inReadFunc: AudioFile_ReadProc; inWriteFunc: AudioFile_WriteProc; inGetSizeFunc: AudioFile_GetSizeProc; inSetSizeFunc: AudioFile_SetSizeProc; inFileType: AudioFileTypeID; const (*var*) inFormat: AudioStreamBasicDescription; inFlags: AudioFileFlags; var outAudioFile: AudioFileID {__nullable * __nonnull} ): OSStatus; external name '_AudioFileInitializeWithCallbacks';
828 (* API_AVAILABLE(macos(10.3), ios(2.0), watchos(2.0), tvos(9.0)) *)
829
830
831 {!
832 @function AudioFileOpenWithCallbacks
833 @abstract Open an existing file. You provide callbacks that the AudioFile API
834 will use to get the data.
835 @param inClientData a constant that will be passed to your callbacks.
836 @param inReadFunc a function that will be called when AudioFile needs to read data.
837 @param inWriteFunc a function that will be called when AudioFile needs to write data.
838 @param inGetSizeFunc a function that will be called when AudioFile needs to know the total file size.
839 @param inSetSizeFunc a function that will be called when AudioFile needs to set the file size.
840
841 @param inFileTypeHint For files which have no filename extension and whose type cannot be easily or
842 uniquely determined from the data (ADTS,AC3), this hint can be used to indicate the file type.
843 Otherwise you can pass zero for this. The hint is only used on OS versions 10.3.1 or greater.
844 For OS versions prior to that, opening files of the above description will fail.
845 @param outAudioFile upon success, an AudioFileID that can be used for subsequent
846 AudioFile calls.
847 @result returns noErr if successful.
848 }
AudioFileOpenWithCallbacksnull849 function AudioFileOpenWithCallbacks( inClientData: UnivPtr; inReadFunc: AudioFile_ReadProc; inWriteFunc: AudioFile_WriteProc {__nullable}; inGetSizeFunc: AudioFile_GetSizeProc; inSetSizeFunc: AudioFile_SetSizeProc {__nullable}; inFileTypeHint: AudioFileTypeID; var outAudioFile: AudioFileID {__nullable * __nonnull} ): OSStatus; external name '_AudioFileOpenWithCallbacks';
850 (* API_AVAILABLE(macos(10.3), ios(2.0), watchos(2.0), tvos(9.0)) *)
851
852
853 {!
854 @function AudioFileClose
855 @abstract Close an existing audio file.
856 @param inAudioFile an AudioFileID.
857 @result returns noErr if successful.
858 }
AudioFileClosenull859 function AudioFileClose( inAudioFile: AudioFileID ): OSStatus; external name '_AudioFileClose';
860 (* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
861
862 {!
863 @function AudioFileOptimize
864 @abstract Move the audio data to the end of the file and other internal optimizations of the file structure.
865 @discussion Optimize the file so additional audio data can be appended to
866 the existing data. Generally, this will place the audio data at
867 the end of the file so additional writes can be placed to the
868 file end. This can be a potentially expensive and time-consuming operation
869 and should not be used during time critical operations. There is
870 a kAudioFilePropertyIsOptimized property for checking on the optimized state
871 of the file.
872 @param inAudioFile an AudioFileID.
873 @result returns noErr if successful.
874 }
AudioFileOptimizenull875 function AudioFileOptimize( inAudioFile: AudioFileID ): OSStatus; external name '_AudioFileOptimize';
876 (* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
877
878 {!
879 @function AudioFileReadBytes
880 @abstract Read bytes of audio data from the audio file.
881
882 @discussion Returns kAudioFileEndOfFileError when read encounters end of file.
883 @param inAudioFile an AudioFileID.
884 @param inUseCache true if it is desired to cache the data upon read, else false
885 @param inStartingByte the byte offset of the audio data desired to be returned
886 @param ioNumBytes on input, the number of bytes to read, on output, the number of
887 bytes actually read.
888 @param outBuffer outBuffer should be a void * to user allocated memory large enough for the requested bytes.
889 @result returns noErr if successful.
890 }
AudioFileReadBytesnull891 function AudioFileReadBytes( inAudioFile: AudioFileID; inUseCache: Boolean; inStartingByte: SInt64; var ioNumBytes: UInt32; outBuffer: UnivPtr ): OSStatus; external name '_AudioFileReadBytes';
892 (* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
893
894 {!
895 @function AudioFileWriteBytes
896 @abstract Write bytes of audio data to the audio file.
897 @param inAudioFile an AudioFileID.
898 @param inUseCache true if it is desired to cache the data upon write, else false
899 @param inStartingByte the byte offset where the audio data should be written
900 @param ioNumBytes on input, the number of bytes to write, on output, the number of
901 bytes actually written.
902 @param inBuffer inBuffer should be a void * containing the bytes to be written
903 @result returns noErr if successful.
904 }
AudioFileWriteBytesnull905 function AudioFileWriteBytes( inAudioFile: AudioFileID; inUseCache: Boolean; inStartingByte: SInt64; var ioNumBytes: UInt32; inBuffer: {const} UnivPtr ): OSStatus; external name '_AudioFileWriteBytes';
906 (* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
907
908 {!
909 @function AudioFileReadPacketData
910 @abstract Read packets of audio data from the audio file.
911 @discussion AudioFileReadPacketData reads as many of the requested number of packets
912 as will fit in the buffer size given by ioNumPackets.
913 Unlike the deprecated AudioFileReadPackets, ioNumPackets must be initialized.
914 If the byte size of the number packets requested is
915 less than the buffer size, ioNumBytes will be reduced.
916 If the buffer is too small for the number of packets
917 requested, ioNumPackets and ioNumBytes will be reduced
918 to the number of packets that can be accommodated and their byte size.
919 Returns kAudioFileEndOfFileError when read encounters end of file.
920 For all uncompressed formats, packets == frames.
921
922 @param inAudioFile an AudioFileID.
923 @param inUseCache true if it is desired to cache the data upon read, else false
924 @param ioNumBytes on input the size of outBuffer in bytes.
925 on output, the number of bytes actually returned.
926 @param outPacketDescriptions An array of packet descriptions describing the packets being returned.
927 The size of the array must be greater or equal to the number of packets requested.
928 On return the packet description will be filled out with the packet offsets and sizes.
929 Packet descriptions are ignored for CBR data.
930 @param inStartingPacket The packet index of the first packet desired to be returned
931 @param ioNumPackets on input, the number of packets to read, on output, the number of
932 packets actually read.
933 @param outBuffer outBuffer should be a pointer to user allocated memory.
934 @result returns noErr if successful.
935 }
AudioFileReadPacketDatanull936 function AudioFileReadPacketData( inAudioFile: AudioFileID; inUseCache: Boolean; var ioNumBytes: UInt32; outPacketDescriptions: AudioStreamPacketDescriptionPtr {* __nullable}; inStartingPacket: SInt64; var ioNumPackets: UInt32; outBuffer: UnivPtr {__nullable} ): OSStatus; external name '_AudioFileReadPacketData';
937 (* API_AVAILABLE(macos(10.6), ios(2.2), watchos(2.0), tvos(9.0)) *)
938
939 {!
940 @function AudioFileReadPackets
941 @abstract Read packets of audio data from the audio file.
942 @discussion AudioFileReadPackets is DEPRECATED. Use AudioFileReadPacketData instead.
943 READ THE HEADER DOC FOR AudioFileReadPacketData. It is not a drop-in replacement.
944 In particular, for AudioFileReadPacketData ioNumBytes must be initialized to the buffer size.
945 AudioFileReadPackets assumes you have allocated your buffer to ioNumPackets times the maximum packet size.
946 For many compressed formats this will only use a portion of the buffer since the ratio of the maximum
947 packet size to the typical packet size can be large. Use AudioFileReadPacketData instead.
948
949 @param inAudioFile an AudioFileID.
950 @param inUseCache true if it is desired to cache the data upon read, else false
951 @param outNumBytes on output, the number of bytes actually returned
952 @param outPacketDescriptions on output, an array of packet descriptions describing
953 the packets being returned. NULL may be passed for this
954 parameter. Nothing will be returned for linear pcm data.
955 @param inStartingPacket the packet index of the first packet desired to be returned
956 @param ioNumPackets on input, the number of packets to read, on output, the number of
957 packets actually read.
958 @param outBuffer outBuffer should be a pointer to user allocated memory of size:
959 number of packets requested times file's maximum (or upper bound on)
960 packet size.
961 @result returns noErr if successful.
962 }
AudioFileReadPacketsnull963 function AudioFileReadPackets ( inAudioFile: AudioFileID; inUseCache: Boolean; var outNumBytes: UInt32; outPacketDescriptions: AudioStreamPacketDescriptionPtr {__nullable}; inStartingPacket: SInt64; var ioNumPackets: UInt32; outBuffer: UnivPtr{__nullable}): OSStatus; external name '_AudioFileReadPackets';
964 (* API_DEPRECATED("no longer supported", macos(10.2, 10.10), ios(2.0, 8.0)) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; *)
965
966
967 {!
968 @function AudioFileWritePackets
969 @abstract Write packets of audio data to the audio file.
970 @discussion For all uncompressed formats, packets == frames.
971 @param inAudioFile an AudioFileID.
972 @param inUseCache true if it is desired to cache the data upon write, else false
973 @param inNumBytes the number of bytes being provided for write
974 @param inPacketDescriptions an array of packet descriptions describing the packets being
975 provided. Not all formats require packet descriptions to be
976 provided. NULL may be passed if no descriptions are required.
977 @param inStartingPacket the packet index of where the first packet provided should be placed.
978 @param ioNumPackets on input, the number of packets to write, on output, the number of
979 packets actually written.
980 @param inBuffer a void * to user allocated memory containing the packets to write.
981 @result returns noErr if successful.
982 }
AudioFileWritePacketsnull983 function AudioFileWritePackets( inAudioFile: AudioFileID; inUseCache: Boolean; inNumBytes: UInt32; {const} inPacketDescriptions: AudioStreamPacketDescriptionPtr {__nullable}; inStartingPacket: SInt64; var ioNumPackets: UInt32; inBuffer: {const} UnivPtr ): OSStatus; external name '_AudioFileWritePackets';
984 (* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
985
986
987 {!
988 @function AudioFileCountUserData
989 @abstract Get the number of user data items with a certain ID in the file
990 @discussion "User Data" refers to chunks in AIFF, CAF and WAVE files, or resources
991 in Sound Designer II files, and possibly other things in other files.
992 For simplicity, referred to below as "chunks".
993 @param inAudioFile an AudioFileID.
994 @param inUserDataID the four char code of the chunk.
995 @param outNumberItems on output, if successful, number of chunks of this type in the file.
996 @result returns noErr if successful.
997 }
AudioFileCountUserDatanull998 function AudioFileCountUserData( inAudioFile: AudioFileID; inUserDataID: UInt32; var outNumberItems: UInt32 ): OSStatus; external name '_AudioFileCountUserData';
999 (* API_AVAILABLE(macos(10.4), ios(2.0), watchos(2.0), tvos(9.0)) *)
1000
1001 {!
1002 @function AudioFileGetUserDataSize
1003 @abstract Get the size of user data in a file
1004 @param inAudioFile an AudioFileID.
1005 @param inUserDataID the four char code of the chunk.
1006 @param inIndex an index specifying which chunk if there are more than one.
1007 @param outUserDataSize on output, if successful, the size of the user data chunk.
1008 @result returns noErr if successful.
1009 }
AudioFileGetUserDataSizenull1010 function AudioFileGetUserDataSize( inAudioFile: AudioFileID; inUserDataID: UInt32; inIndex: UInt32; var outUserDataSize: UInt32 ): OSStatus; external name '_AudioFileGetUserDataSize';
1011 (* API_AVAILABLE(macos(10.4), ios(2.0), watchos(2.0), tvos(9.0)) *)
1012
1013 {!
1014 @function AudioFileGetUserData
1015 @abstract Get the data of a chunk in a file.
1016 @param inAudioFile an AudioFileID.
1017 @param inUserDataID the four char code of the chunk.
1018 @param inIndex an index specifying which chunk if there are more than one.
1019 @param ioUserDataSize the size of the buffer on input, size of bytes copied to buffer on output
1020 @param outUserData a pointer to a buffer in which to copy the chunk data.
1021 @result returns noErr if successful.
1022 }
AudioFileGetUserDatanull1023 function AudioFileGetUserData( inAudioFile: AudioFileID; inUserDataID: UInt32; inIndex: UInt32; var ioUserDataSize: UInt32; outUserData: UnivPtr ): OSStatus; external name '_AudioFileGetUserData';
1024 (* API_AVAILABLE(macos(10.4), ios(2.0), watchos(2.0), tvos(9.0)) *)
1025
1026 {!
1027 @function AudioFileSetUserData
1028 @abstract Set the data of a chunk in a file.
1029 @param inAudioFile an AudioFileID.
1030 @param inUserDataID the four char code of the chunk.
1031 @param inIndex an index specifying which chunk if there are more than one.
1032 @param inUserDataSize on input the size of the data to copy, on output, size of bytes copied from the buffer
1033 @param inUserData a pointer to a buffer from which to copy the chunk data
1034 (only the contents of the chunk, not including the chunk header).
1035 @result returns noErr if successful.
1036 }
AudioFileSetUserDatanull1037 function AudioFileSetUserData( inAudioFile: AudioFileID; inUserDataID: UInt32; inIndex: UInt32; inUserDataSize: UInt32; inUserData: {const} UnivPtr ): OSStatus; external name '_AudioFileSetUserData';
1038 (* API_AVAILABLE(macos(10.4), ios(2.0), watchos(2.0), tvos(9.0)) *)
1039
1040
1041 {!
1042 @function AudioFileRemoveUserData
1043 @abstract Remove a user chunk in a file.
1044 @param inAudioFile an AudioFileID.
1045 @param inUserDataID the four char code of the chunk.
1046 @param inIndex an index specifying which chunk if there are more than one.
1047 @result returns noErr if successful.
1048 }
1049
AudioFileRemoveUserDatanull1050 function AudioFileRemoveUserData( inAudioFile: AudioFileID; inUserDataID: UInt32; inIndex: UInt32 ): OSStatus; external name '_AudioFileRemoveUserData';
1051 (* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
1052
1053
1054 //=============================================================================
1055 // Audio File Properties
1056 //=============================================================================
1057
1058 {!
1059 @enum Audio File Properties
1060 @abstract constants for AudioFile get/set property calls
1061 @constant kAudioFilePropertyFileFormat
1062 An AudioFileTypeID that identifies the format of the file
1063 @constant kAudioFilePropertyDataFormat
1064 An AudioStreamBasicDescription describing the format of the audio data
1065 @constant kAudioFilePropertyFormatList
1066 In order to support formats such as AAC SBR where an encoded data stream can be decoded to
1067 multiple destination formats, this property returns an array of AudioFormatListItems (see AudioFormat.h) of those formats.
1068 The default behavior is to return the an AudioFormatListItem that has the same AudioStreamBasicDescription
1069 that kAudioFilePropertyDataFormat returns.
1070 @constant kAudioFilePropertyIsOptimized
1071 A UInt32 indicating whether an Audio File has been optimized.
1072 Optimized means it is ready to start having sound data written to it.
1073 A value of 0 indicates the file needs to be optimized.
1074 A value of 1 indicates the file is currently optimized.
1075 @constant kAudioFilePropertyMagicCookieData
1076 A void * pointing to memory set up by the caller.
1077 Some file types require that a magic cookie be provided before packets can be written
1078 to the file, so this property should be set before calling
1079 AudioFileWriteBytes()/AudioFileWritePackets() if a magic cookie exists.
1080 @constant kAudioFilePropertyAudioDataByteCount
1081 a UInt64 that indicates the number of bytes of audio data contained in the file
1082 @constant kAudioFilePropertyAudioDataPacketCount
1083 a UInt64 that indicates the number of packets of audio data contained in the file
1084 @constant kAudioFilePropertyMaximumPacketSize
1085 a UInt32 that indicates the maximum size of a packet for the data contained in the file
1086 @constant kAudioFilePropertyDataOffset
1087 a SInt64 that indicates the byte offset in the file of the audio data.
1088 @constant kAudioFilePropertyChannelLayout
1089 An AudioChannelLayout struct.
1090 @constant kAudioFilePropertyDeferSizeUpdates
1091 A UInt32. If 1, then updating the files sizes in the header is not done for every write,
1092 but deferred until the file is read, optimized or closed. This is more efficient, but less safe
1093 since, if the application crashes before the size is updated, the file may not be readable.
1094 The default value is one, it doesn't update the header.
1095 @constant kAudioFilePropertyDataFormatName
1096 This is deprecated. Use kAudioFormatProperty_FormatName in AudioFormat.h instead.
1097 @constant kAudioFilePropertyMarkerList
1098 access the list of markers defined in the file. returns an AudioFileMarkerList.
1099 The CFStringRefs in the returned structs must be released by the client.
1100 (available in 10.2.4 and later)
1101 @constant kAudioFilePropertyRegionList
1102 access the list of regions defined in the file. returns an Array of AudioFileRegions.
1103 The CFStringRefs in the returned structs must be released by the client.
1104 (available in 10.2.4 and later)
1105 @constant kAudioFilePropertyPacketToFrame
1106 pass a AudioFramePacketTranslation with mPacket filled out and get mFrame back. mFrameOffsetInPacket is ignored.
1107 @constant kAudioFilePropertyFrameToPacket
1108 pass a AudioFramePacketTranslation with mFrame filled out and get mPacket and mFrameOffsetInPacket back.
1109
1110 @constant kAudioFilePropertyPacketToByte
1111 pass an AudioBytePacketTranslation struct with mPacket filled out and get mByte back.
1112 mByteOffsetInPacket is ignored. If the mByte value is an estimate then
1113 kBytePacketTranslationFlag_IsEstimate will be set in the mFlags field.
1114 @constant kAudioFilePropertyByteToPacket
1115 pass an AudioBytePacketTranslation struct with mByte filled out and get mPacket and
1116 mByteOffsetInPacket back. If the mPacket value is an estimate then
1117 kBytePacketTranslationFlag_IsEstimate will be set in the mFlags field.
1118
1119 @constant kAudioFilePropertyChunkIDs
1120 returns an array of OSType four char codes for each kind of chunk in the file.
1121 @constant kAudioFilePropertyInfoDictionary
1122 returns a CFDictionary filled with information about the data contained in the file.
1123 See dictionary key constants already defined for info string types.
1124 AudioFileComponents are free to add keys to the dictionaries that they return for this property...
1125 caller is responsible for releasing the CFObject
1126 @constant kAudioFilePropertyPacketTableInfo
1127 Gets or sets an AudioFilePacketTableInfo struct for the file types that support it.
1128 When setting, the sum of mNumberValidFrames, mPrimingFrames and mRemainderFrames must be the same as the total
1129 number of frames in all packets. If not you will get a kAudio_ParamError. The best way to ensure this is to get the value of
1130 the property and make sure the sum of the three values you set has the same sum as the three values you got.
1131 @constant kAudioFilePropertyPacketSizeUpperBound
1132 a UInt32 for the theoretical maximum packet size in the file (without actually scanning
1133 the whole file to find the largest packet, as may happen with kAudioFilePropertyMaximumPacketSize).
1134 @constant kAudioFilePropertyReserveDuration
1135 The value is a Float64 of the duration in seconds of data that is expected to be written.
1136 Setting this property before any data has been written reserves space in the file header for a packet table
1137 and/or other information so that it can appear before the audio data. Otherwise the packet table may get written at the
1138 end of the file, preventing the file from being streamable.
1139 @constant kAudioFilePropertyEstimatedDuration
1140 The value is a Float64 representing an estimated duration in seconds. If duration can be calculated without scanning the entire file,
1141 or all the audio data packets have been scanned, the value will accurately reflect the duration of the audio data.
1142 @constant kAudioFilePropertyBitRate
1143 Returns the bit rate for the audio data as a UInt32. For some formats this will be approximate.
1144 @constant kAudioFilePropertyID3Tag
1145 A void * pointing to memory set up by the caller to contain a fully formatted ID3 tag (get/set v2.2, v2.3, or v2.4, v1 get only).
1146 The ID3 tag is not manipulated in anyway either for read or write.
1147 When setting, this property must be called before calling AudioFileWritePackets.
1148 @constant kAudioFilePropertySourceBitDepth
1149 For encoded data this property returns the bit depth of the source as an SInt32, if known.
1150 The bit depth is expressed as a negative number if the source was floating point, e.g. -32 for float, -64 for double.
1151 @constant kAudioFilePropertyAlbumArtwork
1152 returns a CFDataRef filled with the Album Art or NULL.
1153 The caller is responsible for releasing a non-NULL CFDataRef.
1154 In order to parse the contents of the data, CGImageSourceCreateWithData may be used.
1155 @constant kAudioFilePropertyAudioTrackCount
1156 a UInt32 that indicates the number of audio tracks contained in the file. (get property only)
1157 @constant kAudioFilePropertyUseAudioTrack
1158 a UInt32 that indicates the number of audio tracks contained in the file. (set property only)
1159 }
1160 const
1161 kAudioFilePropertyFileFormat = FourCharCode('ffmt');
1162 kAudioFilePropertyDataFormat = FourCharCode('dfmt');
1163 kAudioFilePropertyIsOptimized = FourCharCode('optm');
1164 kAudioFilePropertyMagicCookieData = FourCharCode('mgic');
1165 kAudioFilePropertyAudioDataByteCount = FourCharCode('bcnt');
1166 kAudioFilePropertyAudioDataPacketCount = FourCharCode('pcnt');
1167 kAudioFilePropertyMaximumPacketSize = FourCharCode('psze');
1168 kAudioFilePropertyDataOffset = FourCharCode('doff');
1169 kAudioFilePropertyChannelLayout = FourCharCode('cmap');
1170 kAudioFilePropertyDeferSizeUpdates = FourCharCode('dszu');
1171 kAudioFilePropertyDataFormatName = FourCharCode('fnme');
1172 kAudioFilePropertyMarkerList = FourCharCode('mkls');
1173 kAudioFilePropertyRegionList = FourCharCode('rgls');
1174 kAudioFilePropertyPacketToFrame = FourCharCode('pkfr');
1175 kAudioFilePropertyFrameToPacket = FourCharCode('frpk');
1176 kAudioFilePropertyPacketToByte = FourCharCode('pkby');
1177 kAudioFilePropertyByteToPacket = FourCharCode('bypk');
1178 kAudioFilePropertyChunkIDs = FourCharCode('chid');
1179 kAudioFilePropertyInfoDictionary = FourCharCode('info');
1180 kAudioFilePropertyPacketTableInfo = FourCharCode('pnfo');
1181 kAudioFilePropertyFormatList = FourCharCode('flst');
1182 kAudioFilePropertyPacketSizeUpperBound = FourCharCode('pkub');
1183 kAudioFilePropertyReserveDuration = FourCharCode('rsrv');
1184 kAudioFilePropertyEstimatedDuration = FourCharCode('edur');
1185 kAudioFilePropertyBitRate = FourCharCode('brat');
1186 kAudioFilePropertyID3Tag = FourCharCode('id3t');
1187 kAudioFilePropertySourceBitDepth = FourCharCode('sbtd');
1188 kAudioFilePropertyAlbumArtwork = FourCharCode('aart');
1189 kAudioFilePropertyAudioTrackCount = FourCharCode('atct');
1190 kAudioFilePropertyUseAudioTrack = FourCharCode('uatk');
1191
1192
1193 {!
1194 @function AudioFileGetPropertyInfo
1195 @abstract Get information about the size of a property of an AudioFile and whether it can be set.
1196 @param inAudioFile an AudioFileID.
1197 @param inPropertyID an AudioFileProperty constant.
1198 @param outDataSize the size in bytes of the current value of the property. In order to get the property value,
1199 you will need a buffer of this size.
1200 @param isWritable will be set to 1 if writable, or 0 if read only.
1201 @result returns noErr if successful.
1202 }
AudioFileGetPropertyInfonull1203 function AudioFileGetPropertyInfo( inAudioFile: AudioFileID; inPropertyID: AudioFilePropertyID; outDataSize: UInt32Ptr {__nullable}; isWritable: UInt32Ptr {__nullable} ): OSStatus; external name '_AudioFileGetPropertyInfo';
1204 (* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
1205
1206 {!
1207 @function AudioFileGetProperty
1208 @abstract Copies the value for a property of an AudioFile into a buffer.
1209 @param inAudioFile an AudioFileID.
1210 @param inPropertyID an AudioFileProperty constant.
1211 @param ioDataSize on input the size of the outPropertyData buffer. On output the number of bytes written to the buffer.
1212 @param outPropertyData the buffer in which to write the property data.
1213 @result returns noErr if successful.
1214 }
AudioFileGetPropertynull1215 function AudioFileGetProperty( inAudioFile: AudioFileID; inPropertyID: AudioFilePropertyID; var ioDataSize: UInt32; outPropertyData: UnivPtr ): OSStatus; external name '_AudioFileGetProperty';
1216 (* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
1217
1218 {!
1219 @function AudioFileSetProperty
1220 @abstract Sets the value for a property of an AudioFile .
1221 @param inAudioFile an AudioFileID.
1222 @param inPropertyID an AudioFileProperty constant.
1223 @param inDataSize the size of the property data.
1224 @param inPropertyData the buffer containing the property data.
1225 @result returns noErr if successful.
1226 }
AudioFileSetPropertynull1227 function AudioFileSetProperty( inAudioFile: AudioFileID; inPropertyID: AudioFilePropertyID; inDataSize: UInt32; inPropertyData: {const} UnivPtr ): OSStatus; external name '_AudioFileSetProperty';
1228 (* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
1229
1230
1231 //=============================================================================
1232 // Audio File Global Info Properties
1233 //=============================================================================
1234
1235 {!
1236 @enum Audio File Global Info Properties
1237 @abstract constants for AudioFileGetGlobalInfo properties
1238 @constant kAudioFileGlobalInfo_ReadableTypes
1239 No specifier needed. Must be set to NULL.
1240 Returns an array of UInt32 containing the file types
1241 (i.e. AIFF, WAVE, etc) that can be opened for reading.
1242 @constant kAudioFileGlobalInfo_WritableTypes
1243 No specifier needed. Must be set to NULL.
1244 Returns an array of UInt32 containing the file types
1245 (i.e. AIFF, WAVE, etc) that can be opened for writing.
1246 @constant kAudioFileGlobalInfo_FileTypeName
1247 Specifier is a pointer to a AudioFileTypeID containing a file type.
1248 Returns a CFString containing the name for the file type.
1249 @constant kAudioFileGlobalInfo_AvailableFormatIDs
1250 Specifier is a pointer to a AudioFileTypeID containing a file type.
1251 Returns a array of format IDs for formats that can be read.
1252 @constant kAudioFileGlobalInfo_AvailableStreamDescriptionsForFormat
1253 Specifier is a pointer to a AudioFileTypeAndFormatID struct defined below.
1254 Returns an array of AudioStreamBasicDescriptions which have all of the
1255 formats for a particular file type and format ID. The AudioStreamBasicDescriptions
1256 have the following fields filled in: mFormatID, mFormatFlags, mBitsPerChannel
1257 writing new files.
1258
1259
1260 @constant kAudioFileGlobalInfo_AllExtensions
1261 No specifier needed. Must be set to NULL.
1262 Returns a CFArray of CFStrings containing all file extensions
1263 that are recognized. The array be used when creating an NSOpenPanel.
1264
1265 @constant kAudioFileGlobalInfo_AllHFSTypeCodes
1266 No specifier needed. Must be set to NULL.
1267 Returns an array of HFSTypeCode's containing all HFSTypeCodes
1268 that are recognized.
1269
1270 @constant kAudioFileGlobalInfo_AllUTIs
1271 No specifier needed. Must be set to NULL.
1272 Returns a CFArray of CFString of all Universal Type Identifiers
1273 that are recognized by AudioFile.
1274 The caller is responsible for releasing the CFArray.
1275
1276 @constant kAudioFileGlobalInfo_AllMIMETypes
1277 No specifier needed. Must be set to NULL.
1278 Returns a CFArray of CFString of all MIME types
1279 that are recognized by AudioFile.
1280 The caller is responsible for releasing the CFArray.
1281
1282
1283 @constant kAudioFileGlobalInfo_ExtensionsForType
1284 Specifier is a pointer to a AudioFileTypeID containing a file type.
1285 Returns a CFArray of CFStrings containing the file extensions
1286 that are recognized for this file type.
1287
1288 @constant kAudioFileGlobalInfo_HFSTypeCodesForType
1289 Specifier is a pointer to an AudioFileTypeID.
1290 Returns an array of HFSTypeCodes corresponding to that file type.
1291 The first type in the array is the preferred one for use when
1292
1293 @constant kAudioFileGlobalInfo_UTIsForType
1294 Specifier is a pointer to an AudioFileTypeID.
1295 Returns a CFArray of CFString of all Universal Type Identifiers
1296 that are recognized by the file type.
1297 The caller is responsible for releasing the CFArray.
1298
1299 @constant kAudioFileGlobalInfo_MIMETypesForType
1300 Specifier is a pointer to an AudioFileTypeID.
1301 Returns a CFArray of CFString of all MIME types
1302 that are recognized by the file type.
1303 The caller is responsible for releasing the CFArray.
1304
1305 these are inverses of the above:
1306
1307 @constant kAudioFileGlobalInfo_TypesForExtension
1308 Specifier is a CFStringRef containing a file extension.
1309 Returns an array of all AudioFileTypeIDs that support the extension.
1310
1311 @constant kAudioFileGlobalInfo_TypesForHFSTypeCode
1312 Specifier is an HFSTypeCode.
1313 Returns an array of all AudioFileTypeIDs that support the HFSTypeCode.
1314
1315 @constant kAudioFileGlobalInfo_TypesForUTI
1316 Specifier is a CFStringRef containing a Universal Type Identifier.
1317 Returns an array of all AudioFileTypeIDs that support the UTI.
1318
1319 @constant kAudioFileGlobalInfo_TypesForMIMEType
1320 Specifier is a CFStringRef containing a MIME Type.
1321 Returns an array of all AudioFileTypeIDs that support the MIME type.
1322
1323 }
1324 const
1325 kAudioFileGlobalInfo_ReadableTypes = FourCharCode('afrf');
1326 kAudioFileGlobalInfo_WritableTypes = FourCharCode('afwf');
1327 kAudioFileGlobalInfo_FileTypeName = FourCharCode('ftnm');
1328 kAudioFileGlobalInfo_AvailableStreamDescriptionsForFormat = FourCharCode('sdid');
1329 kAudioFileGlobalInfo_AvailableFormatIDs = FourCharCode('fmid');
1330 kAudioFileGlobalInfo_AllExtensions = FourCharCode('alxt');
1331 kAudioFileGlobalInfo_AllHFSTypeCodes = FourCharCode('ahfs');
1332 kAudioFileGlobalInfo_AllUTIs = FourCharCode('auti');
1333 kAudioFileGlobalInfo_AllMIMETypes = FourCharCode('amim');
1334 kAudioFileGlobalInfo_ExtensionsForType = FourCharCode('fext');
1335 kAudioFileGlobalInfo_HFSTypeCodesForType = FourCharCode('fhfs');
1336 kAudioFileGlobalInfo_UTIsForType = FourCharCode('futi');
1337 kAudioFileGlobalInfo_MIMETypesForType = FourCharCode('fmim');
1338 kAudioFileGlobalInfo_TypesForMIMEType = FourCharCode('tmim');
1339 kAudioFileGlobalInfo_TypesForUTI = FourCharCode('tuti');
1340 kAudioFileGlobalInfo_TypesForHFSTypeCode = FourCharCode('thfs');
1341 kAudioFileGlobalInfo_TypesForExtension = FourCharCode('text');
1342
1343
1344 {!
1345 @struct AudioFileTypeAndFormatID
1346 @abstract This is used as a specifier for kAudioFileGlobalInfo_AvailableStreamDescriptions
1347 @discussion This struct is used to specify a desired audio file type and data format ID so
1348 that a list of stream descriptions of available formats can be obtained.
1349 @field mFileType
1350 a four char code for the file type such as kAudioFileAIFFType, kAudioFileCAFType, etc.
1351 @field mFormatID
1352 a four char code for the format ID such as kAudioFormatLinearPCM, kAudioFormatMPEG4AAC, etc.
1353 }
1354 type
1355 AudioFileTypeAndFormatID = record
1356 mFileType: AudioFileTypeID;
1357 mFormatID: UInt32;
1358 end;
1359
1360
1361 {!
1362 @function AudioFileGetGlobalInfoSize
1363 @abstract Get the size of a global property.
1364 @param inPropertyID an AudioFileGlobalInfo property constant.
1365 @param inSpecifierSize The size of the specifier data.
1366 @param inSpecifier A specifier is a buffer of data used as an input argument to some of the global info properties.
1367 @param outDataSize the size in bytes of the current value of the property. In order to get the property value,
1368 you will need a buffer of this size.
1369 @result returns noErr if successful.
1370 }
AudioFileGetGlobalInfoSizenull1371 function AudioFileGetGlobalInfoSize( inPropertyID: AudioFilePropertyID; inSpecifierSize: UInt32; inSpecifier: UnivPtr {__nullable}; var outDataSize: UInt32 ): OSStatus; external name '_AudioFileGetGlobalInfoSize';
1372 (* API_AVAILABLE(macos(10.3), ios(2.0), watchos(2.0), tvos(9.0)) *)
1373
1374 {!
1375 @function AudioFileGetGlobalInfo
1376 @abstract Copies the value for a global property into a buffer.
1377 @param inPropertyID an AudioFileGlobalInfo property constant.
1378 @param inSpecifierSize The size of the specifier data.
1379 @param inSpecifier A specifier is a buffer of data used as an input argument to some of the global info properties.
1380 @param ioDataSize on input the size of the outPropertyData buffer. On output the number of bytes written to the buffer.
1381 @param outPropertyData the buffer in which to write the property data.
1382 @result returns noErr if successful.
1383 }
AudioFileGetGlobalInfonull1384 function AudioFileGetGlobalInfo( inPropertyID: AudioFilePropertyID; inSpecifierSize: UInt32; inSpecifier: UnivPtr {__nullable}; var ioDataSize: UInt32; outPropertyData: UnivPtr ): OSStatus; external name '_AudioFileGetGlobalInfo';
1385 (* API_AVAILABLE(macos(10.3), ios(2.0), watchos(2.0), tvos(9.0)) *)
1386
1387 //#pragma mark - Deprecated
1388
1389 (*
1390 struct FSRef;
1391 {!
1392 @function AudioFileCreate
1393 @abstract creates a new audio file
1394 @discussion creates a new audio file located in the parent directory
1395 provided. Upon success, an AudioFileID is returned which can
1396 be used for subsequent calls to the AudioFile APIs.
1397 @param inParentRef an FSRef to the directory where the new file should be created.
1398 @param inFileName a CFStringRef containing the name of the file to be created.
1399 @param inFileType an AudioFileTypeID indicating the type of audio file to create.
1400 @param inFormat an AudioStreamBasicDescription describing the data format that will be
1401 added to the audio file.
1402 @param inFlags relevant flags for creating/opening the file.
1403 @param outNewFileRef if successful, the FSRef of the newly created file.
1404 @param outAudioFile if successful, an AudioFileID that can be used for subsequent AudioFile calls.
1405 @result returns noErr if successful.
1406 @deprecated in Mac OS X 10.6, see AudioFileCreateWithURL
1407 }
1408 extern OSStatus
1409 AudioFileCreate ( const struct FSRef *inParentRef,
1410 CFStringRef inFileName,
1411 AudioFileTypeID inFileType,
1412 const AudioStreamBasicDescription *inFormat,
1413 AudioFileFlags inFlags,
1414 struct FSRef *outNewFileRef,
1415 AudioFileID __nullable * __nonnull outAudioFile) API_DEPRECATED("no longer supported", macos(10.2, 10.6)) API_UNAVAILABLE(ios, watchos, tvos);
1416
1417 {!
1418 @function AudioFileInitialize
1419 @abstract Write over an existing audio file.
1420 @discussion Use AudioFileInitialize to wipe clean an existing audio file
1421 and prepare it to be populated with new data.
1422 @param inFileRef the FSRef of an existing audio file.
1423 @param inFileType an AudioFileTypeID indicating the type of audio file to initialize the file to.
1424 @param inFormat an AudioStreamBasicDescription describing the data format that will be
1425 added to the audio file.
1426 @param inFlags flags for creating/opening the file. Currently zero.
1427 @param outAudioFile upon success, an AudioFileID that can be used for subsequent
1428 AudioFile calls.
1429 @result returns noErr if successful.
1430 @deprecated in Mac OS X 10.6, see AudioFileCreateWithURL
1431 }
1432 extern OSStatus
1433 AudioFileInitialize ( const struct FSRef *inFileRef,
1434 AudioFileTypeID inFileType,
1435 const AudioStreamBasicDescription *inFormat,
1436 AudioFileFlags inFlags,
1437 AudioFileID __nullable * __nonnull outAudioFile) API_DEPRECATED("no longer supported", macos(10.2, 10.6)) API_UNAVAILABLE(ios, watchos, tvos);
1438
1439 {!
1440 @function AudioFileOpen
1441 @abstract Open an existing audio file.
1442 @discussion Open an existing audio file for reading or reading and writing.
1443 @param inFileRef the FSRef of an existing audio file.
1444 @param inPermissions use the permission constants
1445 @param inFileTypeHint For files which have no filename extension and whose type cannot be easily or
1446 uniquely determined from the data (ADTS,AC3), this hint can be used to indicate the file type.
1447 Otherwise you can pass zero for this. The hint is only used on OS versions 10.3.1 or greater.
1448 For OS versions prior to that, opening files of the above description will fail.
1449 @param outAudioFile upon success, an AudioFileID that can be used for subsequent
1450 AudioFile calls.
1451 @result returns noErr if successful.
1452 @deprecated in Mac OS X 10.6, see AudioFileOpenURL
1453 }
1454 extern OSStatus
1455 AudioFileOpen ( const struct FSRef *inFileRef,
1456 AudioFilePermissions inPermissions,
1457 AudioFileTypeID inFileTypeHint,
1458 AudioFileID __nullable * __nonnull outAudioFile) API_DEPRECATED("no longer supported", macos(10.2, 10.6)) API_UNAVAILABLE(ios, watchos, tvos);
1459
1460
1461 *)
1462 //CF_ASSUME_NONNULL_END
1463
1464 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
1465 implementation
1466
NumBytesToNumAudioFileMarkersnull1467 function NumBytesToNumAudioFileMarkers(inNumBytes: size_t): size_t;
1468 begin
1469 if inNumBytes < size_t(@AudioFileMarkerListPtr(nil)^.mMarkers[0]) then
1470 NumBytesToNumAudioFileMarkers := 0
1471 else
1472 NumBytesToNumAudioFileMarkers := inNumBytes - size_t(@AudioFileMarkerListPtr(nil)^.mMarkers[0])
1473 end;
1474
1475
NumAudioFileMarkersToNumBytesnull1476 function NumAudioFileMarkersToNumBytes(inNumMarkers: size_t): size_t;
1477 begin
1478 NumAudioFileMarkersToNumBytes := size_t(@AudioFileMarkerListPtr(nil)^.mMarkers[0]) + (inNumMarkers) * sizeof(AudioFileMarker);
1479 end;
1480
1481
NextAudioFileRegionnull1482 function NextAudioFileRegion(const {var} inAFRegionPtr: AudioFileRegion): AudioFileRegionPtr;
1483 begin
1484 NextAudioFileRegion := AudioFileRegionPtr(
1485 Pointer(@inAFRegionPtr) +
1486 MacPtrUInt(@AudioFileRegionPtr(nil)^.mMarkers) +
1487 (inAFRegionPtr.mNumberMarkers*sizeof(AudioFileMarker))
1488 );
1489 end;
1490
1491 end.
1492
1493 {$endc} {not MACOSALLINCLUDE}
1494