Browse Source

* updated to r441 of the common Mac OS X interfaces:
o fixed declaration of ABSearchComparison for 64 bit targets
o Update AddressBook Framework related interface files to MacOSX10.13.sdk
currency
o minor comment tweaks to ABActions.pas and ABAddressBook.pas
o added new 10.7.sdk declarations & DEPRECATED/AVAILABLE info to
ABGlobals.pas and ABTypedefs.pas
o CarbonCore framework update to MacOSX10.13.sdk
o AE framework update to MacOSX10.13.sdk
o updated AudioToolbox framework translation to 10.14 and translated some
extra units

git-svn-id: trunk@42499 -

Jonas Maebe 6 years ago
parent
commit
701f81f2d8
100 changed files with 9775 additions and 959 deletions
  1. 9 0
      .gitattributes
  2. 9 0
      packages/univint/fpmake.pp
  3. 3 1
      packages/univint/src/ABActions.pas
  4. 6 4
      packages/univint/src/ABAddressBook.pas
  5. 75 19
      packages/univint/src/ABGlobals.pas
  6. 1 0
      packages/univint/src/ABPeoplePicker.pas
  7. 12 4
      packages/univint/src/ABTypedefs.pas
  8. 20 9
      packages/univint/src/AEDataModel.pas
  9. 1 0
      packages/univint/src/AEHelpers.pas
  10. 1 0
      packages/univint/src/AEInteraction.pas
  11. 1 0
      packages/univint/src/AEMach.pas
  12. 1 0
      packages/univint/src/AEObjects.pas
  13. 1 0
      packages/univint/src/AEPackObject.pas
  14. 1 0
      packages/univint/src/AERegistry.pas
  15. 1 0
      packages/univint/src/AEUserTermTypes.pas
  16. 1 0
      packages/univint/src/AIFF.pas
  17. 1 0
      packages/univint/src/ASDebugging.pas
  18. 1 0
      packages/univint/src/ASRegistry.pas
  19. 1 0
      packages/univint/src/ATSFont.pas
  20. 1 0
      packages/univint/src/ATSLayoutTypes.pas
  21. 1 0
      packages/univint/src/ATSTypes.pas
  22. 1 0
      packages/univint/src/ATSUnicodeDirectAccess.pas
  23. 1 0
      packages/univint/src/ATSUnicodeDrawing.pas
  24. 1 0
      packages/univint/src/ATSUnicodeFlattening.pas
  25. 1 0
      packages/univint/src/ATSUnicodeFonts.pas
  26. 1 0
      packages/univint/src/ATSUnicodeGlyphs.pas
  27. 1 0
      packages/univint/src/ATSUnicodeObjects.pas
  28. 1 0
      packages/univint/src/ATSUnicodeTypes.pas
  29. 354 258
      packages/univint/src/AUComponent.pas
  30. 1 0
      packages/univint/src/AVLTree.pas
  31. 1 0
      packages/univint/src/AXActionConstants.pas
  32. 1 0
      packages/univint/src/AXAttributeConstants.pas
  33. 1 0
      packages/univint/src/AXConstants.pas
  34. 1 0
      packages/univint/src/AXErrors.pas
  35. 1 0
      packages/univint/src/AXNotificationConstants.pas
  36. 1 0
      packages/univint/src/AXRoleConstants.pas
  37. 1 0
      packages/univint/src/AXTextAttributedString.pas
  38. 1 0
      packages/univint/src/AXUIElement.pas
  39. 1 0
      packages/univint/src/AXValue.pas
  40. 1 0
      packages/univint/src/AXValueConstants.pas
  41. 1 0
      packages/univint/src/Accessibility.pas
  42. 1 0
      packages/univint/src/Aliases.pas
  43. 1 0
      packages/univint/src/Appearance.pas
  44. 1 0
      packages/univint/src/AppleDiskPartitions.pas
  45. 1 0
      packages/univint/src/AppleEvents.pas
  46. 1 0
      packages/univint/src/AppleHelp.pas
  47. 1 0
      packages/univint/src/AppleScript.pas
  48. 104 25
      packages/univint/src/AudioCodecs.pas
  49. 405 237
      packages/univint/src/AudioComponents.pas
  50. 979 0
      packages/univint/src/AudioConverter.pas
  51. 1489 0
      packages/univint/src/AudioFile.pas
  52. 930 0
      packages/univint/src/AudioFileComponents.pas
  53. 604 0
      packages/univint/src/AudioFileStream.pas
  54. 674 0
      packages/univint/src/AudioFormat.pas
  55. 1 0
      packages/univint/src/AudioHardware.pas
  56. 1 0
      packages/univint/src/AudioHardwareBase.pas
  57. 1 0
      packages/univint/src/AudioHardwareDeprecated.pas
  58. 409 0
      packages/univint/src/AudioHardwareService.pas
  59. 10 15
      packages/univint/src/AudioOutputUnit.pas
  60. 1741 0
      packages/univint/src/AudioQueue.pas
  61. 527 0
      packages/univint/src/AudioServices.pas
  62. 8 16
      packages/univint/src/AudioUnitCarbonViews.pas
  63. 351 143
      packages/univint/src/AudioUnitParameters.pas
  64. 331 228
      packages/univint/src/AudioUnitProperties.pas
  65. 648 0
      packages/univint/src/AudioUnitUtilities.pas
  66. 1 0
      packages/univint/src/AuthSession.pas
  67. 1 0
      packages/univint/src/Authorization.pas
  68. 1 0
      packages/univint/src/AuthorizationDB.pas
  69. 1 0
      packages/univint/src/AuthorizationPlugin.pas
  70. 1 0
      packages/univint/src/AuthorizationTags.pas
  71. 1 0
      packages/univint/src/BackupCore.pas
  72. 1 0
      packages/univint/src/CFArray.pas
  73. 1 0
      packages/univint/src/CFAttributedString.pas
  74. 1 0
      packages/univint/src/CFBag.pas
  75. 1 0
      packages/univint/src/CFBase.pas
  76. 1 0
      packages/univint/src/CFBinaryHeap.pas
  77. 1 0
      packages/univint/src/CFBitVector.pas
  78. 1 0
      packages/univint/src/CFBundle.pas
  79. 1 0
      packages/univint/src/CFByteOrders.pas
  80. 1 0
      packages/univint/src/CFCalendar.pas
  81. 1 0
      packages/univint/src/CFCharacterSet.pas
  82. 1 0
      packages/univint/src/CFData.pas
  83. 1 0
      packages/univint/src/CFDate.pas
  84. 1 0
      packages/univint/src/CFDateFormatter.pas
  85. 1 0
      packages/univint/src/CFDictionary.pas
  86. 1 0
      packages/univint/src/CFError.pas
  87. 1 0
      packages/univint/src/CFFTPStream.pas
  88. 1 0
      packages/univint/src/CFFileDescriptor.pas
  89. 1 0
      packages/univint/src/CFFileSecurity.pas
  90. 1 0
      packages/univint/src/CFHTTPAuthentication.pas
  91. 1 0
      packages/univint/src/CFHTTPMessage.pas
  92. 1 0
      packages/univint/src/CFHTTPStream.pas
  93. 1 0
      packages/univint/src/CFHost.pas
  94. 1 0
      packages/univint/src/CFLocale.pas
  95. 1 0
      packages/univint/src/CFMachPort.pas
  96. 1 0
      packages/univint/src/CFMessagePort.pas
  97. 1 0
      packages/univint/src/CFNetDiagnostics.pas
  98. 1 0
      packages/univint/src/CFNetServices.pas
  99. 1 0
      packages/univint/src/CFNetworkErrorss.pas
  100. 1 0
      packages/univint/src/CFNotificationCenter.pas

+ 9 - 0
.gitattributes

@@ -7877,13 +7877,22 @@ packages/univint/src/AppleHelp.pas svneol=native#text/plain
 packages/univint/src/AppleScript.pas svneol=native#text/plain
 packages/univint/src/AudioCodecs.pas svneol=native#text/plain
 packages/univint/src/AudioComponents.pas svneol=native#text/plain
+packages/univint/src/AudioConverter.pas svneol=native#text/plain
+packages/univint/src/AudioFile.pas svneol=native#text/plain
+packages/univint/src/AudioFileComponents.pas svneol=native#text/plain
+packages/univint/src/AudioFileStream.pas svneol=native#text/plain
+packages/univint/src/AudioFormat.pas svneol=native#text/plain
 packages/univint/src/AudioHardware.pas svneol=native#text/plain
 packages/univint/src/AudioHardwareBase.pas svneol=native#text/plain
 packages/univint/src/AudioHardwareDeprecated.pas svneol=native#text/plain
+packages/univint/src/AudioHardwareService.pas svneol=native#text/plain
 packages/univint/src/AudioOutputUnit.pas svneol=native#text/plain
+packages/univint/src/AudioQueue.pas svneol=native#text/plain
+packages/univint/src/AudioServices.pas svneol=native#text/plain
 packages/univint/src/AudioUnitCarbonViews.pas svneol=native#text/plain
 packages/univint/src/AudioUnitParameters.pas svneol=native#text/plain
 packages/univint/src/AudioUnitProperties.pas svneol=native#text/plain
+packages/univint/src/AudioUnitUtilities.pas svneol=native#text/plain
 packages/univint/src/AuthSession.pas svneol=native#text/plain
 packages/univint/src/Authorization.pas svneol=native#text/plain
 packages/univint/src/AuthorizationDB.pas svneol=native#text/plain

+ 9 - 0
packages/univint/fpmake.pp

@@ -73,13 +73,22 @@ begin
     T:=P.Targets.AddImplicitUnit('AppleScript.pas');
     T:=P.Targets.AddImplicitUnit('AudioCodecs.pas');
     T:=P.Targets.AddImplicitUnit('AudioComponents.pas');
+    T:=P.Targets.AddImplicitUnit('AudioConverter.pas');
+    T:=P.Targets.AddImplicitUnit('AudioFile.pas');
+    T:=P.Targets.AddImplicitUnit('AudioFileComponents.pas');
+    T:=P.Targets.AddImplicitUnit('AudioFileStream.pas');
+    T:=P.Targets.AddImplicitUnit('AudioFormat.pas');
     T:=P.Targets.AddImplicitUnit('AudioHardware.pas');
     T:=P.Targets.AddImplicitUnit('AudioHardwareBase.pas');
     T:=P.Targets.AddImplicitUnit('AudioHardwareDeprecated.pas');
+    T:=P.Targets.AddImplicitUnit('AudioHardwareService.pas');
     T:=P.Targets.AddImplicitUnit('AudioOutputUnit.pas');
+    T:=P.Targets.AddImplicitUnit('AudioQueue.pas');
+    T:=P.Targets.AddImplicitUnit('AudioServices.pas');
     T:=P.Targets.AddImplicitUnit('AudioUnitCarbonViews.pas');
     T:=P.Targets.AddImplicitUnit('AudioUnitParameters.pas');
     T:=P.Targets.AddImplicitUnit('AudioUnitProperties.pas');
+    T:=P.Targets.AddImplicitUnit('AudioUnitUtilities.pas');
     T:=P.Targets.AddImplicitUnit('AuthSession.pas');
     T:=P.Targets.AddImplicitUnit('Authorization.pas');
     T:=P.Targets.AddImplicitUnit('AuthorizationDB.pas');

+ 3 - 1
packages/univint/src/ABActions.pas

@@ -8,6 +8,7 @@
 }
 {	  Pascal Translation:  Peter N Lewis, <[email protected]>, 2004 }
 {	  Pascal Translation Updated:  Gorazd Krosl, <[email protected]>, November 2009 }
+{     Pascal Translation Updated:  Gale R Paeper, <[email protected]>, 2018 }
 
 {
     Modified for use with Free Pascal
@@ -17,6 +18,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}
@@ -214,7 +216,7 @@ uses MacTypes,ABAddressBook,CFBase;
 // --------------------------------------------------------------------------------
 //      Action Support
 // --------------------------------------------------------------------------------
-// This API allows developers to populate AddressBook.app's roll-over menus with custom
+// This API allows developers to populate Contacts.app's roll-over menus with custom
 // entries. Your CFBundle must implement a function named ABActionRegisterCallbacks which
 // will return a pointer to an ABActionCallbacks struct. This struct should be filled out
 // as follows:

+ 6 - 4
packages/univint/src/ABAddressBook.pas

@@ -8,6 +8,7 @@
 }
 {	  Pascal Translation:  Peter N Lewis, <[email protected]>, 2004 }
 {	  Pascal Translation Updated:  Gorazd Krosl, <[email protected]>, November 2009 }
+{     Pascal Translation Updated:  Gale R Paeper, <[email protected]>, 2018 }
 
 {
     Modified for use with Free Pascal
@@ -17,6 +18,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}
@@ -230,10 +232,10 @@ type
 // --------------------------------------------------------------------------------
 //	LSOpenCFURLRef support
 // --------------------------------------------------------------------------------
-// An application can open the AddressBook app and select (and edit) a specific
+// An application can open the Contacts app and select (and edit) a specific
 // person by using the LSOpenCFURLRef API.
 //
-// To launch (or bring to front) the Address Book app and select a given person
+// To launch (or bring to front) the Contacts app and select a given person
 //
 // CFStringRef uniqueId = ABRecordCopyUniqueId(aPerson);
 // CFStringRef urlString = CFStringCreateWithFormat(NULL, CFSTR(addressbook://%@), uniqueId);
@@ -243,7 +245,7 @@ type
 // CFRelease(urlRef);
 // CFRelease(urlString);
 //
-// To launch (or bring to front) the Address Book app and edit a given person
+// To launch (or bring to front) the Contacts app and edit a given person
 //
 // CFStringRef uniqueId = ABRecordCopyUniqueId(aPerson);
 // CFStringRef urlString = CFStringCreateWithFormat(NULL, CFSTR(addressbook://%@?edit), uniqueId);
@@ -277,7 +279,7 @@ function ABCopyRecordTypeFromUniqueId( addressBook: ABAddressBookRef; uniqueId:
 
     // --- Properties
     // Property names must be unique for a record type
-function ABAddPropertiesAndTypes( addressBook: ABAddressBookRef; recordType: CFStringRef; propertiesAnTypes: CFDictionaryRef ): CFIndex; external name '_ABAddPropertiesAndTypes';
+function ABAddPropertiesAndTypes( addressBook: ABAddressBookRef; recordType: CFStringRef; propertiesAndTypes: CFDictionaryRef ): CFIndex; external name '_ABAddPropertiesAndTypes';
 function ABRemoveProperties( addressBook: ABAddressBookRef; recordType: CFStringRef; properties: CFArrayRef ): CFIndex; external name '_ABRemoveProperties';
 function ABCopyArrayOfPropertiesForRecordType( addressBook: ABAddressBookRef; recordType: CFStringRef ): CFArrayRef; external name '_ABCopyArrayOfPropertiesForRecordType';
 function ABTypeOfProperty( addressBook: ABAddressBookRef; recordType: CFStringRef; proprty: CFStringRef ): ABPropertyType; external name '_ABTypeOfProperty';

+ 75 - 19
packages/univint/src/ABGlobals.pas

@@ -2,12 +2,13 @@
  *  ABGlobalsC.h
  *  AddressBook Framework
  *
- *  Copyright (c) 2003-2007 Apple Inc.  All rights reserved.
+ *  Copyright (c) 2003-2010 Apple Inc.  All rights reserved.
  *
  }
 {	  Pascal Translation:  Peter N Lewis, <[email protected]>, 2004 }
 {   Pascal Translation Updated:  Peter N Lewis, <[email protected]>, Feburary 2006 }
 {	  Pascal Translation Updated:  Gorazd Krosl, <[email protected]>, November 2009 }
+{     Pascal Translation Updated:  Gale R Paeper, <[email protected]>, 2018 }
 
 {
     Modified for use with Free Pascal
@@ -17,6 +18,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}
@@ -249,9 +251,12 @@ var kABURLsProperty: CFStringRef; external name '_kABURLsProperty'; (* attribute
 var kABHomePageLabel: CFStringRef; external name '_kABHomePageLabel'; (* attribute const *)
 (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) // Homepage URL
 
+var kABCalendarURIsProperty: CFStringRef; external name '_kABCalendarURIsProperty'; (* attribute const *)
+(* AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER *) // Calendar URIs - kABMultiStringProperty
+
 var kABEmailProperty: CFStringRef; external name '_kABEmailProperty'; (* attribute const *)                 // Email(s) - kABMultiStringProperty
-var kABEmailWorkLabel: CFStringRef; external name '_kABEmailWorkLabel'; (* attribute const *)        // Home email
-var kABEmailHomeLabel: CFStringRef; external name '_kABEmailHomeLabel'; (* attribute const *)        // Work email
+var kABEmailWorkLabel: CFStringRef; external name '_kABEmailWorkLabel'; (* attribute const *)        // Work email
+var kABEmailHomeLabel: CFStringRef; external name '_kABEmailHomeLabel'; (* attribute const *)        // Home email
 
 var kABAddressProperty: CFStringRef; external name '_kABAddressProperty'; (* attribute const *)                // Street Addresses - kABMultiDictionaryProperty
 var kABAddressStreetKey: CFStringRef; external name '_kABAddressStreetKey'; (* attribute const *)           // Street
@@ -360,10 +365,10 @@ var kABManagerLabel: CFStringRef; external name '_kABManagerLabel'; (* attribute
 (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
 
 var kABDepartmentProperty: CFStringRef; external name '_kABDepartmentProperty'; (* attribute const *)
-(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)     // Department name - (Person)
+(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)         // Department name - kABStringProperty - (Person)
 
 var kABPersonFlags: CFStringRef; external name '_kABPersonFlags'; (* attribute const *)
-(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)     // Various flags - kABIntegerProperty
+(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)     // Various flags - kABIntegerProperty - (Person)
 
 const	
 	kABShowAsMask = 7;
@@ -384,27 +389,75 @@ var kABPhoneHomeFAXLabel: CFStringRef; external name '_kABPhoneHomeFAXLabel'; (*
 var kABPhoneWorkFAXLabel: CFStringRef; external name '_kABPhoneWorkFAXLabel'; (* attribute const *)      // FAX number
 var kABPhonePagerLabel: CFStringRef; external name '_kABPhonePagerLabel'; (* attribute const *)        // Pager number
 
-var kABAIMInstantProperty: CFStringRef; external name '_kABAIMInstantProperty'; (* attribute const *)             // AIM Instant Messaging - kABMultiStringProperty
+
+// Deprecated in Mac OS 10.7. You should use kABInstantMessageProperty.
+var kABAIMInstantProperty: CFStringRef; external name '_kABAIMInstantProperty'; (* attribute const *)
+(* DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER *)	// AIM Instant Messaging - kABMultiStringProperty
 var kABAIMWorkLabel: CFStringRef; external name '_kABAIMWorkLabel'; (* attribute const *)
+(* DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER *)
 var kABAIMHomeLabel: CFStringRef; external name '_kABAIMHomeLabel'; (* attribute const *)
+(* DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER *)
 
-var kABJabberInstantProperty: CFStringRef; external name '_kABJabberInstantProperty'; (* attribute const *)          // Jabber Instant Messaging - kABMultiStringProperty
+// Deprecated in Mac OS 10.7. You should use kABInstantMessageProperty.
+var kABJabberInstantProperty: CFStringRef; external name '_kABJabberInstantProperty'; (* attribute const *)
+(* DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER *)	// Jabber Instant Messaging - kABMultiStringProperty
 var kABJabberWorkLabel: CFStringRef; external name '_kABJabberWorkLabel'; (* attribute const *)
+(* DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER *)
 var kABJabberHomeLabel: CFStringRef; external name '_kABJabberHomeLabel'; (* attribute const *)
+(* DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER *)
 
-var kABMSNInstantProperty: CFStringRef; external name '_kABMSNInstantProperty'; (* attribute const *)             // MSN Instant Messaging  - kABMultiStringProperty
+// Deprecated in Mac OS 10.7. You should use kABInstantMessageProperty.
+var kABMSNInstantProperty: CFStringRef; external name '_kABMSNInstantProperty'; (* attribute const *)
+(* DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER *)	// MSN Instant Messaging - kABMultiStringProperty
 var kABMSNWorkLabel: CFStringRef; external name '_kABMSNWorkLabel'; (* attribute const *)
+(* DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER *)
 var kABMSNHomeLabel: CFStringRef; external name '_kABMSNHomeLabel'; (* attribute const *)
+(* DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER *)
 
-var kABYahooInstantProperty: CFStringRef; external name '_kABYahooInstantProperty'; (* attribute const *)           // Yahoo Instant Messaging  - kABMultiStringProperty
+// Deprecated in Mac OS 10.7. You should use kABInstantMessageProperty.
+var kABYahooInstantProperty: CFStringRef; external name '_kABYahooInstantProperty'; (* attribute const *)
+(* DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER *)	// Yahoo Instant Messaging - kABMultiStringProperty
 var kABYahooWorkLabel: CFStringRef; external name '_kABYahooWorkLabel'; (* attribute const *)
+(* DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER *)
 var kABYahooHomeLabel: CFStringRef; external name '_kABYahooHomeLabel'; (* attribute const *)
+(* DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER *)
 
-var kABICQInstantProperty: CFStringRef; external name '_kABICQInstantProperty'; (* attribute const *)             // ICQ Instant Messaging  - kABMultiStringProperty
+// Deprecated in Mac OS 10.7. You should use kABInstantMessageProperty.
+var kABICQInstantProperty: CFStringRef; external name '_kABICQInstantProperty'; (* attribute const *)
+(* DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER *)	// ICQ Instant Messaging - kABMultiStringProperty
 var kABICQWorkLabel: CFStringRef; external name '_kABICQWorkLabel'; (* attribute const *)
+(* DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER *)
 var kABICQHomeLabel: CFStringRef; external name '_kABICQHomeLabel'; (* attribute const *)
-
-var kABNoteProperty: CFStringRef; external name '_kABNoteProperty'; (* attribute const *)                   // Note - kABStringProperty
+(* DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER *)
+
+var kABInstantMessageProperty: CFStringRef; external name '_kABInstantMessageProperty'; (* attribute const *)
+(* AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER *)	// Instant Messaging - kABMultiDictionaryProperty
+var kABInstantMessageUsernameKey: CFStringRef; external name '_kABInstantMessageUsernameKey'; (* attribute const *)
+(* AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER *)		// dictionary key for the instant messaging handle/username
+var kABInstantMessageServiceKey: CFStringRef; external name '_kABInstantMessageServiceKey'; (* attribute const *)
+(* AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER *)		// dictionary key for the service type; possible values follow
+var kABInstantMessageServiceAIM: CFStringRef; external name '_kABInstantMessageServiceAIM'; (* attribute const *)
+(* AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER *)		// AIM
+var kABInstantMessageServiceFacebook: CFStringRef; external name '_kABInstantMessageServiceFacebook'; (* attribute const *)
+(* AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER *)		// Facebook
+var kABInstantMessageServiceGaduGadu: CFStringRef; external name '_kABInstantMessageServiceGaduGadu'; (* attribute const *)
+(* AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER *)		// Gadu-Gadu
+var kABInstantMessageServiceGoogleTalk: CFStringRef; external name '_kABInstantMessageServiceGoogleTalk'; (* attribute const *)
+(* AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER *)		// Google Talk
+var kABInstantMessageServiceICQ: CFStringRef; external name '_kABInstantMessageServiceICQ'; (* attribute const *)
+(* AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER *)		// ICQ
+var kABInstantMessageServiceJabber: CFStringRef; external name '_kABInstantMessageServiceJabber'; (* attribute const *)
+(* AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER *)		// Jabber
+var kABInstantMessageServiceMSN: CFStringRef; external name '_kABInstantMessageServiceMSN'; (* attribute const *)
+(* AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER *)		// MSN
+var kABInstantMessageServiceQQ: CFStringRef; external name '_kABInstantMessageServiceQQ'; (* attribute const *)
+(* AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER *)		// QQ
+var kABInstantMessageServiceSkype: CFStringRef; external name '_kABInstantMessageServiceSkype'; (* attribute const *)
+(* AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER *)		// Skype
+var kABInstantMessageServiceYahoo: CFStringRef; external name '_kABInstantMessageServiceYahoo'; (* attribute const *)
+(* AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER *)		// Yahoo!
+
+var kABNoteProperty: CFStringRef; external name '_kABNoteProperty'; (* attribute const *)                    // Note (string)
 
 var kABMiddleNameProperty: CFStringRef; external name '_kABMiddleNameProperty'; (* attribute const *)             // kABStringProperty
 var kABMiddleNamePhoneticProperty: CFStringRef; external name '_kABMiddleNamePhoneticProperty'; (* attribute const *)     // kABStringProperty
@@ -428,15 +481,20 @@ var kABHomeLabel: CFStringRef; external name '_kABHomeLabel'; (* attribute const
     // Can be used with any multi-value property
 var kABOtherLabel: CFStringRef; external name '_kABOtherLabel'; (* attribute const *)
 
+    // MobileMe - for AIM or email values
+var kABMobileMeLabel: CFStringRef; external name '_kABMobileMeLabel'; (* attribute const *)
+(* AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER *)
+
+
 // ================================================================
 //      RecordTypes
 // ================================================================
 
     // Type of a ABPersonRef
-var kABPersonRecordType : CFStringRef; external name '_kABPersonRecordType'; (* attribute const *)
+var kABPersonRecordType: CFStringRef; external name '_kABPersonRecordType'; (* attribute const *)
 
     // Type of a ABGroupRef
-var kABGroupRecordType : CFStringRef; external name '_kABGroupRecordType'; (* attribute const *)
+var kABGroupRecordType: CFStringRef; external name '_kABGroupRecordType'; (* attribute const *)
 
 // ================================================================
 //      Notifications published when something changes
@@ -450,11 +508,9 @@ var kABDatabaseChangedNotification: CFStringRef; external name '_kABDatabaseChan
     // Another process has changed the DB
 var kABDatabaseChangedExternallyNotification: CFStringRef; external name '_kABDatabaseChangedExternallyNotification'; (* attribute const *)
 
-    // The user info (dictionary) in the above notification will contain
-    // the following 3 keys. Value for each keys is an array of
-    // uniqueId of the Inserted/Updated/Deleted Records.
-    // If all three values are nil assume that everything has changed (could be the case
-    // when restoring from backup)
+    // The user info in the above notifications will contain
+    // the following 3 keys, the values of the keys in the dictionary
+    // will be the uniqueIds of the Inserted/Updated/Deleted Records
 var kABInsertedRecords: CFStringRef; external name '_kABInsertedRecords'; (* attribute const *)
 (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
 var kABUpdatedRecords: CFStringRef; external name '_kABUpdatedRecords'; (* attribute const *)

+ 1 - 0
packages/univint/src/ABPeoplePicker.pas

@@ -17,6 +17,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 12 - 4
packages/univint/src/ABTypedefs.pas

@@ -7,6 +7,7 @@
  }
 {	  Pascal Translation:  Peter N Lewis, <[email protected]>, 2004 }
 {	  Pascal Translation Updated:  Gorazd Krosl, <[email protected]>, November 2009 }
+{     Pascal Translation Updated:  Gale R Paeper, <[email protected]>, 2018 }
 
 {
     Modified for use with Free Pascal
@@ -16,6 +17,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}
@@ -202,7 +204,7 @@ interface
 {$setc TYPE_BOOL := FALSE}
 {$setc TYPE_EXTENDED := FALSE}
 {$setc TYPE_LONGLONG := TRUE}
-uses MacTypes;
+uses MacTypes,CFBase;
 {$endc} {not MACOSALLINCLUDE}
 
 
@@ -222,7 +224,7 @@ const
 	kABMultiValueMask  = $100;
 
 type
-	ABPropertyType = SInt32;
+	ABPropertyType = CFIndex;
 const
     kABErrorInProperty           = 0;
     kABStringProperty            = 1;
@@ -232,6 +234,9 @@ const
     kABArrayProperty             = 5;
     kABDictionaryProperty        = 6;
     kABDataProperty              = 7;
+// #if MAC_OS_X_VERSION_10_7 <= MAC_OS_X_VERSION_MAX_ALLOWED
+	kABDateComponentsProperty    = 8;
+// #endif
     kABMultiStringProperty       = kABMultiValueMask or kABStringProperty;
     kABMultiIntegerProperty      = kABMultiValueMask or kABIntegerProperty;
     kABMultiRealProperty         = kABMultiValueMask or kABRealProperty;
@@ -239,13 +244,16 @@ const
     kABMultiArrayProperty        = kABMultiValueMask or kABArrayProperty;
     kABMultiDictionaryProperty   = kABMultiValueMask or kABDictionaryProperty;
     kABMultiDataProperty         = kABMultiValueMask or kABDataProperty;
+// #if MAC_OS_X_VERSION_10_7 <= MAC_OS_X_VERSION_MAX_ALLOWED
+	kABMultiDateComponentsProperty = kABMultiValueMask or kABDateComponentsProperty;
+// #endif
 
 // ================================================================
 //      Search APIs
 // ================================================================
 
 type
-	ABSearchComparison = SInt32;
+	ABSearchComparison = CFIndex;
 const
 	kABEqual 										= 0;
 	kABNotEqual 									= 1;
@@ -278,7 +286,7 @@ const
 // #endif
 
 type
-	ABSearchConjunction = SInt32;
+	ABSearchConjunction = CFIndex;
 const
 	kABSearchAnd = 0;
 	kABSearchOr = 1;

+ 20 - 9
packages/univint/src/AEDataModel.pas

@@ -13,6 +13,8 @@
                      http://bugs.freepascal.org
  
 }
+{     Pascal Translation Updated:  Gale R Paeper, <[email protected]>, July 2018 }
+
 {
     Modified for use with Free Pascal
     Version 308
@@ -21,6 +23,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}
@@ -368,16 +371,24 @@ const
 	keyOriginalAddressAttr = FourCharCode('from'); { new in 1.0.1 }
 	keyAcceptTimeoutAttr = FourCharCode('actm'); { new for Mac OS X }
 	keyReplyRequestedAttr = FourCharCode('repq'); { Was a reply requested for this event - returned as typeBoolean }
-	keySenderEUIDAttr = FourCharCode('seid'); { read only, returned as typeSInt32.  Will be the euid of the sender of this event. } { Mac OS X 10.6 or later }
-	keySenderEGIDAttr = FourCharCode('sgid'); { read only, returned as typeSInt32.  Will be the egid of the sender of this event. } { Mac OS X 10.6 or later }
-	keySenderUIDAttr = FourCharCode('uids'); { read only, returned as typeSInt32.  Will be the uid of the sender of this event. } { Mac OS X 10.6 or later }
-	keySenderGIDAttr = FourCharCode('gids'); { read only, returned as typeSInt32.  Will be the gid of the sender of this event. } { Mac OS X 10.6 or later }
-	keySenderPIDAttr = FourCharCode('spid'); { read only, returned as typeSInt32.  Will be the pid of the sender of this event. } { Mac OS X 10.6 or later }
-	keySenderAuditTokenAttr = FourCharCode('tokn'); { read only, returned as an audit_token_t.  Will be the audit token of the sender of this event. } { Mac OS X 10.6 or later }
-	keySenderApplescriptEntitlementsAttr = FourCharCode('entl'); { read only, an AEDesc containing opaque data representing the entitlements held by the sender. Interpreted by sandbox routines. } { Mac OS X 10.8 or later }
+//	#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
+	keySenderEUIDAttr = FourCharCode('seid'); { read only, returned as typeSInt32.  Will be the euid of the sender of this event. }
+	keySenderEGIDAttr = FourCharCode('sgid'); { read only, returned as typeSInt32.  Will be the egid of the sender of this event. }
+	keySenderUIDAttr = FourCharCode('uids'); { read only, returned as typeSInt32.  Will be the uid of the sender of this event. }
+	keySenderGIDAttr = FourCharCode('gids'); { read only, returned as typeSInt32.  Will be the gid of the sender of this event. }
+	keySenderPIDAttr = FourCharCode('spid'); { read only, returned as typeSInt32.  Will be the pid of the sender of this event. }
+	keySenderAuditTokenAttr = FourCharCode('tokn'); { read only, returned as an audit_token_t.  Will be the audit token of the sender of this event. }
+//	#endif
+//	#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+	keySenderApplescriptEntitlementsAttr = FourCharCode('entl'); { read only, an AEDesc containing opaque data representing the entitlements held by the sender. Interpreted by sandbox routines. }
 	keySenderApplicationIdentifierEntitlementAttr = FourCharCode('aiea');
-	keySenderApplicationSandboxed = FourCharCode('sssb'); { read-only, an AEDesc typeBoolean, true if the sender application was in an application sandbox } { Mac OS X 10.8 or later }
-	keyActualSenderAuditToken = FourCharCode('acat'); { read-only, an AEDesc typeAuditToken of the acual ( possibly over-ridden ) audit token for the sender of this event } { Mac OS X 10.8 or later }
+	keySenderApplicationSandboxed = FourCharCode('sssb'); { read-only, an AEDesc typeBoolean, true if the sender application was in an application sandbox }
+	keyActualSenderAuditToken = FourCharCode('acat'); { read-only, an AEDesc typeAuditToken of the acual ( possibly over-ridden ) audit token for the sender of this event }
+//	#endif
+
+//	#if defined(__MAC_10_13) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_13
+	keyAppleEventAttributesAttr = FourCharCode('attr'); { read-only, an AEDescList of AEKeyword entries of the attributes on this event. }
+//	#endif
 
 { These bits are specified in the keyXMLDebuggingAttr (an SInt32) }
 const

+ 1 - 0
packages/univint/src/AEHelpers.pas

@@ -21,6 +21,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AEInteraction.pas

@@ -24,6 +24,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AEMach.pas

@@ -21,6 +21,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AEObjects.pas

@@ -21,6 +21,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AEPackObject.pas

@@ -21,6 +21,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AERegistry.pas

@@ -21,6 +21,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AEUserTermTypes.pas

@@ -21,6 +21,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AIFF.pas

@@ -14,6 +14,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/ASDebugging.pas

@@ -24,6 +24,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/ASRegistry.pas

@@ -24,6 +24,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/ATSFont.pas

@@ -24,6 +24,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/ATSLayoutTypes.pas

@@ -25,6 +25,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/ATSTypes.pas

@@ -25,6 +25,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/ATSUnicodeDirectAccess.pas

@@ -24,6 +24,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/ATSUnicodeDrawing.pas

@@ -24,6 +24,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/ATSUnicodeFlattening.pas

@@ -24,6 +24,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/ATSUnicodeFonts.pas

@@ -24,6 +24,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/ATSUnicodeGlyphs.pas

@@ -24,6 +24,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/ATSUnicodeObjects.pas

@@ -24,6 +24,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/ATSUnicodeTypes.pas

@@ -24,6 +24,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

File diff suppressed because it is too large
+ 354 - 258
packages/univint/src/AUComponent.pas


+ 1 - 0
packages/univint/src/AVLTree.pas

@@ -14,6 +14,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AXActionConstants.pas

@@ -19,6 +19,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AXAttributeConstants.pas

@@ -19,6 +19,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AXConstants.pas

@@ -8,6 +8,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AXErrors.pas

@@ -18,6 +18,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AXNotificationConstants.pas

@@ -19,6 +19,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AXRoleConstants.pas

@@ -19,6 +19,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AXTextAttributedString.pas

@@ -17,6 +17,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AXUIElement.pas

@@ -17,6 +17,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AXValue.pas

@@ -18,6 +18,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AXValueConstants.pas

@@ -19,6 +19,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/Accessibility.pas

@@ -14,6 +14,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/Aliases.pas

@@ -15,6 +15,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/Appearance.pas

@@ -24,6 +24,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AppleDiskPartitions.pas

@@ -22,6 +22,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AppleEvents.pas

@@ -23,6 +23,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AppleHelp.pas

@@ -22,6 +22,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AppleScript.pas

@@ -24,6 +24,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 104 - 25
packages/univint/src/AudioCodecs.pas

@@ -1,9 +1,9 @@
 {==================================================================================================
-     File:       AudioUnit/AudioCodec.h
+     File:       AudioToolbox/AudioCodec.h
 
      Contains:   A component API for encoding/decoding audio data.
 
-     Copyright:  (c) 1985-2008 by Apple, Inc., all rights reserved.
+     Copyright:  (c) 1985-2015 by Apple, Inc., all rights reserved.
 
      Bugs?:      For bug reports, consult the following page on
                  the World Wide Web:
@@ -13,6 +13,7 @@
 ==================================================================================================}
 {  Pascal Translation:  Gorazd Krosl <[email protected]>, October 2009 }
 {  Pascal Translation Update: Jonas Maebe <[email protected]>, October 2012 }
+{  Pascal Translation Update: Jonas Maebe <[email protected]>, July 2019 }
 
 {
     Modified for use with Free Pascal
@@ -22,6 +23,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}
@@ -313,7 +315,6 @@ type
 //=============================================================================
 
 
-{$ifc not TARGET_OS_IPHONE}
 {!
 	@enum           AudioCodecComponentType
  
@@ -332,9 +333,7 @@ type
 const
 	kAudioDecoderComponentType = FourCharCode('adec');
 	kAudioEncoderComponentType = FourCharCode('aenc');
-	kAudioUnityCodecComponentType = FourCharCode('acdc');
-{$endc} {TARGET_OS_IPHONE}
-
+	kAudioUnityCodecComponentType = FourCharCode('acdc'); 
 
 //=============================================================================
 //#pragma	mark Global Codec Properties
@@ -481,6 +480,14 @@ const
 						This always refers to the encoded data, so for encoders it refers to the
 						output data and for decoders the input data.
 						Not writable.
+	@constant		kAudioCodecPropertyPacketSizeLimitForVBR
+                        A UInt32 indicating the maximum number of bits in an output packet of an encoder.
+                        The output packet size will not exceed this number. The size should be smaller 
+                        than kAudioCodecPropertyMaximumPacketByteSize. This property will configure the 
+                        encoder to VBR mode with the highest VBR quality that can maintain the packet 
+                        size limit. kAudioCodecPropertySoundQualityForVBR can be used to retrieve the 
+                        quality setting that will be used given that packet size limit.
+                        Writeable if supported.
 	@constant		kAudioCodecPropertyCurrentInputFormat
 						An AudioStreamBasicDescription describing the format the codec
 						expects its input data in
@@ -531,6 +538,11 @@ const
 						This property is only relevant to encoders.
 						See also kAudioCodecPropertyAvailableBitRateRange.
 						Not writable.
+    @constant		kAudioCodecPropertyRecommendedBitRateRange
+                        An array of AudioValueRange indicating the recommended bit rates
+                        at given sample rate.
+                        This property is only relevant to encoders.
+                        Not writable.
 	@constant		kAudioCodecPropertyApplicableInputSampleRates
 						An array of AudioValueRange indicating the valid ranges for the
 						input sample rate of the codec for the current bit rate. 
@@ -602,13 +614,39 @@ const
 						Writable if supported.
     @constant		kAudioCodecPropertyDelayMode
                         A UInt32 specifying the delay mode. See enum below.                        
-                        Encoders only, writable if supported.
- }
+                        Writable if supported.
+	@constant		kAudioCodecPropertyAdjustLocalQuality
+						An SInt32 number in the range [-128, 127] to allow encoding quality adjustements on a packet by packet basis.
+						This property can be set on an initialized encoder object without having to uninitialize and re-intialize it
+						and allows to adjust the encoder quality level for every packet. This is useful for packets streamed over
+						unreliable IP networks where the encoder needs to adapt immediately to network condition changes.
+						Escape property ID's start with a '^' symbol as the first char code. This bypasses the initilization check.
+    @constant		kAudioCodecPropertyProgramTargetLevel
+						A Float32 specifying the program target level in dB FS for decoders.
+						Supported target levels are in the range of -31.0 to -20.0dB.
+						This property controls the decoding of broadcast loudness
+						normalization metadata with goal of achieving consistent loudness across various
+						programs. The property complies with the target level defined in the MPEG Audio
+						standard ISO/IEC 14496-3. It will override kAudioCodecPropertyProgramTargetLevelConstant.
+	@constant		kAudioCodecPropertyProgramTargetLevelConstant
+						A UInt32 specifying the program target level constant in dB FS (Full Scale) for decoders.
+						Supported target levels are defined as enum with the prefix kProgramTargetLevel
+						(see below). This property controls the decoding of broadcast loudness
+						normalization metadata with the goal of achieving consistent loudness across various
+						programs. The property complies with the target level defined in the MPEG Audio
+						standard ISO/IEC 14496-3. The default is kProgramTargetLevel_None.
+    @constant		kAudioCodecPropertyDynamicRangeControlMode
+						A UInt32 specifying the DRC mode. Supported modes are defined as enum with the
+						prefix kDynamicRangeControlMode (see below). This property controls which
+						dynamic range compression scheme is applied if the information is present in
+						the bitstream. The default is kDynamicRangeControlMode_None.
+}
 const
 	kAudioCodecPropertyInputBufferSize = FourCharCode('tbuf');
 	kAudioCodecPropertyPacketFrameSize = FourCharCode('pakf');
 	kAudioCodecPropertyHasVariablePacketByteSizes = FourCharCode('vpk?');
 	kAudioCodecPropertyMaximumPacketByteSize = FourCharCode('pakb');
+	kAudioCodecPropertyPacketSizeLimitForVBR = FourCharCode('pakl');
 	kAudioCodecPropertyCurrentInputFormat = FourCharCode('ifmt');
 	kAudioCodecPropertyCurrentOutputFormat = FourCharCode('ofmt');
 	kAudioCodecPropertyMagicCookie = FourCharCode('kuki');
@@ -619,6 +657,7 @@ const
 	kAudioCodecPropertyCurrentOutputSampleRate = FourCharCode('cosr');
 	kAudioCodecPropertyQualitySetting = FourCharCode('srcq');
 	kAudioCodecPropertyApplicableBitRateRange = FourCharCode('brta');
+	kAudioCodecPropertyRecommendedBitRateRange = FourCharCode('brtr');
 	kAudioCodecPropertyApplicableInputSampleRates = FourCharCode('isra');
 	kAudioCodecPropertyApplicableOutputSampleRates = FourCharCode('osra');
 	kAudioCodecPropertyPaddedZeros = FourCharCode('pad0');
@@ -631,6 +670,10 @@ const
 	kAudioCodecPropertyBitRateControlMode = FourCharCode('acbf');
 	kAudioCodecPropertySoundQualityForVBR = FourCharCode('vbrq');
 	kAudioCodecPropertyDelayMode = FourCharCode('dmod');
+	kAudioCodecPropertyAdjustLocalQuality = FourCharCode('^qal');
+	kAudioCodecPropertyProgramTargetLevel = FourCharCode('pptl');
+	kAudioCodecPropertyDynamicRangeControlMode = FourCharCode('mdrc');
+	kAudioCodecPropertyProgramTargetLevelConstant = FourCharCode('ptlc'); 
 
 
 {!
@@ -727,11 +770,45 @@ const
     @constant		kAudioCodecDelayMode_Optimal
                         In this mode, the resulting bitstream has the minimum amount of priming necessary for the decoder.
                         For aac this number is 1024 which corresponds to exactly one packet.
- }
+}
 const
 	kAudioCodecDelayMode_Compatibility = 0;
 	kAudioCodecDelayMode_Minimum = 1;
-	kAudioCodecDelayMode_Optimal = 2;
+	kAudioCodecDelayMode_Optimal = 2; 
+
+{!
+	@enum			ProgramTargetLevel
+
+	@discussion		Constants to be used with kAudioCodecPropertyProgramTargetLevelConstant
+
+	@constant		kProgramTargetLevel_None
+						
+	@constant		kProgramTargetLevel_Minus31dB
+	@constant		kProgramTargetLevel_Minus23dB
+	@constant		kProgramTargetLevel_Minus20dB
+}
+const
+	kProgramTargetLevel_None = 0;
+	kProgramTargetLevel_Minus31dB = 1;
+	kProgramTargetLevel_Minus23dB = 2;
+	kProgramTargetLevel_Minus20dB = 3; 
+    
+{!
+	@enum			DynamicRangeControlMode
+
+	@discussion		Constants to be used with kAudioCodecPropertyDynamicRangeControlMode
+
+	@constant		kDynamicRangeControlMode_None
+						Dynamic range compression disabled
+	@constant		kDynamicRangeControlMode_Light
+						Light compression according to MPEG-Audio ISO/IEC 14496
+	@constant		kDynamicRangeControlMode_Heavy
+						Heavy compression according to ETSI TS 101 154
+}
+const
+	kDynamicRangeControlMode_None = 0;
+	kDynamicRangeControlMode_Light = 1;
+	kDynamicRangeControlMode_Heavy = 2; 
 
 {!
 	@struct			AudioCodecPrimeInfo 
@@ -784,7 +861,7 @@ const
 
 
 {!
-	@enum			AudioSettingsFlag
+	@enum			AudioSettingsFlags
  
 	@discussion		Constants to be used with kAudioSettings_Hint
 					in the kAudioCodecPropertySettings property dictionary.
@@ -800,6 +877,8 @@ const
 	@constant		kAudioSettingsFlags_UserInterfaceParameter
 						If set, then this is only a user interface element and not reflected in the codec's bit stream.
 }
+type
+	AudioSettingsFlags = UInt32;
 const
 	kAudioSettingsFlags_ExpertParameter = 1 shl 0;
 	kAudioSettingsFlags_InvisibleParameter = 1 shl 1;
@@ -847,7 +926,7 @@ const
 
 //=============================================================================
 //#pragma mark -
-//#pragma mark Selectors for the component routines (preliminary)
+//#pragma mark Selectors for the component routines
 //=============================================================================
 {!
 	@enum			AudioCodecSelectors
@@ -896,6 +975,7 @@ const
 	@constant		kAudioCodecUnsupportedFormatError
 	@constant		kAudioCodecStateError
 	@constant		kAudioCodecNotEnoughBufferSpaceError
+	@constant		kAudioCodecBadDataError
 }
 const
 	kAudioCodecNoError = 0;
@@ -906,6 +986,7 @@ const
 	kAudioCodecUnsupportedFormatError = FourCharCode('!dat');
 	kAudioCodecStateError = FourCharCode('!stt');
 	kAudioCodecNotEnoughBufferSpaceError = FourCharCode('!buf');
+	kAudioCodecBadDataError = FourCharCode('bada'); 
 
 
 //=============================================================================
@@ -933,7 +1014,7 @@ const
 	@result			The OSStatus value
 }
 function AudioCodecGetPropertyInfo( inCodec: AudioCodec; inPropertyID: AudioCodecPropertyID; var outSize: UInt32; var outWritable: Boolean ): OSStatus; external name '_AudioCodecGetPropertyInfo';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) *)
+(* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
 
 
 {!
@@ -955,7 +1036,7 @@ function AudioCodecGetPropertyInfo( inCodec: AudioCodec; inPropertyID: AudioCode
 	@result			The OSStatus value
 }
 function AudioCodecGetProperty( inCodec: AudioCodec; inPropertyID: AudioCodecPropertyID; var ioPropertyDataSize: UInt32; outPropertyData: UnivPtr ): OSStatus; external name '_AudioCodecGetProperty';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) *)
+(* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
 
 
 {!
@@ -975,7 +1056,7 @@ function AudioCodecGetProperty( inCodec: AudioCodec; inPropertyID: AudioCodecPro
 	@result			The OSStatus value
 }
 function AudioCodecSetProperty( inCodec: AudioCodec; inPropertyID: AudioCodecPropertyID; inPropertyDataSize: UInt32; inPropertyData: {const} UnivPtr ): OSStatus; external name '_AudioCodecSetProperty';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) *)
+(* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
 
 
 //=============================================================================
@@ -1005,7 +1086,7 @@ function AudioCodecSetProperty( inCodec: AudioCodec; inPropertyID: AudioCodecPro
 	@result			The OSStatus value
 }
 function AudioCodecInitialize( inCodec: AudioCodec; const (*var*) inInputFormat: AudioStreamBasicDescription; const (*var*) inOutputFormat: AudioStreamBasicDescription; inMagicCookie: {const} UnivPtr; inMagicCookieByteSize: UInt32 ): OSStatus; external name '_AudioCodecInitialize';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) *)
+(* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
 
 
 {!
@@ -1021,7 +1102,7 @@ function AudioCodecInitialize( inCodec: AudioCodec; const (*var*) inInputFormat:
 	@result			The OSStatus value
 }
 function AudioCodecUninitialize( inCodec: AudioCodec ): OSStatus; external name '_AudioCodecUninitialize';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) *)
+(* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
 
 
 {!
@@ -1053,7 +1134,7 @@ function AudioCodecUninitialize( inCodec: AudioCodec ): OSStatus; external name
 	@result			The OSStatus value
 }
 function AudioCodecAppendInputData( inCodec: AudioCodec; inInputData: {const} UnivPtr; var ioInputDataByteSize: UInt32; var ioNumberPackets: UInt32; const (*var*) inPacketDescription: AudioStreamPacketDescription ): OSStatus; external name '_AudioCodecAppendInputData';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) *)
+(* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
 
 
 {!
@@ -1086,15 +1167,13 @@ function AudioCodecAppendInputData( inCodec: AudioCodec; inInputData: {const} Un
 	@result			The OSStatus value
 }
 function AudioCodecProduceOutputPackets( inCodec: AudioCodec; outOutputData: UnivPtr; var ioOutputDataByteSize: UInt32; var ioNumberPackets: UInt32; var outPacketDescription: AudioStreamPacketDescription; var outStatus: UInt32 ): OSStatus; external name '_AudioCodecProduceOutputPackets';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) *)
+(* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
 
-{$ifc not TARGET_OS_IPHONE}
 function AudioCodecAppendInputBufferList( inCodec: AudioCodec; const (*var*) inBufferList: AudioBufferList; var ioNumberPackets: UInt32; const (*var*) inPacketDescription: AudioStreamPacketDescription; var outBytesConsumed: UInt32 ): OSStatus; external name '_AudioCodecAppendInputBufferList';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_NA) *)
+(* API_AVAILABLE(macos(10.7), ios(4.0), watchos(2.0), tvos(9.0)) *)
 
 function AudioCodecProduceOutputBufferList( inCodec: AudioCodec; var ioBufferList: AudioBufferList; var ioNumberPackets: UInt32; var outPacketDescription: AudioStreamPacketDescription; var outStatus: UInt32 ): OSStatus; external name '_AudioCodecProduceOutputBufferList';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_NA) *)
-{$endc} {not TARGET_OS_IPHONE}
+(* API_AVAILABLE(macos(10.7), ios(4.0), watchos(2.0), tvos(9.0)) *)
 
 {!
 	@function		AudioCodecReset
@@ -1108,7 +1187,7 @@ function AudioCodecProduceOutputBufferList( inCodec: AudioCodec; var ioBufferLis
 	@result			the OSStatus value
 }
 function AudioCodecReset( inCodec: AudioCodec ): OSStatus; external name '_AudioCodecReset';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) *)
+(* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
 
 //=====================================================================================================================
 type
@@ -1149,7 +1228,7 @@ type
 {!
     @enum		AudioCodecProperty
     @deprecated
- 
+
     @constant	kAudioCodecPropertyMinimumDelayMode
                     A UInt32 equal 1 sets the encoder, where applicable, in it's lowest possible delay mode. An encoder
                     may prepend zero valued samples to the input signal in order to make additional delays, like e.g.

+ 405 - 237
packages/univint/src/AudioComponents.pas

@@ -1,17 +1,162 @@
-{
-     File:      AudioUnit/AudioComponent.h
- 
-     Contains:  API for finding and opening audio components
-  
-     Copyright: (c) 2007 - 2010 by Apple, Inc., all rights reserved.
- 
-     Bugs?:      For bug reports, consult the following page on
-                 the World Wide Web:
- 
-                     http://bugs.freepascal.org
+{!
+	@file		AudioComponent.h
+ 	@framework	AudioToolbox.framework
+ 	@copyright	(c) 2007-2015 Apple, Inc. All rights reserved.
+	@brief		API's to locate, get information about, and open audio components.
+
+	@discussion
+
+	This file defines a collection of APIs to find, get information about, and open
+	audio components (such as audio units, audio codecs, and audio file components).
+
+	Originally, CoreServices' Component Manager was used for the registration, discovery, and
+	packaging of these loadable code modules. However, in order to provide an API that will be
+	supported going forward from Mac OS X 10.6 and iOS 2.0, it is advised that applications use the
+	Audio Component APIs to find and load (open) audio components such as audio units.
+
+	The type "AudioComponent" or "AudioComponentInstance" should be seen and used as a distinct type
+	from the Component Manager types of "Component" and "ComponentInstance". It is never safe to
+	assume a direct cast is compatible between this type and the other.
+
+	Beginning with Mac OS X 10.7, AudioComponents can be registered and used directly without
+	involving the Component Manager. The system scans certain directories for bundles with names
+	ending in ".audiocomp" or ".component" (the latter permits registering plug-ins in a single
+	bundle with both the Component Manager and the Audio Component system). These directories are
+	scanned non-recursively:
+
+		~/Library/Audio/Plug-Ins/Components
+		/Library/Audio/Plug-Ins/Components
+		/System/Library/Components
+
+	Bundles' Info.plist dictionaries should contain an "AudioComponents" item whose value
+	is an array of dictionaries, e.g.
+
+	@textblock
+		<key>AudioComponents</key>
+		<array>
+			<dict>
+				<key>type</key>
+				<string>aufx</string>
+				<key>subtype</key>
+				<string>XMPL</string>
+				<key>manufacturer</key>
+				<string>ACME</string>
+				<key>name</key>
+				<string>AUExample</string>
+				<key>version</key>
+				<integer>12345</integer>
+				<key>factoryFunction</key>
+				<string>AUExampleFactory</string>
+				
+				<!-- An AudioComponent is sandbox safe -->
+				
+				<key>sandboxSafe</key>
+				<true/>
+				
+				<!-- or it can describe its resource usage -->
+				
+				<key>resourceUsage</key>
+				<dict>
+					<key>iokit.user-client</key>
+					<array>
+						<string>CustomUserClient1</string>
+						<string>CustomUserClient2</string>
+					</array>
+					<key>mach-lookup.global-name</key>
+					<array>
+						<string>MachServiceName1</string>
+						<string>MachServiceName2</string>
+					</array>
+					<key>network.client</key>
+					<true/>
+					<key>temporary-exception.files.all.read-write</key>
+					</true>
+				</dict>
+
+				<!-- An AudioComponent can define its tags -->
+				
+				<key>tags</key>
+				<array>
+					<string>Effect</string>
+					<string>Equalizer</string>
+				</array>
+			</dict>
+		</array>
+	@/textblock
+
+	The type, subtype and manufacturer keys correspond to the OSType fields of the
+	AudioComponentDescription structure. They can be strings if they are 4 ASCII characters;
+	otherwise they must be 32-bit integers.
+
+	The "factoryFunction" is the name of a AudioComponentFactoryFunction in the bundle's binary.
+
+
+	SANDBOX-SAFETY
+
+	The "sandboxSafe" key is used to indicate whether or not an AudioComponent can be loaded
+	directly into a sandboxed process. This key is reflected in the componentFlags field of the the
+	AudioComponentDescription for the AudioComponent with the constant,
+	kAudioComponentFlag_SandboxSafe. Note that if this key is not present, it is assumed that the
+	AudioComponent is not sandbox safe.
+
+	The "resourceUsage" key describes the system resources used by an AudioComponent that is not
+	sandbox safe. The keys for this dictionary are described below. If the "sandboxSafe" key is
+	true, this dictionary should not be included.
+
+	The "iokit.user-client" key is a "resourceUsage" key that describes the IOKit user-client
+	objects the AudioComponent will open. It is an array of the user-clients' class names.
+
+	The "mach-lookup.global-name" key is a "resourceUsage" key that describes the mach services the
+	AudioComponent needs to connect to. It is an array of the names of the services. Note that these
+	services can be direct mach services found via bootstrap_look_up() or XPC services found via
+	xpc_connection_create_mach_service().
+
+	The "network.client" key is a "resourceUsage" key that indicates that the AudioComponent will
+	receive data from the network.
+
+	The "temporary-exception.files.all.read-write" key is a "resourceUsage" key that indicates that
+	the AudioComponent needs arbitrary access to the file system. This is for backward compatibility
+	for AudioComponents that have not yet adopted the usage of security scope bookmarks and/or the
+	usage of the standard file dialog for discovering, accessing and storing persistent references
+	to files on the file system. In a future OS release, this key will not be supported.
+
+	Note that a sandbox-safe AudioComponent can function correctly in even the most severely
+	sandboxed process. This means that the process will have curtailed or no access to common system
+	resources like the file system, device drivers, the network, and communication with other
+	processes.
+
+	When instantiating a sandbox unsafe AudioComponent in a sandboxed process, the system evaluates
+	the "resourceUsage" information against the restrictions the process is under. If the
+	"resourceUsage" will not violate those restrictions, the AudioComponent will be instantiated and
+	can be used as normal. Note that the system will set kAudioComponentFlag_SandboxSafe in the
+	AudioComponentDescription in this case.
+
+	If the "resourceUsage" information includes things that can't be accessed from the process and
+	the process has the entitlement, "com.apple.security.temporary-exception.audio-unit-host", the
+	system will ask the user whether or not it is acceptable for the process to open the unsafe
+	AudioComponent. If the user says yes, the system will suspend the process's sandbox and allow
+	the unsafe AudioComponent to be opened and used.
+
+
+	TAGS
+
+	The "tags" key is an array of tags associated with the defined AudioComponent. The following are
+	the set of predefined standard tags that are localized and can be used in the audio unit
+	definition. "Equalizer", "Dynamics", "Distortion", "Synthesizer", "Effects", "Filter", "Dynamics
+	Processor", "Delay", "Reverb", "Pitch", "Panner", "Imaging", "Sampler", "Mixer", "Format
+	Converter", "Time Effect", "Output", "Offline Effect", "Drums", "Guitar", "Vocal", "Bass",
+	"MIDI". 
+
+	These standard tags should not be localized in the audio unit.
+
+	Localizing the tags is similar to localizing AudioUnit parameter strings. Create a strings 
+	resource file and name it "AudioUnitTags.strings".
+	For more information on strings resource file please check
+	https://developer.apple.com/library/mac/documentation/macosx/conceptual/bpinternational/Articles/StringsFiles.html
 }
 {  Pascal Translation:  Gorazd Krosl <[email protected]>, October 2009 }
 {  Pascal Translation Update: Jonas Maebe <[email protected]>, October 2012 }
+{  Pascal Translation Update: Jonas Maebe <[email protected]>, July 2019 }
 
 {
     Modified for use with Free Pascal
@@ -21,6 +166,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}
@@ -216,138 +362,8 @@ uses MacTypes,CoreAudioTypes,Components,CFBase,CFDictionary;
 //=====================================================================================================================
 //#pragma mark Overview
 
-{!
-    @header AudioComponent
-
-	@discussion
-	
-    This file defines a collection of APIs that are designed to be used when finding and opening
-    audio components (such as audio units, audio codecs, and audio file components).
-    
-    Traditionally, the Component Manager has been used for the registration, discovery, and
-    packaging of these loadable code modules. However, this may not always be the case. In order
-    to provide an API that will be supported going forward from SnowLeopard (10.6) and iPhone
-    2.0, it is advised that applications use the Audio Component APIs to find and load (open)
-	audio components such as audio units. 
-	
-    The type "AudioComponent" or "AudioComponentInstance" should be seen and used as a distinct
-    type from the Component Manager types of "Component" and "ComponentInstance". It is not the
-    case that it is safe to assume a direct cast is compatible between this type and the other.
-
-    The AudioComponent APIs provide a general, and mostly complete service for doing the basic
-    task of finding and using audio components. If however, you find that you need functionality
-    that is not provided by this API that was previously supported by the Component Manager then
-    you should use the ComponentMgr APIs exclusively to find and open the Component Manager
-    components. In other words, you should not assume that an audio component instance is always
-    interchangeable with the existing ComponentInstance type.
-    
-    
-    Beginning with Mac OS X 10.7, AudioComponents can be registered and used directly without
-    involving the Component Manager. The system scans certain directories for bundles with names
-    ending in ".audiocomp" or ".component" (the latter permits registering plug-ins in a single
-    bundle with both the Component Manager and the Audio Component system). These directories
-    are scanned non-recursively:
-    
-        ~/Library/Audio/Plug-Ins/Components
-        /Library/Audio/Plug-Ins/Components
-        /System/Library/Components
-
-    Bundles' Info.plist dictionaries should contain an "AudioComponents" item whose value
-    is an array of dictionaries, e.g.
-
-        <key>AudioComponents</key>
-        <array>
-            <dict>
-                <key>type</key>
-                <string>aufx</string>
-                <key>subtype</key>
-                <string>XMPL</string>
-                <key>manufacturer</key>
-                <string>ACME</string>
-                <key>name</key>
-                <string>AUExample</string>
-                <key>version</key>
-                <integer>12345</integer>
-                <key>factoryFunction</key>
-                <string>AUExampleFactory</string>
-                
-                <!-- An AudioComponent is sandbox safe -->
-                
-                <key>sandboxSafe</key>
-                <true/>
-                
-                <!-- or it can describe it's resource usage -->
-                
-                <key>resourceUsage</key>
-                <dict>
-                    <key>iokit.user-client</key>
-                    <array>
-                        <string>CustomUserClient1</string>
-                        <string>CustomUserClient2</string>
-                    </array>
-                    <key>mach-lookup.global-name</key>
-                    <array>
-                        <string>MachServiceName1</string>
-                        <string>MachServiceName2</string>
-                    </array>
-                    <key>network.client</key>
-                    <true/>
-                    <key>temporary-exception.files.all.read-write</key>
-                    </true>
-                </dict>
-            </dict>
-        </array>
-
-    The type, subtype and manufacturer keys correspond to the OSType fields of the 
-    AudioComponentDescription structure. They can be strings if they are 4 ASCII characters; 
-    otherwise they must be 32-bit integers.
-    
-    The "factoryFunction" is the name of a AudioComponentFactoryFunction in the bundle's binary.
-    
-    The "sandboxSafe" key is used to indicate whether or not an AudioComponent can be loaded
-    directly into a sandboxed process. This key is reflected in the componentFlags field of the the
-    AudioComponentDescription for the AudioComponent with the constant, kAudioComponentFlag_SandboxSafe.
-    Note that if this key is not present, it is assumed that the AudioComponent is not sandbox safe.
-    
-    The "resourceUsage" key describes the system resources used by an AudioComponent that is not
-    sandobox safe. The keys for this dictionary are described below. If the "sandboxSafe" key is
-    true, this dictionary should not be included.
-    
-    The "iokit.user-client" key is a "resourceUsage" key that describes the IOKit user-client
-    objects the AudioComponent will open. It is an array of the user-clients' class names.
-    
-    The "mach-lookup.global-name" key is a "resourceUsage" key that describes the mach services the
-    AudioComponent needs to connect to. It is an array of the names of the services. Note that these
-    services can be direct mach services found via bootstrap_look_up() or XPC services found via
-    xpc_connection_create_mach_service().
-    
-    The "network.client" key is a "resourceUsage" key that indicates that the AudioComponent will
-    receive data from the network.
-    
-    The "temporary-exception.files.all.read-write" key is a "resourceUsage" key that indicates that
-    the AudioComponent needs arbitrary access to the file system. This is for backward compatibility
-    for AudioComponents that have not yet adopted the usage of security scope bookmarks and/or the
-    usage of the standard file dialog for discovering, accessing and storing persistent references
-    to files on the file system. In a future OS release, this key will not be supported.
-    
-    Note that a sandbox safe AudioComponent can function correctly in even the most severely
-    sandboxed process. This means that the process will have curtailed or no access to common system
-    resources like the file system, device drivers, the network, and communication with other
-    processes.
-    
-    When instantiating a sandbox unsafe AudioComponent in a sandboxed process, the system evaluates
-    the "resourceUsage" information against the restrictions the process is under. If the
-    "resourceUsage" will not violate those restrictions, the AudioComponent will be instantiated and
-    can be used as normal. Note that the system will set kAudioComponentFlag_SandboxSafe in the
-    AudioComponentDescription in this case.
-    
-    If the "resourceUsage" information includes things that can't be accessed from the process and
-    the process has the entitlement, "com.apple.security.temporary-exception.audio-unit-host", the
-    system will ask the user whether or not it is acceptable for the process to open the unsafe
-    AudioComponent. If the user says yes, the system will suspend the process's sandbox and allow
-    the unsafe AudioComponent to be opened and used.
-}
 
+//CF_ASSUME_NONNULL_BEGIN
 
 //=====================================================================================================================
 //#pragma mark Constants
@@ -359,36 +375,86 @@ uses MacTypes,CoreAudioTypes,Components,CFBase,CFDictionary;
 	will only return this component when performing a specific, non-wildcard search for the
 	component, i.e. with non-zero values of componentType, componentSubType, and
 	componentManufacturer. This can be useful when privately registering a component.
-	Available starting in Mac OS X 10.7 and iOS 5.0
 	
 	@constant	kAudioComponentFlag_SandboxSafe
 	
-	An AudioComponent sets this bit in it's componentFlags to indicate to the system that the
+	An AudioComponent sets this bit in its componentFlags to indicate to the system that the
 	AudioComponent is safe to open in a sandboxed process.
-	Available starting in Mac OS X 10.8.
+	
+	@constant	kAudioComponentFlag_IsV3AudioUnit
+	
+	The system sets this flag automatically when registering components which implement a version 3
+	Audio Unit.
+	
+	@constant	kAudioComponentFlag_RequiresAsyncInstantiation
+	
+	The system sets this flag automatically when registering components which require asynchronous
+	instantiation via AudioComponentInstantiate (v3 audio units with views).
+	
+	@constant	kAudioComponentFlag_CanLoadInProcess
+	
+	The system sets this flag automatically when registering components which can be loaded into
+	the current process. This is always true for V2 audio units; it depends on the packaging
+	in the case of a V3 audio unit.
+}
+type
+	AudioComponentFlags = UInt32;
+const
+	kAudioComponentFlag_Unsearchable = 1; (* CF_ENUM_AVAILABLE(10_7, 5_0) *)
+	kAudioComponentFlag_SandboxSafe = 2; (* CF_ENUM_AVAILABLE(10_8, 6_0) *)
+	kAudioComponentFlag_IsV3AudioUnit = 4; (* CF_ENUM_AVAILABLE(10_11, 9_0) *)
+	kAudioComponentFlag_RequiresAsyncInstantiation = 8; (* CF_ENUM_AVAILABLE(10_11, 9_0) *)
+	kAudioComponentFlag_CanLoadInProcess = $10; (* CF_ENUM_AVAILABLE(10_11, 9_0) *)
+
+{! @enum       AudioComponentInstantiationOptions
+    @brief      Options controlling component instantiation.
+    @discussion
+        Most component instances are loaded into the calling process.
+
+        A version 3 audio unit, however, can be loaded into a separate extension service process,
+        and this is the default behavior for these components. To be able to load one in-process
+        requires that the developer package the audio unit in a bundle separate from the application
+        extension, since an extension's main binary cannot be dynamically loaded into another
+        process.
+        
+        An OS X host may request in-process loading of such audio units using
+        kAudioComponentInstantiation_LoadInProcess.
+
+        kAudioComponentFlag_IsV3AudioUnit specifies whether an audio unit is implemented using API
+        version 3.
+
+        These options are just requests to the implementation. It may fail and fall back to the
+        default.
+    @constant kAudioComponentInstantiation_LoadOutOfProcess
+        Attempt to load the component into a separate extension process.
+    @constant kAudioComponentInstantiation_LoadInProcess
+        Attempt to load the component into the current process. Only available on OS X.
 }
+type
+	AudioComponentInstantiationOptions = UInt32;
 const
-	kAudioComponentFlag_Unsearchable = 1;
-	kAudioComponentFlag_SandboxSafe = 2;
+	kAudioComponentInstantiation_LoadOutOfProcess = 1; (* CF_ENUM_AVAILABLE(10_11,  9_0) *)
+	kAudioComponentInstantiation_LoadInProcess = 2; (* CF_ENUM_AVAILABLE(10_11,  NA) *)
+
 
 //=====================================================================================================================
 //#pragma mark Data Types
 
 {!
-	@struct			AudioComponentDescription
-	@discussion		A structure used to describe the unique and identifying IDs of an audio component 
-	@field			componentType
+    @struct         AudioComponentDescription
+    @discussion     A structure used to describe the unique and identifying IDs of an audio component 
+    @field          componentType
                         A unique 4-byte code identifying the generic type of an audio component
-	@field			componentSubType
-						the particular flavor of this instance
-	@field			componentManufacturer
-						vendor identification
-	@field			componentFlags
-						must be set to zero unless a known specific value is requested
-	@field			componentFlagsMask
-						must be set to zero unless a known specific value is requested
+    @field          componentSubType
+                        the particular flavor of this instance
+    @field          componentManufacturer
+                        vendor identification
+    @field          componentFlags
+                        must be set to zero unless a known specific value is requested
+    @field          componentFlagsMask
+                        must be set to zero unless a known specific value is requested
 }
-//#pragma pack(push, 4)
+{$packrecords 4}
 
 type
 	AudioComponentDescription = record
@@ -399,56 +465,46 @@ type
 		componentFlagsMask: UInt32;
 	end;
 	AudioComponentDescriptionPtr = ^AudioComponentDescription;
-//#pragma pack(pop)
+{$packrecords c}
 
 {!
-	@typedef		AudioComponent
-	@abstract		The type used to represent a class of particular audio components
+    @typedef        AudioComponent
+    @abstract       The type used to represent a class of particular audio components
     @discussion     An audio component is usually found through a search and is then uniquely
                     identified by the triple of an audio component's type, subtype and
                     manufacturer.
-					
-					It can have properties associated with it (such as a name, a version).
-					
+                    
+                    It can have properties associated with it (such as a name, a version).
+
                     It is then used as a factory (like a class in an object-oriented programming
-                    language) from which to create particular instances. The instances are used
-                    to do the actual work.
-					
-					For example:
-                    'aufx', 'dely', 'appl' describes the digital delay, audio unit effect from
-                    Apple, Inc. You can find this component through searching explicitly for the
-                    audio component that matches this pattern (this is an unique identifier -
-                    there is only one match to this triple ID). Then once found, the Apple delay
-                    effect audio unit can be created from its audio component and used to apply
-                    that effect to an audio signal. While the audio component is a singleton,
-                    you can of course create as many instances of a given audio component that
-                    you need to do the work you need to do.
+                    language) from which to create instances. The instances are used to do the
+                    actual work.
+
+                    For example: the AudioComponentDescription 'aufx'/'dely'/'appl' describes the
+                    delay audio unit effect from Apple, Inc. You can find this component by
+                    searching explicitly for the audio component that matches this pattern (this is
+                    an unique identifier - there is only one match to this triple ID). Then once
+                    found, instances of the Apple delay effect audio unit can be created from its
+                    audio component and used to apply that effect to an audio signal. A single
+                    component can create any number of component instances.
 }
 type
 	AudioComponent = ^OpaqueAudioComponent; { an opaque type }
 	OpaqueAudioComponent = record end;
 
 {!
-	@typedef		AudioComponentInstance
-	@abstract		The type used to represent an instance of a particular audio component
+    @typedef        AudioComponentInstance
+    @abstract       The type used to represent an instance of a particular audio component
     @discussion     An audio component instance is created from its factory/producer audio
                     component. It is the body of code that does the work.
-	
+    
                     A special note: While on the desktop this is typedef'd to a
                     ComponentInstanceRecord *, you should not assume that this will always be
                     compatible and usable with Component Manager calls.
 }
-//#if TARGET_OS_IPHONE
-{$ifc TARGET_OS_IPHONE}
 type
 	AudioComponentInstance = ^OpaqueAudioComponentInstance; { an opaque type }
 	OpaqueAudioComponentInstance = record end;
-//#else
-{$elsec}
-type
-	AudioComponentInstance = ComponentInstanceRecordPtr;
-//#endif
-{$endc}
 
 {!
     @typedef        AudioComponentMethod
@@ -495,11 +551,7 @@ type
     
     @param          inDesc
                         The AudioComponentDescription specifying the component to be instantiated.
-    @result         A pointer to a structure whose first member is a pointer to an
-                    AudioComponentPlugInInterface. Thus the return type could be considered
-                    AudioComponentPlugInInterface **, but since in practice it is never
-                    this basic type, but rather, AudioUnitPlugInInterface, AudioCodecPlugInInterface,
-                    etc., it is declared void * for simplicity.
+    @result         A pointer to a AudioComponentPlugInInterface structure.
 }
 type
 	AudioComponentFactoryFunction = function( const (*var*) inDesc: AudioComponentDescription ): AudioComponentPlugInInterfacePtr;
@@ -512,28 +564,31 @@ type
     @function       AudioComponentFindNext
     @abstract       Finds an audio component.
     @discussion     This function is used to find an audio component that is the closest match
-                    to the provided values.
+                    to the provided values. Note that the list of available components may change
+					dynamically in situations involving inter-app audio on iOS, or version 3
+					audio unit extensions. See kAudioComponentRegistrationsChangedNotification.
+
     @param          inComponent
                         If NULL, then the search starts from the beginning until an audio
                         component is found that matches the description provided by inDesc.
                         If non-NULL, then the search starts (continues) from the previously
                         found audio component specified by inComponent, and will return the next
                         found audio component.
-	@param			inDesc
+    @param          inDesc
                         The type, subtype and manufacturer fields are used to specify the audio
                         component to search for. A value of 0 (zero) for any of these fields is
                         a wildcard, so the first match found is returned.
     @result         An audio component that matches the search parameters, or NULL if none found.
 }
 function AudioComponentFindNext( inComponent: AudioComponent; const (*var*) inDesc: AudioComponentDescription ): AudioComponent; external name '_AudioComponentFindNext';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0) *)
+(* API_AVAILABLE(macos(10.6), ios(2.0), watchos(2.0), tvos(9.0)) *)
 
 {!
     @function       AudioComponentCount
     @abstract       Counts audio components.
     @discussion     Returns the number of AudioComponents that match the specified
                     AudioComponentDescription.
-	@param			inDesc
+    @param          inDesc
                         The type, subtype and manufacturer fields are used to specify the audio
                         components to count A value of 0 (zero) for any of these fields is a
                         wildcard, so will match any value for this field
@@ -541,48 +596,73 @@ function AudioComponentFindNext( inComponent: AudioComponent; const (*var*) inDe
                     search parameters.
 }
 function AudioComponentCount( const (*var*) inDesc: AudioComponentDescription ): UInt32; external name '_AudioComponentCount';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0) *)
+(* API_AVAILABLE(macos(10.6), ios(2.0), watchos(2.0), tvos(9.0)) *)
 
 {!
     @function       AudioComponentCopyName
     @abstract       Retrieves the name of an audio component.
     @discussion     the name of an audio component
-	@param			inComponent
-						the audio component (must not be NULL)
-	@param			outName
+    @param          inComponent
+                        the audio component (must not be NULL)
+    @param          outName
                         a CFString that is the name of the audio component. This string should
                         be released by the caller.
-    @result			an OSStatus result code.
+    @result         an OSStatus result code.
 }
 function AudioComponentCopyName( inComponent: AudioComponent; var outName: CFStringRef ): OSStatus; external name '_AudioComponentCopyName';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0) *)
+(* API_AVAILABLE(macos(10.6), ios(2.0), watchos(2.0), tvos(9.0)) *)
 
 {!
     @function       AudioComponentGetDescription
     @abstract       Retrieve an audio component's description.
     @discussion     This will return the fully specified audio component description for the
                     provided audio component.
-	@param			inComponent
-						the audio component (must not be NULL)
-	@param			outDesc
-						the audio component description for the specified audio component
-    @result			an OSStatus result code.
+    @param          inComponent
+                        the audio component (must not be NULL)
+    @param          outDesc
+                        the audio component description for the specified audio component
+    @result         an OSStatus result code.
 }
 function AudioComponentGetDescription( inComponent: AudioComponent; var outDesc: AudioComponentDescription ): OSStatus; external name '_AudioComponentGetDescription';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0) *)
+(* API_AVAILABLE(macos(10.6), ios(2.0), watchos(2.0), tvos(9.0)) *)
 
 {!
     @function       AudioComponentGetVersion
     @abstract       Retrieve an audio component's version.
     @discussion
-	@param			inComponent
-						the audio component (must not be NULL)
-	@param			outVersion
-						the audio component's version in the form of 0xMMMMmmDD (Major, Minor, Dot)
-    @result			an OSStatus result code.
+    @param          inComponent
+                        the audio component (must not be NULL)
+    @param          outVersion
+                        the audio component's version in the form of 0xMMMMmmDD (Major, Minor, Dot)
+    @result         an OSStatus result code.
 }
 function AudioComponentGetVersion( inComponent: AudioComponent; var outVersion: UInt32 ): OSStatus; external name '_AudioComponentGetVersion';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0) *)
+(* API_AVAILABLE(macos(10.6), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+(*
+Needs to be added to CocoaInt
+
+#if defined(__OBJC__) && !TARGET_OS_IPHONE
+@class NSImage;
+
+{!
+    @function       AudioComponentGetIcon
+    @abstract       Fetches an icon representing the component.
+    @param          comp
+        The component whose icon is to be retrieved.
+    @result
+        An autoreleased NSImage object.
+    @discussion
+        For a component originating in an app extension, the returned icon will be that of the
+        application containing the extension.
+        
+        For components loaded from bundles, the icon will be that of the bundle.
+}
+extern NSImage * __nullable
+AudioComponentGetIcon(AudioComponent comp)
+                                                                            API_AVAILABLE(macos(10.11)) API_UNAVAILABLE(ios, watchos, tvos);
+#endif
+*)
 
 {!
     @function       AudioComponentInstanceNew
@@ -595,26 +675,46 @@ function AudioComponentGetVersion( inComponent: AudioComponent; var outVersion:
                     creates a new instance of that component. This instance is then used to
                     perform the audio tasks for which it was designed (process, mix, synthesise,
                     etc.).
-	@param			inComponent
-						the audio component (must not be NULL)
-	@param			outInstance
-						the audio component instance
-    @result			an OSStatus result code.
+    @param          inComponent
+                        the audio component (must not be NULL)
+    @param          outInstance
+                        the audio component instance
+    @result         an OSStatus result code.
 }
 function AudioComponentInstanceNew( inComponent: AudioComponent; var outInstance: AudioComponentInstance ): OSStatus; external name '_AudioComponentInstanceNew';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0) *)
+(* API_AVAILABLE(macos(10.6), ios(2.0), watchos(2.0), tvos(9.0)) *)
+{!
+    @function       AudioComponentInstantiate
+    @abstract       Creates an audio component instance, asynchronously.
+    @discussion     This is an asynchronous version of AudioComponentInstanceNew(). It must be
+                    used to instantiate any component with kAudioComponentFlag_RequiresAsyncInstantiation
+                    set in its component flags. It may be used for other components as well.
+					
+					Note: Do not block the main thread while waiting for the completion handler
+					to be called; this can deadlock.
+    @param          inComponent
+                        the audio component
+    @param          inOptions
+                        see AudioComponentInstantiationOptions
+    @param          inCompletionHandler
+                        called in an arbitrary thread context when instantiation is complete.
+}
+type
+  TAudioComponentinstantiateCompletionHandler = reference to procedure(instance: AudioComponentInstance; status: OSStatus); cdecl;
+procedure AudioComponentInstantiate( inComponent: AudioComponent; inOptions: AudioComponentInstantiationOptions; inCompletionHandler: TAudioComponentinstantiateCompletionHandler); external name '_AudioComponentInstantiate';
+(* API_AVAILABLE(macos(10.11), ios(9.0), watchos(2.0), tvos(9.0)) *)
 
 {!
     @function       AudioComponentInstanceDispose
     @abstract       Disposes of an audio component instance.
     @discussion     This function will dispose the audio component instance that was created
                     with the New call. It will deallocate any resources that the instance was using.
-	@param			inInstance
-						the audio component instance to dispose (must not be NULL)
-    @result			an OSStatus result code.
+    @param          inInstance
+                        the audio component instance to dispose (must not be NULL)
+    @result         an OSStatus result code.
 }
 function AudioComponentInstanceDispose( inInstance: AudioComponentInstance ): OSStatus; external name '_AudioComponentInstanceDispose';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0) *)
+(* API_AVAILABLE(macos(10.6), ios(2.0), watchos(2.0), tvos(9.0)) *)
 
 // retrieves the class object associated with the instance
 {!
@@ -626,25 +726,25 @@ function AudioComponentInstanceDispose( inInstance: AudioComponentInstance ): OS
                     to retrieve general information about a particular audio component (its
                     name, version, etc) when one just has an audio component instance to work
                     with
-	@param			inInstance
-						the audio component instance (must not be NULL, and instance must be valid - that is, not disposed)
-    @result			a valid audio component or NULL if no component was found.
+    @param          inInstance
+                        the audio component instance (must not be NULL, and instance must be valid - that is, not disposed)
+    @result         a valid audio component or NULL if no component was found.
 }
 function AudioComponentInstanceGetComponent( inInstance: AudioComponentInstance ): AudioComponent; external name '_AudioComponentInstanceGetComponent';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_2_0) *)
+(* API_AVAILABLE(macos(10.6), ios(2.0), watchos(2.0), tvos(9.0)) *)
 
 {!
     @function       AudioComponentInstanceCanDo
     @discussion     Determines if an audio component instance implements a particular component
                     API call as signified by the specified selector identifier token.
-	@param			inInstance
-						the audio component instance
-	@param			inSelectorID
-						a number to signify the audio component API (component selector) as appropriate for the instance's component type.
-    @result			a boolean
+    @param          inInstance
+                        the audio component instance
+    @param          inSelectorID
+                        a number to signify the audio component API (component selector) as appropriate for the instance's component type.
+    @result         a boolean
 }
 function AudioComponentInstanceCanDo( inInstance: AudioComponentInstance; inSelectorID: SInt16 ): Boolean; external name '_AudioComponentInstanceCanDo';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_0) *)
+(* API_AVAILABLE(macos(10.6), ios(3.0), watchos(2.0), tvos(9.0)) *)
 
 {!
     @function       AudioComponentRegister
@@ -669,7 +769,7 @@ function AudioComponentInstanceCanDo( inInstance: AudioComponentInstance; inSele
     @result         an AudioComponent object
 }
 function AudioComponentRegister( const (*var*) inDesc: AudioComponentDescription; inName: CFStringRef; inVersion: UInt32; inFactory: AudioComponentFactoryFunction ): AudioComponent; external name '_AudioComponentRegister';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0) *)
+(* API_AVAILABLE(macos(10.7), ios(5.0), watchos(2.0), tvos(9.0)) *)
 
 {$ifc TARGET_OS_MAC}
 {!
@@ -680,13 +780,81 @@ function AudioComponentRegister( const (*var*) inDesc: AudioComponentDescription
                         The AudioComponent whose info is being fetched.
     @param          outConfigurationInfo
                         On exit, this is CFDictionaryRef that contains information describing the
-                        capabilities of the AudioComoponent. The specific information depends on the
+                        capabilities of the AudioComponent. The specific information depends on the
                         type of AudioComponent. The keys for the dictionary are defined in
                         AudioUnitProperties.h (or other headers as appropriate for the component type).
     @result         An OSStatus indicating success or failure.
 }
 function AudioComponentCopyConfigurationInfo( inComponent: AudioComponent; var outConfigurationInfo: CFDictionaryRef ): OSStatus; external name '_AudioComponentCopyConfigurationInfo';
 (* __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_NA) *)
+
+{!
+	 @enum		 AudioComponentValidationResult
+	 @abstract	 Constants for describing the result of validating an AudioComponent
+	 @constant	 kAudioComponentValidationResult_Passed
+					The AudioComponent passed validation.
+	 @constant	 kAudioComponentValidationResult_Failed
+					The AudioComponent failed validation.
+	 @constant	 kAudioComponentValidationResult_TimedOut
+					The validation operation timed out before completing.
+	 @constant	 kAudioComponentValidationResult_UnauthorizedError_Open
+					The AudioComponent failed validation during open operation as it is not authorized.
+	 @constant	 kAudioComponentValidationResult_UnauthorizedError_Init
+					The AudioComponent failed validation during initialization as it is not authorized.
+}
+type
+	AudioComponentValidationResult = UInt32;
+const
+	kAudioComponentValidationResult_Unknown = 0;
+	kAudioComponentValidationResult_Passed = 1;
+	kAudioComponentValidationResult_Failed = 2;
+	kAudioComponentValidationResult_TimedOut = 3;
+	kAudioComponentValidationResult_UnauthorizedError_Open = 4;
+	kAudioComponentValidationResult_UnauthorizedError_Init = 5;
+	
+{!
+	@define		kAudioComponentConfigurationInfo_ValidationResult
+	@abstract	Dictionary that contains the AudioComponentValidationResult for the component.
+	@discussion
+		The keys in this dictionary are the CPU architectures (e.g. "i386") that generated each result.
+}
+const
+	kAudioComponentConfigurationInfo_ValidationResult = 'ValidationResult';
+	
+{!
+	@function		AudioComponentValidate
+	@abstract		Tests a specified AudioComponent for API and behavioral conformance.
+	@discussion	Currently, only AudioUnits can can be validated.
+	@param			inComponent
+						The AudioComponent to validate.
+	@param			inValidationParameters
+						A CFDictionaryRef that contains parameters for the validation operation.
+						Passing NULL for this argument tells the system to use the default
+						parameters.
+	@param			outValidationResult
+						On exit, this is an AudioComponentValidationResult.
+	@result			an OSStatus result code.
+}
+function AudioComponentValidate( inComponent: AudioComponent; inValidationParameters: CFDictionaryRef; var outValidationResult: AudioComponentValidationResult): OSStatus; external name '_AudioComponentValidate';
+(* API_AVAILABLE(macos(10.7)) *)
+	
+{!
+	@define		kAudioComponentValidationParameter_TimeOut
+	@discussion This is a number that indicates the time in seconds to wait for a validation
+				operation to complete. Note that if a validation operation times out, it will return
+				kAudioComponentValidationResult_TimedOut as its result.
+}
+const
+	kAudioComponentValidationParameter_TimeOut = 'TimeOut';
+	
+{!
+	 @define	 kAudioComponentValidationParameter_ForceValidation
+	 @discussion
+	 	This is a bool that indicates to ignore the cached value and run validation on the specified
+	 	audio unit and update the cache.
+}
+const
+	kAudioComponentValidationParameter_ForceValidation = 'ForceValidation';
 {$endc}
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}

+ 979 - 0
packages/univint/src/AudioConverter.pas

@@ -0,0 +1,979 @@
+{!
+	@file		AudioConverter.h
+	@framework	AudioToolbox.framework
+	@copyright	(c) 1985-2015 by Apple, Inc., all rights reserved.
+    @abstract   API's to perform audio format conversions.
+    
+    @discussion
+		AudioConverters convert between various linear PCM and compressed
+		audio formats. Supported transformations include:
+
+		- PCM float/integer/bit depth conversions
+		- PCM sample rate conversion
+		- PCM interleaving and deinterleaving
+		- encoding PCM to compressed formats
+		- decoding compressed formats to PCM
+
+		A single AudioConverter may perform more than one
+		of the above transformations.
+}
+{  Pascal Translation: Jonas Maebe <[email protected]>, July 2019 }
+{
+    Modified for use with Free Pascal
+    Version 308
+    Please report any bugs to <[email protected]>
+}
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+{$mode macpas}
+{$modeswitch cblocks}
+{$packenum 1}
+{$macro on}
+{$inline on}
+{$calling mwpascal}
+
+unit AudioConverter;
+interface
+{$setc UNIVERSAL_INTERFACES_VERSION := $0400}
+{$setc GAP_INTERFACES_VERSION := $0308}
+
+{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
+    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
+{$endc}
+
+{$ifc defined CPUPOWERPC and defined CPUI386}
+	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
+{$endc}
+{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
+	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
+{$endc}
+
+{$ifc not defined __ppc__ and defined CPUPOWERPC32}
+	{$setc __ppc__ := 1}
+{$elsec}
+	{$setc __ppc__ := 0}
+{$endc}
+{$ifc not defined __ppc64__ and defined CPUPOWERPC64}
+	{$setc __ppc64__ := 1}
+{$elsec}
+	{$setc __ppc64__ := 0}
+{$endc}
+{$ifc not defined __i386__ and defined CPUI386}
+	{$setc __i386__ := 1}
+{$elsec}
+	{$setc __i386__ := 0}
+{$endc}
+{$ifc not defined __x86_64__ and defined CPUX86_64}
+	{$setc __x86_64__ := 1}
+{$elsec}
+	{$setc __x86_64__ := 0}
+{$endc}
+{$ifc not defined __arm__ and defined CPUARM}
+	{$setc __arm__ := 1}
+{$elsec}
+	{$setc __arm__ := 0}
+{$endc}
+{$ifc not defined __arm64__ and defined CPUAARCH64}
+  {$setc __arm64__ := 1}
+{$elsec}
+  {$setc __arm64__ := 0}
+{$endc}
+
+{$ifc defined cpu64}
+  {$setc __LP64__ := 1}
+{$elsec}
+  {$setc __LP64__ := 0}
+{$endc}
+
+
+{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
+	{$error Conflicting definitions for __ppc__ and __i386__}
+{$endc}
+
+{$ifc defined __ppc__ and __ppc__}
+	{$setc TARGET_CPU_PPC := TRUE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __ppc64__ and __ppc64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := TRUE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __i386__ and __i386__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := TRUE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __x86_64__ and __x86_64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := TRUE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __arm__ and __arm__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := TRUE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := TRUE}
+{$elifc defined __arm64__ and __arm64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := TRUE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := TRUE}
+{$elsec}
+	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
+{$endc}
+
+{$ifc defined __LP64__ and __LP64__ }
+  {$setc TARGET_CPU_64 := TRUE}
+{$elsec}
+  {$setc TARGET_CPU_64 := FALSE}
+{$endc}
+
+{$ifc defined FPC_BIG_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
+{$elifc defined FPC_LITTLE_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
+{$elsec}
+	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
+{$endc}
+{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
+{$setc CALL_NOT_IN_CARBON := FALSE}
+{$setc OLDROUTINENAMES := FALSE}
+{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
+{$setc OPAQUE_UPP_TYPES := TRUE}
+{$setc OTCARBONAPPLICATION := TRUE}
+{$setc OTKERNEL := FALSE}
+{$setc PM_USE_SESSION_APIS := TRUE}
+{$setc TARGET_API_MAC_CARBON := TRUE}
+{$setc TARGET_API_MAC_OS8 := FALSE}
+{$setc TARGET_API_MAC_OSX := TRUE}
+{$setc TARGET_CARBON := TRUE}
+{$setc TARGET_CPU_68K := FALSE}
+{$setc TARGET_CPU_MIPS := FALSE}
+{$setc TARGET_CPU_SPARC := FALSE}
+{$setc TARGET_OS_UNIX := FALSE}
+{$setc TARGET_OS_WIN32 := FALSE}
+{$setc TARGET_RT_MAC_68881 := FALSE}
+{$setc TARGET_RT_MAC_CFM := FALSE}
+{$setc TARGET_RT_MAC_MACHO := TRUE}
+{$setc TYPED_FUNCTION_POINTERS := TRUE}
+{$setc TYPE_BOOL := FALSE}
+{$setc TYPE_EXTENDED := FALSE}
+{$setc TYPE_LONGLONG := TRUE}
+uses MacTypes,CoreAudioTypes;
+{$endc} {not MACOSALLINCLUDE}
+
+{$ALIGN POWER}
+
+//==================================================================================================
+
+{!
+    @header     AudioConverter.h
+    
+}
+
+//=============================================================================
+//  Includes
+//=============================================================================
+
+
+//CF_ASSUME_NONNULL_BEGIN
+
+
+//=============================================================================
+//  Theory of Operation
+//=============================================================================
+
+//=============================================================================
+//  Types specific to the Audio Converter API
+//=============================================================================
+
+{!
+    @typedef    AudioConverterRef
+    @abstract   A reference to an AudioConverter object.
+}
+type
+	AudioConverterRef = ^OpaqueAudioConverter; { an opaque type }
+	OpaqueAudioConverter = record end;
+
+type
+	AudioConverterPropertyID = UInt32;
+
+//=============================================================================
+//  Standard Properties
+//=============================================================================
+
+{!
+    @enum       AudioConverterPropertyID
+    @abstract   The properties of an AudioConverter, accessible via AudioConverterGetProperty()
+                and AudioConverterSetProperty().
+    
+    @constant   kAudioConverterPropertyMinimumInputBufferSize
+                    a UInt32 that indicates the size in bytes of the smallest buffer of input
+                    data that can be supplied via the AudioConverterInputProc or as the input to
+                    AudioConverterConvertBuffer
+    @constant   kAudioConverterPropertyMinimumOutputBufferSize
+                    a UInt32 that indicates the size in bytes of the smallest buffer of output
+                    data that can be supplied to AudioConverterFillComplexBuffer or as the output to
+                    AudioConverterConvertBuffer
+    @constant   kAudioConverterPropertyMaximumInputBufferSize
+                    DEPRECATED. The AudioConverter input proc may be passed any number of packets of data.
+                    If fewer are packets are returned than required, then the input proc will be called again.
+                    If more packets are passed than required, they will remain in the client's buffer and be 
+                    consumed as needed.
+    @constant   kAudioConverterPropertyMaximumInputPacketSize
+                    a UInt32 that indicates the size in bytes of the largest single packet of
+                    data in the input format. This is mostly useful for variable bit rate
+                    compressed data (decoders).
+    @constant   kAudioConverterPropertyMaximumOutputPacketSize
+                    a UInt32 that indicates the size in bytes of the largest single packet of
+                    data in the output format. This is mostly useful for variable bit rate
+                    compressed data (encoders).
+    @constant   kAudioConverterPropertyCalculateInputBufferSize
+                    a UInt32 that on input holds a size in bytes that is desired for the output
+                    data. On output, it will hold the size in bytes of the input buffer required
+                    to generate that much output data. Note that some converters cannot do this
+                    calculation.
+    @constant   kAudioConverterPropertyCalculateOutputBufferSize
+                    a UInt32 that on input holds a size in bytes that is desired for the input
+                    data. On output, it will hold the size in bytes of the output buffer
+                    required to hold the output data that will be generated. Note that some
+                    converters cannot do this calculation.
+    @constant   kAudioConverterPropertyInputCodecParameters
+                    The value of this property varies from format to format and is considered
+                    private to the format. It is treated as a buffer of untyped data.
+    @constant   kAudioConverterPropertyOutputCodecParameters
+                    The value of this property varies from format to format and is considered
+                    private to the format. It is treated as a buffer of untyped data.
+    @constant   kAudioConverterSampleRateConverterAlgorithm
+                    DEPRECATED: please use kAudioConverterSampleRateConverterComplexity instead
+    @constant   kAudioConverterSampleRateConverterComplexity
+                    An OSType that specifies the sample rate converter algorithm to use (as defined in
+                    AudioToolbox/AudioUnitProperties.h)
+    @constant   kAudioConverterSampleRateConverterQuality
+                    A UInt32 that specifies rendering quality of the sample rate converter (see
+                    enum constants below)
+    @constant   kAudioConverterSampleRateConverterInitialPhase
+                    A Float64 with value 0.0 <= x < 1.0 giving the initial subsample position of the 
+                    sample rate converter.
+    @constant   kAudioConverterCodecQuality
+                    A UInt32 that specifies rendering quality of a codec (see enum constants
+                    below)
+    @constant   kAudioConverterPrimeMethod
+                    a UInt32 specifying priming method (usually for sample-rate converter) see
+                    explanation for struct AudioConverterPrimeInfo below along with enum
+                    constants
+    @constant   kAudioConverterPrimeInfo
+                    A pointer to AudioConverterPrimeInfo (see explanation for struct
+                    AudioConverterPrimeInfo below)
+    @constant   kAudioConverterChannelMap
+                    An array of SInt32's.  The size of the array is the number of output
+                    channels, and each element specifies which input channel's data is routed to
+                    that output channel (using a 0-based index of the input channels), or -1 if
+                    no input channel is to be routed to that output channel.  The default
+                    behavior is as follows. I = number of input channels, O = number of output
+                    channels. When I > O, the first O inputs are routed to the first O outputs,
+                    and the remaining puts discarded.  When O > I, the first I inputs are routed
+                    to the first O outputs, and the remaining outputs are zeroed.
+                    
+                    A simple example for splitting mono input to stereo output (instead of routing
+                    the input to only the first output channel):
+                    
+<pre>
+   // this should be as large as the number of output channels:
+  SInt32 channelMap[2] = ( 0, 0 );
+  AudioConverterSetProperty(theConverter, kAudioConverterChannelMap, 
+    sizeof(channelMap), channelMap);
+</pre>
+    @constant   kAudioConverterDecompressionMagicCookie
+                    A void * pointing to memory set up by the caller. Required by some formats
+                    in order to decompress the input data.
+    @constant   kAudioConverterCompressionMagicCookie
+                    A void * pointing to memory set up by the caller. Returned by the converter
+                    so that it may be stored along with the output data. It can then be passed
+                    back to the converter for decompression at a later time.
+    @constant   kAudioConverterEncodeBitRate
+                    A UInt32 containing the number of bits per second to aim for when encoding
+                    data. Some decoders will also allow you to get this property to discover the bit rate.
+    @constant   kAudioConverterEncodeAdjustableSampleRate
+                    For encoders where the AudioConverter was created with an output sample rate
+                    of zero, and the codec can do rate conversion on its input, this provides a
+                    way to set the output sample rate. The property value is a Float64.
+    @constant   kAudioConverterInputChannelLayout
+                    The property value is an AudioChannelLayout.
+    @constant   kAudioConverterOutputChannelLayout
+                    The property value is an AudioChannelLayout.
+    @constant   kAudioConverterApplicableEncodeBitRates
+                    The property value is an array of AudioValueRange describing applicable bit
+                    rates based on current settings.
+    @constant   kAudioConverterAvailableEncodeBitRates
+                    The property value is an array of AudioValueRange describing available bit
+                    rates based on the input format. You can get all available bit rates from
+                    the AudioFormat API.
+    @constant   kAudioConverterApplicableEncodeSampleRates
+                    The property value is an array of AudioValueRange describing applicable
+                    sample rates based on current settings.
+    @constant   kAudioConverterAvailableEncodeSampleRates
+                    The property value is an array of AudioValueRange describing available
+                    sample rates based on the input format. You can get all available sample
+                    rates from the AudioFormat API.
+    @constant   kAudioConverterAvailableEncodeChannelLayoutTags
+                    The property value is an array of AudioChannelLayoutTags for the format and
+                    number of channels specified in the input format going to the encoder.
+    @constant   kAudioConverterCurrentOutputStreamDescription
+                    Returns the current completely specified output AudioStreamBasicDescription.
+                    For example when encoding to AAC, your original output stream description
+                    will not have been completely filled out.
+    @constant   kAudioConverterCurrentInputStreamDescription
+                    Returns the current completely specified input AudioStreamBasicDescription.
+    @constant   kAudioConverterPropertySettings
+                    Returns the a CFArray of property settings for converters.
+    @constant   kAudioConverterPropertyBitDepthHint
+                    An SInt32 of the source bit depth to preserve. This is a hint to some
+                    encoders like lossless about how many bits to preserve in the input. The
+                    converter usually tries to preserve as many as possible, but a lossless
+                    encoder will do poorly if more bits are supplied than are desired in the
+                    output. The bit depth is expressed as a negative number if the source was floating point,
+                    e.g. -32 for float, -64 for double.
+    @constant   kAudioConverterPropertyFormatList
+                    An array of AudioFormatListItem structs describing all the data formats produced by the
+                    encoder end of the AudioConverter. If the ioPropertyDataSize parameter indicates that
+                    outPropertyData is sizeof(AudioFormatListItem), then only the best format is returned.
+                    This property may be used for example to discover all the data formats produced by the AAC_HE2
+                    (AAC High Efficiency vers. 2) encoder.
+}
+const
+	kAudioConverterPropertyMinimumInputBufferSize = FourCharCode('mibs');
+	kAudioConverterPropertyMinimumOutputBufferSize = FourCharCode('mobs');
+	kAudioConverterPropertyMaximumInputBufferSize = FourCharCode('xibs');
+	kAudioConverterPropertyMaximumInputPacketSize = FourCharCode('xips');
+	kAudioConverterPropertyMaximumOutputPacketSize = FourCharCode('xops');
+	kAudioConverterPropertyCalculateInputBufferSize = FourCharCode('cibs');
+	kAudioConverterPropertyCalculateOutputBufferSize = FourCharCode('cobs');
+	kAudioConverterPropertyInputCodecParameters = FourCharCode('icdp');
+	kAudioConverterPropertyOutputCodecParameters = FourCharCode('ocdp');
+	kAudioConverterSampleRateConverterAlgorithm = FourCharCode('srci');
+	kAudioConverterSampleRateConverterComplexity = FourCharCode('srca');
+	kAudioConverterSampleRateConverterQuality = FourCharCode('srcq');
+	kAudioConverterSampleRateConverterInitialPhase = FourCharCode('srcp');
+	kAudioConverterCodecQuality = FourCharCode('cdqu');
+	kAudioConverterPrimeMethod = FourCharCode('prmm');
+	kAudioConverterPrimeInfo = FourCharCode('prim');
+	kAudioConverterChannelMap = FourCharCode('chmp');
+	kAudioConverterDecompressionMagicCookie = FourCharCode('dmgc');
+	kAudioConverterCompressionMagicCookie = FourCharCode('cmgc');
+	kAudioConverterEncodeBitRate = FourCharCode('brat');
+	kAudioConverterEncodeAdjustableSampleRate = FourCharCode('ajsr');
+	kAudioConverterInputChannelLayout = FourCharCode('icl ');
+	kAudioConverterOutputChannelLayout = FourCharCode('ocl ');
+	kAudioConverterApplicableEncodeBitRates = FourCharCode('aebr');
+	kAudioConverterAvailableEncodeBitRates = FourCharCode('vebr');
+	kAudioConverterApplicableEncodeSampleRates = FourCharCode('aesr');
+	kAudioConverterAvailableEncodeSampleRates = FourCharCode('vesr');
+	kAudioConverterAvailableEncodeChannelLayoutTags = FourCharCode('aecl');
+	kAudioConverterCurrentOutputStreamDescription = FourCharCode('acod');
+	kAudioConverterCurrentInputStreamDescription = FourCharCode('acid');
+	kAudioConverterPropertySettings = FourCharCode('acps');
+	kAudioConverterPropertyBitDepthHint = FourCharCode('acbd');
+	kAudioConverterPropertyFormatList = FourCharCode('flst'); 
+
+
+//=============================================================================
+//  
+//=============================================================================
+
+{!
+    @enum       Mac OS X AudioConverter Properties
+
+    @constant   kAudioConverterPropertyDithering
+					A UInt32. Set to a value from the enum of dithering algorithms below. 
+					Zero means no dithering and is the default. (Mac OS X only.)
+    @constant   kAudioConverterPropertyDitherBitDepth
+					A UInt32. Dither is applied at this bit depth.  (Mac OS X only.)
+
+}
+const
+	kAudioConverterPropertyDithering = FourCharCode('dith');
+	kAudioConverterPropertyDitherBitDepth = FourCharCode('dbit'); 
+
+{!
+    @enum       Dithering algorithms
+
+    @abstract   Constants to be used as the value for kAudioConverterPropertyDithering.
+
+    @constant   kDitherAlgorithm_TPDF             Dither signal is generated by a white noise source with a triangular probability density function
+    @constant   kDitherAlgorithm_NoiseShaping     Use a static, perceptually weighted noise shaped dither
+}
+const
+	kDitherAlgorithm_TPDF = 1;
+	kDitherAlgorithm_NoiseShaping = 2; 
+
+{!
+    @enum       Quality constants
+
+    @abstract   Constants to be used with kAudioConverterSampleRateConverterQuality.
+
+    @constant   kAudioConverterQuality_Max          maximum quality
+    @constant   kAudioConverterQuality_High         high quality
+    @constant   kAudioConverterQuality_Medium       medium quality
+    @constant   kAudioConverterQuality_Low          low quality
+    @constant   kAudioConverterQuality_Min          minimum quality
+}
+const
+	kAudioConverterQuality_Max = $7F;
+	kAudioConverterQuality_High = $60;
+	kAudioConverterQuality_Medium = $40;
+	kAudioConverterQuality_Low = $20;
+	kAudioConverterQuality_Min = 0; 
+
+
+{!
+    @enum           Sample Rate Converter Complexity
+    @constant       kAudioConverterSampleRateConverterComplexity_Linear
+    @discussion         Linear interpolation. lowest quality, cheapest.
+						InitialPhase and PrimeMethod properties are not operative with this mode.
+    @constant       kAudioConverterSampleRateConverterComplexity_Normal
+    @discussion         Normal quality sample rate conversion.
+    @constant       kAudioConverterSampleRateConverterComplexity_Mastering
+    @discussion         Mastering quality sample rate conversion. More expensive.
+    @constant       kAudioConverterSampleRateConverterComplexity_MinimumPhase
+    @discussion         Minimum phase impulse response. Stopband attenuation varies with quality setting.
+                        The InitialPhase and PrimeMethod properties are not operative with this mode.
+                        There are three levels of quality provided.
+                            kAudioConverterQuality_Low (or Min)  : noise floor to -96 dB
+                            kAudioConverterQuality_Medium        : noise floor to -144 dB
+                            kAudioConverterQuality_High (or Max) : noise floor to -160 dB (this uses double precision internally)
+						Quality equivalences to the other complexity modes are very roughly as follows:
+							MinimumPhase Low    is somewhat better than Normal Medium.
+							MinimumPhase Medium is similar to Normal Max.
+							MinimumPhase High   is similar to Mastering Low.
+						In general, MinimumPhase performs better than Normal and Mastering for the equivalent qualities listed above.
+						MinimumPhase High is several times faster than Mastering Low.
+ 
+}
+const
+	kAudioConverterSampleRateConverterComplexity_Linear = FourCharCode('line');    // linear interpolation
+	kAudioConverterSampleRateConverterComplexity_Normal = FourCharCode('norm');    // normal quality range, the default
+	kAudioConverterSampleRateConverterComplexity_Mastering = FourCharCode('bats');    // higher quality range, more expensive
+	kAudioConverterSampleRateConverterComplexity_MinimumPhase = FourCharCode('minp'); 	// minimum phase impulse response.
+
+
+{!
+    @enum       Prime method constants
+
+    @abstract   Constants to be used with kAudioConverterPrimeMethod.
+    
+    @constant   kConverterPrimeMethod_Pre
+                    Primes with leading + trailing input frames.
+    @constant   kConverterPrimeMethod_Normal
+                    Only primes with trailing (zero latency). Leading frames are assumed to be
+                    silence.
+    @constant   kConverterPrimeMethod_None
+                    Acts in "latency" mode. Both leading and trailing frames assumed to be
+                    silence.
+}
+const
+	kConverterPrimeMethod_Pre = 0;
+	kConverterPrimeMethod_Normal = 1;
+	kConverterPrimeMethod_None = 2; 
+
+{!
+    @struct     AudioConverterPrimeInfo
+    @abstract   Specifies priming information.
+    
+    @field      leadingFrames
+        Specifies the number of leading (previous) input frames, relative to the normal/desired
+        start input frame, required by the converter to perform a high quality conversion. If
+        using kConverterPrimeMethod_Pre, the client should "pre-seek" the input stream provided
+        through the input proc by leadingFrames. If no frames are available previous to the
+        desired input start frame (because, for example, the desired start frame is at the very
+        beginning of available audio), then provide "leadingFrames" worth of initial zero frames
+        in the input proc.  Do not "pre-seek" in the default case of
+        kConverterPrimeMethod_Normal or when using kConverterPrimeMethod_None.
+
+    @field      trailingFrames
+        Specifies the number of trailing input frames (past the normal/expected end input frame)
+        required by the converter to perform a high quality conversion.  The client should be
+        prepared to provide this number of additional input frames except when using
+        kConverterPrimeMethod_None. If no more frames of input are available in the input stream
+        (because, for example, the desired end frame is at the end of an audio file), then zero
+        (silent) trailing frames will be synthesized for the client.
+            
+    @discussion
+        When using AudioConverterFillComplexBuffer() (either a single call or a series of calls), some
+        conversions, particularly involving sample-rate conversion, ideally require a certain
+        number of input frames previous to the normal start input frame and beyond the end of
+        the last expected input frame in order to yield high-quality results.
+        
+        These are expressed in the leadingFrames and trailingFrames members of the structure.
+        
+        The very first call to AudioConverterFillComplexBuffer(), or first call after
+        AudioConverterReset(), will request additional input frames beyond those normally
+        expected in the input proc callback to fulfill this first AudioConverterFillComplexBuffer()
+        request. The number of additional frames requested, depending on the prime method, will
+        be approximately:
+
+        <pre>
+            kConverterPrimeMethod_Pre       leadingFrames + trailingFrames
+            kConverterPrimeMethod_Normal    trailingFrames
+            kConverterPrimeMethod_None      0
+        </pre>
+
+        Thus, in effect, the first input proc callback(s) may provide not only the leading
+        frames, but also may "read ahead" by an additional number of trailing frames depending
+        on the prime method.
+
+        kConverterPrimeMethod_None is useful in a real-time application processing live input,
+        in which case trailingFrames (relative to input sample rate) of through latency will be
+        seen at the beginning of the output of the AudioConverter.  In other real-time
+        applications such as DAW systems, it may be possible to provide these initial extra
+        audio frames since they are stored on disk or in memory somewhere and
+        kConverterPrimeMethod_Pre may be preferable.  The default method is
+        kConverterPrimeMethod_Normal, which requires no pre-seeking of the input stream and
+        generates no latency at the output.
+}
+type
+	AudioConverterPrimeInfo = record
+		leadingFrames: UInt32;
+		trailingFrames: UInt32;
+	end;
+	AudioConverterPrimeInfoPtr = ^AudioConverterPrimeInfo;
+
+//=============================================================================
+//  Errors
+//=============================================================================
+const
+	kAudioConverterErr_FormatNotSupported = FourCharCode('fmt?');
+	kAudioConverterErr_OperationNotSupported = $6F703F3F;  // 'op??', integer used because of trigraph
+	kAudioConverterErr_PropertyNotSupported = FourCharCode('prop');
+	kAudioConverterErr_InvalidInputSize = FourCharCode('insz');
+	kAudioConverterErr_InvalidOutputSize = FourCharCode('otsz'); 
+        // e.g. byte size is not a multiple of the frame size
+	kAudioConverterErr_UnspecifiedError = FourCharCode('what');
+	kAudioConverterErr_BadPropertySizeError = FourCharCode('!siz');
+	kAudioConverterErr_RequiresPacketDescriptionsError = FourCharCode('!pkd');
+	kAudioConverterErr_InputSampleRateOutOfRange = FourCharCode('!isr');
+	kAudioConverterErr_OutputSampleRateOutOfRange = FourCharCode('!osr'); 
+
+
+//=============================================================================
+//  Routines
+//=============================================================================
+
+//-----------------------------------------------------------------------------
+{!
+    @function   AudioConverterNew
+    @abstract   Create a new AudioConverter.
+
+    @param      inSourceFormat
+                    The format of the source audio to be converted.
+    @param      inDestinationFormat
+                    The destination format to which the audio is to be converted.
+    @param      outAudioConverter
+                    On successful return, points to a new AudioConverter instance.
+    @result     An OSStatus result code.
+    
+    @discussion
+                For a pair of linear PCM formats, the following conversions
+                are supported:
+                
+                <ul>
+                <li>addition and removal of channels, when the stream descriptions'
+                mChannelsPerFrame does not match. Channels may also be reordered and removed
+                using the kAudioConverterChannelMap property.</li>
+                <li>sample rate conversion</li>
+                <li>interleaving/deinterleaving, when the stream descriptions' (mFormatFlags &
+                kAudioFormatFlagIsNonInterleaved) does not match.</li>
+                <li>conversion between any pair of the following formats:</li>
+                    <ul>
+                    <li>8 bit integer, signed or unsigned</li>
+                    <li>16, 24, or 32-bit integer, big- or little-endian. Other integral
+                    bit depths, if high-aligned and non-packed, are also supported</li>
+                    <li>32 and 64-bit float, big- or little-endian.</li>
+                    </ul>
+                </ul>
+                
+                Also, encoding and decoding between linear PCM and compressed formats is
+                supported. Functions in AudioToolbox/AudioFormat.h return information about the
+                supported formats. When using a codec, you can use any supported PCM format (as
+                above); the converter will perform any necessary additional conversion between
+                your PCM format and the one created or consumed by the codec.
+}
+function AudioConverterNew( const (*var*) inSourceFormat: AudioStreamBasicDescription; const (*var*) inDestinationFormat: AudioStreamBasicDescription; var outAudioConverter: AudioConverterRef {__nullable * __nonnull} ): OSStatus; external name '_AudioConverterNew';
+(* API_AVAILABLE(macos(10.1), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+
+//-----------------------------------------------------------------------------
+{!
+    @function   AudioConverterNewSpecific
+    @abstract   Create a new AudioConverter using specific codecs.
+
+    @param      inSourceFormat
+                    The format of the source audio to be converted.
+    @param      inDestinationFormat
+                    The destination format to which the audio is to be converted.
+    @param      inNumberClassDescriptions
+                    The number of class descriptions.
+    @param      inClassDescriptions
+                    AudioClassDescriptions specifiying the codec to instantiate.
+    @param      outAudioConverter
+                    On successful return, points to a new AudioConverter instance.
+    @result     An OSStatus result code.
+    
+    @discussion
+                This function is identical to AudioConverterNew(), except that the client may
+                explicitly choose which codec to instantiate if there is more than one choice.
+}
+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';
+(* API_AVAILABLE(macos(10.4), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+//-----------------------------------------------------------------------------
+{!
+    @function   AudioConverterDispose
+    @abstract   Destroy an AudioConverter.
+
+    @param      inAudioConverter
+                    The AudioConverter to dispose.
+    @result     An OSStatus result code.
+}
+function AudioConverterDispose( inAudioConverter: AudioConverterRef ): OSStatus; external name '_AudioConverterDispose';
+(* API_AVAILABLE(macos(10.1), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+//-----------------------------------------------------------------------------
+{!
+    @function   AudioConverterReset
+    @abstract   Reset an AudioConverter
+
+    @param      inAudioConverter
+                    The AudioConverter to reset.
+    @result     An OSStatus result code.
+    
+    @discussion
+                Should be called whenever there is a discontinuity in the source audio stream
+                being provided to the converter. This will flush any internal buffers in the
+                converter.
+}
+
+function AudioConverterReset( inAudioConverter: AudioConverterRef ): OSStatus; external name '_AudioConverterReset';
+(* API_AVAILABLE(macos(10.1), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+//-----------------------------------------------------------------------------
+{!
+    @function   AudioConverterGetPropertyInfo
+    @abstract   Returns information about an AudioConverter property.
+
+    @param      inAudioConverter
+                    The AudioConverter to query.
+    @param      inPropertyID
+                    The property to query.
+    @param      outSize
+                    If non-null, on exit, the maximum size of the property value in bytes.
+    @param      outWritable
+                    If non-null, on exit, indicates whether the property value is writable.
+    @result     An OSStatus result code.
+}
+function AudioConverterGetPropertyInfo( inAudioConverter: AudioConverterRef; inPropertyID: AudioConverterPropertyID; outSize: UInt32Ptr {* __nullable}; outWritable: BooleanPtr {* __nullable} ): OSStatus; external name '_AudioConverterGetPropertyInfo';
+(* API_AVAILABLE(macos(10.1), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+//-----------------------------------------------------------------------------
+{!
+    @function   AudioConverterGetProperty
+    @abstract   Returns an AudioConverter property value.
+
+    @param      inAudioConverter
+                    The AudioConverter to query.
+    @param      inPropertyID
+                    The property to fetch.
+    @param      ioPropertyDataSize
+                    On entry, the size of the memory pointed to by outPropertyData. On 
+                    successful exit, the size of the property value.
+    @param      outPropertyData
+                    On exit, the property value.
+    @result     An OSStatus result code.
+}
+function AudioConverterGetProperty( inAudioConverter: AudioConverterRef; inPropertyID: AudioConverterPropertyID; var ioPropertyDataSize: UInt32; outPropertyData: UnivPtr ): OSStatus; external name '_AudioConverterGetProperty';
+(* API_AVAILABLE(macos(10.1), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+//-----------------------------------------------------------------------------
+{!
+    @function   AudioConverterSetProperty
+    @abstract   Sets an AudioConverter property value.
+
+    @param      inAudioConverter
+                    The AudioConverter to modify.
+    @param      inPropertyID
+                    The property to set.
+    @param      inPropertyDataSize
+                    The size in bytes of the property value.
+    @param      inPropertyData
+                    Points to the new property value.
+    @result     An OSStatus result code.
+}
+function AudioConverterSetProperty( inAudioConverter: AudioConverterRef; inPropertyID: AudioConverterPropertyID; inPropertyDataSize: UInt32; inPropertyData: {const} UnivPtr ): OSStatus; external name '_AudioConverterSetProperty';
+(* API_AVAILABLE(macos(10.1), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+//-----------------------------------------------------------------------------
+{!
+    @typedef    AudioConverterInputDataProc
+    @abstract   Callback function for supplying input data to AudioConverterFillBuffer.
+
+    @param      inAudioConverter
+                    The AudioConverter requesting input.
+    @param      ioDataSize
+                    On entry, the minimum number of bytes of audio data the converter
+                    would like in order to fulfill its current FillBuffer request.
+                    On exit, the number of bytes of audio data actually being provided
+                    for input, or 0 if there is no more input.
+    @param      outData
+                    On exit, *outData should point to the audio data being provided
+                    for input.
+    @param      inUserData
+                    The inInputDataProcUserData parameter passed to AudioConverterFillBuffer().
+    @result     An OSStatus result code.
+    
+    @discussion
+                <b>NOTE:</b> This API is now deprecated, 
+                use AudioConverterFillComplexBuffer instead.
+
+                This callback function supplies input to AudioConverterFillBuffer.
+                
+                The AudioConverter requests a minimum amount of data (*ioDataSize). The callback
+                may return any amount of data. If it is less than than the minimum, the callback
+                will simply be called again in the near future.
+
+                The callback supplies a pointer to a buffer of audio data. The callback is
+                responsible for not freeing or altering this buffer until it is called again.
+                
+                If the callback returns an error, it must return zero bytes of data.
+                AudioConverterFillBuffer will stop producing output and return whatever output
+                has already been produced to its caller, along with the error code. This
+                mechanism can be used when an input proc has temporarily run out of data, but
+                has not yet reached end of stream.
+}
+type
+	AudioConverterInputDataProc = function( inAudioConverter: AudioConverterRef; var ioDataSize: UInt32; var outData: UnivPtr {__nonnull * __nonnull}; inUserData: UnivPtr {__nullable} ): OSStatus;
+
+//-----------------------------------------------------------------------------
+(*
+{!
+    @function   AudioConverterFillBuffer
+    @abstract   Converts data supplied by an input callback function.
+
+    @param      inAudioConverter
+                    The AudioConverter to use.
+    @param      inInputDataProc
+                    A callback function which supplies the input data.
+    @param      inInputDataProcUserData
+                    A value for the use of the callback function.
+    @param      ioOutputDataSize
+                    On entry, the size of the buffer pointed to by outOutputData.
+                    On exit, the number of bytes written to outOutputData
+    @param      outOutputData
+                    The buffer into which the converted data is written.
+    @result     An OSStatus result code.
+    
+    @discussion
+                <b>NOTE:</b> This API is now deprecated, 
+                use AudioConverterFillComplexBuffer instead.
+
+                Produces a buffer of output data from an AudioConverter. The supplied input
+                callback function is called whenever necessary.             
+}
+extern OSStatus
+AudioConverterFillBuffer(   AudioConverterRef               inAudioConverter,
+                            AudioConverterInputDataProc     inInputDataProc,
+                            void * __nullable               inInputDataProcUserData,
+                            UInt32 *                        ioOutputDataSize,
+                            void *                          outOutputData)
+                            
+                                API_DEPRECATED("no longer supported", macos(10.1, 10.5)) API_UNAVAILABLE(ios, watchos, tvos);
+*)
+//-----------------------------------------------------------------------------
+{!
+    @function   AudioConverterConvertBuffer
+    @abstract   Converts data from an input buffer to an output buffer.
+
+    @param      inAudioConverter
+                    The AudioConverter to use.
+    @param      inInputDataSize
+                    The size of the buffer inInputData.
+    @param      inInputData
+                    The input audio data buffer.
+    @param      ioOutputDataSize
+                    On entry, the size of the buffer outOutputData. On exit, the number of bytes
+                    written to outOutputData.
+    @param      outOutputData
+                    The output data buffer.
+    @result
+                Produces a buffer of output data from an AudioConverter, using the supplied
+                input buffer.
+    @discussion
+                <b>WARNING:</b> this function will fail for any conversion where there is a
+                variable relationship between the input and output data buffer sizes. This
+                includes sample rate conversions and most compressed formats. In these cases,
+                use AudioConverterFillComplexBuffer. Generally this function is only appropriate for
+                PCM-to-PCM conversions where there is no sample rate conversion.
+}
+function AudioConverterConvertBuffer( inAudioConverter: AudioConverterRef; inInputDataSize: UInt32; inInputData: {const} UnivPtr; var ioOutputDataSize: UInt32; outOutputData: UnivPtr ): OSStatus; external name '_AudioConverterConvertBuffer';
+(* API_AVAILABLE(macos(10.1), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+//-----------------------------------------------------------------------------
+{!
+    @typedef    AudioConverterComplexInputDataProc
+    @abstract   Callback function for supplying input data to AudioConverterFillComplexBuffer.
+
+    @param      inAudioConverter
+                    The AudioConverter requesting input.
+    @param      ioNumberDataPackets
+                    On entry, the minimum number of packets of input audio data the converter
+                    would like in order to fulfill its current FillBuffer request. On exit, the
+                    number of packets of audio data actually being provided for input, or 0 if
+                    there is no more input.
+    @param      ioData
+                    On exit, the members of ioData should be set to point to the audio data
+                    being provided for input.
+    @param      outDataPacketDescription
+                    If non-null, on exit, the callback is expected to fill this in with
+                    an AudioStreamPacketDescription for each packet of input data being provided.
+    @param      inUserData
+                    The inInputDataProcUserData parameter passed to AudioConverterFillComplexBuffer().
+    @result     An OSStatus result code.
+    
+    @discussion
+                This callback function supplies input to AudioConverterFillComplexBuffer.
+                
+                The AudioConverter requests a minimum number of packets (*ioNumberDataPackets).
+                The callback may return one or more packets. If this is less than the minimum,
+                the callback will simply be called again in the near future.
+
+                The callback manipulates the members of ioData to point to one or more buffers
+                of audio data (multiple buffers are used with non-interleaved PCM data). The
+                callback is responsible for not freeing or altering this buffer until it is
+                called again.
+
+                If the callback returns an error, it must return zero packets of data.
+                AudioConverterFillComplexBuffer will stop producing output and return whatever
+                output has already been produced to its caller, along with the error code. This
+                mechanism can be used when an input proc has temporarily run out of data, but
+                has not yet reached end of stream.
+}
+type
+	AudioConverterComplexInputDataProc = function( inAudioConverter: AudioConverterRef; var ioNumberDataPackets: UInt32; var ioData: AudioBufferList; outDataPacketDescription: AudioStreamPacketDescriptionPtrPtr {* __nullable * __nullable}; inUserData: UnivPtr {__nullable} ): OSStatus;
+
+//-----------------------------------------------------------------------------
+{!
+    @function   AudioConverterFillComplexBuffer
+    @abstract   Converts data supplied by an input callback function, supporting non-interleaved
+                and packetized formats.
+
+    @param      inAudioConverter
+                    The AudioConverter to use.
+    @param      inInputDataProc
+                    A callback function which supplies the input data.
+    @param      inInputDataProcUserData
+                    A value for the use of the callback function.
+    @param      ioOutputDataPacketSize
+                    On entry, the capacity of outOutputData expressed in packets in the
+                    converter's output format. On exit, the number of packets of converted
+                    data that were written to outOutputData.
+    @param      outOutputData
+                    The converted output data is written to this buffer.
+    @param      outPacketDescription
+                    If non-null, and the converter's output uses packet descriptions, then
+                    packet descriptions are written to this array. It must point to a memory
+                    block capable of holding *ioOutputDataPacketSize packet descriptions.
+                    (See AudioFormat.h for ways to determine whether an audio format
+                    uses packet descriptions).
+    @result     An OSStatus result code.
+
+    @discussion
+                Produces a buffer list of output data from an AudioConverter. The supplied input
+                callback function is called whenever necessary.
+}
+function AudioConverterFillComplexBuffer( inAudioConverter: AudioConverterRef; inInputDataProc: AudioConverterComplexInputDataProc; inInputDataProcUserData: UnivPtr {__nullable}; var ioOutputDataPacketSize: UInt32; var outOutputData: AudioBufferList; outPacketDescription: AudioStreamPacketDescriptionPtr {* __nullable} ): OSStatus; external name '_AudioConverterFillComplexBuffer';
+(* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+
+//-----------------------------------------------------------------------------
+{!
+    @function   AudioConverterConvertComplexBuffer
+    @abstract   Converts PCM data from an input buffer list to an output buffer list.
+
+    @param      inAudioConverter
+                    The AudioConverter to use.
+    @param      inNumberPCMFrames
+                    The number of PCM frames to convert.
+    @param      inInputData
+                    The source audio buffer list.
+    @param      outOutputData
+                    The converted output data is written to this buffer list.
+    @result     An OSStatus result code.
+    @discussion
+                <b>WARNING:</b> this function will fail for any conversion where there is a
+                variable relationship between the input and output data buffer sizes. This
+                includes sample rate conversions and most compressed formats. In these cases,
+                use AudioConverterFillComplexBuffer. Generally this function is only appropriate for
+                PCM-to-PCM conversions where there is no sample rate conversion.
+}
+function AudioConverterConvertComplexBuffer( inAudioConverter: AudioConverterRef; inNumberPCMFrames: UInt32; const (*var*) inInputData: AudioBufferList; var outOutputData: AudioBufferList ): OSStatus; external name '_AudioConverterConvertComplexBuffer';
+(* API_AVAILABLE(macos(10.7), ios(5.0), watchos(2.0), tvos(9.0)) *)
+
+
+//CF_ASSUME_NONNULL_END
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+
+end.
+{$endc} {not MACOSALLINCLUDE}

+ 1489 - 0
packages/univint/src/AudioFile.pas

@@ -0,0 +1,1489 @@
+{!
+	@file		AudioFile.h
+	@framework	AudioToolbox.framework
+	@copyright	(c) 1985-2015 by Apple, Inc., all rights reserved.
+	@abstract	API's to read and write audio files in the filesystem or in memory.
+}
+{  Pascal Translation: Jonas Maebe <[email protected]>, July 2019 }
+{
+    Modified for use with Free Pascal
+    Version 308
+    Please report any bugs to <[email protected]>
+}
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+{$mode macpas}
+{$modeswitch cblocks}
+{$packenum 1}
+{$macro on}
+{$inline on}
+{$calling mwpascal}
+
+unit AudioFile;
+interface
+{$setc UNIVERSAL_INTERFACES_VERSION := $0400}
+{$setc GAP_INTERFACES_VERSION := $0308}
+
+{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
+    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
+{$endc}
+
+{$ifc defined CPUPOWERPC and defined CPUI386}
+	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
+{$endc}
+{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
+	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
+{$endc}
+
+{$ifc not defined __ppc__ and defined CPUPOWERPC32}
+	{$setc __ppc__ := 1}
+{$elsec}
+	{$setc __ppc__ := 0}
+{$endc}
+{$ifc not defined __ppc64__ and defined CPUPOWERPC64}
+	{$setc __ppc64__ := 1}
+{$elsec}
+	{$setc __ppc64__ := 0}
+{$endc}
+{$ifc not defined __i386__ and defined CPUI386}
+	{$setc __i386__ := 1}
+{$elsec}
+	{$setc __i386__ := 0}
+{$endc}
+{$ifc not defined __x86_64__ and defined CPUX86_64}
+	{$setc __x86_64__ := 1}
+{$elsec}
+	{$setc __x86_64__ := 0}
+{$endc}
+{$ifc not defined __arm__ and defined CPUARM}
+	{$setc __arm__ := 1}
+{$elsec}
+	{$setc __arm__ := 0}
+{$endc}
+{$ifc not defined __arm64__ and defined CPUAARCH64}
+  {$setc __arm64__ := 1}
+{$elsec}
+  {$setc __arm64__ := 0}
+{$endc}
+
+{$ifc defined cpu64}
+  {$setc __LP64__ := 1}
+{$elsec}
+  {$setc __LP64__ := 0}
+{$endc}
+
+
+{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
+	{$error Conflicting definitions for __ppc__ and __i386__}
+{$endc}
+
+{$ifc defined __ppc__ and __ppc__}
+	{$setc TARGET_CPU_PPC := TRUE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __ppc64__ and __ppc64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := TRUE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __i386__ and __i386__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := TRUE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __x86_64__ and __x86_64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := TRUE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __arm__ and __arm__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := TRUE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := TRUE}
+{$elifc defined __arm64__ and __arm64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := TRUE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := TRUE}
+{$elsec}
+	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
+{$endc}
+
+{$ifc defined __LP64__ and __LP64__ }
+  {$setc TARGET_CPU_64 := TRUE}
+{$elsec}
+  {$setc TARGET_CPU_64 := FALSE}
+{$endc}
+
+{$ifc defined FPC_BIG_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
+{$elifc defined FPC_LITTLE_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
+{$elsec}
+	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
+{$endc}
+{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
+{$setc CALL_NOT_IN_CARBON := FALSE}
+{$setc OLDROUTINENAMES := FALSE}
+{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
+{$setc OPAQUE_UPP_TYPES := TRUE}
+{$setc OTCARBONAPPLICATION := TRUE}
+{$setc OTKERNEL := FALSE}
+{$setc PM_USE_SESSION_APIS := TRUE}
+{$setc TARGET_API_MAC_CARBON := TRUE}
+{$setc TARGET_API_MAC_OS8 := FALSE}
+{$setc TARGET_API_MAC_OSX := TRUE}
+{$setc TARGET_CARBON := TRUE}
+{$setc TARGET_CPU_68K := FALSE}
+{$setc TARGET_CPU_MIPS := FALSE}
+{$setc TARGET_CPU_SPARC := FALSE}
+{$setc TARGET_OS_UNIX := FALSE}
+{$setc TARGET_OS_WIN32 := FALSE}
+{$setc TARGET_RT_MAC_68881 := FALSE}
+{$setc TARGET_RT_MAC_CFM := FALSE}
+{$setc TARGET_RT_MAC_MACHO := TRUE}
+{$setc TYPED_FUNCTION_POINTERS := TRUE}
+{$setc TYPE_BOOL := FALSE}
+{$setc TYPE_EXTENDED := FALSE}
+{$setc TYPE_LONGLONG := TRUE}
+uses MacTypes,CFBase,CoreAudioTypes,CoreFoundation;
+{$endc} {not MACOSALLINCLUDE}
+
+{$ALIGN POWER}
+
+
+//=============================================================================
+//	Includes
+//=============================================================================
+
+
+//CF_ASSUME_NONNULL_BEGIN
+
+
+{!
+	@typedef	AudioFileTypeID
+	@abstract	Identifier for an audio file type.
+}
+type
+	AudioFileTypeID = UInt32;
+
+{!
+    @enum Audio File Types
+    @abstract   Constants for the built-in audio file types.
+    @discussion These constants are used to indicate the type of file to be written, or as a hint to
+					what type of file to expect from data provided.
+    @constant   kAudioFileAIFFType
+					Audio Interchange File Format (AIFF)
+    @constant   kAudioFileAIFCType
+					Audio Interchange File Format Compressed (AIFF-C)
+    @constant   kAudioFileWAVEType
+					Microsoft WAVE
+    @constant   kAudioFileRF64Type
+                    File Format specified in EBU Tech 3306
+    @constant   kAudioFileSoundDesigner2Type
+					Sound Designer II
+    @constant   kAudioFileNextType
+					NeXT / Sun
+    @constant   kAudioFileMP3Type
+					MPEG Audio Layer 3 (.mp3)
+    @constant   kAudioFileMP2Type
+					MPEG Audio Layer 2 (.mp2)
+    @constant   kAudioFileMP1Type
+					MPEG Audio Layer 1 (.mp1)
+    @constant   kAudioFileAC3Type
+					AC-3
+    @constant   kAudioFileAAC_ADTSType
+					Advanced Audio Coding (AAC) Audio Data Transport Stream (ADTS)
+    @constant   kAudioFileMPEG4Type
+    @constant   kAudioFileM4AType
+    @constant   kAudioFileM4BType
+    @constant   kAudioFileCAFType
+                    CoreAudio File Format
+    @constant   kAudioFile3GPType
+    @constant   kAudioFile3GP2Type
+    @constant   kAudioFileAMRType
+    @constant   kAudioFileFLACType
+                    Free Lossless Audio Codec
+}
+const
+	kAudioFileAIFFType = FourCharCode('AIFF');
+	kAudioFileAIFCType = FourCharCode('AIFC');
+	kAudioFileWAVEType = FourCharCode('WAVE');
+	kAudioFileRF64Type = FourCharCode('RF64');
+	kAudioFileSoundDesigner2Type = FourCharCode('Sd2f');
+	kAudioFileNextType = FourCharCode('NeXT');
+	kAudioFileMP3Type = FourCharCode('MPG3'); 	// mpeg layer 3
+	kAudioFileMP2Type = FourCharCode('MPG2'); 	// mpeg layer 2
+	kAudioFileMP1Type = FourCharCode('MPG1'); 	// mpeg layer 1
+	kAudioFileAC3Type = FourCharCode('ac-3');
+	kAudioFileAAC_ADTSType = FourCharCode('adts');
+	kAudioFileMPEG4Type = FourCharCode('mp4f');
+	kAudioFileM4AType = FourCharCode('m4af');
+	kAudioFileM4BType = FourCharCode('m4bf');
+	kAudioFileCAFType = FourCharCode('caff');
+	kAudioFile3GPType = FourCharCode('3gpp');
+	kAudioFile3GP2Type = FourCharCode('3gp2');
+	kAudioFileAMRType = FourCharCode('amrf');
+	kAudioFileFLACType = FourCharCode('flac'); 
+
+{!
+    @enum AudioFile error codes
+    @abstract   These are the error codes returned from the AudioFile API.
+    @constant   kAudioFileUnspecifiedError 
+		An unspecified error has occurred.
+    @constant   kAudioFileUnsupportedFileTypeError 
+		The file type is not supported.
+    @constant   kAudioFileUnsupportedDataFormatError 
+		The data format is not supported by this file type.
+    @constant   kAudioFileUnsupportedPropertyError 
+		The property is not supported.
+    @constant   kAudioFileBadPropertySizeError 
+		The size of the property data was not correct.
+    @constant   kAudioFilePermissionsError 
+		The operation violated the file permissions. For example, trying to write to a file opened with kAudioFileReadPermission.
+    @constant   kAudioFileNotOptimizedError 
+		There are chunks following the audio data chunk that prevent extending the audio data chunk. 
+		The file must be optimized in order to write more audio data.
+    @constant   kAudioFileInvalidChunkError 
+		The chunk does not exist in the file or is not supported by the file. 
+    @constant   kAudioFileDoesNotAllow64BitDataSizeError 
+		The a file offset was too large for the file type. AIFF and WAVE have a 32 bit file size limit. 
+    @constant   kAudioFileInvalidPacketOffsetError 
+		A packet offset was past the end of the file, or not at the end of the file when writing a VBR format, 
+		or a corrupt packet size was read when building the packet table. 
+    @constant   kAudioFileInvalidFileError 
+		The file is malformed, or otherwise not a valid instance of an audio file of its type. 
+    @constant   kAudioFileOperationNotSupportedError 
+		The operation cannot be performed. For example, setting kAudioFilePropertyAudioDataByteCount to increase 
+		the size of the audio data in a file is not a supported operation. Write the data instead.
+    @constant   kAudioFileNotOpenError 
+		The file is closed.
+	@constant   kAudioFileEndOfFileError 
+		End of file.
+	@constant   kAudioFilePositionError 
+		Invalid file position.
+	@constant   kAudioFileFileNotFoundError 
+		File not found.
+ }
+const
+	kAudioFileUnspecifiedError = FourCharCode('wht?'); 		// 0x7768743F, 2003334207
+	kAudioFileUnsupportedFileTypeError = FourCharCode('typ?'); 		// 0x7479703F, 1954115647
+	kAudioFileUnsupportedDataFormatError = FourCharCode('fmt?'); 		// 0x666D743F, 1718449215
+	kAudioFileUnsupportedPropertyError = FourCharCode('pty?'); 		// 0x7074793F, 1886681407
+	kAudioFileBadPropertySizeError = FourCharCode('!siz'); 		// 0x2173697A,  561211770
+	kAudioFilePermissionsError = FourCharCode('prm?'); 		// 0x70726D3F, 1886547263
+	kAudioFileNotOptimizedError = FourCharCode('optm'); 		// 0x6F70746D, 1869640813
+        // file format specific error codes
+	kAudioFileInvalidChunkError = FourCharCode('chk?'); 		// 0x63686B3F, 1667787583
+	kAudioFileDoesNotAllow64BitDataSizeError = FourCharCode('off?'); 		// 0x6F66663F, 1868981823
+	kAudioFileInvalidPacketOffsetError = FourCharCode('pck?'); 		// 0x70636B3F, 1885563711
+	kAudioFileInvalidFileError = FourCharCode('dta?'); 		// 0x6474613F, 1685348671
+	kAudioFileOperationNotSupportedError = $6F703F3F;  	// 'op??', integer used because of trigraph
+		// general file error codes
+	kAudioFileNotOpenError = -38;
+	kAudioFileEndOfFileError = -39;
+	kAudioFilePositionError = -40;
+	kAudioFileFileNotFoundError = -43; 
+
+{!
+    @enum AudioFileFlags
+    @abstract   These are flags that can be used with the CreateURL API call
+    @constant   kAudioFileFlags_EraseFile 
+		If set, then the CreateURL call will erase the contents of an existing file
+		If not set, then the CreateURL call will fail if the file already exists
+    @constant   kAudioFileFlags_DontPageAlignAudioData 
+		Normally, newly created and optimized files will have padding added in order to page align 
+		the data to 4KB boundaries. This makes reading the data more efficient. 
+		When disk space is a concern, this flag can be set so that the padding will not be added.
+}
+type
+	AudioFileFlags = UInt32;
+const
+	kAudioFileFlags_EraseFile = 1;
+	kAudioFileFlags_DontPageAlignAudioData = 2; 
+
+type
+	AudioFilePermissions = SInt8;
+const
+	kAudioFileReadPermission = $01;
+	kAudioFileWritePermission = $02;
+	kAudioFileReadWritePermission = $03; 
+
+//=============================================================================
+//	Types specific to the Audio File API
+//=============================================================================
+
+{!
+    @typedef	AudioFileID
+    @abstract   An opaque reference to an AudioFile object.
+}
+type
+	OpaqueAudioFileID = record end;
+	AudioFileID = ^OpaqueAudioFileID;
+{!
+    @typedef	AudioFilePropertyID
+    @abstract   A constant for an AudioFile property.
+}
+type
+	AudioFilePropertyID = UInt32;
+
+{!
+    @enum		AudioFileLoopDirection
+    @abstract   These constants describe the playback direction of a looped segment of a file.
+    @constant   kAudioFileLoopDirection_NoLooping
+					The segment is not looped.
+    @constant   kAudioFileLoopDirection_Forward
+					play segment forward.
+    @constant   kAudioFileLoopDirection_Backward
+					play segment backward.
+    @constant   kAudioFileLoopDirection_ForwardAndBackward
+					play segment forward and backward.
+}
+const
+	kAudioFileLoopDirection_NoLooping = 0;
+	kAudioFileLoopDirection_Forward = 1;
+	kAudioFileLoopDirection_ForwardAndBackward = 2;
+	kAudioFileLoopDirection_Backward = 3; 
+
+//=============================================================================
+//	Markers, Regions
+//=============================================================================
+
+
+{!
+    @struct		AudioFile_SMPTE_Time
+    @abstract   A struct for describing a SMPTE time.
+    @field      mHours						The hours.
+    @field      mMinutes					The minutes.
+    @field      mSeconds					The seconds.
+    @field      mFrames						The frames.
+    @field      mSubFrameSampleOffset		The sample offset within a frame.
+}
+type
+	AudioFile_SMPTE_Time = record
+		mHours: SInt8;
+		mMinutes: UInt8;
+		mSeconds: UInt8;
+		mFrames: UInt8;
+		mSubFrameSampleOffset: UInt32;
+	end;
+
+
+{!
+    @enum		AudioFileMarkerType
+    @abstract   constants for types of markers within a file. Used in the mType field of AudioFileMarker.
+    @constant   kAudioFileMarkerType_Generic		A generic marker. See CAFFile.h for marker types specific to CAF files.
+}
+const
+	kAudioFileMarkerType_Generic = 0; 
+
+
+{!
+    @struct		AudioFileMarker
+    @abstract   A marker annotates a position in an audio file with additional information.
+    @discussion (description)
+    @field      mFramePosition	The frame in the file counting from the start of the audio data.
+    @field      mName			The name of this marker.
+    @field      mMarkerID		A unique ID for this marker.
+    @field      mSMPTETime		The SMPTE time for this marker.
+    @field      mType			The marker type.
+    @field      mReserved		A reserved field. Set to zero.
+    @field      mChannel		The channel number that the marker refers to. Set to zero if marker applies to all channels.
+}
+type
+	AudioFileMarker = record
+		mFramePosition: Float64;
+	
+		mName: CFStringRef	{__nullable};
+		mMarkerID: SInt32;
+
+		mSMPTETime: AudioFile_SMPTE_Time;
+		mType: UInt32;
+		mReserved: UInt16;
+		mChannel: UInt16;
+	end;
+	AudioFileMarkerPtr = ^AudioFileMarker;
+
+{!
+    @struct		AudioFileMarkerList
+    @abstract   A list of AudioFileMarker.
+    @field      mSMPTE_TimeType
+					This defines the SMPTE timing scheme used in the marker list. See CAFFile.h for the values used here.
+    @field      mNumberMarkers
+					The number of markers in the mMarkers list.
+    @field      mMarkers
+					A list of AudioFileMarker.
+}
+type
+	AudioFileMarkerList = record
+		mSMPTE_TimeType: UInt32;
+		mNumberMarkers: UInt32;
+		mMarkers: array [0..1-1] of AudioFileMarker; // this is a variable length array of mNumberMarkers elements
+	end;
+	AudioFileMarkerListPtr = ^AudioFileMarkerList;
+
+{!
+    @function	NumBytesToNumAudioFileMarkers
+    @abstract   Converts a size in bytes to the number of AudioFileMarkers that can be contained in that number of bytes.
+    @discussion This can be used for the kAudioFilePropertyMarkerList property when calculating the number of 
+				markers that will be returned. 
+    @param      inNumBytes 
+					a number of bytes.
+    @result     the number of AudioFileMarkers that can be contained in that number of bytes.
+}
+
+function NumBytesToNumAudioFileMarkers(inNumBytes: size_t): size_t;
+{FPC-ONLY-START}
+inline;
+{FPC-ONLY-END}
+
+{!
+    @function	NumAudioFileMarkersToNumBytes
+    @abstract   Converts a number of AudioFileMarkers to a size in bytes.
+    @discussion This can be used for the kAudioFilePropertyMarkerList property when calculating the size required to 
+				contain a number of AudioFileMarkers. 
+    @param      inNumMarkers 
+					a number of AudioFileMarkers.
+    @result     the size in bytes required to contain that number of AudioFileMarkers.
+}
+
+function NumAudioFileMarkersToNumBytes(inNumMarkers: size_t): size_t;
+{FPC-ONLY-START}
+inline;
+{FPC-ONLY-END}
+
+{!
+    @enum		AudioFileRegionFlags
+    @abstract   These are flags for an AudioFileRegion that specify a playback direction.
+    @discussion One or multiple of these flags can be set. For example, if both kAudioFileRegionFlag_LoopEnable and 
+				kAudioFileRegionFlag_PlayForward are set, then the region will play as a forward loop. If only 
+				kAudioFileRegionFlag_PlayForward is set, then the region will be played forward once.
+    @constant   kAudioFileRegionFlag_LoopEnable
+					If this flag is set, the region will be looped. One or both of the following must also be set.
+    @constant   kAudioFileRegionFlag_PlayForward
+					If this flag is set, the region will be played forward.
+    @constant   kAudioFileRegionFlag_PlayBackward
+					If this flag is set, the region will be played backward.
+}
+type
+	AudioFileRegionFlags = UInt32;
+const
+	kAudioFileRegionFlag_LoopEnable = 1;
+	kAudioFileRegionFlag_PlayForward = 2;
+	kAudioFileRegionFlag_PlayBackward = 4; 
+
+{!
+    @struct		AudioFileRegion
+    @abstract   An AudioFileRegion specifies a segment of audio data.
+    @discussion Generally a region consists of at least two markers marking the beginning and end of the segment.
+				There may also be other markers defining other meta information such as sync point.
+    @field      mRegionID 
+					each region must have a unique ID.
+    @field      mName 
+					The name of the region.
+    @field      mFlags 
+					AudioFileRegionFlags.
+    @field      mNumberMarkers 
+					The number of markers in the mMarkers array.
+    @field      mMarkers 
+					A variable length array of AudioFileMarkers.
+}
+type
+	AudioFileRegion = record
+		mRegionID: UInt32;
+		mName: CFStringRef;
+		mFlags: AudioFileRegionFlags;
+		mNumberMarkers: UInt32;
+		mMarkers: array [0..1-1] of AudioFileMarker; // this is a variable length array of mNumberMarkers elements
+	end;
+	AudioFileRegionPtr = ^AudioFileRegion;
+
+
+{!
+    @struct		AudioFileRegionList
+    @abstract   A list of the AudioFileRegions in a file.
+    @discussion This is the struct used by the kAudioFilePropertyRegionList property.
+    @field      mSMPTE_TimeType
+					This defines the SMPTE timing scheme used in the file. See CAFFile.h for the values used here.
+    @field      mNumberRegions
+					The number of regions in the mRegions list.
+    @field      mRegions
+					A list of AudioFileRegions. Note that AudioFileMarkers are variable length, so this list cannot 
+					be accessed as an array. Use the NextAudioFileRegion macro for traversing the list instead.
+}
+type
+	AudioFileRegionList = record
+		mSMPTE_TimeType: UInt32;
+		mNumberRegions: UInt32;
+		mRegions: array [0..1-1] of AudioFileRegion; // this is a variable length array of mNumberRegions elements
+	end;
+	AudioFileRegionListPtr = ^AudioFileRegionList;
+
+{!
+    @function	NextAudioFileRegion
+    @abstract   convenience macro for traversing the region list.
+    @discussion because AudioFileRegions are variable length, you cannot access them as an array. Use NextAudioFileRegion 
+				to walk the list.
+    @param      inAFRegionPtr 
+					a pointer to the current region.
+    @result     a pointer to the region after the current region. This does not protect you from walking off the end of the list, 
+				so obey mNumberRegions.
+}
+
+function NextAudioFileRegion(const {var} inAFRegionPtr: AudioFileRegion): AudioFileRegionPtr;
+{FPC-ONLY-START}
+inline;
+{FPC-ONLY-END}
+
+{!
+    @struct		AudioFramePacketTranslation
+    @abstract   used for properties kAudioFilePropertyPacketToFrame and kAudioFilePropertyFrameToPacket
+    @discussion See description of kAudioFilePropertyPacketToFrame and kAudioFilePropertyFrameToPacket
+    @field      mFrame		a frame number.
+    @field      mPacket		a packet number.
+    @field      mFrameOffsetInPacket		a frame offset in a packet.
+}
+type
+	AudioFramePacketTranslation = record
+		mFrame: SInt64;
+		mPacket: SInt64;
+		mFrameOffsetInPacket: UInt32;
+	end;
+	AudioFramePacketTranslationPtr = ^AudioFramePacketTranslation;
+
+
+{!
+    @enum		AudioBytePacketTranslation Flags
+	
+    @abstract   flags for the AudioBytePacketTranslation mFlags field
+    @discussion		There is currently only one flag.
+					
+    @constant   kBytePacketTranslationFlag_IsEstimate
+					If the set then the result value is an estimate.
+}
+type
+	AudioBytePacketTranslationFlags = UInt32;
+const
+	kBytePacketTranslationFlag_IsEstimate = 1; 
+
+{!
+    @struct		AudioBytePacketTranslation
+    @abstract   used for properties kAudioFileByteToPacket and kAudioFilePacketToByte
+    @discussion See description of kAudioFileByteToPacket and kAudioFilePacketToByte
+    @field      mByte		a byte number.
+    @field      mPacket		a packet number.
+    @field      mByteOffsetInPacket		a byte offset in a packet.
+    @field      mFlags		if kBytePacketTranslationFlag_IsEstimate is set, then the value is an estimate.
+}
+type
+	AudioBytePacketTranslation = record
+		mByte: SInt64;
+		mPacket: SInt64;
+		mByteOffsetInPacket: UInt32;
+		mFlags: AudioBytePacketTranslationFlags;
+	end;
+	AudioBytePacketTranslationPtr = ^AudioBytePacketTranslation;
+
+
+{!
+    @struct		AudioFilePacketTableInfo
+    @abstract   This contains information about the number of valid frames in a file and where they begin and end.
+    @discussion	Some data formats may have packets whose contents are not completely valid, but represent priming or remainder 
+				frames that are not meant to be played. For example a file with 100 packets of AAC is nominally 1024 * 100 = 102400 frames
+				of data. However the first 2112 frames of that may be priming frames and there may be some 
+				number of remainder frames added to pad out to a full packet of 1024 frames. The priming and remainder frames should be 
+				discarded. The total number of packets in the file times the frames per packet (or counting each packet's frames 
+				individually for a variable frames per packet format) minus mPrimingFrames, minus mRemainderFrames, should 
+				equal mNumberValidFrames.
+    @field      mNumberValidFrames the number of valid frames in the file.
+    @field      mPrimingFrames the number of invalid frames at the beginning of the file.
+    @field      mRemainderFrames the number of invalid frames at the end of the file.
+}
+type
+	AudioFilePacketTableInfo = record
+		mNumberValidFrames: SInt64;
+		mPrimingFrames: SInt32;
+		mRemainderFrames: SInt32;
+	end;
+	AudioFilePacketTableInfoPtr = ^AudioFilePacketTableInfo;
+
+//=============================================================================
+//	Info String Keys
+//=============================================================================
+
+// Get key values from the InfoDictionary by making CFStrings from the following constants
+
+const
+	kAFInfoDictionary_Album = 'album';
+const
+	kAFInfoDictionary_ApproximateDurationInSeconds = 'approximate duration in seconds';
+const
+	kAFInfoDictionary_Artist = 'artist';
+const
+	kAFInfoDictionary_ChannelLayout = 'channel layout';
+const
+	kAFInfoDictionary_Comments = 'comments';
+const
+	kAFInfoDictionary_Composer = 'composer';
+const
+	kAFInfoDictionary_Copyright = 'copyright';
+const
+	kAFInfoDictionary_EncodingApplication = 'encoding application';
+const
+	kAFInfoDictionary_Genre = 'genre';
+const
+	kAFInfoDictionary_ISRC = 'ISRC';  // International Standard Recording Code
+const
+	kAFInfoDictionary_KeySignature = 'key signature';
+const
+	kAFInfoDictionary_Lyricist = 'lyricist';
+const
+	kAFInfoDictionary_NominalBitRate = 'nominal bit rate';
+const
+	kAFInfoDictionary_RecordedDate = 'recorded date';
+const
+	kAFInfoDictionary_SourceBitDepth = 'source bit depth';
+const
+	kAFInfoDictionary_SourceEncoder = 'source encoder';
+const
+	kAFInfoDictionary_SubTitle = 'subtitle';
+const
+	kAFInfoDictionary_Tempo = 'tempo';
+const
+	kAFInfoDictionary_TimeSignature = 'time signature';
+const
+	kAFInfoDictionary_Title = 'title';
+const
+	kAFInfoDictionary_TrackNumber = 'track number';
+const
+	kAFInfoDictionary_Year = 'year';
+
+//=============================================================================
+//	Routines
+//=============================================================================
+
+{!
+    @function	AudioFileCreateWithURL
+    @abstract   creates a new audio file (or initialises an existing file)
+    @discussion	creates a new (or initialises an existing) audio file specified by the URL.
+					Upon success, an AudioFileID is returned which can be used for subsequent calls 
+					to the AudioFile APIs.
+    @param inFileRef		an CFURLRef fully specifying the path of the file to create/initialise
+    @param inFileType		an AudioFileTypeID indicating the type of audio file to create.
+    @param inFormat			an AudioStreamBasicDescription describing the data format that will be
+							added to the audio file.
+    @param inFlags			relevant flags for creating/opening the file. 
+								if kAudioFileFlags_EraseFile is set, it will erase an existing file
+								 if not set, then the Create call will fail if the URL is an existing file
+    @param outAudioFile		if successful, an AudioFileID that can be used for subsequent AudioFile calls.
+    @result					returns noErr if successful.
+}
+function AudioFileCreateWithURL( inFileRef: CFURLRef; inFileType: AudioFileTypeID; const (*var*) inFormat: AudioStreamBasicDescription; inFlags: AudioFileFlags; var outAudioFile: AudioFileID {__nullable * __nonnull} ): OSStatus; external name '_AudioFileCreateWithURL';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function				AudioFileOpenURL
+    @abstract				Open an existing audio file.
+    @discussion				Open an existing audio file for reading or reading and writing.
+    @param inFileRef		the CFURLRef of an existing audio file.
+    @param inPermissions	use the permission constants
+    @param inFileTypeHint	For files which have no filename extension and whose type cannot be easily or
+							uniquely determined from the data (ADTS,AC3), this hint can be used to indicate the file type. 
+							Otherwise you can pass zero for this. The hint is only used on OS versions 10.3.1 or greater.
+							For OS versions prior to that, opening files of the above description will fail.
+    @param outAudioFile		upon success, an AudioFileID that can be used for subsequent
+							AudioFile calls.
+    @result					returns noErr if successful.
+}
+function AudioFileOpenURL( inFileRef: CFURLRef; inPermissions: AudioFilePermissions; inFileTypeHint: AudioFileTypeID; var outAudioFile: AudioFileID {__nullable * __nonnull} ): OSStatus; external name '_AudioFileOpenURL';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @typedef	AudioFile_ReadProc
+    @abstract   A callback for reading data. used with AudioFileOpenWithCallbacks or AudioFileInitializeWithCallbacks.
+    @discussion a function that will be called when AudioFile needs to read data.
+    @param      inClientData	A pointer to the client data as set in the inClientData parameter to AudioFileXXXWithCallbacks.
+    @param      inPosition		An offset into the data from which to read.
+    @param      requestCount	The number of bytes to read.
+    @param      buffer			The buffer in which to put the data read.
+    @param      actualCount		The callback should set this to the number of bytes successfully read.
+    @result						The callback should return noErr on success, or an appropriate error code on failure.
+}
+type
+	AudioFile_ReadProc = function( inClientData: UnivPtr; inPosition: SInt64; requestCount: UInt32; buffer: UnivPtr; var actualCount: UInt32 ): OSStatus;
+
+{!
+    @typedef	AudioFile_WriteProc
+    @abstract   A callback for writing data. used with AudioFileOpenWithCallbacks or AudioFileInitializeWithCallbacks.
+    @discussion a function that will be called when AudioFile needs to write data.
+    @param      inClientData	A pointer to the client data as set in the inClientData parameter to AudioFileXXXWithCallbacks.
+    @param      inPosition		An offset into the data from which to read.
+    @param      requestCount	The number of bytes to write.
+    @param      buffer			The buffer containing the data to write.
+    @param      actualCount		The callback should set this to the number of bytes successfully written.
+    @result						The callback should return noErr on success, or an appropriate error code on failure.
+}
+type
+	AudioFile_WriteProc = function( inClientData: UnivPtr; inPosition: SInt64; requestCount: UInt32; buffer: {const} UnivPtr; var actualCount: UInt32 ): OSStatus;
+								
+{!
+    @typedef	AudioFile_GetSizeProc
+    @abstract   A callback for getting the size of the file data. used with AudioFileOpenWithCallbacks or AudioFileInitializeWithCallbacks.
+    @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 
+				data in the file, not just the audio data.
+    @param      inClientData	A pointer to the client data as set in the inClientData parameter to AudioFileXXXWithCallbacks.
+    @result						The callback should return the size of the data.
+}
+type
+	AudioFile_GetSizeProc = function( inClientData: UnivPtr ): SInt64;
+
+{!
+    @typedef	AudioFile_SetSizeProc
+    @abstract   A callback for setting the size of the file data. used with AudioFileOpenWithCallbacks or AudioFileInitializeWithCallbacks.
+    @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 
+				data in the file, not just the audio data. This will only be called if the file is written to.
+    @param      inClientData	A pointer to the client data as set in the inClientData parameter to AudioFileXXXWithCallbacks.
+    @result						The callback should return the size of the data.
+}
+type
+	AudioFile_SetSizeProc = function( inClientData: UnivPtr; inSize: SInt64 ): OSStatus;
+
+{!
+    @function	AudioFileInitializeWithCallbacks
+    @abstract   Wipe clean an existing file. You provide callbacks that the AudioFile API
+				will use to get the data.
+    @param inClientData		a constant that will be passed to your callbacks.
+	@param inReadFunc		a function that will be called when AudioFile needs to read data.
+	@param inWriteFunc		a function that will be called when AudioFile needs to write data.
+	@param inGetSizeFunc	a function that will be called when AudioFile needs to know the file size.
+	@param inSetSizeFunc	a function that will be called when AudioFile needs to set the file size.
+	
+    @param inFileType 		an AudioFileTypeID indicating the type of audio file to which to initialize the file. 
+    @param inFormat 		an AudioStreamBasicDescription describing the data format that will be
+							added to the audio file.
+    @param inFlags			flags for creating/opening the file. Currently zero.
+    @param outAudioFile		upon success, an AudioFileID that can be used for subsequent
+							AudioFile calls.
+    @result					returns noErr if successful.
+}
+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';
+(* API_AVAILABLE(macos(10.3), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+
+{!
+    @function	AudioFileOpenWithCallbacks
+    @abstract   Open an existing file. You provide callbacks that the AudioFile API
+				will use to get the data.
+    @param inClientData					a constant that will be passed to your callbacks.
+	@param inReadFunc					a function that will be called when AudioFile needs to read data.
+	@param inWriteFunc					a function that will be called when AudioFile needs to write data.
+	@param inGetSizeFunc				a function that will be called when AudioFile needs to know the total file size.
+	@param inSetSizeFunc				a function that will be called when AudioFile needs to set the file size.
+	
+    @param inFileTypeHint	For files which have no filename extension and whose type cannot be easily or
+							uniquely determined from the data (ADTS,AC3), this hint can be used to indicate the file type. 
+							Otherwise you can pass zero for this. The hint is only used on OS versions 10.3.1 or greater.
+							For OS versions prior to that, opening files of the above description will fail.
+    @param outAudioFile		upon success, an AudioFileID that can be used for subsequent
+							AudioFile calls.
+    @result					returns noErr if successful.
+}
+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';
+(* API_AVAILABLE(macos(10.3), ios(2.0), watchos(2.0), tvos(9.0)) *)
+				
+
+{!
+    @function	AudioFileClose
+    @abstract   Close an existing audio file.
+    @param      inAudioFile		an AudioFileID.
+    @result						returns noErr if successful.
+}
+function AudioFileClose( inAudioFile: AudioFileID ): OSStatus; external name '_AudioFileClose';
+(* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function	AudioFileOptimize
+    @abstract   Move the audio data to the end of the file and other internal optimizations of the file structure.
+	@discussion			Optimize the file so additional audio data can be appended to 
+                        the existing data. Generally, this will place the audio data at 
+                        the end of the file so additional writes can be placed to the 
+                        file end. This can be a potentially expensive and time-consuming operation 
+                        and should not be used during time critical operations. There is 
+                        a kAudioFilePropertyIsOptimized property for checking on the optimized state 
+                        of the file.
+    @param      inAudioFile		an AudioFileID.
+    @result						returns noErr if successful.
+}
+function AudioFileOptimize( inAudioFile: AudioFileID ): OSStatus; external name '_AudioFileOptimize';
+(* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function	AudioFileReadBytes
+    @abstract   Read bytes of audio data from the audio file. 
+				
+    @discussion				Returns kAudioFileEndOfFileError when read encounters end of file.
+    @param inAudioFile		an AudioFileID.
+    @param inUseCache 		true if it is desired to cache the data upon read, else false
+    @param inStartingByte	the byte offset of the audio data desired to be returned
+    @param ioNumBytes 		on input, the number of bytes to read, on output, the number of
+							bytes actually read.
+    @param outBuffer 		outBuffer should be a void * to user allocated memory large enough for the requested bytes. 
+    @result					returns noErr if successful.
+}
+function AudioFileReadBytes( inAudioFile: AudioFileID; inUseCache: Boolean; inStartingByte: SInt64; var ioNumBytes: UInt32; outBuffer: UnivPtr ): OSStatus; external name '_AudioFileReadBytes';
+(* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function				AudioFileWriteBytes
+    @abstract				Write bytes of audio data to the audio file.
+    @param inAudioFile		an AudioFileID.
+    @param inUseCache 		true if it is desired to cache the data upon write, else false
+    @param inStartingByte	the byte offset where the audio data should be written
+    @param ioNumBytes 		on input, the number of bytes to write, on output, the number of
+							bytes actually written.
+    @param inBuffer 		inBuffer should be a void * containing the bytes to be written 
+    @result					returns noErr if successful.
+}
+function AudioFileWriteBytes( inAudioFile: AudioFileID; inUseCache: Boolean; inStartingByte: SInt64; var ioNumBytes: UInt32; inBuffer: {const} UnivPtr ): OSStatus; external name '_AudioFileWriteBytes';
+(* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function	AudioFileReadPacketData
+    @abstract   Read packets of audio data from the audio file.
+    @discussion AudioFileReadPacketData reads as many of the requested number of packets
+				as will fit in the buffer size given by ioNumPackets.
+				Unlike the deprecated AudioFileReadPackets, ioNumPackets must be initialized.
+				If the byte size of the number packets requested is 
+				less than the buffer size, ioNumBytes will be reduced.
+				If the buffer is too small for the number of packets 
+				requested, ioNumPackets and ioNumBytes will be reduced 
+				to the number of packets that can be accommodated and their byte size.
+				Returns kAudioFileEndOfFileError when read encounters end of file.
+				For all uncompressed formats, packets == frames.
+
+    @param inAudioFile				an AudioFileID.
+    @param inUseCache 				true if it is desired to cache the data upon read, else false
+    @param ioNumBytes				on input the size of outBuffer in bytes. 
+									on output, the number of bytes actually returned.
+    @param outPacketDescriptions 	An array of packet descriptions describing the packets being returned. 
+									The size of the array must be greater or equal to the number of packets requested. 
+									On return the packet description will be filled out with the packet offsets and sizes.
+									Packet descriptions are ignored for CBR data.   
+    @param inStartingPacket 		The packet index of the first packet desired to be returned
+    @param ioNumPackets 			on input, the number of packets to read, on output, the number of
+									packets actually read.
+    @param outBuffer 				outBuffer should be a pointer to user allocated memory.
+    @result							returns noErr if successful.
+}
+function AudioFileReadPacketData( inAudioFile: AudioFileID; inUseCache: Boolean; var ioNumBytes: UInt32; outPacketDescriptions: AudioStreamPacketDescriptionPtr {* __nullable}; inStartingPacket: SInt64; var ioNumPackets: UInt32; outBuffer: UnivPtr {__nullable} ): OSStatus; external name '_AudioFileReadPacketData';
+(* API_AVAILABLE(macos(10.6), ios(2.2), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function	AudioFileReadPackets
+    @abstract   Read packets of audio data from the audio file.
+    @discussion AudioFileReadPackets is DEPRECATED. Use AudioFileReadPacketData instead.
+				READ THE HEADER DOC FOR AudioFileReadPacketData. It is not a drop-in replacement.
+				In particular, for AudioFileReadPacketData ioNumBytes must be initialized to the buffer size.
+				AudioFileReadPackets assumes you have allocated your buffer to ioNumPackets times the maximum packet size.
+				For many compressed formats this will only use a portion of the buffer since the ratio of the maximum 
+				packet size to the typical packet size can be large. Use AudioFileReadPacketData instead.
+	
+    @param inAudioFile				an AudioFileID.
+    @param inUseCache 				true if it is desired to cache the data upon read, else false
+    @param outNumBytes				on output, the number of bytes actually returned
+    @param outPacketDescriptions 	on output, an array of packet descriptions describing
+									the packets being returned. NULL may be passed for this
+									parameter. Nothing will be returned for linear pcm data.   
+    @param inStartingPacket 		the packet index of the first packet desired to be returned
+    @param ioNumPackets 			on input, the number of packets to read, on output, the number of
+									packets actually read.
+    @param outBuffer 				outBuffer should be a pointer to user allocated memory of size: 
+									number of packets requested times file's maximum (or upper bound on)
+									packet size.
+    @result							returns noErr if successful.
+}
+function AudioFileReadPackets (	inAudioFile: AudioFileID; inUseCache: Boolean; var outNumBytes: UInt32; outPacketDescriptions: AudioStreamPacketDescriptionPtr {__nullable}; inStartingPacket: SInt64; var ioNumPackets: UInt32; outBuffer: UnivPtr{__nullable}): OSStatus; external name '_AudioFileReadPackets';
+(* API_DEPRECATED("no longer supported", macos(10.2, 10.10), ios(2.0, 8.0)) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; *)
+
+
+{!
+    @function	AudioFileWritePackets
+    @abstract   Write packets of audio data to the audio file.
+    @discussion For all uncompressed formats, packets == frames.
+    @param inAudioFile				an AudioFileID.
+    @param inUseCache 				true if it is desired to cache the data upon write, else false
+    @param inNumBytes				the number of bytes being provided for write
+    @param inPacketDescriptions 	an array of packet descriptions describing the packets being 
+									provided. Not all formats require packet descriptions to be 
+									provided. NULL may be passed if no descriptions are required.   
+    @param inStartingPacket 		the packet index of where the first packet provided should be placed.
+    @param ioNumPackets 			on input, the number of packets to write, on output, the number of
+									packets actually written.
+    @param inBuffer 				a void * to user allocated memory containing the packets to write.
+    @result							returns noErr if successful.
+}
+function AudioFileWritePackets( inAudioFile: AudioFileID; inUseCache: Boolean; inNumBytes: UInt32; {const} inPacketDescriptions: AudioStreamPacketDescriptionPtr {__nullable}; inStartingPacket: SInt64; var ioNumPackets: UInt32; inBuffer: {const} UnivPtr ): OSStatus; external name '_AudioFileWritePackets';
+(* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+
+{!
+    @function	AudioFileCountUserData
+    @abstract   Get the number of user data items with a certain ID in the file
+    @discussion		"User Data" refers to chunks in AIFF, CAF and WAVE files, or resources 
+					in Sound Designer II files, and possibly other things in other files.
+					For simplicity, referred to below as "chunks".
+    @param      inAudioFile			an AudioFileID.
+    @param      inUserDataID		the four char code of the chunk.
+    @param      outNumberItems		on output, if successful, number of chunks of this type in the file.
+    @result							returns noErr if successful.
+}
+function AudioFileCountUserData( inAudioFile: AudioFileID; inUserDataID: UInt32; var outNumberItems: UInt32 ): OSStatus; external name '_AudioFileCountUserData';
+(* API_AVAILABLE(macos(10.4), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function	AudioFileGetUserDataSize
+    @abstract   Get the size of user data in a file
+    @param      inAudioFile			an AudioFileID.
+    @param      inUserDataID		the four char code of the chunk.
+    @param      inIndex				an index specifying which chunk if there are more than one.
+    @param      outUserDataSize		on output, if successful, the size of the user data chunk.
+    @result							returns noErr if successful.
+}
+function AudioFileGetUserDataSize( inAudioFile: AudioFileID; inUserDataID: UInt32; inIndex: UInt32; var outUserDataSize: UInt32 ): OSStatus; external name '_AudioFileGetUserDataSize';
+(* API_AVAILABLE(macos(10.4), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function	AudioFileGetUserData
+    @abstract   Get the data of a chunk in a file.
+    @param      inAudioFile			an AudioFileID.
+    @param      inUserDataID		the four char code of the chunk.
+    @param      inIndex				an index specifying which chunk if there are more than one.
+	@param		ioUserDataSize		the size of the buffer on input, size of bytes copied to buffer on output 
+    @param      outUserData			a pointer to a buffer in which to copy the chunk data.
+    @result							returns noErr if successful.
+}
+function AudioFileGetUserData( inAudioFile: AudioFileID; inUserDataID: UInt32; inIndex: UInt32; var ioUserDataSize: UInt32; outUserData: UnivPtr ): OSStatus; external name '_AudioFileGetUserData';
+(* API_AVAILABLE(macos(10.4), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function	AudioFileSetUserData
+    @abstract   Set the data of a chunk in a file.
+    @param      inAudioFile			an AudioFileID.
+    @param      inUserDataID		the four char code of the chunk.
+    @param      inIndex				an index specifying which chunk if there are more than one.
+	@param		inUserDataSize		on input the size of the data to copy, on output, size of bytes copied from the buffer  
+    @param      inUserData			a pointer to a buffer from which to copy the chunk data 
+									(only the contents of the chunk, not including the chunk header).
+    @result							returns noErr if successful.
+}
+function AudioFileSetUserData( inAudioFile: AudioFileID; inUserDataID: UInt32; inIndex: UInt32; inUserDataSize: UInt32; inUserData: {const} UnivPtr ): OSStatus; external name '_AudioFileSetUserData';
+(* API_AVAILABLE(macos(10.4), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+
+{!
+    @function	AudioFileRemoveUserData
+    @abstract   Remove a user chunk in a file.
+    @param      inAudioFile			an AudioFileID.
+    @param      inUserDataID		the four char code of the chunk.
+    @param      inIndex				an index specifying which chunk if there are more than one.
+    @result							returns noErr if successful.
+}
+
+function AudioFileRemoveUserData( inAudioFile: AudioFileID; inUserDataID: UInt32; inIndex: UInt32 ): OSStatus; external name '_AudioFileRemoveUserData';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+
+//=============================================================================
+//	Audio File Properties
+//=============================================================================
+
+{!
+    @enum		Audio File Properties
+    @abstract   constants for AudioFile get/set property calls
+    @constant   kAudioFilePropertyFileFormat 
+					An AudioFileTypeID that identifies the format of the file
+    @constant   kAudioFilePropertyDataFormat 
+					An AudioStreamBasicDescription describing the format of the audio data
+    @constant   kAudioFilePropertyFormatList 
+					In order to support formats such as AAC SBR where an encoded data stream can be decoded to 
+					multiple destination formats, this property returns an array of AudioFormatListItems (see AudioFormat.h) of those formats.
+					The default behavior is to return the an AudioFormatListItem that has the same AudioStreamBasicDescription 
+					that kAudioFilePropertyDataFormat returns.
+    @constant   kAudioFilePropertyIsOptimized 
+					A UInt32 indicating whether an Audio File has been optimized.
+					Optimized means it is ready to start having sound data written to it. 
+					A value of 0 indicates the file needs to be optimized.
+					A value of 1 indicates the file is currently optimized.
+    @constant   kAudioFilePropertyMagicCookieData 
+					A void * pointing to memory set up by the caller.
+					Some file types require that a magic cookie be provided before packets can be written
+					to the file, so this property should be set before calling 
+					AudioFileWriteBytes()/AudioFileWritePackets() if a magic cookie exists.
+    @constant   kAudioFilePropertyAudioDataByteCount 
+					a UInt64 that indicates the number of bytes of audio data contained in the file
+    @constant   kAudioFilePropertyAudioDataPacketCount 
+					a UInt64 that indicates the number of packets of audio data contained in the file
+    @constant   kAudioFilePropertyMaximumPacketSize 
+					a UInt32 that indicates the maximum size of a packet for the data contained in the file
+    @constant   kAudioFilePropertyDataOffset 
+					a SInt64 that indicates the byte offset in the file of the audio data.
+    @constant   kAudioFilePropertyChannelLayout 
+					An AudioChannelLayout struct.
+    @constant   kAudioFilePropertyDeferSizeUpdates 
+					A UInt32. If 1, then updating the files sizes in the header is not done for every write, 
+					but deferred until the file is read, optimized or closed. This is more efficient, but less safe
+					since, if the application crashes before the size is updated, the file may not be readable.
+					The default value is one, it doesn't update the header.
+    @constant   kAudioFilePropertyDataFormatName 
+					This is deprecated. Use kAudioFormatProperty_FormatName in AudioFormat.h instead.
+    @constant   kAudioFilePropertyMarkerList 
+					access the list of markers defined in the file. returns an AudioFileMarkerList.
+					The CFStringRefs in the returned structs must be released by the client.
+					(available in 10.2.4 and later)
+    @constant   kAudioFilePropertyRegionList 
+					access the list of regions defined in the file. returns an Array of AudioFileRegions.
+					The CFStringRefs in the returned structs must be released by the client.
+					(available in 10.2.4 and later)
+    @constant   kAudioFilePropertyPacketToFrame 
+					pass a AudioFramePacketTranslation with mPacket filled out and get mFrame back. mFrameOffsetInPacket is ignored.
+    @constant   kAudioFilePropertyFrameToPacket 
+					pass a AudioFramePacketTranslation with mFrame filled out and get mPacket and mFrameOffsetInPacket back.
+					
+	@constant	kAudioFilePropertyPacketToByte
+					pass an AudioBytePacketTranslation struct with mPacket filled out and get mByte back.
+					mByteOffsetInPacket is ignored. If the mByte value is an estimate then 
+					kBytePacketTranslationFlag_IsEstimate will be set in the mFlags field.
+	@constant	kAudioFilePropertyByteToPacket
+					pass an AudioBytePacketTranslation struct with mByte filled out and get mPacket and
+					mByteOffsetInPacket back. If the mPacket value is an estimate then 
+					kBytePacketTranslationFlag_IsEstimate will be set in the mFlags field.
+					
+    @constant   kAudioFilePropertyChunkIDs 
+					returns an array of OSType four char codes for each kind of chunk in the file.
+    @constant   kAudioFilePropertyInfoDictionary 
+					returns a CFDictionary filled with information about the data contained in the file. 
+					See dictionary key constants already defined for info string types. 
+					AudioFileComponents are free to add keys to the dictionaries that they return for this property...
+					caller is responsible for releasing the CFObject
+    @constant   kAudioFilePropertyPacketTableInfo 
+					Gets or sets an AudioFilePacketTableInfo struct for the file types that support it.
+					When setting, the sum of mNumberValidFrames, mPrimingFrames and mRemainderFrames must be the same as the total
+					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
+					the property and make sure the sum of the three values you set has the same sum as the three values you got.
+	@constant	kAudioFilePropertyPacketSizeUpperBound
+					a UInt32 for the theoretical maximum packet size in the file (without actually scanning
+					the whole file to find the largest packet, as may happen with kAudioFilePropertyMaximumPacketSize).
+	@constant	kAudioFilePropertyReserveDuration
+					The value is a Float64 of the duration in seconds of data that is expected to be written.
+					Setting this property before any data has been written reserves space in the file header for a packet table 
+					and/or other information so that it can appear before the audio data. Otherwise the packet table may get written at the 
+					end of the file, preventing the file from being streamable.
+	@constant	kAudioFilePropertyEstimatedDuration
+					The value is a Float64 representing an estimated duration in seconds. If duration can be calculated without scanning the entire file,
+					or all the audio data packets have been scanned, the value will accurately reflect the duration of the audio data. 
+	@constant	kAudioFilePropertyBitRate
+					Returns the bit rate for the audio data as a UInt32. For some formats this will be approximate.
+	@constant	kAudioFilePropertyID3Tag
+					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).
+					The ID3 tag is not manipulated in anyway either for read or write. 
+					When setting, this property must be called before calling AudioFileWritePackets.
+	@constant	kAudioFilePropertySourceBitDepth
+					For encoded data this property returns the bit depth of the source as an SInt32, if known.
+					The bit depth is expressed as a negative number if the source was floating point, e.g. -32 for float, -64 for double.
+	@constant	kAudioFilePropertyAlbumArtwork
+					returns a CFDataRef filled with the Album Art or NULL. 
+					The caller is responsible for releasing a non-NULL CFDataRef.
+					In order to parse the contents of the data, CGImageSourceCreateWithData may be used.
+    @constant	kAudioFilePropertyAudioTrackCount
+                    a UInt32 that indicates the number of audio tracks contained in the file. (get property only)
+    @constant	kAudioFilePropertyUseAudioTrack
+                    a UInt32 that indicates the number of audio tracks contained in the file. (set property only)
+ }
+const
+	kAudioFilePropertyFileFormat = FourCharCode('ffmt');
+	kAudioFilePropertyDataFormat = FourCharCode('dfmt');
+	kAudioFilePropertyIsOptimized = FourCharCode('optm');
+	kAudioFilePropertyMagicCookieData = FourCharCode('mgic');
+	kAudioFilePropertyAudioDataByteCount = FourCharCode('bcnt');
+	kAudioFilePropertyAudioDataPacketCount = FourCharCode('pcnt');
+	kAudioFilePropertyMaximumPacketSize = FourCharCode('psze');
+	kAudioFilePropertyDataOffset = FourCharCode('doff');
+	kAudioFilePropertyChannelLayout = FourCharCode('cmap');
+	kAudioFilePropertyDeferSizeUpdates = FourCharCode('dszu');
+	kAudioFilePropertyDataFormatName = FourCharCode('fnme');
+	kAudioFilePropertyMarkerList = FourCharCode('mkls');
+	kAudioFilePropertyRegionList = FourCharCode('rgls');
+	kAudioFilePropertyPacketToFrame = FourCharCode('pkfr');
+	kAudioFilePropertyFrameToPacket = FourCharCode('frpk');
+	kAudioFilePropertyPacketToByte = FourCharCode('pkby');
+	kAudioFilePropertyByteToPacket = FourCharCode('bypk');
+	kAudioFilePropertyChunkIDs = FourCharCode('chid');
+	kAudioFilePropertyInfoDictionary = FourCharCode('info');
+	kAudioFilePropertyPacketTableInfo = FourCharCode('pnfo');
+	kAudioFilePropertyFormatList = FourCharCode('flst');
+	kAudioFilePropertyPacketSizeUpperBound = FourCharCode('pkub');
+	kAudioFilePropertyReserveDuration = FourCharCode('rsrv');
+	kAudioFilePropertyEstimatedDuration = FourCharCode('edur');
+	kAudioFilePropertyBitRate = FourCharCode('brat');
+	kAudioFilePropertyID3Tag = FourCharCode('id3t');
+	kAudioFilePropertySourceBitDepth = FourCharCode('sbtd');
+	kAudioFilePropertyAlbumArtwork = FourCharCode('aart');
+	kAudioFilePropertyAudioTrackCount = FourCharCode('atct');
+	kAudioFilePropertyUseAudioTrack = FourCharCode('uatk'); 
+
+
+{!
+    @function	AudioFileGetPropertyInfo
+    @abstract   Get information about the size of a property of an AudioFile  and whether it can be set.
+    @param      inAudioFile			an AudioFileID.
+    @param      inPropertyID		an AudioFileProperty constant.
+    @param      outDataSize			the size in bytes of the current value of the property. In order to get the property value, 
+									you will need a buffer of this size.
+    @param      isWritable			will be set to 1 if writable, or 0 if read only.
+    @result							returns noErr if successful.
+}
+function AudioFileGetPropertyInfo( inAudioFile: AudioFileID; inPropertyID: AudioFilePropertyID; outDataSize: UInt32Ptr {__nullable}; isWritable: UInt32Ptr {__nullable} ): OSStatus; external name '_AudioFileGetPropertyInfo';
+(* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
+                                
+{!
+    @function	AudioFileGetProperty
+    @abstract   Copies the value for a property of an AudioFile into a buffer.
+    @param      inAudioFile			an AudioFileID.
+    @param      inPropertyID		an AudioFileProperty constant.
+    @param      ioDataSize			on input the size of the outPropertyData buffer. On output the number of bytes written to the buffer.
+    @param      outPropertyData		the buffer in which to write the property data.
+    @result							returns noErr if successful.
+}
+function AudioFileGetProperty( inAudioFile: AudioFileID; inPropertyID: AudioFilePropertyID; var ioDataSize: UInt32; outPropertyData: UnivPtr ): OSStatus; external name '_AudioFileGetProperty';
+(* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
+                        
+{!
+    @function	AudioFileSetProperty
+    @abstract   Sets the value for a property of an AudioFile .
+    @param      inAudioFile			an AudioFileID.
+    @param      inPropertyID		an AudioFileProperty constant.
+    @param      inDataSize			the size of the property data.
+    @param      inPropertyData		the buffer containing the property data.
+    @result							returns noErr if successful.
+}
+function AudioFileSetProperty( inAudioFile: AudioFileID; inPropertyID: AudioFilePropertyID; inDataSize: UInt32; inPropertyData: {const} UnivPtr ): OSStatus; external name '_AudioFileSetProperty';
+(* API_AVAILABLE(macos(10.2), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+
+//=============================================================================
+//	Audio File Global Info Properties
+//=============================================================================
+
+{!
+    @enum		Audio File Global Info Properties
+    @abstract   constants for AudioFileGetGlobalInfo properties
+    @constant   kAudioFileGlobalInfo_ReadableTypes
+					No specifier needed. Must be set to NULL.
+					Returns an array of UInt32 containing the file types 
+					(i.e. AIFF, WAVE, etc) that can be opened for reading.
+    @constant   kAudioFileGlobalInfo_WritableTypes
+					No specifier needed. Must be set to NULL.
+					Returns an array of UInt32 containing the file types 
+					(i.e. AIFF, WAVE, etc) that can be opened for writing.
+    @constant   kAudioFileGlobalInfo_FileTypeName
+					Specifier is a pointer to a AudioFileTypeID containing a file type.
+					Returns a CFString containing the name for the file type. 
+    @constant   kAudioFileGlobalInfo_AvailableFormatIDs
+					Specifier is a pointer to a AudioFileTypeID containing a file type.
+					Returns a array of format IDs for formats that can be read. 
+    @constant   kAudioFileGlobalInfo_AvailableStreamDescriptionsForFormat
+					Specifier is a pointer to a AudioFileTypeAndFormatID struct defined below.
+					Returns an array of AudioStreamBasicDescriptions which have all of the 
+					formats for a particular file type and format ID. The AudioStreamBasicDescriptions
+					have the following fields filled in: mFormatID, mFormatFlags, mBitsPerChannel
+					writing new files.
+					
+					
+    @constant   kAudioFileGlobalInfo_AllExtensions
+					No specifier needed. Must be set to NULL.
+					Returns a CFArray of CFStrings containing all file extensions 
+					that are recognized. The array be used when creating an NSOpenPanel.
+
+    @constant   kAudioFileGlobalInfo_AllHFSTypeCodes
+					No specifier needed. Must be set to NULL.
+					Returns an array of HFSTypeCode's containing all HFSTypeCodes
+					that are recognized.
+
+    @constant   kAudioFileGlobalInfo_AllUTIs
+					No specifier needed. Must be set to NULL.
+					Returns a CFArray of CFString of all Universal Type Identifiers
+					that are recognized by AudioFile. 
+					The caller is responsible for releasing the CFArray.
+
+    @constant   kAudioFileGlobalInfo_AllMIMETypes
+					No specifier needed. Must be set to NULL.
+					Returns a CFArray of CFString of all MIME types
+					that are recognized by AudioFile. 
+					The caller is responsible for releasing the CFArray.
+
+
+    @constant   kAudioFileGlobalInfo_ExtensionsForType
+					Specifier is a pointer to a AudioFileTypeID containing a file type.
+					Returns a CFArray of CFStrings containing the file extensions 
+					that are recognized for this file type. 
+
+    @constant   kAudioFileGlobalInfo_HFSTypeCodesForType
+					Specifier is a pointer to an AudioFileTypeID.
+					Returns an array of HFSTypeCodes corresponding to that file type.
+					The first type in the array is the preferred one for use when
+
+    @constant   kAudioFileGlobalInfo_UTIsForType
+					Specifier is a pointer to an AudioFileTypeID.
+					Returns a CFArray of CFString of all Universal Type Identifiers
+					that are recognized by the file type. 
+					The caller is responsible for releasing the CFArray.
+
+    @constant   kAudioFileGlobalInfo_MIMETypesForType
+					Specifier is a pointer to an AudioFileTypeID.
+					Returns a CFArray of CFString of all MIME types
+					that are recognized by the file type. 
+					The caller is responsible for releasing the CFArray.
+
+	these are inverses of the above:
+
+    @constant   kAudioFileGlobalInfo_TypesForExtension
+					Specifier is a CFStringRef containing a file extension.
+					Returns an array of all AudioFileTypeIDs that support the extension. 
+	
+    @constant   kAudioFileGlobalInfo_TypesForHFSTypeCode
+					Specifier is an HFSTypeCode.
+					Returns an array of all AudioFileTypeIDs that support the HFSTypeCode. 
+
+    @constant   kAudioFileGlobalInfo_TypesForUTI
+					Specifier is a CFStringRef containing a Universal Type Identifier.
+					Returns an array of all AudioFileTypeIDs that support the UTI. 
+
+    @constant   kAudioFileGlobalInfo_TypesForMIMEType
+					Specifier is a CFStringRef containing a MIME Type.
+					Returns an array of all AudioFileTypeIDs that support the MIME type. 
+
+}
+const
+	kAudioFileGlobalInfo_ReadableTypes = FourCharCode('afrf');
+	kAudioFileGlobalInfo_WritableTypes = FourCharCode('afwf');
+	kAudioFileGlobalInfo_FileTypeName = FourCharCode('ftnm');
+	kAudioFileGlobalInfo_AvailableStreamDescriptionsForFormat = FourCharCode('sdid');
+	kAudioFileGlobalInfo_AvailableFormatIDs = FourCharCode('fmid');
+	kAudioFileGlobalInfo_AllExtensions = FourCharCode('alxt');
+	kAudioFileGlobalInfo_AllHFSTypeCodes = FourCharCode('ahfs');
+	kAudioFileGlobalInfo_AllUTIs = FourCharCode('auti');
+	kAudioFileGlobalInfo_AllMIMETypes = FourCharCode('amim');
+	kAudioFileGlobalInfo_ExtensionsForType = FourCharCode('fext');
+	kAudioFileGlobalInfo_HFSTypeCodesForType = FourCharCode('fhfs');
+	kAudioFileGlobalInfo_UTIsForType = FourCharCode('futi');
+	kAudioFileGlobalInfo_MIMETypesForType = FourCharCode('fmim');
+	kAudioFileGlobalInfo_TypesForMIMEType = FourCharCode('tmim');
+	kAudioFileGlobalInfo_TypesForUTI = FourCharCode('tuti');
+	kAudioFileGlobalInfo_TypesForHFSTypeCode = FourCharCode('thfs');
+	kAudioFileGlobalInfo_TypesForExtension = FourCharCode('text'); 
+
+
+{!
+    @struct		AudioFileTypeAndFormatID
+    @abstract   This is used as a specifier for kAudioFileGlobalInfo_AvailableStreamDescriptions
+    @discussion This struct is used to specify a desired audio file type and data format ID  so
+				that a list of stream descriptions of available formats can be obtained.
+    @field      mFileType
+					a four char code for the file type such as kAudioFileAIFFType, kAudioFileCAFType, etc.
+    @field      mFormatID
+					a four char code for the format ID such as kAudioFormatLinearPCM, kAudioFormatMPEG4AAC, etc.
+}
+type
+	AudioFileTypeAndFormatID = record
+		mFileType: AudioFileTypeID;
+		mFormatID: UInt32;
+	end;
+
+
+{!
+    @function	AudioFileGetGlobalInfoSize
+    @abstract   Get the size of a global property.
+    @param      inPropertyID		an AudioFileGlobalInfo property constant.
+    @param      inSpecifierSize		The size of the specifier data.
+    @param      inSpecifier			A specifier is a buffer of data used as an input argument to some of the global info properties.
+    @param      outDataSize			the size in bytes of the current value of the property. In order to get the property value, 
+									you will need a buffer of this size.
+    @result							returns noErr if successful.
+}
+function AudioFileGetGlobalInfoSize( inPropertyID: AudioFilePropertyID; inSpecifierSize: UInt32; inSpecifier: UnivPtr {__nullable}; var outDataSize: UInt32 ): OSStatus; external name '_AudioFileGetGlobalInfoSize';
+(* API_AVAILABLE(macos(10.3), ios(2.0), watchos(2.0), tvos(9.0)) *)
+                                
+{!
+    @function	AudioFileGetGlobalInfo
+    @abstract   Copies the value for a global property into a buffer.
+    @param      inPropertyID		an AudioFileGlobalInfo property constant.
+    @param      inSpecifierSize		The size of the specifier data.
+    @param      inSpecifier			A specifier is a buffer of data used as an input argument to some of the global info properties.
+    @param      ioDataSize			on input the size of the outPropertyData buffer. On output the number of bytes written to the buffer.
+    @param      outPropertyData		the buffer in which to write the property data.
+    @result							returns noErr if successful.
+}
+function AudioFileGetGlobalInfo( inPropertyID: AudioFilePropertyID; inSpecifierSize: UInt32; inSpecifier: UnivPtr {__nullable}; var ioDataSize: UInt32; outPropertyData: UnivPtr ): OSStatus; external name '_AudioFileGetGlobalInfo';
+(* API_AVAILABLE(macos(10.3), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+//#pragma mark - Deprecated
+
+(*	
+struct FSRef;
+{!
+    @function	AudioFileCreate
+    @abstract   creates a new audio file
+    @discussion	creates a new audio file located in the parent directory 
+                      provided. Upon success, an AudioFileID is returned which can
+                      be used for subsequent calls to the AudioFile APIs.
+    @param inParentRef		an FSRef to the directory where  the new file should be created.
+    @param inFileName		a CFStringRef containing the name of the file to be created.
+    @param inFileType		an AudioFileTypeID indicating the type of audio file to create.
+    @param inFormat			an AudioStreamBasicDescription describing the data format that will be
+							added to the audio file.
+    @param inFlags			relevant flags for creating/opening the file. 
+    @param outNewFileRef	if successful, the FSRef of the newly created file.
+    @param outAudioFile		if successful, an AudioFileID that can be used for subsequent AudioFile calls.
+    @result					returns noErr if successful.
+	@deprecated				in Mac OS X 10.6, see AudioFileCreateWithURL
+}
+extern OSStatus	
+AudioFileCreate (	const struct FSRef					*inParentRef, 
+                    CFStringRef							inFileName,
+                    AudioFileTypeID						inFileType,
+                    const AudioStreamBasicDescription	*inFormat,
+                    AudioFileFlags						inFlags,
+                    struct FSRef						*outNewFileRef,
+                    AudioFileID	__nullable * __nonnull	outAudioFile)		API_DEPRECATED("no longer supported", macos(10.2, 10.6)) API_UNAVAILABLE(ios, watchos, tvos);
+
+{!
+    @function				AudioFileInitialize
+    @abstract				Write over an existing audio file.
+    @discussion				Use AudioFileInitialize to wipe clean an existing audio file
+							and prepare it to be populated with new data.
+    @param inFileRef		the FSRef of an existing audio file.
+    @param inFileType		an AudioFileTypeID indicating the type of audio file to initialize the file to. 
+    @param inFormat			an AudioStreamBasicDescription describing the data format that will be
+							added to the audio file.
+    @param inFlags			flags for creating/opening the file. Currently zero.
+    @param outAudioFile		upon success, an AudioFileID that can be used for subsequent
+							AudioFile calls.
+    @result					returns noErr if successful.
+	@deprecated				in Mac OS X 10.6, see AudioFileCreateWithURL
+}
+extern OSStatus	
+AudioFileInitialize (	const struct FSRef					*inFileRef,
+                        AudioFileTypeID						inFileType,
+                        const AudioStreamBasicDescription	*inFormat,
+                        AudioFileFlags						inFlags,
+                        AudioFileID	__nullable * __nonnull	outAudioFile)	API_DEPRECATED("no longer supported", macos(10.2, 10.6)) API_UNAVAILABLE(ios, watchos, tvos);
+
+{!
+    @function				AudioFileOpen
+    @abstract				Open an existing audio file.
+    @discussion				Open an existing audio file for reading or reading and writing.
+    @param inFileRef		the FSRef of an existing audio file.
+    @param inPermissions	use the permission constants
+    @param inFileTypeHint	For files which have no filename extension and whose type cannot be easily or
+							uniquely determined from the data (ADTS,AC3), this hint can be used to indicate the file type. 
+							Otherwise you can pass zero for this. The hint is only used on OS versions 10.3.1 or greater.
+							For OS versions prior to that, opening files of the above description will fail.
+    @param outAudioFile		upon success, an AudioFileID that can be used for subsequent
+							AudioFile calls.
+    @result					returns noErr if successful.
+	@deprecated				in Mac OS X 10.6, see AudioFileOpenURL
+}
+extern OSStatus	
+AudioFileOpen (	const struct FSRef		*inFileRef,
+                AudioFilePermissions	inPermissions,
+                AudioFileTypeID			inFileTypeHint,
+                AudioFileID	__nullable * __nonnull	outAudioFile)			API_DEPRECATED("no longer supported", macos(10.2, 10.6)) API_UNAVAILABLE(ios, watchos, tvos);
+
+	
+*)
+//CF_ASSUME_NONNULL_END
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+implementation
+
+function NumBytesToNumAudioFileMarkers(inNumBytes: size_t): size_t;
+begin
+  if inNumBytes < size_t(@AudioFileMarkerListPtr(nil)^.mMarkers[0]) then
+    NumBytesToNumAudioFileMarkers := 0
+  else
+    NumBytesToNumAudioFileMarkers := inNumBytes - size_t(@AudioFileMarkerListPtr(nil)^.mMarkers[0])
+end;
+
+
+function NumAudioFileMarkersToNumBytes(inNumMarkers: size_t): size_t;
+begin
+	NumAudioFileMarkersToNumBytes := size_t(@AudioFileMarkerListPtr(nil)^.mMarkers[0]) + (inNumMarkers) * sizeof(AudioFileMarker);
+end;
+
+
+function NextAudioFileRegion(const {var} inAFRegionPtr: AudioFileRegion): AudioFileRegionPtr;
+begin
+  NextAudioFileRegion := AudioFileRegionPtr(
+    Pointer(@inAFRegionPtr) +
+    MacPtrUInt(@AudioFileRegionPtr(nil)^.mMarkers) +
+    (inAFRegionPtr.mNumberMarkers*sizeof(AudioFileMarker))
+    );
+  end;
+
+end.
+
+{$endc} {not MACOSALLINCLUDE}

+ 930 - 0
packages/univint/src/AudioFileComponents.pas

@@ -0,0 +1,930 @@
+{!
+	@file		AudioFileComponent.h
+	@framework	AudioToolbox.framework
+	@copyright	(c) 2004-2015 by Apple, Inc., all rights reserved.
+
+	@abstract	Interfaces for components which implement knowledge of audio file formats.
+    @discussion
+    	Audio file components are not for the use of clients. Rather, they are called by the
+    	implementation of the AudioFile API to implement the various semantics of that API.
+		Most of these calls match a call in the AudioFile API which calls through to the component.
+
+		A component may be used in two ways, either associated with a file or not. If a component is
+		not associated with a file, it may be used to answer questions about the file type in
+		general and whether some data is recognized by that file type. A component is associated
+		with a file by calling one of the AudioFile Create, Open or Initialize calls. If a component
+		is associated with a file, then it can also be asked to perform any of the calls that
+		implement the AudioFile API.
+}
+{  Pascal Translation: Jonas Maebe <[email protected]>, July 2019 }
+{
+    Modified for use with Free Pascal
+    Version 308
+    Please report any bugs to <[email protected]>
+}
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+{$mode macpas}
+{$modeswitch cblocks}
+{$packenum 1}
+{$macro on}
+{$inline on}
+{$calling mwpascal}
+
+unit AudioFileComponents;
+interface
+{$setc UNIVERSAL_INTERFACES_VERSION := $0400}
+{$setc GAP_INTERFACES_VERSION := $0308}
+
+{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
+    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
+{$endc}
+
+{$ifc defined CPUPOWERPC and defined CPUI386}
+	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
+{$endc}
+{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
+	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
+{$endc}
+
+{$ifc not defined __ppc__ and defined CPUPOWERPC32}
+	{$setc __ppc__ := 1}
+{$elsec}
+	{$setc __ppc__ := 0}
+{$endc}
+{$ifc not defined __ppc64__ and defined CPUPOWERPC64}
+	{$setc __ppc64__ := 1}
+{$elsec}
+	{$setc __ppc64__ := 0}
+{$endc}
+{$ifc not defined __i386__ and defined CPUI386}
+	{$setc __i386__ := 1}
+{$elsec}
+	{$setc __i386__ := 0}
+{$endc}
+{$ifc not defined __x86_64__ and defined CPUX86_64}
+	{$setc __x86_64__ := 1}
+{$elsec}
+	{$setc __x86_64__ := 0}
+{$endc}
+{$ifc not defined __arm__ and defined CPUARM}
+	{$setc __arm__ := 1}
+{$elsec}
+	{$setc __arm__ := 0}
+{$endc}
+{$ifc not defined __arm64__ and defined CPUAARCH64}
+  {$setc __arm64__ := 1}
+{$elsec}
+  {$setc __arm64__ := 0}
+{$endc}
+
+{$ifc defined cpu64}
+  {$setc __LP64__ := 1}
+{$elsec}
+  {$setc __LP64__ := 0}
+{$endc}
+
+
+{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
+	{$error Conflicting definitions for __ppc__ and __i386__}
+{$endc}
+
+{$ifc defined __ppc__ and __ppc__}
+	{$setc TARGET_CPU_PPC := TRUE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __ppc64__ and __ppc64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := TRUE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __i386__ and __i386__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := TRUE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __x86_64__ and __x86_64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := TRUE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __arm__ and __arm__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := TRUE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := TRUE}
+{$elifc defined __arm64__ and __arm64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := TRUE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := TRUE}
+{$elsec}
+	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
+{$endc}
+
+{$ifc defined __LP64__ and __LP64__ }
+  {$setc TARGET_CPU_64 := TRUE}
+{$elsec}
+  {$setc TARGET_CPU_64 := FALSE}
+{$endc}
+
+{$ifc defined FPC_BIG_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
+{$elifc defined FPC_LITTLE_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
+{$elsec}
+	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
+{$endc}
+{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
+{$setc CALL_NOT_IN_CARBON := FALSE}
+{$setc OLDROUTINENAMES := FALSE}
+{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
+{$setc OPAQUE_UPP_TYPES := TRUE}
+{$setc OTCARBONAPPLICATION := TRUE}
+{$setc OTKERNEL := FALSE}
+{$setc PM_USE_SESSION_APIS := TRUE}
+{$setc TARGET_API_MAC_CARBON := TRUE}
+{$setc TARGET_API_MAC_OS8 := FALSE}
+{$setc TARGET_API_MAC_OSX := TRUE}
+{$setc TARGET_CARBON := TRUE}
+{$setc TARGET_CPU_68K := FALSE}
+{$setc TARGET_CPU_MIPS := FALSE}
+{$setc TARGET_CPU_SPARC := FALSE}
+{$setc TARGET_OS_UNIX := FALSE}
+{$setc TARGET_OS_WIN32 := FALSE}
+{$setc TARGET_RT_MAC_68881 := FALSE}
+{$setc TARGET_RT_MAC_CFM := FALSE}
+{$setc TARGET_RT_MAC_MACHO := TRUE}
+{$setc TYPED_FUNCTION_POINTERS := TRUE}
+{$setc TYPE_BOOL := FALSE}
+{$setc TYPE_EXTENDED := FALSE}
+{$setc TYPE_LONGLONG := TRUE}
+uses MacTypes,CFBase,CoreAudioTypes,Files,AudioFile,AudioComponents;
+{$endc} {not MACOSALLINCLUDE}
+
+{$ALIGN POWER}
+
+
+//==================================================================================================
+//	Includes
+//==================================================================================================
+
+
+//CF_ASSUME_NONNULL_BEGIN
+
+
+{!
+    @typedef	AudioFileComponent
+    @abstract		represents an instance of an AudioFileComponent.
+}
+type
+	AudioFileComponent = AudioComponentInstance;
+	AudioFileComponentPtr = ^AudioFileComponent;
+{!
+    @typedef	AudioFileComponentPropertyID
+    @abstract		a four char code for a property ID.
+}
+type
+	AudioFileComponentPropertyID = UInt32;
+	AudioFileComponentPropertyIDPtr = ^AudioFileComponentPropertyID;
+
+{$ifc TARGET_OS_MAC}
+{!
+    @function	AudioFileComponentCreateURL
+    @abstract   creates a new (or initialises an existing) audio file specified by the URL.
+    @discussion	creates a new (or initialises an existing) audio file specified by the URL.
+    @param inComponent		an AudioFileComponent
+    @param inFileRef		an CFURLRef fully specifying the path of the file to create/initialise
+    @param inFormat			an AudioStreamBasicDescription describing the data format that will be
+							added to the audio file.
+    @param inFlags			relevant flags for creating/opening the file. 
+								if kAudioFileFlags_EraseFile is set, it will erase an existing file
+								 if not set, then the Create call will fail if the URL is an existing file
+    @result					returns noErr if successful.
+}
+function AudioFileComponentCreateURL( inComponent: AudioFileComponent; inFileRef: CFURLRef; const (*var*) inFormat: AudioStreamBasicDescription; inFlags: UInt32 ): OSStatus; external name '_AudioFileComponentCreateURL';
+(* API_AVAILABLE(macos(10.5)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+{!
+    @function				AudioFileComponentOpenURL
+    @abstract				Open an existing audio file.
+    @discussion				Open an existing audio file for reading or reading and writing.
+    @param inComponent		an AudioFileComponent.
+    @param inFileRef		the CFURLRef of an existing audio file.
+    @param inPermissions	use the permission constants.
+    @param inFileDescriptor	an open file descriptor.
+    @result					returns noErr if successful.
+}
+function AudioFileComponentOpenURL( inComponent: AudioFileComponent; inFileRef: CFURLRef; inPermissions: SInt8; inFileDescriptor: SInt32 ): OSStatus; external name '_AudioFileComponentOpenURL';
+(* API_AVAILABLE(macos(10.5)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+{!
+    @function	AudioFileComponentOpenWithCallbacks
+    @abstract   implements AudioFileOpenWithCallbacks
+    @param inComponent		an AudioFileComponent
+    @param inClientData 	a constant that will be passed to your callbacks.
+	@param inReadFunc		a function that will be called when AudioFile needs to read data.
+	@param inWriteFunc		a function that will be called when AudioFile needs to write data.
+	@param inGetSizeFunc	a function that will be called when AudioFile needs to know the file size.
+	@param inSetSizeFunc	a function that will be called when AudioFile needs to set the file size.
+    @result					returns noErr if successful.
+}
+function AudioFileComponentOpenWithCallbacks( inComponent: AudioFileComponent; inClientData: UnivPtr; inReadFunc: AudioFile_ReadProc; inWriteFunc: AudioFile_WriteProc; inGetSizeFunc: AudioFile_GetSizeProc; inSetSizeFunc: AudioFile_SetSizeProc ): OSStatus; external name '_AudioFileComponentOpenWithCallbacks';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+{!
+    @function	AudioFileComponentInitializeWithCallbacks
+    @abstract   implements AudioFileInitializeWithCallbacks
+    @param inComponent		an AudioFileComponent
+    @param inClientData 	a constant that will be passed to your callbacks.
+	@param inReadFunc		a function that will be called when AudioFile needs to read data.
+	@param inWriteFunc		a function that will be called when AudioFile needs to write data.
+	@param inGetSizeFunc	a function that will be called when AudioFile needs to know the file size.
+	@param inSetSizeFunc	a function that will be called when AudioFile needs to set the file size.
+    @param inFileType 		an AudioFileTypeID indicating the type of audio file to which to initialize the file. 
+    @param inFormat			an AudioStreamBasicDescription describing the data format that will be
+							added to the audio file.
+    @param inFlags			relevant flags for creating/opening the file. Currently zero.
+    @result					returns noErr if successful.
+}
+function AudioFileComponentInitializeWithCallbacks( inComponent: AudioFileComponent; inClientData: UnivPtr; inReadFunc: AudioFile_ReadProc; inWriteFunc: AudioFile_WriteProc; inGetSizeFunc: AudioFile_GetSizeProc; inSetSizeFunc: AudioFile_SetSizeProc; inFileType: UInt32; const (*var*) inFormat: AudioStreamBasicDescription; inFlags: UInt32 ): OSStatus; external name '_AudioFileComponentInitializeWithCallbacks';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+
+{!
+    @function	AudioFileComponentCloseFile
+    @abstract   implements AudioFileClose.
+    @param inComponent		an AudioFileComponent
+    @result					returns noErr if successful.
+}
+function AudioFileComponentCloseFile( inComponent: AudioFileComponent ): OSStatus; external name '_AudioFileComponentCloseFile';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+				
+{!
+    @function	AudioFileComponentOptimize
+    @abstract   implements AudioFileOptimize.
+    @param inComponent		an AudioFileComponent
+    @result					returns noErr if successful.
+}
+function AudioFileComponentOptimize( inComponent: AudioFileComponent ): OSStatus; external name '_AudioFileComponentOptimize';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+				
+{!
+    @function	AudioFileComponentReadBytes
+    @abstract   implements AudioFileReadBytes. 
+				
+    @discussion				Returns kAudioFileEndOfFileError when read encounters end of file.
+    @param inComponent		an AudioFileComponent
+    @param inUseCache 		true if it is desired to cache the data upon read, else false
+    @param inStartingByte	the byte offset of the audio data desired to be returned
+    @param ioNumBytes 		on input, the number of bytes to read, on output, the number of
+							bytes actually read.
+    @param outBuffer 		outBuffer should be a void * to user allocated memory large enough for the requested bytes. 
+    @result					returns noErr if successful.
+}
+function AudioFileComponentReadBytes( inComponent: AudioFileComponent; inUseCache: Boolean; inStartingByte: SInt64; var ioNumBytes: UInt32; outBuffer: UnivPtr ): OSStatus; external name '_AudioFileComponentReadBytes';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+						
+{!
+    @function				AudioFileComponentWriteBytes
+    @abstract				implements AudioFileWriteBytes.
+    @param inComponent		an AudioFileComponent
+    @param inUseCache 		true if it is desired to cache the data upon write, else false
+    @param inStartingByte	the byte offset where the audio data should be written
+    @param ioNumBytes 		on input, the number of bytes to write, on output, the number of
+							bytes actually written.
+    @param inBuffer 		inBuffer should be a void * containing the bytes to be written 
+    @result					returns noErr if successful.
+}
+function AudioFileComponentWriteBytes( inComponent: AudioFileComponent; inUseCache: Boolean; inStartingByte: SInt64; var ioNumBytes: UInt32; inBuffer: {const} UnivPtr ): OSStatus; external name '_AudioFileComponentWriteBytes';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+						
+{!
+    @function	AudioFileComponentReadPackets
+    @abstract   implements AudioFileReadPackets.
+    @discussion For all uncompressed formats, packets == frames.
+				ioNumPackets less than requested indicates end of file.
+
+    @param inComponent				an AudioFileComponent
+    @param inUseCache 				true if it is desired to cache the data upon read, else false
+    @param outNumBytes				on output, the number of bytes actually returned
+    @param outPacketDescriptions 	on output, an array of packet descriptions describing
+									the packets being returned. NULL may be passed for this
+									parameter. Nothing will be returned for linear pcm data.   
+    @param inStartingPacket 		the packet index of the first packet desired to be returned
+    @param ioNumPackets 			on input, the number of packets to read, on output, the number of
+									packets actually read.
+    @param outBuffer 				outBuffer should be a pointer to user allocated memory of size: 
+									number of packets requested times file's maximum (or upper bound on)
+									packet size.
+    @result							returns noErr if successful.
+}
+function AudioFileComponentReadPackets( inComponent: AudioFileComponent; inUseCache: Boolean; var outNumBytes: UInt32; outPacketDescriptions: AudioStreamPacketDescriptionPtr {* __nullable}; inStartingPacket: SInt64; var ioNumPackets: UInt32; outBuffer: UnivPtr ): OSStatus; external name '_AudioFileComponentReadPackets';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+									
+
+{!
+    @function	AudioFileComponentReadPacketData
+    @abstract   implements AudioFileReadPacketData.
+    @discussion For all uncompressed formats, packets == frames.
+				If the byte size of the number packets requested is 
+				less than the buffer size, ioNumBytes will be reduced.
+				If the buffer is too small for the number of packets 
+				requested, ioNumPackets and ioNumBytes will be reduced 
+				to the number of packets that can be accommodated and their byte size.
+				Returns kAudioFileEndOfFileError when read encounters end of file.
+
+    @param inComponent				an AudioFileComponent
+    @param inUseCache 				true if it is desired to cache the data upon read, else false
+    @param ioNumBytes				on input the size of outBuffer in bytes. 
+									on output, the number of bytes actually returned.
+    @param outPacketDescriptions 	on output, an array of packet descriptions describing
+									the packets being returned. NULL may be passed for this
+									parameter. Nothing will be returned for linear pcm data.   
+    @param inStartingPacket 		the packet index of the first packet desired to be returned
+    @param ioNumPackets 			on input, the number of packets to read, on output, the number of
+									packets actually read.
+    @param outBuffer 				outBuffer should be a pointer to user allocated memory.
+    @result							returns noErr if successful.
+}
+function AudioFileComponentReadPacketData( inComponent: AudioFileComponent; inUseCache: Boolean; var ioNumBytes: UInt32; outPacketDescriptions: AudioStreamPacketDescriptionPtr {* __nullable}; inStartingPacket: SInt64; var ioNumPackets: UInt32; outBuffer: UnivPtr ): OSStatus; external name '_AudioFileComponentReadPacketData';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+									
+{!
+    @function	AudioFileComponentWritePackets
+    @abstract   implements AudioFileWritePackets.
+    @discussion For all uncompressed formats, packets == frames.
+    @param inComponent				an AudioFileComponent
+    @param inUseCache 				true if it is desired to cache the data upon write, else false
+    @param inNumBytes				the number of bytes being provided for write
+    @param inPacketDescriptions 	an array of packet descriptions describing the packets being 
+									provided. Not all formats require packet descriptions to be 
+									provided. NULL may be passed if no descriptions are required.   
+    @param inStartingPacket 		the packet index of where the first packet provided should be placed.
+    @param ioNumPackets 			on input, the number of packets to write, on output, the number of
+									packets actually written.
+    @param inBuffer 				a void * to user allocated memory containing the packets to write.
+    @result							returns noErr if successful.
+}
+function AudioFileComponentWritePackets( inComponent: AudioFileComponent; inUseCache: Boolean; inNumBytes: UInt32; {const} inPacketDescriptions: AudioStreamPacketDescriptionPtr {* __nullable}; inStartingPacket: SInt64; var ioNumPackets: UInt32; inBuffer: {const} UnivPtr ): OSStatus; external name '_AudioFileComponentWritePackets';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+
+{!
+    @function	AudioFileComponentGetPropertyInfo
+    @abstract   implements AudioFileGetPropertyInfo.
+    @param		inComponent			an AudioFileComponent
+    @param      inPropertyID		an AudioFileProperty constant.
+    @param      outPropertySize		the size in bytes of the current value of the property. In order to get the property value, 
+									you will need a buffer of this size.
+    @param      outWritable			will be set to 1 if writable, or 0 if read only.
+    @result							returns noErr if successful.
+}
+function AudioFileComponentGetPropertyInfo( inComponent: AudioFileComponent; inPropertyID: AudioFileComponentPropertyID; outPropertySize: UInt32Ptr {* __nullable}; outWritable: UInt32Ptr {* __nullable} ): OSStatus; external name '_AudioFileComponentGetPropertyInfo';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+
+{!
+    @function	AudioFileComponentGetProperty
+    @abstract   implements AudioFileGetProperty.
+    @param		inComponent			an AudioFileComponent
+    @param      inPropertyID		an AudioFileProperty constant.
+    @param      ioPropertyDataSize	on input the size of the outPropertyData buffer. On output the number of bytes written to the buffer.
+    @param      outPropertyData		the buffer in which to write the property data.
+    @result							returns noErr if successful.
+}
+function AudioFileComponentGetProperty( inComponent: AudioFileComponent; inPropertyID: AudioFileComponentPropertyID; var ioPropertyDataSize: UInt32; outPropertyData: UnivPtr ): OSStatus; external name '_AudioFileComponentGetProperty';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+{!
+    @function	AudioFileComponentSetProperty
+    @abstract   implements AudioFileSetProperty.
+    @param		inComponent			an AudioFileComponent
+    @param      inPropertyID		an AudioFileProperty constant.
+    @param      inPropertyDataSize	the size of the property data.
+    @param      inPropertyData		the buffer containing the property data.
+    @result							returns noErr if successful.
+}
+function AudioFileComponentSetProperty( inComponent: AudioFileComponent; inPropertyID: AudioFileComponentPropertyID; inPropertyDataSize: UInt32; inPropertyData: {const} UnivPtr ): OSStatus; external name '_AudioFileComponentSetProperty';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+
+{!
+    @function	AudioFileComponentCountUserData
+    @abstract   implements AudioFileCountUserData
+    @discussion		"User Data" refers to chunks in AIFF, CAF and WAVE files, or resources 
+					in Sound Designer II files, and possibly other things in other files.
+					For simplicity, referred to below as "chunks".
+    @param inComponent				an AudioFileComponent
+    @param inUserDataID				the four char code of the chunk.
+    @param outNumberItems			on output, if successful, number of chunks of this type in the file.
+    @result							returns noErr if successful.
+}
+function AudioFileComponentCountUserData( inComponent: AudioFileComponent; inUserDataID: UInt32; var outNumberItems: UInt32 ): OSStatus; external name '_AudioFileComponentCountUserData';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+{!
+    @function	AudioFileComponentGetUserDataSize
+    @abstract   implements AudioFileGetUserDataSize
+    @param inComponent				an AudioFileComponent
+    @param inUserDataID				the four char code of the chunk.
+    @param inIndex					an index specifying which chunk if there are more than one.
+    @param outUserDataSize			on output, if successful, the size of the user data chunk.
+    @result							returns noErr if successful.
+}
+function AudioFileComponentGetUserDataSize( inComponent: AudioFileComponent; inUserDataID: UInt32; inIndex: UInt32; var outUserDataSize: UInt32 ): OSStatus; external name '_AudioFileComponentGetUserDataSize';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+{!
+    @function	AudioFileGetUserData
+    @abstract   implements AudioFileGetUserData.
+    @param		inComponent			an AudioFileComponent
+    @param      inUserDataID		the four char code of the chunk.
+    @param      inIndex				an index specifying which chunk if there are more than one.
+	@param		ioUserDataSize		the size of the buffer on input, size of bytes copied to buffer on output 
+    @param      outUserData			a pointer to a buffer in which to copy the chunk data.
+    @result							returns noErr if successful.
+}
+function AudioFileComponentGetUserData( inComponent: AudioFileComponent; inUserDataID: UInt32; inIndex: UInt32; var ioUserDataSize: UInt32; outUserData: UnivPtr ): OSStatus; external name '_AudioFileComponentGetUserData';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+{!
+    @function	AudioFileComponentSetUserData
+    @abstract   implements AudioFileSetUserData.
+    @param		inComponent			an AudioFileComponent
+    @param      inUserDataID		the four char code of the chunk.
+    @param      inIndex				an index specifying which chunk if there are more than one.
+	@param		inUserDataSize		on input the size of the data to copy, on output, size of bytes copied from the buffer  
+    @param      inUserData			a pointer to a buffer from which to copy the chunk data 
+									(only the contents of the chunk, not including the chunk header).
+    @result							returns noErr if successful.
+}
+function AudioFileComponentSetUserData( inComponent: AudioFileComponent; inUserDataID: UInt32; inIndex: UInt32; inUserDataSize: UInt32; inUserData: {const} UnivPtr ): OSStatus; external name '_AudioFileComponentSetUserData';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+
+{!
+    @function	AudioFileComponentRemoveUserData
+    @abstract   implements AudioFileRemoveUserData.
+    @param		inComponent			an AudioFileComponent
+    @param      inUserDataID		the four char code of the chunk.
+    @param      inIndex				an index specifying which chunk if there are more than one.
+    @result							returns noErr if successful.
+}
+function AudioFileComponentRemoveUserData( inComponent: AudioFileComponent; inUserDataID: UInt32; inIndex: UInt32 ): OSStatus; external name '_AudioFileComponentRemoveUserData';
+(* API_AVAILABLE(macos(10.5)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+//	The following calls are not made on AudioFile instances.
+//  These calls are used to determine the audio file type of some data. 
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+{!
+    @function	AudioFileComponentExtensionIsThisFormat
+    @abstract   used by the AudioFile API to determine if this component is appropriate for handling a file.
+    @param		inComponent			an AudioFileComponent
+    @param      inExtension			a CFString containing a file name extension.
+    @param      outResult			on output, is set to 1 if the extension is recognized by this component, 0 if not.
+    @result							returns noErr if successful.
+}
+function AudioFileComponentExtensionIsThisFormat( inComponent: AudioFileComponent; inExtension: CFStringRef; var outResult: UInt32 ): OSStatus; external name '_AudioFileComponentExtensionIsThisFormat';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+
+{!
+    @function	AudioFileComponentFileDataIsThisFormat
+    @abstract   used by the AudioFile API to determine if this component is appropriate for handling a file.
+    @param		inComponent			an AudioFileComponent
+    @param      inDataByteSize		the size of inData in bytes.
+    @param      inData				a pointer to a buffer of audio file data.
+    @param      outResult			on output, is set to 1 if the file is recognized by this component, 0 if not.
+    @result							returns noErr if successful.
+}
+function AudioFileComponentFileDataIsThisFormat( inComponent: AudioFileComponent; inDataByteSize: UInt32; inData: {const} UnivPtr; var outResult: UInt32 ): OSStatus; external name '_AudioFileComponentFileDataIsThisFormat';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+{$ifc false}
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+//	The following two calls are deprecated. 
+//  Please implement AudioFileComponentFileDataIsThisFormat instead.
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+{!
+    @function	AudioFileComponentFileIsThisFormat
+    @abstract   deprecated. use AudioFileComponentFileDataIsThisFormat instead.
+    @param		inComponent			an AudioFileComponent
+    @param      inFileRefNum		a refNum of a file.
+    @param      outResult			on output, is set to 1 if the file is recognized by this component, 0 if not.
+    @result							returns noErr if successful.
+}
+function AudioFileComponentFileIsThisFormat( inComponent: AudioFileComponent; inFileRefNum: SInt16; var outResult: UInt32 ): OSStatus; external name '_AudioFileComponentFileIsThisFormat';
+(* API_DEPRECATED("no longer supported", macos(10.4, 10.5)) API_UNAVAILABLE(ios, watchos, tvos) *) 
+	
+{!
+    @function	AudioFileComponentDataIsThisFormat
+    @abstract   deprecated. use AudioFileComponentFileDataIsThisFormat instead.
+    @param		inComponent			an AudioFileComponent
+    @param		inClientData		a constant that will be passed to your callbacks.
+	@param		inReadFunc			a function that will be called when AudioFile needs to read data.
+	@param		inWriteFunc			a function that will be called when AudioFile needs to write data.
+	@param		inGetSizeFunc		a function that will be called when AudioFile needs to know the file size.
+	@param		inSetSizeFunc		a function that will be called when AudioFile needs to set the file size.
+    @param      outResult			on output, is set to 1 if the file data is recognized by this component, 0 if not.
+    @result							returns noErr if successful.
+}
+function AudioFileComponentDataIsThisFormat( inComponent: AudioFileComponent; inClientData: UnivPtr {__nullable}; inReadFunc: AudioFile_ReadProc {__nullable}; inWriteFunc: AudioFile_WriteProc {__nullable}; inGetSizeFunc: AudioFile_GetSizeProc {__nullable}; inSetSizeFunc: AudioFile_SetSizeProc {__nullable}; var outResult: UInt32 ): OSStatus; external name '_AudioFileComponentDataIsThisFormat';
+(* API_DEPRECATED("no longer supported", macos(10.4, 10.5)) API_UNAVAILABLE(ios, watchos, tvos) *) 
+{$endc}
+
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+//	The following calls are not made on AudioFile instances.
+//  They implement the AudioFileGetGlobalInfo calls.
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+
+{!
+    @function	AudioFileComponentGetGlobalInfoSize
+    @abstract   implements AudioFileGetGlobalInfoSize.
+    @param		inComponent			an AudioFileComponent
+    @param      inPropertyID		an AudioFileGlobalInfo property constant.
+    @param      inSpecifierSize		The size of the specifier data.
+    @param      inSpecifier			A specifier is a buffer of data used as an input argument to some of the global info properties.
+    @param      outPropertySize		the size in bytes of the current value of the property. In order to get the property value, 
+									you will need a buffer of this size.
+    @result							returns noErr if successful.
+}
+function AudioFileComponentGetGlobalInfoSize( inComponent: AudioFileComponent; inPropertyID: AudioFileComponentPropertyID; inSpecifierSize: UInt32; {const} inSpecifier: UnivPtr {__nullable}; var outPropertySize: UInt32 ): OSStatus; external name '_AudioFileComponentGetGlobalInfoSize';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+{!
+    @function	AudioFileComponentGetGlobalInfo
+    @abstract   implements AudioFileGetGlobalInfo.
+    @param		inComponent			an AudioFileComponent
+    @param      inPropertyID		an AudioFileGlobalInfo property constant.
+    @param      inSpecifierSize		The size of the specifier data.
+    @param      inSpecifier			A specifier is a buffer of data used as an input argument to some of the global info properties.
+    @param      ioPropertyDataSize	on input the size of the outPropertyData buffer. On output the number of bytes written to the buffer.
+    @param      outPropertyData		the buffer in which to write the property data.
+    @result							returns noErr if successful.
+}
+function AudioFileComponentGetGlobalInfo( inComponent: AudioFileComponent; inPropertyID: AudioFileComponentPropertyID; inSpecifierSize: UInt32; {const} inSpecifier: UnivPtr {__nullable}; var ioPropertyDataSize: UInt32; outPropertyData: UnivPtr ): OSStatus; external name '_AudioFileComponentGetGlobalInfo';
+(* API_AVAILABLE(macos(10.4)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+//==================================================================================================
+//	Properties for AudioFileComponentGetGlobalInfo. 
+//==================================================================================================
+
+{!
+    @enum AudioFileComponent specific properties
+    @constant   kAudioFileComponent_CanRead
+					Is file type readable? Returns a UInt32 1 or 0. 
+    @constant   kAudioFileComponent_CanWrite
+					Is file type writeable? Returns a UInt32 1 or 0. 
+    @constant   kAudioFileComponent_FileTypeName
+					Returns a CFString containing the name for the file type. 
+    @constant   kAudioFileComponent_ExtensionsForType
+					Returns a CFArray of CFStrings containing the file extensions 
+					that are recognized for this file type. 
+    @constant   kAudioFileComponent_UTIsForType
+					Returns a CFArray of CFStrings containing the universal type identifiers 
+					for this file type. 
+    @constant   kAudioFileComponent_MIMETypesForType
+					Returns a CFArray of CFStrings containing the MIME types 
+					for this file type. 
+    @constant   kAudioFileComponent_AvailableFormatIDs
+					Returns a array of format IDs for formats that can be read. 
+    @constant   kAudioFileComponent_AvailableStreamDescriptionsForFormat
+					The specifier is the format ID for the requested format.
+					Returns an array of AudioStreamBasicDescriptions which have all of the 
+					formats for a particular file type and format ID. The AudioStreamBasicDescriptions
+					have the following fields filled in: mFormatID, mFormatFlags, mBitsPerChannel
+    @constant   kAudioFileComponent_FastDispatchTable
+					Deprecated. This selector is no longer called by the implementation. 
+    @constant   kAudioFileComponent_HFSTypeCodesForType
+					Returns an array of HFSTypeCodes corresponding to this file type.
+					The first type in the array is the preferred one for use when
+					writing new files.
+}
+const
+	kAudioFileComponent_CanRead = FourCharCode('cnrd');
+	kAudioFileComponent_CanWrite = FourCharCode('cnwr');
+	kAudioFileComponent_FileTypeName = FourCharCode('ftnm');
+	kAudioFileComponent_UTIsForType = FourCharCode('futi');
+	kAudioFileComponent_MIMETypesForType = FourCharCode('fmim');
+	kAudioFileComponent_ExtensionsForType = FourCharCode('fext');
+	kAudioFileComponent_AvailableFormatIDs = FourCharCode('fmid');
+	kAudioFileComponent_AvailableStreamDescriptionsForFormat = FourCharCode('sdid');
+	kAudioFileComponent_FastDispatchTable = FourCharCode('fdft');
+	kAudioFileComponent_HFSTypeCodesForType = FourCharCode('fhfs'); 
+
+//==================================================================================================
+//	Selectors for the component routines 
+//==================================================================================================
+
+const
+	kAudioFileCreateSelect = $0001;
+	kAudioFileOpenSelect = $0002;
+	kAudioFileInitializeSelect = $0003;
+	kAudioFileOpenWithCallbacksSelect = $0004;
+	kAudioFileInitializeWithCallbacksSelect = $0005;
+	kAudioFileCloseSelect = $0006;
+	kAudioFileOptimizeSelect = $0007;
+	kAudioFileReadBytesSelect = $0008;
+	kAudioFileWriteBytesSelect = $0009;
+	kAudioFileReadPacketsSelect = $000A;
+	kAudioFileWritePacketsSelect = $000B;
+	kAudioFileGetPropertyInfoSelect = $000C;
+	kAudioFileGetPropertySelect = $000D;
+	kAudioFileSetPropertySelect = $000E;
+	kAudioFileExtensionIsThisFormatSelect = $000F;
+	kAudioFileFileIsThisFormatSelect = $0010;
+	kAudioFileDataIsThisFormatSelect = $0011;
+	kAudioFileGetGlobalInfoSizeSelect = $0012;
+	kAudioFileGetGlobalInfoSelect = $0013;
+	kAudioFileCountUserDataSelect = $0014;
+	kAudioFileGetUserDataSizeSelect = $0015;
+	kAudioFileGetUserDataSelect = $0016;
+	kAudioFileSetUserDataSelect = $0017;
+	kAudioFileRemoveUserDataSelect = $0018;
+	kAudioFileCreateURLSelect = $0019;
+	kAudioFileOpenURLSelect = $001A;
+	kAudioFileFileDataIsThisFormatSelect = $001B;
+	kAudioFileReadPacketDataSelect = $001C; 
+
+
+//#pragma mark -
+//#pragma mark Deprecated
+
+//==================================================================================================
+// Fast Dispatch Function typedefs. Deprecated. These are no longer used by the implementation.
+//==================================================================================================
+
+type
+	ReadBytesFDF = function( inComponentStorage: UnivPtr; inUseCache: Boolean; inStartingByte: SInt64; var ioNumBytes: UInt32; outBuffer: UnivPtr ): OSStatus;
+								
+type
+	WriteBytesFDF = function( inComponentStorage: UnivPtr; inUseCache: Boolean; inStartingByte: SInt64; var ioNumBytes: UInt32; inBuffer: {const} UnivPtr ): OSStatus;
+							
+type
+	ReadPacketsFDF = function( inComponentStorage: UnivPtr; inUseCache: Boolean; var outNumBytes: UInt32; outPacketDescriptions: AudioStreamPacketDescriptionPtr {* __nullable}; inStartingPacket: SInt64; var ioNumPackets: UInt32; outBuffer: UnivPtr ): OSStatus;
+
+type
+	ReadPacketDataFDF = function( inComponentStorage: UnivPtr; inUseCache: Boolean; var ioNumBytes: UInt32; outPacketDescriptions: AudioStreamPacketDescriptionPtr {* __nullable}; inStartingPacket: SInt64; var ioNumPackets: UInt32; outBuffer: UnivPtr ): OSStatus;
+
+type
+	WritePacketsFDF = function( inComponentStorage: UnivPtr; inUseCache: Boolean; inNumBytes: UInt32; {const} inPacketDescriptions: AudioStreamPacketDescriptionPtr {* __nullable}; inStartingPacket: SInt64; var ioNumPackets: UInt32; inBuffer: {const} UnivPtr ): OSStatus;
+								
+type
+	GetPropertyInfoFDF = function( inComponentStorage: UnivPtr; inPropertyID: AudioFilePropertyID; outDataSize: UInt32Ptr {* __nullable}; isWritable: UInt32Ptr {* __nullable} ): OSStatus;
+								
+type
+	GetPropertyFDF = function( inComponentStorage: UnivPtr; inPropertyID: AudioFilePropertyID; var ioDataSize: UInt32; ioPropertyData: UnivPtr ): OSStatus;
+							
+type
+	SetPropertyFDF = function( inComponentStorage: UnivPtr; inPropertyID: AudioFilePropertyID; inDataSize: UInt32; inPropertyData: {const} UnivPtr ): OSStatus;
+
+type
+	CountUserDataFDF = function( inComponentStorage: UnivPtr; inUserDataID: UInt32; var outNumberItems: UInt32 ): OSStatus;
+
+type
+	GetUserDataSizeFDF = function( inComponentStorage: UnivPtr; inUserDataID: UInt32; inIndex: UInt32; var outDataSize: UInt32 ): OSStatus;
+
+type
+	GetUserDataFDF = function( inComponentStorage: UnivPtr; inUserDataID: UInt32; inIndex: UInt32; var ioUserDataSize: UInt32; outUserData: UnivPtr ): OSStatus;
+
+type
+	SetUserDataFDF = function( inComponentStorage: UnivPtr; inUserDataID: UInt32; inIndex: UInt32; inUserDataSize: UInt32; inUserData: {const} UnivPtr ): OSStatus;
+										
+{ no fast dispatch for kAudioFileRemoveUserDataSelect }
+
+//#pragma /mark -
+//#pragma /mark Deprecated
+
+//==================================================================================================
+// Fast Dispatch Function tables. Deprecated. These are no longer used by the implementation.
+//==================================================================================================
+
+type
+	AudioFileFDFTable = record
+		mComponentStorage: UnivPtr;
+	 	mReadBytesFDF: ReadBytesFDF;
+		mWriteBytesFDF: WriteBytesFDF;
+		mReadPacketsFDF: ReadPacketsFDF;
+		mWritePacketsFDF: WritePacketsFDF;
+
+		mGetPropertyInfoFDF: GetPropertyInfoFDF;
+		mGetPropertyFDF: GetPropertyFDF;
+		mSetPropertyFDF: SetPropertyFDF;
+	
+		mCountUserDataFDF: CountUserDataFDF;
+		mGetUserDataSizeFDF: GetUserDataSizeFDF;
+		mGetUserDataFDF: GetUserDataFDF;
+		mSetUserDataFDF: SetUserDataFDF;
+	end;
+	AudioFileFDFTablePtr = ^AudioFileFDFTable;
+	(* API_DEPRECATED("no longer supported", macos(10.4, 10.7)) API_UNAVAILABLE(ios, watchos, tvos); *)
+
+type
+	AudioFileFDFTableExtended = record
+		mComponentStorage: UnivPtr;
+	 	mReadBytesFDF: ReadBytesFDF;
+		mWriteBytesFDF: WriteBytesFDF;
+		mReadPacketsFDF: ReadPacketsFDF;
+		mWritePacketsFDF: WritePacketsFDF;
+
+		mGetPropertyInfoFDF: GetPropertyInfoFDF;
+		mGetPropertyFDF: GetPropertyFDF;
+		mSetPropertyFDF: SetPropertyFDF;
+	
+		mCountUserDataFDF: CountUserDataFDF;
+		mGetUserDataSizeFDF: GetUserDataSizeFDF;
+		mGetUserDataFDF: GetUserDataFDF;
+		mSetUserDataFDF: SetUserDataFDF;
+
+		mReadPacketDataFDF: ReadPacketDataFDF;
+	end;
+	AudioFileFDFTableExtendedPtr = ^AudioFileFDFTableExtended;
+	(* API_DEPRECATED("no longer supported", macos(10.4, 10.7)) API_UNAVAILABLE(ios, watchos, tvos);*)
+
+{!
+	@functiongroup Deprecated AFComponent
+	@discussion		These API calls are no longer called on Snow Leopard, instead the URL versions are used.
+					They can be provided by the file component for compatibility with Leopard and Tiger systems
+}
+
+{!
+    @function	AudioFileComponentCreate
+    @abstract   implements AudioFileCreate
+    @param inComponent		an AudioFileComponent
+    @param inParentRef		an FSRef to the directory where  the new file should be created.
+    @param inFileName		a CFStringRef containing the name of the file to be created.
+    @param inFormat			an AudioStreamBasicDescription describing the data format that will be
+							added to the audio file.
+    @param inFlags			relevant flags for creating/opening the file. Currently zero.
+    @param outNewFileRef	if successful, the FSRef of the newly created file.
+    @result					returns noErr if successful.
+}
+function AudioFileComponentCreate( inComponent: AudioFileComponent; {const} inParentRef: FSRefPtr; inFileName: CFStringRef; const (*var*) inFormat: AudioStreamBasicDescription; inFlags: UInt32; outNewFileRef: FSRefPtr ): OSStatus; external name '_AudioFileComponentCreate';
+(* API_DEPRECATED("no longer supported", macos(10.4, 10.6)) API_UNAVAILABLE(ios, watchos, tvos) *)
+                                
+
+{!
+    @function	AudioFileComponentInitialize
+    @abstract   implements AudioFileInitialize
+    @param inComponent		an AudioFileComponent
+    @param inFileRef		the FSRef of an existing audio file.
+    @param inFormat			an AudioStreamBasicDescription describing the data format that will be
+							added to the audio file.
+    @param inFlags			flags for creating/opening the file. Currently zero.
+    @result					returns noErr if successful.
+}
+function AudioFileComponentInitialize( inComponent: AudioFileComponent; {const} inFileRef: FSRefPtr; const (*var*) inFormat: AudioStreamBasicDescription; inFlags: UInt32 ): OSStatus; external name '_AudioFileComponentInitialize';
+(* API_DEPRECATED("no longer supported", macos(10.4, 10.6)) API_UNAVAILABLE(ios, watchos, tvos) *)
+							
+{!
+    @function	AudioFileComponentOpenFile
+    @abstract   implements AudioFileOpen
+    @param inComponent		an AudioFileComponent
+    @param inFileRef		the FSRef of an existing audio file.
+    @param inPermissions	use the permission constants
+    @param inRefNum			the file refNum for the opened file. This avoids opening the file twice
+							- once to determine which file type to which to delegate and once to parse it.
+    @result					returns noErr if successful.
+}
+function AudioFileComponentOpenFile( inComponent: AudioFileComponent; {const} inFileRef: FSRefPtr; inPermissions: SInt8; inRefNum: SInt16 ): OSStatus; external name '_AudioFileComponentOpenFile';
+(* API_DEPRECATED("no longer supported", macos(10.4, 10.6)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+
+//=====================================================================================================================
+
+type
+	AudioFileComponentCreateURLProc = function( self: UnivPtr; inFileRef: CFURLRef; const (*var*) inFormat: AudioStreamBasicDescription; inFlags: UInt32 ): OSStatus;
+	AudioFileComponentOpenURLProc = function( self: UnivPtr; inFileRef: CFURLRef; inPermissions: SInt8; inFileDescriptor: SInt32 ): OSStatus;
+								
+type
+	AudioFileComponentOpenWithCallbacksProc = function( self: UnivPtr; inClientData: UnivPtr; inReadFunc: AudioFile_ReadProc; inWriteFunc: AudioFile_WriteProc; inGetSizeFunc: AudioFile_GetSizeProc; inSetSizeFunc: AudioFile_SetSizeProc ): OSStatus;
+
+type
+	AudioFileComponentInitializeWithCallbacksProc = function( self: UnivPtr; inClientData: UnivPtr; inReadFunc: AudioFile_ReadProc; inWriteFunc: AudioFile_WriteProc; inGetSizeFunc: AudioFile_GetSizeProc; inSetSizeFunc: AudioFile_SetSizeProc; inFileType: UInt32; const (*var*) inFormat: AudioStreamBasicDescription; inFlags: UInt32 ): OSStatus;
+
+type
+	AudioFileComponentCloseProc = function( self: UnivPtr ): OSStatus;
+				
+type
+	AudioFileComponentOptimizeProc = function( self: UnivPtr ): OSStatus;
+				
+type
+	AudioFileComponentReadBytesProc = function( self: UnivPtr; inUseCache: Boolean; inStartingByte: SInt64; var ioNumBytes: UInt32; outBuffer: UnivPtr ): OSStatus;	
+						
+type
+	AudioFileComponentWriteBytesProc = function( self: UnivPtr; inUseCache: Boolean; inStartingByte: SInt64; var ioNumBytes: UInt32; inBuffer: {const} UnivPtr ): OSStatus;	
+						
+type
+	AudioFileComponentReadPacketsProc = function( self: UnivPtr; inUseCache: Boolean; var outNumBytes: UInt32; outPacketDescriptions: AudioStreamPacketDescriptionPtr {* __nullable}; inStartingPacket: SInt64; var ioNumPackets: UInt32; outBuffer: UnivPtr ): OSStatus;	
+									
+
+type
+	AudioFileComponentReadPacketDataProc = function( self: UnivPtr; inUseCache: Boolean; var ioNumBytes: UInt32; outPacketDescriptions: AudioStreamPacketDescription {* __nullable}; inStartingPacket: SInt64; var ioNumPackets: UInt32; outBuffer: UnivPtr ): OSStatus;	
+									
+type
+	AudioFileComponentWritePacketsProc = function( self: UnivPtr; inUseCache: Boolean; inNumBytes: UInt32; {const} inPacketDescriptions: AudioStreamPacketDescription {* __nullable}; inStartingPacket: SInt64; var ioNumPackets: UInt32; inBuffer: {const} UnivPtr ): OSStatus;
+
+
+type
+	AudioFileComponentGetPropertyInfoProc = function( self: UnivPtr; inPropertyID: AudioFileComponentPropertyID; outPropertySize: UInt32Ptr {* __nullable}; outWritable: UInt32Ptr {* __nullable} ): OSStatus;
+
+
+type
+	AudioFileComponentGetPropertyProc = function( self: UnivPtr; inPropertyID: AudioFileComponentPropertyID; var ioPropertyDataSize: UInt32; outPropertyData: UnivPtr ): OSStatus;
+
+type
+	AudioFileComponentSetPropertyProc = function( self: UnivPtr; inPropertyID: AudioFileComponentPropertyID; inPropertyDataSize: UInt32; inPropertyData: {const} UnivPtr ): OSStatus;
+
+
+type
+	AudioFileComponentCountUserDataProc = function( self: UnivPtr; inUserDataID: UInt32; var outNumberItems: UInt32 ): OSStatus;
+
+type
+	AudioFileComponentGetUserDataSizeProc = function( self: UnivPtr; inUserDataID: UInt32; inIndex: UInt32; var outUserDataSize: UInt32 ): OSStatus;
+
+type
+	AudioFileComponentGetUserDataProc = function( self: UnivPtr; inUserDataID: UInt32; inIndex: UInt32; var ioUserDataSize: UInt32; outUserData: UnivPtr ): OSStatus;
+
+type
+	AudioFileComponentSetUserDataProc = function( self: UnivPtr; inUserDataID: UInt32; inIndex: UInt32; inUserDataSize: UInt32; inUserData: {const} UnivPtr ): OSStatus;
+
+
+type
+	AudioFileComponentRemoveUserDataProc = function( self: UnivPtr; inUserDataID: UInt32; inIndex: UInt32 ): OSStatus;
+
+type
+	AudioFileComponentExtensionIsThisFormatProc = function( self: UnivPtr; inExtension: CFStringRef; var outResult: UInt32 ): OSStatus;	
+
+
+type
+	AudioFileComponentFileDataIsThisFormatProc = function( self: UnivPtr; inDataByteSize: UInt32; inData: {const} UnivPtr; var outResult: UInt32 ): OSStatus;	
+
+
+type
+	AudioFileComponentGetGlobalInfoSizeProc = function( self: UnivPtr; inPropertyID: AudioFileComponentPropertyID; inSpecifierSize: UInt32; {const} inSpecifier: UnivPtr {__nullable}; var outPropertySize: UInt32 ): OSStatus;
+
+type
+	AudioFileComponentGetGlobalInfoProc = function( self: UnivPtr; inPropertyID: AudioFileComponentPropertyID; inSpecifierSize: UInt32; {const} inSpecifier: UnivPtr {__nullable}; var ioPropertyDataSize: UInt32; outPropertyData: UnivPtr ): OSStatus;
+
+{$endc} {TARGET_OS_MAC}
+//CF_ASSUME_NONNULL_END
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+
+end.
+{$endc} {not MACOSALLINCLUDE}

+ 604 - 0
packages/univint/src/AudioFileStream.pas

@@ -0,0 +1,604 @@
+{!
+	@file		AudioFileStream.h
+	@framework	AudioToolbox.framework
+	@copyright	(c) 1985-2015 by Apple, Inc., all rights reserved.
+
+	@brief		API's to parse streamed audio files into packets of audio data.
+
+	@discussion
+
+	AudioFileStream addresses situations where, in a stream of audio data, only a limited window
+	of data may be available at any time.
+
+	This case differs significantly enough from the random access file case to warrant a separate
+	API rather than overload the AudioFile API with additional semantics. With a random access file,
+	one can always assume that a read request for contiguous data that doesn't include EOF will
+	always supply all of the data. This makes parsing straightforward and inexpensive. In the
+	streaming case such an assumption cannot be made. A request by the parser for data from the
+	stream may only be partially satisfied. Any partially satisfied requests must be remembered and
+	retried before any other requests are satisfied, otherwise the streamed data might be lost
+	forever in the past. So the parser must be able to suspend work at any point and resume parsing
+	where it left off.
+	
+	The client provides data to the parser using AudioFileStreamParseBytes and the parser calls back
+	to the client with properties or packets using the AudioFileStream_PropertyListenerProc and
+	AudioFileStream_PacketsProc function pointers.
+}
+{  Pascal Translation: Jonas Maebe <[email protected]>, July 2019 }
+{
+    Modified for use with Free Pascal
+    Version 308
+    Please report any bugs to <[email protected]>
+}
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+{$mode macpas}
+{$modeswitch cblocks}
+{$packenum 1}
+{$macro on}
+{$inline on}
+{$calling mwpascal}
+
+unit AudioFileStream;
+interface
+{$setc UNIVERSAL_INTERFACES_VERSION := $0400}
+{$setc GAP_INTERFACES_VERSION := $0308}
+
+{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
+    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
+{$endc}
+
+{$ifc defined CPUPOWERPC and defined CPUI386}
+	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
+{$endc}
+{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
+	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
+{$endc}
+
+{$ifc not defined __ppc__ and defined CPUPOWERPC32}
+	{$setc __ppc__ := 1}
+{$elsec}
+	{$setc __ppc__ := 0}
+{$endc}
+{$ifc not defined __ppc64__ and defined CPUPOWERPC64}
+	{$setc __ppc64__ := 1}
+{$elsec}
+	{$setc __ppc64__ := 0}
+{$endc}
+{$ifc not defined __i386__ and defined CPUI386}
+	{$setc __i386__ := 1}
+{$elsec}
+	{$setc __i386__ := 0}
+{$endc}
+{$ifc not defined __x86_64__ and defined CPUX86_64}
+	{$setc __x86_64__ := 1}
+{$elsec}
+	{$setc __x86_64__ := 0}
+{$endc}
+{$ifc not defined __arm__ and defined CPUARM}
+	{$setc __arm__ := 1}
+{$elsec}
+	{$setc __arm__ := 0}
+{$endc}
+{$ifc not defined __arm64__ and defined CPUAARCH64}
+  {$setc __arm64__ := 1}
+{$elsec}
+  {$setc __arm64__ := 0}
+{$endc}
+
+{$ifc defined cpu64}
+  {$setc __LP64__ := 1}
+{$elsec}
+  {$setc __LP64__ := 0}
+{$endc}
+
+
+{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
+	{$error Conflicting definitions for __ppc__ and __i386__}
+{$endc}
+
+{$ifc defined __ppc__ and __ppc__}
+	{$setc TARGET_CPU_PPC := TRUE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __ppc64__ and __ppc64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := TRUE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __i386__ and __i386__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := TRUE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __x86_64__ and __x86_64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := TRUE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __arm__ and __arm__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := TRUE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := TRUE}
+{$elifc defined __arm64__ and __arm64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := TRUE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := TRUE}
+{$elsec}
+	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
+{$endc}
+
+{$ifc defined __LP64__ and __LP64__ }
+  {$setc TARGET_CPU_64 := TRUE}
+{$elsec}
+  {$setc TARGET_CPU_64 := FALSE}
+{$endc}
+
+{$ifc defined FPC_BIG_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
+{$elifc defined FPC_LITTLE_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
+{$elsec}
+	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
+{$endc}
+{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
+{$setc CALL_NOT_IN_CARBON := FALSE}
+{$setc OLDROUTINENAMES := FALSE}
+{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
+{$setc OPAQUE_UPP_TYPES := TRUE}
+{$setc OTCARBONAPPLICATION := TRUE}
+{$setc OTKERNEL := FALSE}
+{$setc PM_USE_SESSION_APIS := TRUE}
+{$setc TARGET_API_MAC_CARBON := TRUE}
+{$setc TARGET_API_MAC_OS8 := FALSE}
+{$setc TARGET_API_MAC_OSX := TRUE}
+{$setc TARGET_CARBON := TRUE}
+{$setc TARGET_CPU_68K := FALSE}
+{$setc TARGET_CPU_MIPS := FALSE}
+{$setc TARGET_CPU_SPARC := FALSE}
+{$setc TARGET_OS_UNIX := FALSE}
+{$setc TARGET_OS_WIN32 := FALSE}
+{$setc TARGET_RT_MAC_68881 := FALSE}
+{$setc TARGET_RT_MAC_CFM := FALSE}
+{$setc TARGET_RT_MAC_MACHO := TRUE}
+{$setc TYPED_FUNCTION_POINTERS := TRUE}
+{$setc TYPE_BOOL := FALSE}
+{$setc TYPE_EXTENDED := FALSE}
+{$setc TYPE_LONGLONG := TRUE}
+uses MacTypes,CoreAudioTypes,AudioFile;
+{$endc} {not MACOSALLINCLUDE}
+
+{$ALIGN POWER}
+
+
+//=============================================================================
+//	Includes
+//=============================================================================
+
+
+//CF_ASSUME_NONNULL_BEGIN
+
+
+//=============================================================================
+//	AudioFileStream flags
+//=============================================================================
+//#pragma mark flags
+
+{!
+    @enum AudioFileStreamPropertyFlags
+    @constant   kAudioFileStreamPropertyFlag_PropertyIsCached 
+		This flag is set in a call to AudioFileStream_PropertyListenerProc when the value of the property
+		can be obtained at any later time. If this flag is not set, then you should either get the value of 
+		the property from within this callback or set the flag kAudioFileStreamPropertyFlag_CacheProperty in order to signal
+		to the parser to begin caching the property data. Otherwise the value may not be available in the future.
+		
+    @constant   kAudioFileStreamPropertyFlag_CacheProperty 
+		This flag can be set by a property listener in order to signal to the parser that the client is
+		interested in the value of the property and that it should be cached until the full value of the property is available.
+}
+type
+	AudioFileStreamPropertyFlags = UInt32;
+	AudioFileStreamPropertyFlagsPtr = ^AudioFileStreamPropertyFlags;
+const
+	kAudioFileStreamPropertyFlag_PropertyIsCached = 1;
+	kAudioFileStreamPropertyFlag_CacheProperty = 2; 
+
+{!	@enum	AudioFileStreamParseFlags
+    @constant   kAudioFileStreamParseFlag_Discontinuity 
+		This flag is passed in to AudioFileStreamParseBytes to signal a discontinuity. Any partial packet straddling a buffer
+		boundary will be discarded. This is necessary to avoid being called with a corrupt packet. After a discontinuity occurs
+		seeking may be approximate in some data formats.
+}
+type
+	AudioFileStreamParseFlags = UInt32;
+	AudioFileStreamParseFlagsPtr = ^AudioFileStreamParseFlags;
+const
+	kAudioFileStreamParseFlag_Discontinuity = 1; 
+
+{!	@enum	AudioFileStreamParseFlags
+    @constant   kAudioFileStreamSeekFlag_OffsetIsEstimated 
+		This flag may be returned from AudioFileStreamSeek if the byte offset is only an estimate, not exact.
+}
+type
+	AudioFileStreamSeekFlags = UInt32;
+	AudioFileStreamSeekFlagsPtr = ^AudioFileStreamSeekFlags;
+const
+	kAudioFileStreamSeekFlag_OffsetIsEstimated = 1; 
+
+//=============================================================================
+//	AudioFileStream Types
+//=============================================================================
+//#pragma mark types
+
+type
+	AudioFileStreamPropertyID = UInt32;
+	AudioFileStreamPropertyIDPtr = ^AudioFileStreamPropertyID;
+
+	AudioFileStreamID = record end;
+	OpaqueAudioFileStreamID = ^AudioFileStreamID;
+
+type
+	AudioFileStream_PropertyListenerProc = procedure( inClientData: UnivPtr; inAudioFileStream: AudioFileStreamID; inPropertyID: AudioFileStreamPropertyID; var ioFlags: AudioFileStreamPropertyFlags );
+
+type
+	AudioFileStream_PacketsProc = procedure( inClientData: UnivPtr; inNumberBytes: UInt32; inNumberPackets: UInt32; inInputData: {const} UnivPtr; var inPacketDescriptions: AudioStreamPacketDescription );
+
+//=============================================================================
+//	AudioFileStream error codes
+//=============================================================================
+//#pragma mark Error codes
+{!
+    @enum AudioFileStream error codes
+
+    @abstract   These are the error codes returned from the AudioFile API.
+
+    @constant   kAudioFileStreamError_UnsupportedFileType 
+		The file type is not supported.
+    @constant   kAudioFileStreamError_UnsupportedDataFormat 
+		The data format is not supported by this file type.
+    @constant   kAudioFileStreamError_UnsupportedProperty 
+		The property is not supported.
+    @constant   kAudioFileStreamError_BadPropertySize 
+		The size of the property data was not correct.
+    @constant   kAudioFileStreamError_NotOptimized 
+		It is not possible to produce output packets because the file's packet table or other defining 
+		info is either not present or is after the audio data.
+    @constant   kAudioFileStreamError_InvalidPacketOffset 
+		A packet offset was less than zero, or past the end of the file,
+		or a corrupt packet size was read when building the packet table. 
+    @constant   kAudioFileStreamError_InvalidFile 
+		The file is malformed, or otherwise not a valid instance of an audio file of its type, or 
+		is not recognized as an audio file. 
+    @constant   kAudioFileStreamError_ValueUnknown 
+		The property value is not present in this file before the audio data.
+	@constant	kAudioFileStreamError_DataUnavailable
+		The amount of data provided to the parser was insufficient to produce any result.
+	@constant	kAudioFileStreamError_IllegalOperation
+		An illegal operation was attempted.
+    @constant   kAudioFileStreamError_UnspecifiedError 
+		An unspecified error has occurred.
+		
+}
+const
+	kAudioFileStreamError_UnsupportedFileType = FourCharCode('typ?');
+	kAudioFileStreamError_UnsupportedDataFormat = FourCharCode('fmt?');
+	kAudioFileStreamError_UnsupportedProperty = FourCharCode('pty?');
+	kAudioFileStreamError_BadPropertySize = FourCharCode('!siz');
+	kAudioFileStreamError_NotOptimized = FourCharCode('optm');
+	kAudioFileStreamError_InvalidPacketOffset = FourCharCode('pck?');
+	kAudioFileStreamError_InvalidFile = FourCharCode('dta?');
+	kAudioFileStreamError_ValueUnknown = FourCharCode('unk?');
+	kAudioFileStreamError_DataUnavailable = FourCharCode('more');
+	kAudioFileStreamError_IllegalOperation = FourCharCode('nope');
+	kAudioFileStreamError_UnspecifiedError = FourCharCode('wht?');
+	kAudioFileStreamError_DiscontinuityCantRecover = FourCharCode('dsc!'); 
+
+//=============================================================================
+//	AudioFileStream Properties
+//=============================================================================
+//#pragma mark Properties
+
+{!
+    @enum		AudioFileStream Properties
+	
+    @abstract   constants for AudioFileStream get property calls
+    @discussion		There are currently no settable properties.
+
+					
+    @constant   kAudioFileStreamProperty_ReadyToProducePackets
+					An UInt32 which is zero until the parser has parsed up to the beginning of the audio data. 
+					Once it has reached the audio data, the value of this property becomes one. 
+					When this value has become one, all properties that can be known about the stream are known.
+					
+    @constant   kAudioFileStreamProperty_FileFormat 
+					An UInt32 four char code that identifies the format of the file
+    @constant   kAudioFileStreamProperty_DataFormat 
+					An AudioStreamBasicDescription describing the format of the audio data
+    @constant   kAudioFileStreamProperty_FormatList 
+					In order to support formats such as AAC SBR where an encoded data stream can be decoded to 
+					multiple destination formats, this property returns an array of AudioFormatListItems 
+					(see AudioFormat.h) of those formats.
+					The default behavior is to return the an AudioFormatListItem that has the same 
+					AudioStreamBasicDescription that kAudioFileStreamProperty_DataFormat returns.
+    @constant   kAudioFileStreamProperty_MagicCookieData 
+					A void * pointing to memory set up by the caller.
+					Some file types require that a magic cookie be provided before packets can be written
+					to the file, so this property should be set before calling 
+					AudioFileWriteBytes()/AudioFileWritePackets() if a magic cookie exists.
+    @constant   kAudioFileStreamProperty_AudioDataByteCount 
+					a UInt64 that indicates the number of bytes of audio data contained in the file
+    @constant   kAudioFileStreamProperty_AudioDataPacketCount 
+					a UInt64 that indicates the number of packets of audio data contained in the file
+    @constant   kAudioFileStreamProperty_MaximumPacketSize 
+					a UInt32 that indicates the maximum size of a packet for the data contained in the file
+    @constant   kAudioFileStreamProperty_DataOffset 
+					a SInt64 that indicates the byte offset in the file of the audio data.
+    @constant   kAudioFileStreamProperty_ChannelLayout 
+					An AudioChannelLayout struct.
+    @constant   kAudioFileStreamProperty_PacketToFrame 
+					pass a AudioFramePacketTranslation with mPacket filled out and get mFrame back. 
+					mFrameOffsetInPacket is ignored.
+    @constant   kAudioFileStreamProperty_FrameToPacket 
+					pass a AudioFramePacketTranslation with mFrame filled out and get mPacket and 
+					mFrameOffsetInPacket back.
+	@constant	kAudioFileStreamProperty_PacketToByte
+					pass an AudioBytePacketTranslation struct with mPacket filled out and get mByte back.
+					mByteOffsetInPacket is ignored. If the mByte value is an estimate then 
+					kBytePacketTranslationFlag_IsEstimate will be set in the mFlags field.
+	@constant	kAudioFileStreamProperty_ByteToPacket
+					pass an AudioBytePacketTranslation struct with mByte filled out and get mPacket and
+					mByteOffsetInPacket back. If the mPacket value is an estimate then 
+					kBytePacketTranslationFlag_IsEstimate will be set in the mFlags field.
+    @constant   kAudioFileStreamProperty_PacketTableInfo 
+					Gets the AudioFilePacketTableInfo struct for the file types that support it.
+	@constant	kAudioFileStreamProperty_PacketSizeUpperBound
+					a UInt32 for the theoretical maximum packet size in the file.
+	@constant	kAudioFileStreamProperty_AverageBytesPerPacket
+					a Float64 of giving the average bytes per packet seen. 
+					For CBR and files with packet tables, this number will be exact. Otherwise, it is a
+					running average of packets parsed.
+	@constant	kAudioFileStreamProperty_BitRate
+					a UInt32 of the bit rate in bits per second.
+    @constant	kAudioFileStreamProperty_InfoDictionary
+                    a CFDictionary filled with information about the data contained in the stream.
+                    See AudioFile.h for InfoDictionary key strings. Caller is responsible for releasing the CFObject.
+}
+const
+	kAudioFileStreamProperty_ReadyToProducePackets = FourCharCode('redy');
+	kAudioFileStreamProperty_FileFormat = FourCharCode('ffmt');
+	kAudioFileStreamProperty_DataFormat = FourCharCode('dfmt');
+	kAudioFileStreamProperty_FormatList = FourCharCode('flst');
+	kAudioFileStreamProperty_MagicCookieData = FourCharCode('mgic');
+	kAudioFileStreamProperty_AudioDataByteCount = FourCharCode('bcnt');
+	kAudioFileStreamProperty_AudioDataPacketCount = FourCharCode('pcnt');
+	kAudioFileStreamProperty_MaximumPacketSize = FourCharCode('psze');
+	kAudioFileStreamProperty_DataOffset = FourCharCode('doff');
+	kAudioFileStreamProperty_ChannelLayout = FourCharCode('cmap');
+	kAudioFileStreamProperty_PacketToFrame = FourCharCode('pkfr');
+	kAudioFileStreamProperty_FrameToPacket = FourCharCode('frpk');
+	kAudioFileStreamProperty_PacketToByte = FourCharCode('pkby');
+	kAudioFileStreamProperty_ByteToPacket = FourCharCode('bypk');
+	kAudioFileStreamProperty_PacketTableInfo = FourCharCode('pnfo');
+	kAudioFileStreamProperty_PacketSizeUpperBound = FourCharCode('pkub');
+	kAudioFileStreamProperty_AverageBytesPerPacket = FourCharCode('abpp');
+	kAudioFileStreamProperty_BitRate = FourCharCode('brat');
+	kAudioFileStreamProperty_InfoDictionary = FourCharCode('info'); 
+
+//=============================================================================
+//	AudioFileStream Functions
+//=============================================================================
+//#pragma mark Functions
+
+
+{!
+	@function		AudioFileStreamOpen
+
+	@discussion		Create a new audio file stream parser.
+					The client provides the parser with data and the parser calls
+					callbacks when interesting things are found in the data, such as properties and 
+					audio packets.
+
+    @param			inClientData					
+						a constant that will be passed to your callbacks.
+	@param			inPropertyListenerProc
+						Whenever the value of a property is parsed in the data, this function will be called.
+						You can then get the value of the property from in the callback. In some cases, due to 
+						boundaries in the input data, the property may return kAudioFileStreamError_DataUnavailable.
+						When unavailable data is requested from within the property listener, the parser will begin 
+						caching the property value and will call the property listener again when the property is
+						available. For property values for which kAudioFileStreamPropertyFlag_PropertyIsCached is unset, this 
+						will be the only opportunity to get the value of the property, since the data will be 
+						disposed upon return of the property listener callback. 
+	@param			inPacketsProc
+						Whenever packets are parsed in the data, a pointer to the packets is passed to the client 
+						using this callback. At times only a single packet may be passed due to boundaries in the 
+						input data.
+    @param 			inFileTypeHint	
+						For files whose type cannot be easily or uniquely determined from the data (ADTS,AC3), 
+						this hint can be used to indicate the file type. 
+						Otherwise if you do not know the file type, you can pass zero. 
+	@param			outAudioFileStream 
+						A new file stream ID for use in other AudioFileStream API calls.
+} 
+function AudioFileStreamOpen( inClientData: UnivPtr {__nullable}; inPropertyListenerProc: AudioFileStream_PropertyListenerProc; inPacketsProc: AudioFileStream_PacketsProc; inFileTypeHint: AudioFileTypeID; var outAudioFileStream: AudioFileStreamID {__nullable * __nonnull} ): OSStatus; external name '_AudioFileStreamOpen';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+
+{!
+	@function		AudioFileStreamParseBytes
+
+	@discussion		This call is the means for streams to supply data to the parser. 
+					Data is expected to be passed in sequentially from the beginning of the file, without gaps.
+					In the course of parsing, the client's property and/or packets callbacks may be called.
+					At the end of the stream, this function must be called once with null data pointer and zero
+					data byte size to flush any remaining packets out of the parser.
+
+	@param			inAudioFileStream 
+						The file stream ID
+	@param			inDataByteSize 
+						The number of bytes passed in for parsing. Must be zero when flushing the parser.
+	@param			inData 
+						The data passed in to be parsed. Must be null when flushing the parser.
+	@param			inFlags 
+						If there is a data discontinuity, then kAudioFileStreamParseFlag_Discontinuity should be set true. 
+}
+function AudioFileStreamParseBytes( inAudioFileStream: AudioFileStreamID; inDataByteSize: UInt32; {const} inData: UnivPtr {__nullable}; inFlags: AudioFileStreamParseFlags ): OSStatus; external name '_AudioFileStreamParseBytes';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+	@function		AudioFileStreamSeek
+
+	@discussion		This call is used to seek in the data stream. The client passes in a packet 
+					offset to seek to and the parser passes back a byte offset from which to
+					get the data to satisfy that request. The data passed to the next call to 
+					AudioFileParseBytes will be assumed to be from that byte offset.
+					For file formats which do not contain packet tables the byte offset may 
+					be an estimate. If so, the flag kAudioFileStreamSeekFlag_OffsetIsEstimated will be true.
+
+	@param			inAudioFileStream 
+						The file stream ID
+	@param			inPacketOffset 
+						The offset from the beginning of the file of the packet to which to seek.
+	@param			outDataByteOffset 
+						The byte offset of the data from the file's data offset returned. 
+						You need to add the value of kAudioFileStreamProperty_DataOffset to get an absolute byte offset in the file.
+	@param			ioFlags
+						If outDataByteOffset is an estimate, then kAudioFileStreamSeekFlag_OffsetIsEstimated will be set on output.
+						There are currently no flags defined for passing into this call.
+}
+function AudioFileStreamSeek( inAudioFileStream: AudioFileStreamID; inPacketOffset: SInt64; var outDataByteOffset: SInt64; var ioFlags: AudioFileStreamSeekFlags ): OSStatus; external name '_AudioFileStreamSeek';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+	@function		AudioFileStreamGetPropertyInfo
+ 
+	@discussion		Retrieve the info about the given property. The outSize argument
+					will return the size in bytes of the current value of the property.
+ 
+	@param			inAudioFileStream 
+						The file stream ID
+	@param			inPropertyID
+						Property ID whose value should be read
+	@param			outPropertyDataSize
+						Size in bytes of the property
+	@param			outWritable
+						whether the property is writable
+ 
+	@result			an OSStatus return code
+}
+function AudioFileStreamGetPropertyInfo( inAudioFileStream: AudioFileStreamID; inPropertyID: AudioFileStreamPropertyID; outPropertyDataSize: UInt32Ptr {__nullable}; outWritable: BooleanPtr {__nullable} ): OSStatus; external name '_AudioFileStreamGetPropertyInfo';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+
+{!
+	@function		AudioFileStreamGetProperty
+ 
+	@discussion		Retrieve the indicated property data. 
+ 
+	@param			inAudioFileStream 
+						The file stream ID
+	@param			inPropertyID
+						Property ID whose value should be read
+	@param			ioPropertyDataSize
+						On input, the size of the buffer pointed to by outPropertyData. On output, 
+						the number of bytes written.
+	@param			outPropertyData
+						Pointer to the property data buffer
+
+	@result			an OSStatus return code
+}
+function AudioFileStreamGetProperty( inAudioFileStream: AudioFileStreamID; inPropertyID: AudioFileStreamPropertyID; var ioPropertyDataSize: UInt32; outPropertyData: UnivPtr ): OSStatus; external name '_AudioFileStreamGetProperty';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+	@function		AudioFileStreamSetProperty
+ 
+	@discussion		Set the value of the property. There are currently no settable properties.
+ 
+	@param			inAudioFileStream 
+						The file stream ID
+	@param			inPropertyID
+						Property ID whose value should be set
+	@param			inPropertyDataSize
+						Size in bytes of the property data
+	@param			inPropertyData
+						Pointer to the property data buffer
+
+	@result			an OSStatus return code
+}
+function AudioFileStreamSetProperty( inAudioFileStream: AudioFileStreamID; inPropertyID: AudioFileStreamPropertyID; inPropertyDataSize: UInt32; inPropertyData: {const} UnivPtr ): OSStatus; external name '_AudioFileStreamSetProperty';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+	@function		AudioFileStreamClose
+ 
+	@discussion		Close and deallocate the file stream object.
+
+	@param			inAudioFileStream 
+						The file stream ID
+}
+function AudioFileStreamClose( inAudioFileStream: AudioFileStreamID ): OSStatus; external name '_AudioFileStreamClose';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+
+//CF_ASSUME_NONNULL_END
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+
+end.
+{$endc} {not MACOSALLINCLUDE}

+ 674 - 0
packages/univint/src/AudioFormat.pas

@@ -0,0 +1,674 @@
+{!
+	@file		AudioFormat.h
+	@framework	AudioToolbox.framework
+	@copyright	(c) 1985-2015 by Apple, Inc., all rights reserved.
+    @abstract	API for finding things out about audio formats.
+}
+{
+    Modified for use with Free Pascal
+    Version 308
+    Please report any bugs to <[email protected]>
+}
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+{$mode macpas}
+{$modeswitch cblocks}
+{$packenum 1}
+{$macro on}
+{$inline on}
+{$calling mwpascal}
+
+unit AudioFormat;
+interface
+{$setc UNIVERSAL_INTERFACES_VERSION := $0400}
+{$setc GAP_INTERFACES_VERSION := $0308}
+
+{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
+    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
+{$endc}
+
+{$ifc defined CPUPOWERPC and defined CPUI386}
+	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
+{$endc}
+{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
+	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
+{$endc}
+
+{$ifc not defined __ppc__ and defined CPUPOWERPC32}
+	{$setc __ppc__ := 1}
+{$elsec}
+	{$setc __ppc__ := 0}
+{$endc}
+{$ifc not defined __ppc64__ and defined CPUPOWERPC64}
+	{$setc __ppc64__ := 1}
+{$elsec}
+	{$setc __ppc64__ := 0}
+{$endc}
+{$ifc not defined __i386__ and defined CPUI386}
+	{$setc __i386__ := 1}
+{$elsec}
+	{$setc __i386__ := 0}
+{$endc}
+{$ifc not defined __x86_64__ and defined CPUX86_64}
+	{$setc __x86_64__ := 1}
+{$elsec}
+	{$setc __x86_64__ := 0}
+{$endc}
+{$ifc not defined __arm__ and defined CPUARM}
+	{$setc __arm__ := 1}
+{$elsec}
+	{$setc __arm__ := 0}
+{$endc}
+{$ifc not defined __arm64__ and defined CPUAARCH64}
+  {$setc __arm64__ := 1}
+{$elsec}
+  {$setc __arm64__ := 0}
+{$endc}
+
+{$ifc defined cpu64}
+  {$setc __LP64__ := 1}
+{$elsec}
+  {$setc __LP64__ := 0}
+{$endc}
+
+
+{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
+	{$error Conflicting definitions for __ppc__ and __i386__}
+{$endc}
+
+{$ifc defined __ppc__ and __ppc__}
+	{$setc TARGET_CPU_PPC := TRUE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __ppc64__ and __ppc64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := TRUE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __i386__ and __i386__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := TRUE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __x86_64__ and __x86_64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := TRUE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __arm__ and __arm__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := TRUE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := TRUE}
+{$elifc defined __arm64__ and __arm64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := TRUE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := TRUE}
+{$elsec}
+	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
+{$endc}
+
+{$ifc defined __LP64__ and __LP64__ }
+  {$setc TARGET_CPU_64 := TRUE}
+{$elsec}
+  {$setc TARGET_CPU_64 := FALSE}
+{$endc}
+
+{$ifc defined FPC_BIG_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
+{$elifc defined FPC_LITTLE_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
+{$elsec}
+	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
+{$endc}
+{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
+{$setc CALL_NOT_IN_CARBON := FALSE}
+{$setc OLDROUTINENAMES := FALSE}
+{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
+{$setc OPAQUE_UPP_TYPES := TRUE}
+{$setc OTCARBONAPPLICATION := TRUE}
+{$setc OTKERNEL := FALSE}
+{$setc PM_USE_SESSION_APIS := TRUE}
+{$setc TARGET_API_MAC_CARBON := TRUE}
+{$setc TARGET_API_MAC_OS8 := FALSE}
+{$setc TARGET_API_MAC_OSX := TRUE}
+{$setc TARGET_CARBON := TRUE}
+{$setc TARGET_CPU_68K := FALSE}
+{$setc TARGET_CPU_MIPS := FALSE}
+{$setc TARGET_CPU_SPARC := FALSE}
+{$setc TARGET_OS_UNIX := FALSE}
+{$setc TARGET_OS_WIN32 := FALSE}
+{$setc TARGET_RT_MAC_68881 := FALSE}
+{$setc TARGET_RT_MAC_CFM := FALSE}
+{$setc TARGET_RT_MAC_MACHO := TRUE}
+{$setc TYPED_FUNCTION_POINTERS := TRUE}
+{$setc TYPE_BOOL := FALSE}
+{$setc TYPE_EXTENDED := FALSE}
+{$setc TYPE_LONGLONG := TRUE}
+{$endc} {not MACOSALLINCLUDE}
+{  Pascal Translation: Jonas Maebe <[email protected]>, July 2019 }
+uses MacTypes,CoreAudioTypes;
+{$ALIGN POWER}
+
+
+//=============================================================================
+//	Includes
+//=============================================================================
+
+//	System Includes
+
+//CF_ASSUME_NONNULL_BEGIN
+
+
+//=============================================================================
+//	Types
+//=============================================================================
+
+{!
+    @typedef	AudioFormatPropertyID
+    @abstract   A type for four char codes for property IDs
+}
+type
+	AudioFormatPropertyID = UInt32;
+	AudioFormatPropertyIDPtr = ^AudioFormatPropertyID;
+
+{!
+    @enum		PanningMode
+    @abstract   Different panning algorithms.
+    @constant   kPanningMode_SoundField
+					Sound field panning algorithm
+    @constant   kPanningMode_VectorBasedPanning
+					Vector based panning algorithm
+}
+type
+	AudioPanningMode = UInt32;
+	AudioPanningModePtr = ^AudioPanningMode;
+const
+	kPanningMode_SoundField = 3;
+	kPanningMode_VectorBasedPanning = 4; 
+
+{!
+    @struct		AudioPanningInfo
+    @abstract   This struct is for use with kAudioFormatProperty_PanningMatrix.
+    @field      mPanningMode			the PanningMode to be used for the pan
+    @field      mCoordinateFlags		the coordinates are specified as in the AudioChannelDescription struct in CoreAudioTypes.h
+    @field      mCoordinates			the coordinates are specified as in the AudioChannelDescription struct in CoreAudioTypes.h
+    @field      mGainScale				
+					mGainScale is used to multiply the panning values.
+					In typical usage you are applying an existing volume.
+					value in 0 -> 1 (where 1 is unity gain) to the panned values.
+					1 would give you panning at unity.
+					0 would give you back a matrix of zeroes.
+    @field      mOutputChannelMap				
+					This is the channel map that is going to be used to determine channel volumes for this pan.
+}
+type
+	AudioPanningInfo = record
+		mPanningMode: AudioPanningMode;
+		mCoordinateFlags: UInt32;
+		mCoordinates: array [0..3-1] of Float32;	
+		mGainScale: Float32;
+		mOutputChannelMap: {const} AudioChannelLayoutPtr;
+	end;
+	AudioPanningInfoPtr = ^AudioPanningInfo;
+
+{!
+    @enum		AudioBalanceFadeType
+    @abstract   used for mType field of AudioBalanceFade struct
+    @constant   kAudioBalanceFadeType_MaxUnityGain
+					the gain value never exceeds 1.0, the opposite channel fades out. 
+					This can reduce overall loudness when the balance or fade is not in the center.
+    @constant   kAudioBalanceFadeType_EqualPower
+					The overall loudness remains constant, but gain can exceed 1.0.
+					the gain value is 1.0 when the balance and fade are in the center.
+					From there they can increase to +3dB (1.414) and decrease to -inf dB (0.0).
+}
+type
+	AudioBalanceFadeType = UInt32;
+	AudioBalanceFadeTypePtr = ^AudioBalanceFadeType;
+const
+	kAudioBalanceFadeType_MaxUnityGain = 0;
+	kAudioBalanceFadeType_EqualPower = 1; 
+	
+{!
+    @struct		AudioBalanceFade
+    @abstract   this struct is used with kAudioFormatProperty_BalanceFade
+    @field      mLeftRightBalance 
+					-1 is full left, 0 is center, +1 is full right
+    @field      mBackFrontFade 
+					-1 is full rear, 0 is center, +1 is full front
+    @field      mType 
+					an AudioBalanceFadeType constant
+    @field      mChannelLayout 
+					a pointer to an AudioChannelLayout
+}
+type
+	AudioBalanceFade = record
+		mLeftRightBalance: Float32;		// -1 is full left, 0 is center, +1 is full right
+		mBackFrontFade: Float32;			// -1 is full rear, 0 is center, +1 is full front
+		mType: AudioBalanceFadeType;					// max unity gain, or equal power.
+		mChannelLayout: {const} AudioChannelLayoutPtr;
+	end;
+	AudioBalanceFadePtr = ^AudioBalanceFade;
+
+{!
+    @struct		AudioFormatInfo
+    @abstract   this struct is used as a specifier for the kAudioFormatProperty_FormatList property
+    @field      mASBD 
+					an AudioStreamBasicDescription
+    @field      mMagicCookie 
+					a pointer to the decompression info for the data described in mASBD
+    @field      mMagicCookieSize 
+					the size in bytes of mMagicCookie
+}
+type
+	AudioFormatInfo = record
+		mASBD: AudioStreamBasicDescription;
+		mMagicCookie: {const} UnivPtr;
+		mMagicCookieSize: UInt32;
+	end;
+	AudioFormatInfoPtr = ^AudioFormatInfo;
+
+{!
+    @struct		ExtendedAudioFormatInfo
+    @abstract   this struct is used as a specifier for the kAudioFormatProperty_FormatList property
+    @field      mASBD 
+					an AudioStreamBasicDescription
+    @field      mMagicCookie 
+					a pointer to the decompression info for the data described in mASBD
+    @field      mMagicCookieSize 
+					the size in bytes of mMagicCookie
+	@field		mClassDescription
+					an AudioClassDescription specifying the codec to be used in answering the question.
+}
+type
+	ExtendedAudioFormatInfo = record
+		mASBD: AudioStreamBasicDescription;
+		mMagicCookie: {const} UnivPtr {__nullable};
+		mMagicCookieSize: UInt32;
+		mClassDescription: AudioClassDescription;
+	end;
+	ExtendedAudioFormatInfoPtr = ^ExtendedAudioFormatInfo;
+
+{!
+    @struct		AudioFormatListItem
+    @abstract   this struct is used as output from the kAudioFormatProperty_FormatList property
+    @field      mASBD 
+					an AudioStreamBasicDescription
+    @field      mChannelLayoutTag 
+					an AudioChannelLayoutTag
+}
+type
+	AudioFormatListItem = record
+		mASBD: AudioStreamBasicDescription;
+		mChannelLayoutTag: AudioChannelLayoutTag;
+	end;
+	AudioFormatListItemPtr = ^AudioFormatListItem;
+
+//=============================================================================
+//	Properties - for various format structures.
+//=============================================================================
+
+{!
+    @enum		AudioFormatProperty constants
+    @abstract   constants for use with AudioFormatGetPropertyInfo and AudioFormatGetProperty.
+    @constant   kAudioFormatProperty_FormatInfo
+					Retrieves general information about a format. The specifier is a
+					magic cookie, or NULL.
+					On input, the property value is an AudioStreamBasicDescription which 
+					should have at least the mFormatID filled out. On output it will be filled out
+					as much as possible given the information known about the format 
+					and the contents of the magic cookie (if any is given).
+					If multiple formats can be described by the AudioStreamBasicDescription and the associated magic cookie,
+					this property will return the base level format.
+    @constant   kAudioFormatProperty_FormatIsVBR
+					Returns whether or not a format has a variable number of bytes per
+					packet. The specifier is an AudioStreamBasicDescription describing
+					the format to ask about. The value is a UInt32 where non-zero means
+					the format is variable bytes per packet.
+    @constant   kAudioFormatProperty_FormatIsExternallyFramed
+					Returns whether or not a format requires external framing information,
+					i.e. AudioStreamPacketDescriptions. 
+					The specifier is an AudioStreamBasicDescription describing
+					the format to ask about. The value is a UInt32 where non-zero means
+					the format is externally framed. Any format which has variable byte sized packets
+					requires AudioStreamPacketDescriptions.
+    @constant   kAudioFormatProperty_FormatIsEncrypted
+                    Returns whether or not a format is encrypted. The specifier is a UInt32 format ID.
+                    The value is a UInt32 where non-zero means the format is encrypted.
+    @constant   kAudioFormatProperty_EncodeFormatIDs
+					No specifier needed. Must be set to NULL.
+					Returns an array of UInt32 format IDs for formats that are valid output formats 
+					for a converter. 
+    @constant   kAudioFormatProperty_DecodeFormatIDs
+					No specifier needed. Must be set to NULL.
+					Returns an array of UInt32 format IDs for formats that are valid input formats 
+					for a converter. 
+    @constant   kAudioFormatProperty_Encoders
+					The specifier is the format that you are interested in, e.g. 'aac '
+					Returns an array of AudioClassDescriptions for all installed encoders for the given format 
+    @constant   kAudioFormatProperty_Decoders
+					The specifier is the format that you are interested in, e.g. 'aac '
+					Returns an array of AudioClassDescriptions for all installed decoders for the given format 
+    @constant   kAudioFormatProperty_AvailableEncodeBitRates
+					The specifier is a UInt32 format ID.
+					The property value is an array of AudioValueRange describing all available bit rates.
+    @constant   kAudioFormatProperty_AvailableEncodeSampleRates
+					The specifier is a UInt32 format ID.
+					The property value is an array of AudioValueRange describing all available sample rates.
+    @constant   kAudioFormatProperty_AvailableEncodeChannelLayoutTags
+					The specifier is an AudioStreamBasicDescription with at least the mFormatID 
+					and mChannelsPerFrame fields set.
+					The property value is an array of AudioChannelLayoutTags for the format and number of
+					channels specified. If mChannelsPerFrame is zero, then all layouts supported by
+					the format are returned.	
+    @constant   kAudioFormatProperty_AvailableEncodeNumberChannels
+					The specifier is an AudioStreamBasicDescription with at least the mFormatID field set.
+					The property value is an array of UInt32 indicating the number of channels that can be encoded.
+					A value of 0xFFFFFFFF indicates that any number of channels may be encoded. 
+    @constant   kAudioFormatProperty_FormatName
+					Returns a name for a given format. The specifier is an
+					AudioStreamBasicDescription describing the format to ask about.
+					The value is a CFStringRef. The caller is responsible for releasing the
+					returned string. For some formats (eg, Linear PCM) you will get back a
+					descriptive string (e.g. 16-bit, interleaved, etc...)
+    @constant   kAudioFormatProperty_ASBDFromESDS
+					Returns an audio stream description for a given ESDS. The specifier is an ESDS. 
+					The value is a AudioStreamBasicDescription. If multiple formats can be described 
+					by the ESDS this property will return the base level format.
+    @constant   kAudioFormatProperty_ChannelLayoutFromESDS
+					Returns an audio channel layout for a given ESDS. The specifier is an
+					ESDS. The value is a AudioChannelLayout.
+    @constant   kAudioFormatProperty_ASBDFromMPEGPacket
+					Returns an audio stream description for a given MPEG Packet. The specifier is an MPEG Packet. 
+					The value is a AudioStreamBasicDescription.					
+    @constant   kAudioFormatProperty_FormatList
+					Returns a list of AudioFormatListItem structs describing the audio formats contained within the compressed bit stream
+					as described by the magic cookie. The specifier is an AudioFormatInfo struct. The mFormatID member of the 
+					ASBD struct must filled in. Formats are returned in order from the most to least 'rich', with 
+					channel count taking the highest precedence followed by sample rate. The kAudioFormatProperty_FormatList property 
+					is the preferred method for discovering format information of the audio data. If the audio data can only be described
+					by a single AudioFormatListItem, this property would be equivalent to using the kAudioFormatProperty_FormatInfo property,
+					which should be used by the application as a fallback case, to ensure backward compatibility with existing systems 
+					when kAudioFormatProperty_FormatList is not present on the running system.
+    @constant   kAudioFormatProperty_OutputFormatList
+					Returns a list of AudioFormatListItem structs describing the audio formats which may be obtained by decoding the format
+					described by the specifier.
+					The specifier is an AudioFormatInfo struct. At a minimum formatID member of the ASBD struct must filled in. Other fields
+					may be filled in. If there is no magic cookie, then the number of channels and sample rate should be filled in. 
+	@constant	kAudioFormatProperty_FirstPlayableFormatFromList
+					The specifier is a list of 1 or more AudioFormatListItem. Generally it is the list of these items returned from kAudioFormatProperty_FormatList. The property value retrieved is an UInt32 that specifies an index into that list. The list that the caller provides is generally sorted with the first item as the best format (most number of channels, highest sample rate), and the returned index represents the first item in that list that can be played by the system. 
+					Thus, the property is typically used to determine the best playable format for a given (layered) audio stream
+	@constant   kAudioFormatProperty_ValidateChannelLayout
+					The specifier is an AudioChannelLayout. The property value and size are not used and must be set to NULL.
+					This property validates an AudioChannelLayout. This is useful if the layout has come from an untrusted source such as a file.
+					It returns noErr if the AudioChannelLayout is OK, kAudio_ParamError if there is a structural problem with the layout,
+					or kAudioFormatUnknownFormatError for unrecognized layout tags or channel labels.
+	@constant   kAudioFormatProperty_ChannelLayoutForTag
+					Returns the channel descriptions for a standard channel layout.
+					The specifier is a AudioChannelLayoutTag (the mChannelLayoutTag field 
+					of the AudioChannelLayout struct) containing the layout constant. 
+					The value is an AudioChannelLayout structure. In typical use a AudioChannelLayout
+					can be valid with just a defined AudioChannelLayoutTag (ie, those layouts
+					have predefined speaker locations and orderings).
+					Returns an error if the tag is kAudioChannelLayoutTag_UseChannelBitmap 
+    @constant   kAudioFormatProperty_TagForChannelLayout
+					Returns an AudioChannelLayoutTag for a layout, if there is one.
+					The specifier is an AudioChannelLayout containing the layout description.
+					The value is an AudioChannelLayoutTag.
+					This can be used to reduce a layout specified by kAudioChannelLayoutTag_UseChannelDescriptions
+					or kAudioChannelLayoutTag_UseChannelBitmap to a known AudioChannelLayoutTag.
+    @constant   kAudioFormatProperty_ChannelLayoutForBitmap
+					Returns the channel descriptions for a standard channel layout.
+					The specifier is a UInt32 (the mChannelBitmap field 
+					of the AudioChannelLayout struct) containing the layout bitmap. The value
+					is an AudioChannelLayout structure. In some uses, an AudioChannelLayout can be 
+					valid with the layoutTag set to "use bitmap" and the bitmap set appropriately.
+    @constant   kAudioFormatProperty_BitmapForLayoutTag
+					Returns a bitmap for an AudioChannelLayoutTag, if there is one.
+					The specifier is a AudioChannelLayoutTag  containing the layout tag.
+					The value is an UInt32 bitmap. The bits are as defined in CoreAudioTypes.h.
+					To go in the other direction, i.e. get a layout tag for a bitmap, 
+					use kAudioFormatProperty_TagForChannelLayout where your layout tag 
+					is kAudioChannelLayoutTag_UseChannelBitmap and the bitmap is filled in.
+    @constant   kAudioFormatProperty_ChannelLayoutName
+					Returns the a name for a particular channel layout. The specifier is
+					an AudioChannelLayout containing the layout description. The value
+					is a CFStringRef. The caller is responsible for releasing the
+					returned string.
+    @constant   kAudioFormatProperty_ChannelLayoutSimpleName
+					Returns the a simpler name for a channel layout than does kAudioFormatProperty_ChannelLayoutName. 
+					It omits the channel labels from the name. The specifier is
+					an AudioChannelLayout containing the layout description. The value
+					is a CFStringRef. The caller is responsible for releasing the
+					returned string.
+    @constant   kAudioFormatProperty_ChannelName
+					Returns the name for a particular channel. The specifier is an
+					AudioChannelDescription which has the mChannelLabel field set. The value
+					is a CFStringRef. The caller is responsible for releasing the
+					returned string.
+    @constant   kAudioFormatProperty_ChannelShortName
+					Returns an abbreviated name for a particular channel. The specifier is an
+					AudioChannelDescription which has the mChannelLabel field set. The value
+					is a CFStringRef. The caller is responsible for releasing the
+					returned string.
+    @constant   kAudioFormatProperty_MatrixMixMap
+					Returns a matrix of scaling coefficients for converting audio from one channel map 
+					to another in a standard way, if one is known. Otherwise an error is returned.
+					The specifier is an array of two pointers to AudioChannelLayout structures. 
+					The first points to the input layout, the second to the output layout.
+					The value is a two dimensional array of Float32 where the first dimension (rows) 
+					is the input channel and the second dimension (columns) is the output channel. 
+    @constant   kAudioFormatProperty_ChannelMap
+					Returns an array of SInt32 for reordering input channels.
+					The specifier is an array of two pointers to AudioChannelLayout structures. 
+					The first points to the input layout, the second to the output layout.
+					The length of the output array is equal to the number of output channels.
+    @constant   kAudioFormatProperty_NumberOfChannelsForLayout
+					This is a general call for parsing a AudioChannelLayout provided as the specifier,
+					to determine the number of valid channels that are represented. So, if the
+					LayoutTag is specified, it returns the number of channels for that layout. If 
+					the bitmap is specified, it returns the number of channels represented by that bitmap.
+					If the layout tag is 'kAudioChannelLayoutTag_UseChannelDescriptions' it returns
+						the number of channel descriptions.
+    @constant   kAudioFormatProperty_AreChannelLayoutsEquivalent
+					Returns a UInt32 which is 1 if two layouts are equivalent and 0 if they are not equivalent.
+					In order to be equivalent, the layouts must describe the same channels in the same order.
+					Whether the layout is represented by a bitmap, channel descriptions or a channel layout tag is not significant.
+					The channel coordinates are only significant if the channel label is kAudioChannelLabel_UseCoordinates.
+					The specifier is an array of two pointers to AudioChannelLayout structures. 
+					The value is a pointer to the UInt32 result.
+    @constant   kAudioFormatProperty_ChannelLayoutHash
+					Returns a UInt32 which represents the hash of the provided channel layout.
+					The specifier is a pointer to an AudioChannelLayout structure.
+					The value is a pointer to the UInt32 result.
+    @constant   kAudioFormatProperty_TagsForNumberOfChannels
+					returns an array of AudioChannelLayoutTags for the number of channels specified.
+					The specifier is a UInt32 number of channels. 
+    @constant   kAudioFormatProperty_PanningMatrix
+					This call will pass in an AudioPanningInfo struct that specifies one of the
+					kPanningMode_ constants for the panning algorithm and an AudioChannelLayout
+					to describe the destination channel layout. As in kAudioFormatProperty_MatrixMixMap
+					the return value is an array of Float32 values of the number of channels
+						represented by this specified channel layout. It is presumed that the source 
+					being panned is mono (thus for a quad channel layout, 4 Float32 values are returned).
+					The intention of this API is to provide support for panning operations that are
+					strictly manipulating the respective volumes of the channels. Thus, more
+					complex panners (like HRTF, distance filtering etc,) will not be represented
+						by this API. The resultant volume scalars can then be applied to a mixer
+					or some other processing code to adapt the individual volumes of the mixed
+					output.
+					The volume values will typically be presented within a 0->1 range (where 1 is unity gain)
+					For stereo formats, vector based panning is equivalent to the equal-power pan mode.
+    @constant   kAudioFormatProperty_BalanceFade
+					get an array of coefficients for applying left/right balance and front/back fade.
+					The specifier is an AudioBalanceFade struct. 
+					the return value is an array of Float32 values of the number of channels
+						represented by this specified channel layout.  
+					The volume values will typically be presented within a 0->1 range (where 1 is unity gain)
+    @constant   kAudioFormatProperty_ID3TagSize
+					Returns a UInt32 indicating the ID3 tag size. 
+					The specifier must begin with the ID3 tag header and be at least 10 bytes in length
+    @constant   kAudioFormatProperty_ID3TagToDictionary
+					Returns a CFDictionary containing key/value pairs for the frames in the ID3 tag
+					The specifier is the entire ID3 tag
+					Caller must call CFRelease for the returned dictionary
+					
+}
+const
+//=============================================================================
+//	The following properties are concerned with the AudioStreamBasicDescription
+//=============================================================================
+	kAudioFormatProperty_FormatInfo = FourCharCode('fmti');
+	kAudioFormatProperty_FormatName = FourCharCode('fnam');
+	kAudioFormatProperty_EncodeFormatIDs = FourCharCode('acof');
+	kAudioFormatProperty_DecodeFormatIDs = FourCharCode('acif');
+	kAudioFormatProperty_FormatList = FourCharCode('flst');
+	kAudioFormatProperty_ASBDFromESDS = FourCharCode('essd');
+	kAudioFormatProperty_ChannelLayoutFromESDS = FourCharCode('escl');
+	kAudioFormatProperty_OutputFormatList = FourCharCode('ofls');
+	kAudioFormatProperty_FirstPlayableFormatFromList = FourCharCode('fpfl');
+	kAudioFormatProperty_FormatIsVBR = FourCharCode('fvbr');
+	kAudioFormatProperty_FormatIsExternallyFramed = FourCharCode('fexf');
+	kAudioFormatProperty_FormatIsEncrypted = FourCharCode('cryp');
+	kAudioFormatProperty_Encoders = FourCharCode('aven');
+	kAudioFormatProperty_Decoders = FourCharCode('avde');
+	kAudioFormatProperty_AvailableEncodeBitRates = FourCharCode('aebr');
+	kAudioFormatProperty_AvailableEncodeSampleRates = FourCharCode('aesr');
+	kAudioFormatProperty_AvailableEncodeChannelLayoutTags = FourCharCode('aecl');
+	kAudioFormatProperty_AvailableEncodeNumberChannels = FourCharCode('avnc');
+	kAudioFormatProperty_ASBDFromMPEGPacket = FourCharCode('admp'); 
+
+
+//=============================================================================
+//	The following properties concern the AudioChannelLayout struct (speaker layouts)
+//=============================================================================
+	kAudioFormatProperty_BitmapForLayoutTag = FourCharCode('bmtg');
+	kAudioFormatProperty_MatrixMixMap = FourCharCode('mmap');
+	kAudioFormatProperty_ChannelMap = FourCharCode('chmp');
+	kAudioFormatProperty_NumberOfChannelsForLayout = FourCharCode('nchm');
+	kAudioFormatProperty_AreChannelLayoutsEquivalent = FourCharCode('cheq');
+	kAudioFormatProperty_ChannelLayoutHash = FourCharCode('chha');
+	kAudioFormatProperty_ValidateChannelLayout = FourCharCode('vacl');
+	kAudioFormatProperty_ChannelLayoutForTag = FourCharCode('cmpl');
+	kAudioFormatProperty_TagForChannelLayout = FourCharCode('cmpt');
+	kAudioFormatProperty_ChannelLayoutName = FourCharCode('lonm');
+	kAudioFormatProperty_ChannelLayoutSimpleName = FourCharCode('lsnm');
+	kAudioFormatProperty_ChannelLayoutForBitmap = FourCharCode('cmpb');
+	kAudioFormatProperty_ChannelName = FourCharCode('cnam');
+	kAudioFormatProperty_ChannelShortName = FourCharCode('csnm');
+	kAudioFormatProperty_TagsForNumberOfChannels = FourCharCode('tagc');
+	kAudioFormatProperty_PanningMatrix = FourCharCode('panm');
+	kAudioFormatProperty_BalanceFade = FourCharCode('balf'); 
+
+//=============================================================================
+//	The following properties concern the ID3 Tags
+//=============================================================================
+
+	kAudioFormatProperty_ID3TagSize = FourCharCode('id3s');
+	kAudioFormatProperty_ID3TagToDictionary = FourCharCode('id3d'); 
+
+
+//=============================================================================
+//	Routines
+//=============================================================================
+
+{!
+    @function	AudioFormatGetPropertyInfo
+    @abstract   Retrieve information about the given property
+    @param      inPropertyID		an AudioFormatPropertyID constant.
+    @param      inSpecifierSize		The size of the specifier data.
+    @param      inSpecifier			A specifier is a buffer of data used as an input argument to some of the properties.
+    @param      outPropertyDataSize	The size in bytes of the current value of the property. In order to get the property value,
+									you will need a buffer of this size.
+    @result     returns noErr if successful.
+}
+function AudioFormatGetPropertyInfo( inPropertyID: AudioFormatPropertyID; inSpecifierSize: UInt32; {const} inSpecifier: UnivPtr {__nullable}; var outPropertyDataSize: UInt32 ): OSStatus; external name '_AudioFormatGetPropertyInfo';
+(* API_AVAILABLE(macos(10.3), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function	AudioFormatGetProperty
+    @abstract   Retrieve the indicated property data
+    @param      inPropertyID		an AudioFormatPropertyID constant.
+    @param      inSpecifierSize		The size of the specifier data.
+    @param      inSpecifier			A specifier is a buffer of data used as an input argument to some of the properties.
+    @param      ioPropertyDataSize	on input the size of the outPropertyData buffer. On output the number of bytes written to the buffer.
+    @param      outPropertyData		the buffer in which to write the property data. If outPropertyData is NULL and ioPropertyDataSize is
+									not, the amount that would have been written will be reported.
+    @result     returns noErr if successful.
+}
+function AudioFormatGetProperty( inPropertyID: AudioFormatPropertyID; inSpecifierSize: UInt32; {const} inSpecifier: UnivPtr {__nullable}; ioPropertyDataSize: UInt32Ptr {* __nullable}; outPropertyData: UnivPtr {__nullable} ): OSStatus; external name '_AudioFormatGetProperty';
+(* API_AVAILABLE(macos(10.3), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+
+//-----------------------------------------------------------------------------
+//  AudioFormat Error Codes
+//-----------------------------------------------------------------------------
+const
+	kAudioFormatUnspecifiedError = FourCharCode('what'); 	// 0x77686174, 2003329396
+	kAudioFormatUnsupportedPropertyError = FourCharCode('prop'); 	// 0x70726F70, 1886547824
+	kAudioFormatBadPropertySizeError = FourCharCode('!siz'); 	// 0x2173697A, 561211770
+	kAudioFormatBadSpecifierSizeError = FourCharCode('!spc'); 	// 0x21737063, 561213539
+	kAudioFormatUnsupportedDataFormatError = FourCharCode('fmt?'); 	// 0x666D743F, 1718449215
+	kAudioFormatUnknownFormatError = FourCharCode('!fmt'); 	// 0x21666D74, 560360820
+
+
+//CF_ASSUME_NONNULL_END
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+
+end.
+{$endc} {not MACOSALLINCLUDE}

+ 1 - 0
packages/univint/src/AudioHardware.pas

@@ -22,6 +22,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AudioHardwareBase.pas

@@ -18,6 +18,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AudioHardwareDeprecated.pas

@@ -18,6 +18,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 409 - 0
packages/univint/src/AudioHardwareService.pas

@@ -0,0 +1,409 @@
+{!
+	@file		AudioHardwareService.h
+	@framework	AudioToolbox.framework
+	@copyright	(c) 2006-2015 by Apple, Inc., all rights reserved.
+    @abstract   API's for general high level audio services.
+ 
+    @discussion
+ 
+     The Audio Hardware Service (AHS) provides a way for applications to query and manipulate the
+     aspects of an audio hardware device without incurring the overhead of loading the full audio
+     HAL. AHS provides access to all the AudioObjects and their properties on the system. However,
+     access is limited to only those properties that do not directly impact IO. For example, you can
+     query the device's format but you can't query its IO buffer size. As such, the AHS API directly
+     incorporates the various structures and constants in HAL's API, with the caveat that the
+     AudioObjectIDs used in AHS cannot be used with the HAL.
+}
+{  Pascal Translation: Jonas Maebe <[email protected]>, July 2019 }
+{
+    Modified for use with Free Pascal
+    Version 308
+    Please report any bugs to <[email protected]>
+}
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+{$mode macpas}
+{$modeswitch cblocks}
+{$packenum 1}
+{$macro on}
+{$inline on}
+{$calling mwpascal}
+
+unit AudioHardwareService;
+interface
+{$setc UNIVERSAL_INTERFACES_VERSION := $0400}
+{$setc GAP_INTERFACES_VERSION := $0308}
+
+{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
+    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
+{$endc}
+
+{$ifc defined CPUPOWERPC and defined CPUI386}
+	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
+{$endc}
+{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
+	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
+{$endc}
+
+{$ifc not defined __ppc__ and defined CPUPOWERPC32}
+	{$setc __ppc__ := 1}
+{$elsec}
+	{$setc __ppc__ := 0}
+{$endc}
+{$ifc not defined __ppc64__ and defined CPUPOWERPC64}
+	{$setc __ppc64__ := 1}
+{$elsec}
+	{$setc __ppc64__ := 0}
+{$endc}
+{$ifc not defined __i386__ and defined CPUI386}
+	{$setc __i386__ := 1}
+{$elsec}
+	{$setc __i386__ := 0}
+{$endc}
+{$ifc not defined __x86_64__ and defined CPUX86_64}
+	{$setc __x86_64__ := 1}
+{$elsec}
+	{$setc __x86_64__ := 0}
+{$endc}
+{$ifc not defined __arm__ and defined CPUARM}
+	{$setc __arm__ := 1}
+{$elsec}
+	{$setc __arm__ := 0}
+{$endc}
+{$ifc not defined __arm64__ and defined CPUAARCH64}
+  {$setc __arm64__ := 1}
+{$elsec}
+  {$setc __arm64__ := 0}
+{$endc}
+
+{$ifc defined cpu64}
+  {$setc __LP64__ := 1}
+{$elsec}
+  {$setc __LP64__ := 0}
+{$endc}
+
+
+{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
+	{$error Conflicting definitions for __ppc__ and __i386__}
+{$endc}
+
+{$ifc defined __ppc__ and __ppc__}
+	{$setc TARGET_CPU_PPC := TRUE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __ppc64__ and __ppc64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := TRUE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __i386__ and __i386__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := TRUE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __x86_64__ and __x86_64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := TRUE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __arm__ and __arm__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := TRUE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := TRUE}
+{$elifc defined __arm64__ and __arm64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := TRUE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := TRUE}
+{$elsec}
+	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
+{$endc}
+
+{$ifc defined __LP64__ and __LP64__ }
+  {$setc TARGET_CPU_64 := TRUE}
+{$elsec}
+  {$setc TARGET_CPU_64 := FALSE}
+{$endc}
+
+{$ifc defined FPC_BIG_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
+{$elifc defined FPC_LITTLE_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
+{$elsec}
+	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
+{$endc}
+{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
+{$setc CALL_NOT_IN_CARBON := FALSE}
+{$setc OLDROUTINENAMES := FALSE}
+{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
+{$setc OPAQUE_UPP_TYPES := TRUE}
+{$setc OTCARBONAPPLICATION := TRUE}
+{$setc OTKERNEL := FALSE}
+{$setc PM_USE_SESSION_APIS := TRUE}
+{$setc TARGET_API_MAC_CARBON := TRUE}
+{$setc TARGET_API_MAC_OS8 := FALSE}
+{$setc TARGET_API_MAC_OSX := TRUE}
+{$setc TARGET_CARBON := TRUE}
+{$setc TARGET_CPU_68K := FALSE}
+{$setc TARGET_CPU_MIPS := FALSE}
+{$setc TARGET_CPU_SPARC := FALSE}
+{$setc TARGET_OS_UNIX := FALSE}
+{$setc TARGET_OS_WIN32 := FALSE}
+{$setc TARGET_RT_MAC_68881 := FALSE}
+{$setc TARGET_RT_MAC_CFM := FALSE}
+{$setc TARGET_RT_MAC_MACHO := TRUE}
+{$setc TYPED_FUNCTION_POINTERS := TRUE}
+{$setc TYPE_BOOL := FALSE}
+{$setc TYPE_EXTENDED := FALSE}
+{$setc TYPE_LONGLONG := TRUE}
+uses MacTypes,AudioHardwareBase,AudioHardware;
+{$endc} {not MACOSALLINCLUDE}
+
+{$ALIGN POWER}
+
+
+
+
+    
+//==================================================================================================
+//#pragma mark    Audio Hardware Service Properties
+
+{!
+    @enum           Audio Hardware Service Properties
+    @abstract       AudioObjectPropertySelector values that apply to various kinds of AudioObjects
+                    only when accessed via the Audio Hardware Service API.
+    @constant       kAudioHardwareServiceProperty_ServiceRestarted
+                        A Float32 whose value has no meaning. Rather, this property exists so that
+                        clients can be informed when the service has been reset for some reason.
+                        When a reset happens, any state the client has with AHS, such as cached data
+                        or added listeners, must be re-established by the client.
+    @constant       kAudioHardwareServiceDeviceProperty_VirtualMasterVolume
+                        A Float32 that represents the value of the volume control. The range is
+                        between 0.0 and 1.0 (inclusive). This actual volume controls this property
+                        manipulates depends on what the device provides. If the device has a true
+                        master volume control, this property directly controls that. If the device
+                        has individual channel volume controls, this property will apply to those
+                        identified by the device's preferred multi-channel layout (or preferred
+                        stereo pair if the device is stereo only). Note that this control maintains
+                        the relative balance between all the channels it affects.
+    @constant       kAudioHardwareServiceDeviceProperty_VirtualMasterBalance
+                        A Float32 that represents the value of the stereo balance control. The range
+                        is from 0.0 (all power to the left) to 1.0 (all power to the right) with
+                        the value of 0.5 signifying that the channels have equal power. This control
+                        is only present for devices that have individual channel volume controls. It
+                        manipulates the relative balance between the volume controls on the channels
+                        identified as the device's default stereo pair.
+}
+const
+	kAudioHardwareServiceProperty_ServiceRestarted = FourCharCode('srst');
+	kAudioHardwareServiceDeviceProperty_VirtualMasterVolume = FourCharCode('vmvc');
+	kAudioHardwareServiceDeviceProperty_VirtualMasterBalance = FourCharCode('vmbc'); 
+
+//==================================================================================================
+//#pragma mark    Audio Hardware Service Functions
+
+{$ifc TARGET_OS_MAC}
+
+{!
+    @functiongroup  Audio Hardware Service
+}
+
+{!
+    @function       AudioHardwareServiceHasProperty
+    @abstract       Queries an AudioObject about whether or not it has the given property.
+    @param          inObjectID
+                        The AudioObject to query.
+    @param          inAddress
+                        An AudioObjectPropertyAddress indicating which property is being queried.
+    @result         A Boolean indicating whether or not the AudioObject has the given property.
+}
+function AudioHardwareServiceHasProperty( inObjectID: AudioObjectID; const (*var*) inAddress: AudioObjectPropertyAddress ): Boolean; external name '_AudioHardwareServiceHasProperty';
+(* API_DEPRECATED("no longer supported", macos(10.5, 10.11)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+{!
+    @function       AudioHardwareServiceIsPropertySettable
+    @abstract       Queries an AudioObject about whether or not the given property can be set using
+                    AudioHardwareServiceSetPropertyData.
+    @param          inObjectID
+                        The AudioObject to query.
+    @param          inAddress
+                        An AudioObjectPropertyAddress indicating which property is being queried.
+    @param          outIsSettable
+                        A Boolean indicating whether or not the property can be set.
+    @result         An OSStatus indicating success or failure.
+}
+function AudioHardwareServiceIsPropertySettable( inObjectID: AudioObjectID; const (*var*) inAddress: AudioObjectPropertyAddress; var outIsSettable: Boolean ): OSStatus; external name '_AudioHardwareServiceIsPropertySettable';
+(* API_DEPRECATED("no longer supported", macos(10.5, 10.11)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+{!
+    @function       AudioHardwareServiceGetPropertyDataSize
+    @abstract       Queries an AudioObject to find the size of the data for the given property.
+    @param          inObjectID
+                        The AudioObject to query.
+    @param          inAddress
+                        An AudioObjectPropertyAddress indicating which property is being queried.
+    @param          inQualifierDataSize
+                        A UInt32 indicating the size of the buffer pointed to by inQualifierData.
+                        Note that not all properties require qualification, in which case this
+                        value will be 0.
+    @param          inQualifierData
+                        A buffer of data to be used in determining the data of the property being
+                        queried. Note that not all properties require qualification, in which case
+                        this value will be NULL.
+    @param          outDataSize
+                        A UInt32 indicating how many bytes the data for the given property occupies.
+    @result         An OSStatus indicating success or failure.
+}
+function AudioHardwareServiceGetPropertyDataSize( inObjectID: AudioObjectID; const (*var*) inAddress: AudioObjectPropertyAddress; inQualifierDataSize: UInt32; inQualifierData: {const} UnivPtr; var outDataSize: UInt32 ): OSStatus; external name '_AudioHardwareServiceGetPropertyDataSize';
+(* API_DEPRECATED("no longer supported", macos(10.5, 10.11)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+{!
+    @function       AudioHardwareServiceGetPropertyData
+    @abstract       Queries an AudioObject to get the data of the given property and places it in
+                    the provided buffer.
+    @param          inObjectID
+                        The AudioObject to query.
+    @param          inAddress
+                        An AudioObjectPropertyAddress indicating which property is being queried.
+    @param          inQualifierDataSize
+                        A UInt32 indicating the size of the buffer pointed to by inQualifierData.
+                        Note that not all properties require qualification, in which case this
+                        value will be 0.
+    @param          inQualifierData
+                        A buffer of data to be used in determining the data of the property being
+                        queried. Note that not all properties require qualification, in which case
+                        this value will be NULL.
+    @param          ioDataSize
+                        A UInt32 which on entry indicates the size of the buffer pointed to by
+                        outData and on exit indicates how much of the buffer was used.
+    @param          outData
+                        The buffer into which the AudioObject will put the data for the given
+                        property.
+    @result         An OSStatus indicating success or failure.
+}
+function AudioHardwareServiceGetPropertyData( inObjectID: AudioObjectID; const (*var*) inAddress: AudioObjectPropertyAddress; inQualifierDataSize: UInt32; inQualifierData: {const} UnivPtr; var ioDataSize: UInt32; outData: UnivPtr ): OSStatus; external name '_AudioHardwareServiceGetPropertyData';
+(* API_DEPRECATED("no longer supported", macos(10.5, 10.11)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+{!
+    @function       AudioHardwareServiceSetPropertyData
+    @abstract       Tells an AudioObject to change the value of the given property using the
+                    provided data.
+    @discussion     Note that the value of the property should not be considered changed until the
+                    HAL has called the listeners as many properties values are changed
+                    asynchronously.
+    @param          inObjectID
+                        The AudioObject to change.
+    @param          inAddress
+                        An AudioObjectPropertyAddress indicating which property is being changed.
+    @param          inQualifierDataSize
+                        A UInt32 indicating the size of the buffer pointed to by inQualifierData.
+                        Note that not all properties require qualification, in which case this
+                        value will be 0.
+    @param          inQualifierData
+                        A buffer of data to be used in determining the data of the property being
+                        queried. Note that not all properties require qualification, in which case
+                        this value will be NULL.
+    @param          inDataSize
+                        A UInt32 indicating the size of the buffer pointed to by inData.
+    @param          inData
+                        The buffer containing the data to be used to change the property's value.
+    @result         An OSStatus indicating success or failure.
+}
+function AudioHardwareServiceSetPropertyData( inObjectID: AudioObjectID; const (*var*) inAddress: AudioObjectPropertyAddress; inQualifierDataSize: UInt32; inQualifierData: {const} UnivPtr; inDataSize: UInt32; inData: {const} UnivPtr ): OSStatus; external name '_AudioHardwareServiceSetPropertyData';
+(* API_DEPRECATED("no longer supported", macos(10.5, 10.11)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+{!
+    @function       AudioHardwareServiceAddPropertyListener
+    @abstract       Registers the given AudioObjectPropertyListenerProc to receive notifications
+                    when the given properties change.
+    @param          inObjectID
+                        The AudioObject to register the listener with.
+    @param          inAddress
+                        The AudioObjectPropertyAddresses indicating which property the listener
+                        should be notified about.
+    @param          inListener
+                        The AudioObjectPropertyListenerProc to call.
+    @param          inClientData
+                        A pointer to client data that is passed to the listener when it is called.
+    @result         An OSStatus indicating success or failure.
+}
+function AudioHardwareServiceAddPropertyListener( inObjectID: AudioObjectID; const (*var*) inAddress: AudioObjectPropertyAddress; inListener: AudioObjectPropertyListenerProc; inClientData: UnivPtr ): OSStatus; external name '_AudioHardwareServiceAddPropertyListener';
+(* API_DEPRECATED("no longer supported", macos(10.5, 10.11)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+{!
+    @function       AudioHardwareServiceRemovePropertyListener
+    @abstract       Unregisters the given AudioObjectPropertyListenerProc from receiving
+                    notifications when the given properties change.
+    @param          inObjectID
+                        The AudioObject to unregister the listener from.
+    @param          inAddress
+                        The AudioObjectPropertyAddresses indicating which property the listener
+                        will stop being notified about.
+    @param          inListener
+                        The AudioObjectPropertyListenerProc being removed.
+    @param          inClientData
+                        A pointer to client data that is passed to the listener when it is called.
+    @result         An OSStatus indicating success or failure.
+}
+function AudioHardwareServiceRemovePropertyListener( inObjectID: AudioObjectID; const (*var*) inAddress: AudioObjectPropertyAddress; inListener: AudioObjectPropertyListenerProc; inClientData: UnivPtr ): OSStatus; external name '_AudioHardwareServiceRemovePropertyListener';
+(* API_DEPRECATED("no longer supported", macos(10.5, 10.11)) API_UNAVAILABLE(ios, watchos, tvos) *)
+
+{$endc}
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+
+end.
+{$endc} {not MACOSALLINCLUDE}

+ 10 - 15
packages/univint/src/AudioOutputUnit.pas

@@ -1,18 +1,12 @@
-{
-     File:       AudioOutputUnit.h
- 
-     Contains:   AudioOutputUnit Interfaces
- 
-     Copyright:  © 2000-2008 by Apple, Inc., all rights reserved.
- 
-     Bugs?:      For bug reports, consult the following page on
-                 the World Wide Web:
- 
-                     http://bugs.freepascal.org
- 
+{!
+	@file		AudioOutputUnit.h
+ 	@framework	AudioToolbox.framework
+ 	@copyright	(c) 2000-2015 Apple, Inc. All rights reserved.
+	@brief		Additional Audio Unit API for audio input/output units.
 }
 {  Pascal Translation:  Gorazd Krosl <[email protected]>, October 2009 }
 {  Pascal Translation Update: Jonas Maebe <[email protected]>, October 2012 }
+{  Pascal Translation Update: Jonas Maebe <[email protected]>, July 2019 }
 
 {
     Modified for use with Free Pascal
@@ -22,6 +16,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}
@@ -232,16 +227,16 @@ uses MacTypes,AUComponent;
 //	Start/stop methods for output units
 //-----------------------------------------------------------------------------
 function AudioOutputUnitStart( ci: AudioUnit ): OSStatus; external name '_AudioOutputUnitStart';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_0,__IPHONE_2_0) *)
+(* API_AVAILABLE(macos(10.0), ios(2.0), watchos(2.0), tvos(9.0)) *)
 
 function AudioOutputUnitStop( ci: AudioUnit ): OSStatus; external name '_AudioOutputUnitStop';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_0,__IPHONE_2_0) *)
+(* API_AVAILABLE(macos(10.0), ios(2.0), watchos(2.0), tvos(9.0)) *)
 
 //-----------------------------------------------------------------------------
 //	Selectors for component and audio plugin calls
 //-----------------------------------------------------------------------------
 const
-	kAudioOutputUnitRange = $0200;	// selector range
+	kAudioOutputUnitRange = $0200; 	// selector range
 	kAudioOutputUnitStartSelect = $0201;
 	kAudioOutputUnitStopSelect = $0202;
 

+ 1741 - 0
packages/univint/src/AudioQueue.pas

@@ -0,0 +1,1741 @@
+{!
+	@file		AudioQueue.h
+	@framework	AudioToolbox.framework
+	@copyright	(c) 2006-2015 by Apple, Inc., all rights reserved.
+    @abstract   API's to record and play audio buffers.
+
+    @discussion
+    
+	Audio queues are software objects you use for recording or playing audio in Mac OS X. Audio
+	queues perform the following tasks:
+
+		- Connect to audio hardware
+		- Manage audio data buffers
+		- Employ codecs, as necessary, for compressed audio formats
+		- Mediate playback or recording
+
+	Audio queues can record and play audio in linear PCM, in compressed formats (such as Apple
+	Lossless, AAC, and MP3), and in other formats for which users have installed codecs. The API set
+	includes high-level support for the use of hardware recording and playback devices, and lets you
+	use sophisticated codecs without knowledge of how they work.
+
+	Additional advanced features support scheduled playback and synchronization of multiple audio
+	queues and synchronization of audio with video.
+}
+{  Pascal Translation: Jonas Maebe <[email protected]>, July 2019 }
+{
+    Modified for use with Free Pascal
+    Version 308
+    Please report any bugs to <[email protected]>
+}
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+{$mode macpas}
+{$modeswitch cblocks}
+{$packenum 1}
+{$macro on}
+{$inline on}
+{$calling mwpascal}
+
+unit AudioQueue;
+interface
+{$setc UNIVERSAL_INTERFACES_VERSION := $0400}
+{$setc GAP_INTERFACES_VERSION := $0308}
+
+{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
+    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
+{$endc}
+
+{$ifc defined CPUPOWERPC and defined CPUI386}
+	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
+{$endc}
+{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
+	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
+{$endc}
+
+{$ifc not defined __ppc__ and defined CPUPOWERPC32}
+	{$setc __ppc__ := 1}
+{$elsec}
+	{$setc __ppc__ := 0}
+{$endc}
+{$ifc not defined __ppc64__ and defined CPUPOWERPC64}
+	{$setc __ppc64__ := 1}
+{$elsec}
+	{$setc __ppc64__ := 0}
+{$endc}
+{$ifc not defined __i386__ and defined CPUI386}
+	{$setc __i386__ := 1}
+{$elsec}
+	{$setc __i386__ := 0}
+{$endc}
+{$ifc not defined __x86_64__ and defined CPUX86_64}
+	{$setc __x86_64__ := 1}
+{$elsec}
+	{$setc __x86_64__ := 0}
+{$endc}
+{$ifc not defined __arm__ and defined CPUARM}
+	{$setc __arm__ := 1}
+{$elsec}
+	{$setc __arm__ := 0}
+{$endc}
+{$ifc not defined __arm64__ and defined CPUAARCH64}
+  {$setc __arm64__ := 1}
+{$elsec}
+  {$setc __arm64__ := 0}
+{$endc}
+
+{$ifc defined cpu64}
+  {$setc __LP64__ := 1}
+{$elsec}
+  {$setc __LP64__ := 0}
+{$endc}
+
+
+{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
+	{$error Conflicting definitions for __ppc__ and __i386__}
+{$endc}
+
+{$ifc defined __ppc__ and __ppc__}
+	{$setc TARGET_CPU_PPC := TRUE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __ppc64__ and __ppc64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := TRUE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __i386__ and __i386__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := TRUE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __x86_64__ and __x86_64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := TRUE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __arm__ and __arm__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := TRUE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := TRUE}
+{$elifc defined __arm64__ and __arm64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := TRUE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := TRUE}
+{$elsec}
+	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
+{$endc}
+
+{$ifc defined __LP64__ and __LP64__ }
+  {$setc TARGET_CPU_64 := TRUE}
+{$elsec}
+  {$setc TARGET_CPU_64 := FALSE}
+{$endc}
+
+{$ifc defined FPC_BIG_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
+{$elifc defined FPC_LITTLE_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
+{$elsec}
+	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
+{$endc}
+{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
+{$setc CALL_NOT_IN_CARBON := FALSE}
+{$setc OLDROUTINENAMES := FALSE}
+{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
+{$setc OPAQUE_UPP_TYPES := TRUE}
+{$setc OTCARBONAPPLICATION := TRUE}
+{$setc OTKERNEL := FALSE}
+{$setc PM_USE_SESSION_APIS := TRUE}
+{$setc TARGET_API_MAC_CARBON := TRUE}
+{$setc TARGET_API_MAC_OS8 := FALSE}
+{$setc TARGET_API_MAC_OSX := TRUE}
+{$setc TARGET_CARBON := TRUE}
+{$setc TARGET_CPU_68K := FALSE}
+{$setc TARGET_CPU_MIPS := FALSE}
+{$setc TARGET_CPU_SPARC := FALSE}
+{$setc TARGET_OS_UNIX := FALSE}
+{$setc TARGET_OS_WIN32 := FALSE}
+{$setc TARGET_RT_MAC_68881 := FALSE}
+{$setc TARGET_RT_MAC_CFM := FALSE}
+{$setc TARGET_RT_MAC_MACHO := TRUE}
+{$setc TYPED_FUNCTION_POINTERS := TRUE}
+{$setc TYPE_BOOL := FALSE}
+{$setc TYPE_EXTENDED := FALSE}
+{$setc TYPE_LONGLONG := TRUE}
+uses MacTypes,CFBase,CFRunLoop,CoreAudioTypes,CoreFoundation;
+{$endc} {not MACOSALLINCLUDE}
+
+{$ALIGN POWER}
+
+
+//CF_ASSUME_NONNULL_BEGIN
+
+
+//#pragma mark -
+//#pragma mark Constants
+
+
+//#pragma mark -
+//#pragma mark Types
+//==================================================================================================
+//  TYPES
+//==================================================================================================
+
+{!
+    @typedef    AudioQueuePropertyID
+    @abstract   A value that uniquely identifies an audio queue property.
+}
+type
+	AudioQueuePropertyID = UInt32;
+	AudioQueuePropertyIDPtr = ^AudioQueuePropertyID;
+
+{!
+    @typedef    AudioQueueParameterID
+    @abstract   A value that uniquely identifies an audio queue parameter.
+}
+type
+	AudioQueueParameterID = UInt32;
+	AudioQueueParameterIDPtr = ^AudioQueueParameterID;
+
+{!
+    @typedef    AudioQueueParameterID
+    @abstract   A value for an audio queue parameter.
+}
+type
+	AudioQueueParameterValue = Float32;
+	AudioQueueParameterValuePtr = ^AudioQueueParameterValue;
+
+{!
+    @typedef    AudioQueueRef
+    @abstract   Defines an opaque data type that represents an audio queue.
+}
+type
+	AudioQueueRef = ^OpaqueAudioQueue; { an opaque type }
+	OpaqueAudioQueue = record end;
+
+{!
+    @typedef    AudioQueueTimelineRef
+    @abstract   Defines an opaque data type that represents an audio queue timeline.
+    @discussion
+        You can use this object to observe any overloads in the audio device associated with the
+        audio queue. A timeline object receives notifications of discontinuities in the audio
+        hardware's sample timeline--for instance, a period of silence when sound was expected.
+        Causes of discontinuities include changes in the device state or processing overloads.
+        See Technical Q & A: QA 1467 for a discussion of Core Audio overload warnings. These
+        warnings indicate you are taking too long to process audio data and the system has cut
+        you off. You query a timeline object by passing it as a parameter to
+        AudioQueueGetCurrentTime, which means a discontinuity has occurred.
+}
+type
+	OpaqueAudioQueueTimeline = record end;
+	AudioQueueTimelineRef = ^OpaqueAudioQueueTimeline; { an opaque type }
+	AudioQueueTimelineRefPtr = ^AudioQueueTimelineRef;
+
+
+//==================================================================================================
+//  CONSTANTS
+//==================================================================================================
+{!
+    @enum Result Codes
+    @abstract   The OSStatus result codes returned by Audio Queue functions.
+
+    @constant   kAudioQueueErr_InvalidBuffer        The specified buffer does not belong to the
+                                                    audio queue.
+    @constant   kAudioQueueErr_BufferEmpty          The buffer is empty (that is, the
+                                                    mAudioDataByteSize field = 0).
+    @constant   kAudioQueueErr_DisposalPending      The function cannot act on the audio queue
+                                                    because it is being asynchronously disposed of.
+    @constant   kAudioQueueErr_InvalidProperty      The specified property ID is invalid.
+    @constant   kAudioQueueErr_InvalidPropertySize  The size of the specified property is invalid.
+    @constant   kAudioQueueErr_InvalidParameter     The specified parameter ID is invalid.
+    @constant   kAudioQueueErr_CannotStart          The audio queue has encountered a problem and
+                                                    cannot start.
+    @constant   kAudioQueueErr_InvalidDevice        The device assigned to the queue could not
+                                                    be located, or is not properly configured.
+    @constant   kAudioQueueErr_BufferInQueue        The buffer cannot be disposed of when it is
+                                                    enqueued.
+    @constant   kAudioQueueErr_InvalidRunState      The queue is running but the function can
+                                                    only operate on the queue when it is stopped,
+                                                    or vice versa.
+    @constant   kAudioQueueErr_InvalidQueueType     The queue is an input queue but the function can
+                                                    only operate on an output queue, or vice versa.
+    @constant   kAudioQueueErr_Permissions          You do not have the required permissions to call 
+                                                    the function
+    @constant   kAudioQueueErr_InvalidPropertyValue The specified property value is invalid.
+    @constant   kAudioQueueErr_PrimeTimedOut        During Prime, the queue's AudioConverter failed to
+                                                    convert the requested number of sample frames.
+    @constant   kAudioQueueErr_CodecNotFound        The required audio codec was not found.
+    @constant   kAudioQueueErr_InvalidCodecAccess   Access to the required codec is not permitted
+                                                    (possibly due to incompatible AudioSession
+                                                    settings on iPhoneOS).
+    @constant   kAudioQueueErr_QueueInvalidated     On iPhoneOS, the audio server has exited, causing
+                                                    this audio queue to have become invalid.
+    @constant   kAudioQueueErr_TooManyTaps          There can only be one processing tap per
+                                                    audio queue.
+    @constant   kAudioQueueErr_InvalidTapContext    GetTapSourceAudio can only be called from the
+                                                    tap's callback.
+    @constant   kAudioQueueErr_InvalidTapType       GetTapQueueTime can only be called on an output queue's
+                                                    tap.
+    @constant   kAudioQueueErr_RecordUnderrun       During recording, data was lost because there
+                                                    was no enqueued buffer into which to store it.
+    @constant   kAudioQueueErr_BufferEnqueuedTwice  A buffer was enqueued twice on an input queue
+                                                    (before being returned as a result of being filled
+                                                    or from Reset).
+    @constant   kAudioQueueErr_CannotStartYet       Starting the audio queue failed because an internal
+                                                    reconfiguration (typically initiated by a hardware
+                                                    stream format or sample rate change) was in progress.
+                                                    Sleeping briefly and retrying is recommended.
+    @constant   kAudioQueueErr_EnqueueDuringReset   During Reset, Stop, or Dispose, it is not
+                                                    permitted to enqueue buffers.
+    @constant   kAudioQueueErr_InvalidOfflineMode   The operation requires the queue to be in
+                                                    offline mode but it isn't, or vice versa.
+                                                    (Offline mode is entered and exited via
+                                                    AudioQueueSetOfflineRenderFormat).
+}
+const
+	kAudioQueueErr_InvalidBuffer = -66687;
+	kAudioQueueErr_BufferEmpty = -66686;
+	kAudioQueueErr_DisposalPending = -66685;
+	kAudioQueueErr_InvalidProperty = -66684;
+	kAudioQueueErr_InvalidPropertySize = -66683;
+	kAudioQueueErr_InvalidParameter = -66682;
+	kAudioQueueErr_CannotStart = -66681;
+	kAudioQueueErr_InvalidDevice = -66680;
+	kAudioQueueErr_BufferInQueue = -66679;
+	kAudioQueueErr_InvalidRunState = -66678;
+	kAudioQueueErr_InvalidQueueType = -66677;
+	kAudioQueueErr_Permissions = -66676;
+	kAudioQueueErr_InvalidPropertyValue = -66675;
+	kAudioQueueErr_PrimeTimedOut = -66674;
+	kAudioQueueErr_CodecNotFound = -66673;
+	kAudioQueueErr_InvalidCodecAccess = -66672;
+	kAudioQueueErr_QueueInvalidated = -66671;
+	kAudioQueueErr_TooManyTaps = -66670;
+	kAudioQueueErr_InvalidTapContext = -66669;
+	kAudioQueueErr_RecordUnderrun = -66668;
+	kAudioQueueErr_InvalidTapType = -66667;
+	kAudioQueueErr_BufferEnqueuedTwice = -66666;
+	kAudioQueueErr_CannotStartYet = -66665;
+	kAudioQueueErr_EnqueueDuringReset = -66632;
+	kAudioQueueErr_InvalidOfflineMode = -66626; 
+
+
+{!
+    @enum Audio Queue Property IDs
+    @abstract   Constants that identify properties for audio queues.
+    @discussion
+    @constant   kAudioQueueProperty_IsRunning
+        A read-only property whose value is a UInt32 that indicates whether or not the queue is
+        running. A notification is sent when the audio device starts or stops, which is not
+        necessarily when the start or stop function is called.
+    @constant   kAudioQueueDeviceProperty_SampleRate
+        A read-only property whose value is a Float64 that indicates the sampling rate of the
+        associated audio device.
+    @constant   kAudioQueueDeviceProperty_NumberChannels
+        A read-only property whose value is a UInt32 that indicates the number of channels in
+        the associated audio device.
+    @constant   kAudioQueueProperty_CurrentDevice
+        A read/write property whose value is a CFStringRef that contains the unique identifier
+        (UID) of the associated audio device.
+		If the audio queue is tracking the default system device and the device changes, it will
+		generate a property changed notification for this property. You can then query the HAL 
+		for info on the new default system device.
+    @constant   kAudioQueueProperty_MagicCookie
+        A read/write property whose value is an audio format magic cookie. If the audio format
+        requires a magic cookie, you must set this property before enqueuing any buffers.
+    @constant   kAudioQueueProperty_MaximumOutputPacketSize
+        A read-only UInt32 that indicates the size in bytes of the largest single packet of
+        data in the output format. This is mostly useful for recording/encoding variable bit rate
+        compressed data.
+    @constant   kAudioQueueProperty_StreamDescription
+        A read-only AudioStreamBasicDescription that indicates the queue's recording format.
+        This is useful when recording, where you may specify a sample rate of 0 during
+        construction, 
+    @constant   kAudioQueueProperty_ChannelLayout
+        A read/write property whose value is an audio channel layout structure that describes
+        the audio queue's channel layout. The number of channels must match the format of the
+        queue. If more than two channels (for instance, a five-channel surround sound) exist in
+        the queue, there may be a need to specify a channel layout. This layout indicates the
+        specific order in which the channels do appear, such as left, then center, then right.
+    @constant   kAudioQueueProperty_EnableLevelMetering
+        A read-write property whose value is a UInt32 that indicates whether metering of
+        audio levels is enabled for the audio queue. (0=off, 1=on).
+    @constant   kAudioQueueProperty_CurrentLevelMeter
+        A read-only property whose value is an array of AudioQueueLevelMeter structures, one
+        array element per audio channel. The values in the AudioQueueLevelMeters are in the
+        range 0-1.
+    @constant   kAudioQueueProperty_CurrentLevelMeterDB
+        A read-only property whose value is an array of AudioQueueLevelMeter structures, one
+        array element per audio channel. The values in the AudioQueueLevelMeters are in
+        decibels.
+    @constant   kAudioQueueProperty_DecodeBufferSizeFrames
+        A read/write property whose value is a UInt32 that is the size of the buffer into which
+        an output audio queue decodes buffers. A large buffer provides more reliability and
+        better long-term performance at the expense of memory and decreased responsiveness
+        in some situations.
+    @constant   kAudioQueueProperty_ConverterError
+        A read-only property whose value is a UInt32 indicating the most recent error (if any)
+        encountered by the queue's internal encoding/decoding process.
+    @constant   kAudioQueueProperty_EnableTimePitch
+        A read/write property whose value is a UInt32 describing whether there is a time/pitch unit
+        inserted into the queue's audio signal chain. This property may only be set while
+        the queue is stopped.
+    @constant   kAudioQueueProperty_TimePitchAlgorithm
+        A read/write property whose value is a UInt32 describing the time/pitch algorithm in use.
+        This property is only valid while a time/pitch has been inserted, and may only be changed
+        when the queue is not running.
+    @constant   kAudioQueueProperty_TimePitchBypass
+        A read/write property whose value is a UInt32 describing whether the time/pitch unit
+        has been bypassed (1=bypassed, 0=not bypassed).
+}
+const
+	kAudioQueueProperty_IsRunning = FourCharCode('aqrn');        // value is UInt32
+
+	kAudioQueueDeviceProperty_SampleRate = FourCharCode('aqsr');        // value is Float64
+	kAudioQueueDeviceProperty_NumberChannels = FourCharCode('aqdc');        // value is UInt32
+	kAudioQueueProperty_CurrentDevice = FourCharCode('aqcd');        // value is CFStringRef
+    
+	kAudioQueueProperty_MagicCookie = FourCharCode('aqmc');        // value is void*
+	kAudioQueueProperty_MaximumOutputPacketSize = FourCharCode('xops');        // value is UInt32
+	kAudioQueueProperty_StreamDescription = FourCharCode('aqft');        // value is AudioStreamBasicDescription
+       
+	kAudioQueueProperty_ChannelLayout = FourCharCode('aqcl');        // value is AudioChannelLayout
+	kAudioQueueProperty_EnableLevelMetering = FourCharCode('aqme');        // value is UInt32
+	kAudioQueueProperty_CurrentLevelMeter = FourCharCode('aqmv');        // value is array of AudioQueueLevelMeterState, 1 per channel
+	kAudioQueueProperty_CurrentLevelMeterDB = FourCharCode('aqmd');        // value is array of AudioQueueLevelMeterState, 1 per channel
+
+	kAudioQueueProperty_DecodeBufferSizeFrames = FourCharCode('dcbf');        // value is UInt32
+	kAudioQueueProperty_ConverterError = FourCharCode('qcve');        // value is UInt32
+
+	kAudioQueueProperty_EnableTimePitch = FourCharCode('q_tp');        // value is UInt32, 0/1
+	kAudioQueueProperty_TimePitchAlgorithm = FourCharCode('qtpa');        // value is UInt32. See values below.
+	kAudioQueueProperty_TimePitchBypass = FourCharCode('qtpb');        // value is UInt32, 1=bypassed
+
+{!
+    @enum       Time/Pitch algorithms
+    @abstract   Constants that identify values of kAudioQueueProperty_TimePitchAlgorithm
+
+    @constant kAudioQueueTimePitchAlgorithm_Spectral
+        Highest quality, most computationally expensive. Suitable for music.
+        Default algorithm on OS X.
+    @constant kAudioQueueTimePitchAlgorithm_TimeDomain
+        Modest quality, less expensive. Suitable for voice.
+    @constant kAudioQueueTimePitchAlgorithm_Varispeed
+        High quality, but pitch varies with rate.
+}
+const
+	kAudioQueueTimePitchAlgorithm_Spectral = FourCharCode('spec');
+	kAudioQueueTimePitchAlgorithm_TimeDomain = FourCharCode('tido');
+	kAudioQueueTimePitchAlgorithm_Varispeed = FourCharCode('vspd'); 
+
+
+{!
+    @enum       AudioQueueParameterID
+    @abstract   Constants that identify the parameters for audio queues.
+    @discussion
+        You can set a parameter in one of two ways:
+        
+        <ul>
+        <li>    Assign a parameter value to an audio queue to take effect immediately using
+                AudioQueueSetParameter.</li>
+        <li>    Schedule a parameter to take effect when a buffer is enqueued. You supply the
+                parameter when you queue a buffer, and the new value of the parameter is applied
+                when that buffer is rendered.
+        </ul>
+        
+        AudioQueueGetParameter always returns the current value of the parameter
+
+    @constant   kAudioQueueParam_Volume
+        A value from 0.0 to 1.0 indicating the linearly scaled gain for the queue. A value of
+        1.0 (the default) indicates unity gain. A value of 0.0 indicates zero gain, or silence.
+    @constant   kAudioQueueParam_PlayRate
+        A value from 0.5 to 2.0 indicating the rate at which the queue is to play. A value of
+        1.0 (the default) indicates that the queue should play at its normal rate. Only
+        applicable when the time/pitch processor has been enabled and on Mac OS X 10.6 and higher.
+    @constant   kAudioQueueParam_Pitch
+        A value from -2400 to 2400 indicating the number of cents to pitch-shift the queue's
+        playback. (1200 cents is one octave.) Only applicable when the time/pitch processor has 
+        been enabled with the spectral algorithm, and on Mac OS X 10.6 and higher.
+    @constant   kAudioQueueParam_VolumeRampTime
+        A value indicating the number of seconds over which subsequent volume changes will be
+        ramped. For example, to fade out from full unity gain to silence over the course of 1
+        second, set kAudioQueueParam_VolumeRampTime to 1 then kAudioQueueParam_Volume to 0.
+    @constant   kAudioQueueParam_Pan
+        A value from -1 to 1 indicating the pan position of a mono source (-1 = hard left, 0 =
+        center, 1 = hard right). For a stereo source this parameter affects left/right balance.
+        For multi-channel sources, this parameter has no effect.
+}
+const
+	kAudioQueueParam_Volume = 1;
+	kAudioQueueParam_PlayRate = 2;
+	kAudioQueueParam_Pitch = 3;
+	kAudioQueueParam_VolumeRampTime = 4;
+	kAudioQueueParam_Pan = 13; 
+
+{!
+    @enum       AudioQueueProcessingTap flags
+    @abstract   Flags used in conjunction with processing taps
+
+    @discussion
+        In the flags passed to AudioQueueProcessingTapNew, either the PreEffects
+        or PostEffects flag must be set, but not both. 
+
+    @constant   kAudioQueueProcessingTap_PreEffects
+        Signifies that the processing tap is inserted before any effects.
+        Passed to AudioQueueProcessingTapNew and to the callback.
+    @constant   kAudioQueueProcessingTap_PostEffects
+        Signifies that the processing tap is inserted after any effects.
+        Passed to AudioQueueProcessingTapNew and to the callback.
+    @constant   kAudioQueueProcessingTap_Siphon
+        Signifies that the processing tap is a siphon; it does not call
+        GetSourceAudio. The callback instead receives the source audio
+        and may not modify it. Passed to AudioQueueProcessingTapNew and to the callback.
+    @constant   kAudioQueueProcessingTap_StartOfStream
+        Signifies that the source audio is the beginning of a continuous stream,
+        i.e. following the beginning or resumption of playback or recording.
+        Returned from GetSourceAudio.
+    @constant   kAudioQueueProcessingTap_EndOfStream
+        Signifies that the source audio is past the end of stream. This happens when
+        the audio queue is being stopped asynchronously and has finished playing
+        all of its data. Returned from GetSourceAudio and should be propagated
+        on return from the callback.
+}
+type
+	AudioQueueProcessingTapFlags = UInt32;
+	AudioQueueProcessingTapFlagsPtr = ^AudioQueueProcessingTapFlags;
+const
+//  these are flags that are passed to both the constructor and the callback
+	kAudioQueueProcessingTap_PreEffects = 1 shl 0;      // 0x01
+	kAudioQueueProcessingTap_PostEffects = 1 shl 1;      // 0x02
+	kAudioQueueProcessingTap_Siphon = 1 shl 2;      // 0x04
+
+    //  these are flags that are passed to the callback and from GetSourceAudio
+	kAudioQueueProcessingTap_StartOfStream = 1 shl 8;      // 0x100
+	kAudioQueueProcessingTap_EndOfStream = 1 shl 9;      // 0x200
+
+//#pragma mark -
+//#pragma mark Structs
+//==================================================================================================
+//  STRUCTS
+//==================================================================================================
+
+{!
+    @struct     AudioQueueBuffer
+    @abstract   Defines a buffer of audio data to be managed by an audio queue.
+    @discussion 
+        Each audio queue has an associated set of audio queue buffers. You can request that a
+        queue allocate buffers using the AudioQueueAllocateBuffer function and dispose of them
+        using the AudioQueueFreeBuffer function.
+        
+        You may also use AudioQueueAllocateBufferWithPacketDescriptions to allocate buffers
+        with space for AudioPacketDescriptions, as used in VBR formats. The 
+        mPacketDescriptionCapacity, mmPacketDescriptions, and mPacketDescriptionCount
+        fields may only be used with buffers allocated with this function.
+        
+    @field      mAudioDataBytesCapacity
+        The size of the buffer, in bytes. This size is set when the buffer is allocated and
+        cannot be changed.
+    @field      mAudioData
+       A pointer to the audio data in the buffer. Although you can write data to this buffer,
+       you cannot make it point to another address.
+    @field      mAudioDataByteSize
+        The number of bytes of valid audio data in the buffer. You set this value when providing
+        data for playback; the audio queue sets this value when recording data from a recording
+        queue.
+    @field      mUserData
+        A value you may specify to identify the buffer when it is passed back in recording or
+        playback callback functions.
+    @field      mPacketDescriptionCapacity
+        The maximum number of packet descriptions that can be stored in mPacketDescriptions.
+    @field      mPacketDescriptions
+        An array of AudioStreamPacketDescriptions associated with the buffer.
+    @field      mPacketDescriptionCount
+        The number of valid packet descriptions in the buffer. You set this value when providing
+        buffers for playback; the audio queue sets this value when returning buffers from
+        a recording queue.
+}
+
+type
+	AudioQueueBuffer = record
+		mAudioDataBytesCapacity: {const} UInt32;
+		mAudioData: UnivPtr {const};
+		mAudioDataByteSize: UInt32;
+		mUserData: UnivPtr {__nullable};
+
+		mPacketDescriptionCapacity: {const} UInt32;
+		mPacketDescriptions: AudioStreamPacketDescriptionPtr {const __nullable};
+		mPacketDescriptionCount: UInt32;
+	end;
+	AudioQueueBufferPtr = ^AudioQueueBuffer;
+
+{!
+    @typedef    AudioQueueBufferRef
+    @abstract   An pointer to an AudioQueueBuffer.
+}
+type
+	AudioQueueBufferRef = AudioQueueBufferPtr;
+	AudioQueueBufferRefPtr = ^AudioQueueBufferRef;
+
+{!
+    @struct     AudioQueueParameterEvent
+    @abstract   Specifies a value for an audio queue parameter.
+    @discussion
+        Two ways are available to supply an audio queue with parameters:
+        
+        <ul>
+        <li>    Provide one or more parameters by calling the
+                AudioQueueEnqueueBufferWithParameters function. In this case, the parameters are
+                applied to the specified buffer when it is played.</li>
+        <li>    Assign a parameter value immediately to an audio queue by calling the
+                AudioQueueSetParameter function.</li>
+        </ul>
+        
+        Note that the AudioQueueGetParameter function always returns the actual value of the
+        parameter.
+
+        In Mac OS X v10.5, audio queues have one parameter available: kAudioQueueParam_Volume,
+        which controls the queue's playback volume.
+        
+    @field      mID
+        The parameter.
+    @field      mValue
+        The value of the specified parameter.
+}
+type
+	AudioQueueParameterEvent = record
+		mID: AudioQueueParameterID;
+		mValue: AudioQueueParameterValue;
+	end;
+	AudioQueueParameterEventPtr = ^AudioQueueParameterEvent;
+
+
+{!
+    @struct     AudioQueueLevelMeterState
+    @abstract   Specifies the current level metering information for one channel of an audio queue.
+    @discussion
+    @field      mAveragePower
+        The audio channel's average RMS power.
+    @field      mPeakPower
+        The audio channel's peak RMS power
+}
+type
+	AudioQueueLevelMeterState = record
+		mAveragePower: Float32;
+		mPeakPower: Float32;
+	end;
+	AudioQueueLevelMeterStatePtr = ^AudioQueueLevelMeterState;
+
+{!
+    @typedef    AudioQueueProcessingTapRef
+    @abstract   An object for intercepting and processing audio within an audio queue.
+}
+type
+	AudioQueueProcessingTapRef = ^OpaqueAudioQueueProcessingTap; { an opaque type }
+	OpaqueAudioQueueProcessingTap = record end;
+
+
+//#pragma mark -
+//#pragma mark Callbacks
+//==================================================================================================
+//  CALLBACKS
+//==================================================================================================
+
+
+{!
+    @typedef    AudioQueueOutputCallback
+    @abstract   Defines a pointer to a callback function that is called when a playback audio
+                queue has finished taking data from a buffer.
+
+    @discussion
+        A playback buffer callback is invoked when the audio queue has finished with the data to
+        be played and the buffer is available to your application for reuse. Your application
+        might want to immediately refill and re-enqueue the completed buffer at this time.
+    @param      inUserData
+        The value specified by the inUserData parameter of the AudioQueueNewOutput function.
+    @param      inAQ
+        The audio queue that invoked the callback.
+    @param      inBuffer
+        The audio queue buffer made available by the audio queue.
+}
+type
+	AudioQueueOutputCallback = procedure( inUserData: UnivPtr {__nullable}; inAQ: AudioQueueRef; inBuffer: AudioQueueBufferRef );
+
+{!
+    @typedef    AudioQueueInputCallback
+    @abstract   Defines a pointer to a callback function that is called when a recording audio
+                queue has finished filling a buffer.
+    @discussion
+        You specify a recording buffer callback when calling AudioQueueNewInput. Your callback
+        is invoked each time the recording audio queue has filled a buffer with input data.
+        Typically, your callback should write the audio queue buffer's data to a file or other
+        buffer, and then re-queue the audio queue buffer to receive more data.
+        
+    @param      inUserData
+        The value you've specified in the inUserData parameter of the AudioQueueNewInput
+        function.
+    @param      inAQ
+        The audio queue that invoked the callback.
+    @param      inBuffer
+        An audio queue buffer, newly filled by the audio queue, containing the new audio data
+        your callback needs to write.
+    @param      inStartTime
+        A pointer to an audio time stamp structure corresponding to the first sample contained
+        in the buffer. This contains the sample time of the first sample in the buffer.
+    @param      inNumberPacketDescriptions
+        The number of audio packets contained in the data provided to the callback
+    @param      inPacketDescs
+        For compressed formats which require packet descriptions, the packet descriptions
+        produced by the encoder for the incoming buffer.
+}
+type
+	AudioQueueInputCallback = procedure( inUserData: UnivPtr {__nullable}; inAQ: AudioQueueRef; inBuffer: AudioQueueBufferRef; const (*var*) inStartTime: AudioTimeStamp; inNumberPacketDescriptions: UInt32; {const} inPacketDescs: AudioStreamPacketDescriptionPtr {* __nullable} );
+
+
+{!
+    @typedef    AudioQueuePropertyListenerProc
+    @abstract   Defines a pointer to a callback function that is called when a specified
+                property changes value.
+    @discussion
+        You assign a property listener callback when calling AudioQueueAddPropertyListener.
+        
+    @param      inUserData
+        A pointer to the data specified by the inUserData parameter of the
+        AudioQueueAddPropertyListener function.
+    @param      inAQ
+        The audio queue that invoked the callback.
+    @param      inID
+        The ID of the property that invoked the callback.
+}
+type
+	AudioQueuePropertyListenerProc = procedure( inUserData: UnivPtr {__nullable}; inAQ: AudioQueueRef; inID: AudioQueuePropertyID );
+
+{!
+@typedef    AudioQueueProcessingTapCallback
+@abstract   A function called when an audio queue has data to be processed by its tap
+
+@discussion
+    A processing callback is invoked when the audio queue has data that can be processed by a given
+    tap.
+
+    The audio queue will call the processing callback when it has sufficient data to provide for
+    processing.
+
+    In the case of a siphoning tap, the callback function can inspect the audio data in ioData, but
+    should not otherwise modify it. The callback should not call
+    AudioQueueProcessingTapGetSourceAudio.
+
+    A non-siphoning callback should call AudioQueueProcessingTapGetSourceAudio to request from the
+    queue as much source data as it needs in order to produce the requested number of output
+    samples. When the callback requests source data it may receive less data than it requests.
+
+    In the case of a tap on an audio output queue, the tap must emit the exact number of sample
+    frames that the queue requests. In normal circumstances, the tap's requests for source data will
+    be satisfied (as the client running the audio queue is also providing the queue with the audio
+    source material). If there is insufficient source data available (this is indicated by the
+    outNumberFrames from the GetSource call), then the processing tap should deal as best as it can;
+    it can either return less data than was requested or insert silence, noise, etc. itself. If it
+    returns less data than requested, the hosting audio queue will fill in the remainder with
+    silence.
+
+    In the case of a tap on an audio input queue, the tap may provide back less audio data than is
+    being requested. Typically this will occur because the tap will ask for source data that is not
+    available at this time (the audio input hasn't arrived yet), so the tap should cache the source
+    data that it needs and return as many processed samples as it can. If the processing tap falls
+    behind and is not providing data quickly enough silence will be generated in the data provided
+    to the client (and there is no signal about this either).
+
+    A processing tap executes in a semi-real-time context, so the general limitations for real-time
+    processing apply. Avoid using API's which may block. In particular, it is not safe to call the
+    audio queue on which the tap was installed, with the exceptions of
+    AudioQueueProcessingTapGetSourceAudio and AudioQueueProcessingTapGetQueueTime.
+
+    In normal operation the source data will be continuous from the last time the callback was
+    called and the processed samples should be continuous from the previous samples returned. If
+    there is any discontinuity between the last samples provided for processing the audio queue will
+    set the bit for kAudioQueueProcessing_StartOfStream in the inFlags. After a discontinuity the
+    first sample that the processing tap outputs should correspond to the first sample that was
+    provided in the source samples (so a reset and then consequent process serves to re-anchor a
+    relationship between the processing tap's source and processed samples). In this case the
+    processing tap will typically discard any previous state (for instance, if a processing tap was
+    adding a reverb to a signal, then the discontinuity flag would act the same as AudioUnitReset;
+    any previous source information in the processing tap should be discarded).
+
+    The caller is responsible for absorbing any processing delays. For example, if the processing is
+    to be done by an audio unit that reports a processing latency, then the caller should remove
+    those latency samples from the audio unit's rendering and not return them to the audio queue.
+
+    The processing tap is able to operate on the provided source data in place (that is, it can do
+    "in place processing") and return pointers to that buffer rather than its own. This works in a
+    similar way as AudioUnit render operations.
+
+    When an output audio queue is being stopped asynchronously, the processing tap will see the
+    kAudioQueueProcessingTap_EndOfStream bit set on return from GetSourceAudio, and is responsible
+    for propagating this bit from the callback when its processing has reached this point.
+
+    A processing tap will NEVER see the same source data again, so, it should keep its own copy if
+    it needs to keep it for further reference past the duration of this call. It also cannot assume
+    that the pointers to the source data that it retrieves will remain valid AFTER the processing
+    tap has executed.
+
+    The processing tap should ensure that the data pointers it provides in outProcessedData remain
+    valid until the tap is executed again.
+
+    A processing tap is destroyed implicitly when its audio queue is disposed. It may also be
+    removed explicitly, via AudioQueueProcessingTapDispose.
+
+    @param      inClientData
+                    the client data pointer passed to AudioQueueProcessingTapNew
+    @param      inAQ
+                    The audio queue that invoked the callback.
+    @param      inAQTap
+                    The tap for this callback.
+    @param      inNumberFrames
+                    The requested number of sample frames to be rendered.
+    @param      ioFlags
+                    On entry, the flags passed at construction time are provided. On exit,
+                    the start/end of stream flags should be set when appropriate.
+    @param      ioAudioTimeStamp
+                    On an input audio queue, the timestamp must be returned from this function.
+                    On an output audio queue, the callback is provided a continuous timestamp.
+    @param      outNumberFrames
+                    The number of frames of audio data provided in the processed data. Can be 0.
+    @param      ioData
+                    For non-siphoning taps, on entry, the buffer pointers are null and the lengths
+                    are zero. On exit, they should contain the tap's output.
+                    
+                    Siphoning taps receive valid buffers which they must not alter.
+}
+type
+	AudioQueueProcessingTapCallback = procedure( inClientData: UnivPtr; inAQTap: AudioQueueProcessingTapRef; inNumberFrames: UInt32; var ioTimeStamp: AudioTimeStamp; var ioFlags: AudioQueueProcessingTapFlags; var outNumberFrames: UInt32; var ioData: AudioBufferList );
+
+//==================================================================================================
+//  FUNCTIONS
+//==================================================================================================
+
+//#pragma /mark -
+//#pragma /mark Creating/destroying queues
+//=============================================================================
+//  Creating/destroying queues
+//=============================================================================
+
+{!
+    @function   AudioQueueNewOutput
+    @abstract   Creates a new audio queue for playing audio data.
+    @discussion
+        To create an playback audio queue, you allocate buffers, then queue buffers (using
+        AudioQueueEnqueueBuffer). The callback receives buffers and typically queues them again.
+        To schedule a buffer for playback, providing parameter and start time information, call
+        AudioQueueEnqueueBufferWithParameters.
+       
+    @param      inFormat
+        A pointer to a structure describing the format of the audio data to be played. For
+        linear PCM, only interleaved formats are supported. Compressed formats are supported.
+    @param      inCallbackProc
+        A pointer to a callback function to be called when the audio queue has finished playing
+        a buffer.
+    @param      inUserData
+        A value or pointer to data that you specify to be passed to the callback function.
+    @param      inCallbackRunLoop
+        The event loop on which inCallbackProc is to be called. If you specify NULL, the
+        callback is called on one of the audio queue's internal threads.
+    @param      inCallbackRunLoopMode
+        The run loop mode in which to call the callback. Typically, you pass
+        kCFRunLoopCommonModes. (NULL also specifies kCFRunLoopCommonModes). Other
+        possibilities are implementation specific. You can choose to create your own thread with
+        your own run loops. For more information on run loops, see Run Loops or CFRunLoop
+        Reference.
+    @param      inFlags
+        Reserved for future use. Pass 0.
+    @param      outAQ
+        On return, this variable contains a pointer to the newly created playback audio queue
+        object.
+    @result     An OSStatus result code.
+}
+function AudioQueueNewOutput( const (*var*) inFormat: AudioStreamBasicDescription; inCallbackProc: AudioQueueOutputCallback; inUserData: UnivPtr {__nullable}; inCallbackRunLoop: CFRunLoopRef {__nullable}; inCallbackRunLoopMode: CFStringRef {__nullable}; inFlags: UInt32; var outAQ: AudioQueueRef {__nullable * __nonnull} ): OSStatus; external name '_AudioQueueNewOutput';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+
+{!
+    @function   AudioQueueNewInput
+    @abstract   Creates a new audio queue for recording audio data.
+    @discussion
+        
+        Outline of how to use the queue for input:
+        
+        - create input queue
+        - allocate buffers
+        - enqueue buffers (AudioQueueEnqueueBuffer, not with parameters, no packet descriptions)
+        - the callback receives buffers and re-enqueues them
+        
+    @param      inFormat
+        A pointer to a structure describing the format of the audio data to be recorded. For
+        linear PCM, only interleaved formats are supported. Compressed formats are supported.
+    @param      inCallbackProc
+        A pointer to a callback function to be called when the audio queue has finished filling
+        a buffer.
+    @param      inUserData
+        A value or pointer to data that you specify to be passed to the callback function.
+    @param      inCallbackRunLoop
+        The event loop on which inCallbackProc is to be called. If you specify NULL, the
+        callback is called on one of the audio queue's internal threads.
+    @param      inCallbackRunLoopMode
+        The run loop mode in which to call the callback. Typically, you pass
+        kCFRunLoopCommonModes. (NULL also specifies kCFRunLoopCommonModes). Other
+        possibilities are implementation specific. You can choose to create your own thread with
+        your own run loops. For more information on run loops, see Run Loops or CFRunLoop
+        Reference.
+    @param      inFlags
+        Reserved for future use. Pass 0.
+    @param      outAQ
+        On return, this variable contains a pointer to the newly created recording audio queue
+        object.
+    @result     An OSStatus result code.
+}
+function AudioQueueNewInput( const (*var*) inFormat: AudioStreamBasicDescription; inCallbackProc: AudioQueueInputCallback; inUserData: UnivPtr {__nullable}; inCallbackRunLoop: CFRunLoopRef {__nullable}; inCallbackRunLoopMode: CFStringRef {__nullable}; inFlags: UInt32; var outAQ: AudioQueueRef {__nullable * __nonnull} ): OSStatus; external name '_AudioQueueNewInput';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+
+{!
+    @function   AudioQueueDispose
+    @abstract   Disposes an existing audio queue.
+    @discussion
+        Disposing of the audio queue also disposes of all its resources, including its buffers.
+    @param      inAQ
+        The audio queue you want to dispose of
+    @param      inImmediate
+        If you pass true, the audio queue is disposed of immediately (that is, synchronously).
+        If you pass false, disposal does not take place until all enqueued buffers are
+        processed. Whether you call AudioQueueDispose synchronously or asynchronously, you can
+        no longer interact with the queue, and the queue no longer invokes any callbacks to your
+        application after the function returns.
+		
+		Note that if AudioQueueDispose is called from a buffer completion callback or property
+		listener, you may receive further callbacks afterwards.
+    @result     An OSStatus result code.
+}
+function AudioQueueDispose( inAQ: AudioQueueRef; inImmediate: Boolean ): OSStatus; external name '_AudioQueueDispose';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+//#pragma /mark -
+//#pragma /mark Buffer Management
+//=============================================================================
+//  Buffer Management
+//=============================================================================
+
+{!
+    @function   AudioQueueAllocateBuffer
+    @abstract   Asks an audio queue to allocate a buffer.
+    @discussion
+        Once allocated, the pointer to the buffer and the buffer's size are fixed and cannot be
+        changed. The mAudioDataByteSize field in the audio queue buffer structure,
+        AudioQueueBuffer, is initially set to 0.
+        
+    @param      inAQ
+        The audio queue you want to allocate a buffer.
+    @param      inBufferByteSize
+        The desired size of the new buffer, in bytes. An appropriate buffer size depends on the
+        processing you will perform on the data as well as on the audio data format.
+    @param      outBuffer
+        On return, points to the newly created audio buffer. The mAudioDataByteSize field in the
+        audio queue buffer structure, AudioQueueBuffer, is initially set to 0.
+    @result     An OSStatus result code.
+}
+function AudioQueueAllocateBuffer( inAQ: AudioQueueRef; inBufferByteSize: UInt32; var outBuffer: AudioQueueBufferRef {__nullable * __nonnull} ): OSStatus; external name '_AudioQueueAllocateBuffer';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueAllocateBufferWithPacketDescriptions
+    @abstract   Asks an audio queue to allocate a buffer with space for packet descriptions.
+    @discussion
+        Once allocated, the pointer to the buffer and the buffer's size are fixed and cannot be
+        changed. The mAudioDataByteSize field in the audio queue buffer structure,
+        AudioQueueBuffer, is initially set to 0.
+        
+    @param      inAQ
+        The audio queue you want to allocate a buffer.
+    @param      inBufferByteSize
+        The desired size of the new buffer, in bytes. An appropriate buffer size depends on the
+        processing you will perform on the data as well as on the audio data format.
+    @param      inNumberPacketDescriptions
+        The desired capacity of the packet description array in the new buffer.
+    @param      outBuffer
+        On return, points to the newly created audio buffer. The mAudioDataByteSize field in the
+        audio queue buffer structure, AudioQueueBuffer, is initially set to 0.
+    @result     An OSStatus result code.
+}
+function AudioQueueAllocateBufferWithPacketDescriptions( inAQ: AudioQueueRef; inBufferByteSize: UInt32; inNumberPacketDescriptions: UInt32; var outBuffer: AudioQueueBufferRef {__nullable * __nonnull} ): OSStatus; external name '_AudioQueueAllocateBufferWithPacketDescriptions';
+(* API_AVAILABLE(macos(10.6), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueFreeBuffer
+    @abstract   Disposes of an audio queue buffer.
+    @discussion
+        This function disposes of the buffer allocated by AudioQueueAllocateBuffer. Disposing of
+        an audio queue also automatically disposes of any associated buffers and timeline
+        objects. Call this function only if you want to dispose of a particular buffer while
+        continuing to use an audio queue. You can dispose of buffers only when the associated
+        queue is stopped (that is, not processing audio data).
+    @param      inAQ
+        The queue from which the buffer was allocated.
+    @param      inBuffer
+        The buffer to be disposed.
+    @result     An OSStatus result code.
+}
+function AudioQueueFreeBuffer( inAQ: AudioQueueRef; inBuffer: AudioQueueBufferRef ): OSStatus; external name '_AudioQueueFreeBuffer';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+
+{!
+    @function   AudioQueueEnqueueBuffer
+    @abstract   Assigns a buffer to an audio queue for recording or playback.
+    @discussion
+        If the buffer was allocated with AudioQueueAllocateBufferWithPacketDescriptions,
+        the client should provide packet descriptions in the buffer's mPacketDescriptions
+        and mPacketDescriptionCount fields rather than in inPacketDescs and
+        inNumPacketDescs, which should be NULL and 0, respectively, in this case.
+        
+        For an input queue, pass 0 and NULL for inNumPacketDescs and inPacketDescs,
+        respectively. Your callback will receive packet descriptions owned by the audio queue.
+
+    @param      inAQ
+        The audio queue you are assigning the buffer to.
+    @param      inBuffer
+        The buffer to queue (that is, to be recorded into or played from).
+    @param      inNumPacketDescs
+        The number of packet descriptions pointed to by the inPacketDescs pointer. Applicable
+        only for output queues and required only for variable-bit-rate (VBR) audio formats. Pass
+        0 for input queues (no packet descriptions are required).
+    @param      inPacketDescs
+        An array of packet descriptions. Applicable only for output queues and required only for
+        variable-bit-rate (VBR) audio formats. Pass NULL for input queues (no packet
+        descriptions are required).
+    @result     An OSStatus result code.
+}
+function AudioQueueEnqueueBuffer( inAQ: AudioQueueRef; inBuffer: AudioQueueBufferRef; inNumPacketDescs: UInt32; {const} inPacketDescs: AudioStreamPacketDescriptionPtr {* __nullable} ): OSStatus; external name '_AudioQueueEnqueueBuffer';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueEnqueueBufferWithParameters
+    @abstract   Assigns a buffer to an audio queue for playback, providing parameters
+                and start time information.
+    @discussion
+        You can exert some control of the buffer queue by using this function. You can assign
+        audio queue settings that are in effect carried by an audio queue buffer as you enqueue
+        it. Hence, these changes only take effect when an audio queue buffer begins playing.
+        
+        This function queues a buffer for playback only, not for recording. Audio queues for
+        recording have no parameters, do not support variable-bit-rate (VBR) formats (which
+        might require trimming), and have a different way to handle timing. When queued for
+        playback, the buffer must contain the audio data to be played back. See
+        AudioQueueEnqueueBuffer for details on queuing a buffer for recording.
+
+        If the buffer was allocated with AudioQueueAllocateBufferWithPacketDescriptions,
+        the client should provide packet descriptions in the buffer's mPacketDescriptions
+        and mPacketDescriptionCount fields rather than in inPacketDescs and
+        inNumPacketDescs, which should be NULL and 0, respectively, in this case.
+    @param      inAQ
+        The audio queue associated with the buffer.
+    @param      inBuffer
+        The buffer to be played from.
+    @param      inNumPacketDescs
+        The number of packet descriptions pointed to by the inPacketDescs parameter. Required
+        only for variable-bit-rate (VBR) audio formats. Pass 0 if no packet descriptions are
+        required.
+    @param      inPacketDescs
+        A pointer to an array of audio stream packet descriptions. Required only for VBR audio
+        formats. Pass NULL if no packet descriptions are required.
+    @param      inTrimFramesAtStart
+        The number of priming frames to skip at the start of the buffer.
+    @param      inTrimFramesAtEnd
+        The number of frames to skip at the end of the buffer.
+    @param      inNumParamValues
+        The number of parameter values pointed to by the inParamValues parameter.
+    @param      inParamValues
+        An array of parameter values. (In Mac OS X v10.5, there is only one parameter,
+        kAudioQueueParam_Volume.) These values are set before buffer playback and cannot be
+        changed while the buffer is playing. How accurately changes in parameters can be
+        scheduled depends on the size of the buffer. If there are no parameters to set
+        (inNumParamValues = 0), pass NULL.
+    @param      inStartTime
+        A pointer to a structure containing the desired start time for playing the buffer. If
+        you specify the time using the mSampleTime field of the AudioTimeStamp structure, the
+        sample time is relative to the time the queue started. If you pass NULL for the start
+        time, the buffer starts immediately after the previously queued buffer, or as soon as
+        possible if no buffers are queued ahead of it. Buffers are played in the order they are
+        queued. If multiple buffers are queued, their times must be in ascending order or NULL;
+        otherwise, an error occurs. The start time indicates when the actual audio data in the
+        buffer is to be played (that is, the trim frames are not counted).
+        
+        Note: When specifying a start time for a buffer, if the buffer is not the first enqueued
+        since AudioQueueStop or AudioQueueReset, it is normally necessary to call AudioQueueFlush
+        before AudioQueueEnqueueBufferWithParameters.
+    @param      outActualStartTime
+        On return, points to an AudioTimeStamp structure indicating when the buffer will
+        actually play.
+    @result     An OSStatus result code.
+}
+function AudioQueueEnqueueBufferWithParameters( inAQ: AudioQueueRef; inBuffer: AudioQueueBufferRef; inNumPacketDescs: UInt32; {const} inPacketDescs: AudioStreamPacketDescriptionPtr {* __nullable}; inTrimFramesAtStart: UInt32; inTrimFramesAtEnd: UInt32; inNumParamValues: UInt32; {const} inParamValues: AudioQueueParameterEventPtr {* __nullable}; {const} inStartTime: AudioTimeStampPtr {* __nullable}; outActualStartTime: AudioTimeStampPtr {* __nullable} ): OSStatus; external name '_AudioQueueEnqueueBufferWithParameters';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+//#pragma /mark -
+//#pragma /mark Queue Control
+//=============================================================================
+//  Queue Control
+//=============================================================================
+
+{!
+    @function   AudioQueueStart
+    @abstract   Begins playing or recording audio.
+    @discussion
+        If the audio hardware is not already running, this function starts it.
+    @param      inAQ
+        The audio queue to start.
+    @param      inStartTime
+        A pointer to the time at which the audio queue should start. If you specify the time
+        using the mSampleTime field of the AudioTimeStamp structure, the sample time is
+        referenced to the sample frame timeline of the associated audio device. May be NULL.
+    @result     An OSStatus result code.
+}
+function AudioQueueStart( inAQ: AudioQueueRef; {const} inStartTime: AudioTimeStampPtr {* __nullable} ): OSStatus; external name '_AudioQueueStart';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueuePrime
+    @abstract   Begins decoding buffers in preparation for playback.
+    @discussion
+        This function begins decoding buffers in preparation for playback. It returns when at
+        least the number of audio sample frames are decoded and ready to play or when all
+        enqueued buffers have been completely decoded. To ensure that a buffer has been decoded
+        and is completely ready for playback, before playback:
+            1.  Call AudioQueueEnqueueBuffer.
+            2.  Call AudioQueuePrime, which waits if you pass 0 to have a default number of
+                frames decoded.
+            3.  Call AudioQueueStart.
+
+        Calls to AudioQueuePrime following AudioQueueStart/AudioQueuePrime, and before
+        AudioQueueReset/AudioQueueStop, will have no useful effect. In this situation,
+        outNumberOfFramesPrepared will not have a useful return value.
+    @param      inAQ
+        The audio queue to be primed.
+    @param      inNumberOfFramesToPrepare
+        The number of frames to decode before returning. Pass 0 to decode all enqueued buffers.
+    @param      outNumberOfFramesPrepared
+        If not NULL, on return, a pointer to the number of frames actually decoded and prepared
+        for playback.
+    @result     An OSStatus result code.
+}
+function AudioQueuePrime( inAQ: AudioQueueRef; inNumberOfFramesToPrepare: UInt32; outNumberOfFramesPrepared: UInt32Ptr {* __nullable} ): OSStatus; external name '_AudioQueuePrime';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueStop
+    @abstract   Stops playing or recording audio.
+    @discussion
+        This function resets the audio queue and stops the audio hardware associated with the
+        queue if it is not in use by other audio services. Synchronous stops occur immediately,
+        regardless of previously buffered audio data. Asynchronous stops occur after all queued
+        buffers have been played or recorded.
+    @param      inAQ
+        The audio queue to stop.
+    @param      inImmediate
+        If you pass true, the stop request occurs immediately (that is, synchronously), and the
+        function returns when the audio queue has stopped. Buffer callbacks are invoked during
+        the stopping. If you pass false, the function returns immediately, but the queue does
+        not stop until all its queued buffers are played or filled (that is, the stop occurs
+        asynchronously). Buffer callbacks are invoked as necessary until the queue actually
+        stops. Also, a playback audio queue callback calls this function when there is no more
+        audio to play.
+
+        Note that when stopping immediately, all pending buffer callbacks are normally invoked
+        during the process of stopping. But if the calling thread is responding to a buffer
+        callback, then it is possible for additional buffer callbacks to occur after
+        AudioQueueStop returns.
+    @result     An OSStatus result code.
+}
+function AudioQueueStop( inAQ: AudioQueueRef; inImmediate: Boolean ): OSStatus; external name '_AudioQueueStop';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueuePause
+    @abstract   Pauses audio playback or recording.
+    @discussion
+        Pausing the queue does not affect buffers or reset the audio queue. To resume playback
+        or recording using the audio queue, call AudioQueueStart.
+    @param      inAQ
+        The queue to be paused.
+    @result     An OSStatus result code.
+}
+function AudioQueuePause( inAQ: AudioQueueRef ): OSStatus; external name '_AudioQueuePause';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueFlush
+    @abstract   Resets the audio queue's decoder state.
+    @discussion
+        After all queued buffers have been played, the function cleans up all decoder state
+        information. You must call this function following a sequence of buffers of encoded
+        audio; otherwise, some of the audio might not play in the next set of queued buffers.
+        The only time it is not necessary to call AudioQueueFlush is following AudioQueueStop
+        with inImmediate=false. (This action internally calls AudioQueueFlush.)
+        
+        Also, you might wish to call this function before calling AudioQueueStop depending on
+        whether you want to stop immediately regardless of what has played or whether you want
+        to ensure that all buffered data and all data that is in the middle of processing gets
+        recorded or played before stopping.
+        
+    @param      inAQ
+        The audio queue to be flushed.
+        
+    @result     An OSStatus result code.
+}
+function AudioQueueFlush( inAQ: AudioQueueRef ): OSStatus; external name '_AudioQueueFlush';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueReset
+    @abstract   Resets an audio queue.
+    @discussion
+        This function immediately resets an audio queue, flushes any queued buffer, removes all
+        buffers from previously scheduled use, and resets any decoder and digital signal
+        processing (DSP) state information. It also invokes callbacks for any flushed buffers.
+        If you queue any buffers after calling this function, processing does not occur until
+        the decoder and DSP state information is reset. Hence, a discontinuity (that is, a
+        "glitch") might occur.
+
+        Note that when resetting, all pending buffer callbacks are normally invoked
+        during the process of resetting. But if the calling thread is responding to a buffer
+        callback, then it is possible for additional buffer callbacks to occur after
+        AudioQueueReset returns.
+    @param      inAQ
+        The audio queue to reset.
+
+    @result     An OSStatus result code.
+}
+function AudioQueueReset( inAQ: AudioQueueRef ): OSStatus; external name '_AudioQueueReset';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+//#pragma /mark -
+//#pragma /mark Parameter Management
+//=============================================================================
+//  Parameter Management
+//=============================================================================
+
+{!
+    @function   AudioQueueGetParameter
+    @abstract   Obtains an audio queue parameter value.
+    @discussion
+        You can access the current parameter values for an audio queue at any time with this
+        function.
+    @param      inAQ
+        The audio queue whose parameter value you want to obtain.
+    @param      inParamID
+        The ID of the parameter you want to obtain. In Mac OS X v10.5, audio queues have one
+        parameter available: kAudioQueueParam_Volume, which controls the queue's playback
+        volume.
+    @param      outValue
+        On return, points to the current value of the specified parameter.
+    @result
+        An OSStatus result code.
+}
+function AudioQueueGetParameter( inAQ: AudioQueueRef; inParamID: AudioQueueParameterID; var outValue: AudioQueueParameterValue ): OSStatus; external name '_AudioQueueGetParameter';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueSetParameter
+    @abstract   Sets an audio queue parameter value.
+    @discussion
+    @param      inAQ
+        The audio queue whose parameter value you want to set.
+    @param      inParamID
+        The ID of the parameter you want to set.
+    @param      inValue
+        The parameter value to set.
+    @result
+        An OSStatus result code.
+}
+function AudioQueueSetParameter( inAQ: AudioQueueRef; inParamID: AudioQueueParameterID; inValue: AudioQueueParameterValue ): OSStatus; external name '_AudioQueueSetParameter';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+                                                                        
+//#pragma /mark -
+//#pragma /mark Property Management
+//=============================================================================
+//  Property Management
+//=============================================================================
+
+{!
+    @function   AudioQueueGetProperty
+    @abstract   Obtains an audio queue property value.
+    @discussion 
+    @param      inAQ
+        The audio queue whose property value you want to obtain.
+    @param      inID
+        The ID of the property you want to obtain. See "Audio Queue Property IDs."
+    @param      outData
+        On return, points to the desired property value.
+    @param      ioDataSize
+        A pointer to the size of the property data. On input, points to the maximum bytes of
+        space the caller expects to receive. On return, points to the actual data size.
+    @result
+        An OSStatus result code.
+}
+function AudioQueueGetProperty( inAQ: AudioQueueRef; inID: AudioQueuePropertyID; outData: UnivPtr; var ioDataSize: UInt32 ): OSStatus; external name '_AudioQueueGetProperty';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueSetProperty
+    @abstract   Sets an audio queue property value.
+    @discussion 
+    @param      inAQ
+        The audio queue whose property value you want to set.
+    @param      inID
+        The ID of the property you want to set. See "Audio Queue Property IDs" for the various
+        audio queue properties.
+    @param      inData
+        A pointer to the property value to set.
+    @param      inDataSize
+        The size of the property data.
+    @result
+        An OSStatus result code.
+}
+function AudioQueueSetProperty( inAQ: AudioQueueRef; inID: AudioQueuePropertyID; inData: {const} UnivPtr; inDataSize: UInt32 ): OSStatus; external name '_AudioQueueSetProperty';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+
+{!
+    @function   AudioQueueGetPropertySize
+    @abstract   Obtains the size of an audio queue property.
+    @discussion 
+    @param      inAQ
+        The audio queue containing the property value whose size you want to obtain.
+    @param      inID
+        The ID of the property value whose size you want to obtain. See "Audio Queue Property
+        IDs" for possible values.
+    @param      outDataSize
+        On return, points to the size of the specified property value.
+    @result
+        An OSStatus result code.
+}
+function AudioQueueGetPropertySize( inAQ: AudioQueueRef; inID: AudioQueuePropertyID; var outDataSize: UInt32 ): OSStatus; external name '_AudioQueueGetPropertySize';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueAddPropertyListener
+    @abstract   Adds a listener callback for a property.
+    @discussion 
+        This callback is used to act upon a change in an audio queue property such as
+        kAudioQueueProperty_IsRunning. For instance, if your application has a user interface
+        with a Play/Stop button, and kAudioQueueProperty_IsRunning changes, you need to update
+        your button.
+    @param      inAQ
+        The audio queue that owns the property you want to assign the listener callback to.
+    @param      inID
+        The ID of the property to which you want to assign a listener callback. See "Audio Queue Property IDs".
+    @param      inProc
+        The listener callback to be called when the property value changes.
+    @param      inUserData
+        A value to be passed to the listener callback when it is called.
+    @result
+        An OSStatus result code.
+}
+function AudioQueueAddPropertyListener( inAQ: AudioQueueRef; inID: AudioQueuePropertyID; inProc: AudioQueuePropertyListenerProc; inUserData: UnivPtr {__nullable} ): OSStatus; external name '_AudioQueueAddPropertyListener';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueRemovePropertyListener
+    @abstract   Removes a listener callback for a property.
+    @discussion 
+    @param      inAQ
+        The audio queue that owns the property from which you want to remove a listener.
+    @param      inID
+        The ID of the property from which you want to remove a listener.
+    @param      inProc
+        The listener being removed.
+    @param      inUserData
+        The same inUserData value that was previously passed to AudioQueueAddPropertyListener.
+    @result
+        An OSStatus result code.
+}
+function AudioQueueRemovePropertyListener( inAQ: AudioQueueRef; inID: AudioQueuePropertyID; inProc: AudioQueuePropertyListenerProc; inUserData: UnivPtr {__nullable} ): OSStatus; external name '_AudioQueueRemovePropertyListener';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+                                    
+
+//#pragma /mark -
+//#pragma /mark Handling Timing
+//=============================================================================
+//  Handling Timing
+//=============================================================================
+
+{!
+    @function   AudioQueueCreateTimeline
+    @abstract   Creates a timeline object.
+    @discussion
+        You need to instantiate a timeline object if you want to know about any timeline
+        discontinuities. See AudioQueueGetCurrentTime for more details.
+    @param      inAQ
+        The audio queue to associate with the new timeline object.
+    @param      outTimeline
+        On return, points to the newly created timeline object.
+    @result
+        An OSStatus result code.
+}
+function AudioQueueCreateTimeline( inAQ: AudioQueueRef; var outTimeline: AudioQueueTimelineRef {__nullable * __nonnull} ): OSStatus; external name '_AudioQueueCreateTimeline';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueDisposeTimeline
+    @abstract   Disposes of a timeline object.
+    @discussion
+        Disposing of an audio queue automatically disposes of any associated timeline objects.
+        Call this function only if you want to dispose of a timeline object and not the audio
+        queue associated with it.
+    @param      inAQ
+        The audio queue associated with the timeline object you want to dispose of.
+    @param      inTimeline
+        The timeline object to dispose of.
+    @result
+        An OSStatus result code.
+}
+function AudioQueueDisposeTimeline( inAQ: AudioQueueRef; inTimeline: AudioQueueTimelineRef ): OSStatus; external name '_AudioQueueDisposeTimeline';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueGetCurrentTime
+    @abstract   Obtains the current audio queue time.
+    @discussion
+        You must specify a timeline object if you want to be notified about any timeline
+        discontinuities in the outTimelineDiscontinuity parameter. If you don't care about
+        discontinuities, pass NULL in the inTimeLine and outTimelineDiscontinuity parameters.
+    @param      inAQ
+        The audio queue whose current time you want to obtain.
+    @param      inTimeline
+        The audio queue timeline object to which any timeline discontinuities are reported. May
+        be NULL.
+    @param      outTimeStamp
+        On return, points to an audio timestamp structure containing the current audio queue
+        time. The mSampleTime field is in terms of the audio queue's sample rate, and relative
+        to the time at which the queue has started or will start.
+    @param      outTimelineDiscontinuity
+        Can be NULL. On return, only set to true or false if the inTimeLine parameter is not
+        NULL. Set to true if a discontinuity has occurred in the sample timeline of the audio
+        queue. For instance, the device's sample rate changed and a gap occurred in playback or
+        recording, or the audio queue was unable to prepare and playback in time because it was
+        late.
+    @result
+        An OSStatus result code.
+}
+function AudioQueueGetCurrentTime( inAQ: AudioQueueRef; inTimeline: AudioQueueTimelineRefPtr {__nullable}; outTimeStamp: AudioTimeStampPtr {* __nullable}; outTimelineDiscontinuity: BooleanPtr {* __nullable} ): OSStatus; external name '_AudioQueueGetCurrentTime';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueDeviceGetCurrentTime
+    @abstract   Obtains the current time of the audio device associated with an audio queue.
+    @discussion
+        If the audio device associated with the audio queue is not running, the only valid field
+        in the audio timestamp structure is mHostTime. This result differentiates the action of
+        this function from that of the AudioDeviceGetCurrentTime function, (declared in
+        AudioHardware.h) which returns an error if the audio device is not running.
+    @param      inAQ
+        The audio queue whose audio device is to be queried.
+    @param      outTimeStamp
+        A pointer to a structure that, on return, contains the current time of the audio device
+        associated with the audio queue.
+    @result
+        An OSStatus result code.
+}
+function AudioQueueDeviceGetCurrentTime( inAQ: AudioQueueRef; var outTimeStamp: AudioTimeStamp ): OSStatus; external name '_AudioQueueDeviceGetCurrentTime';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueDeviceTranslateTime
+    @abstract   Converts the time in the time base of the associated audio device from one
+                representation to another.
+    @discussion
+        This function converts from one time representation to another (for example, from sample
+        time to host time or vice versa):
+        
+        <ul>
+        <li>    Sample time is the absolute sample frame time.
+        Sample numbers are the count of the samples on the audio device.</li>
+        <li>    Host time is the
+        time base of the host machine such as the time of the bus clock on the CPU.</li>
+        </ul>
+
+        The mSampleTime field in the AudioTimestamp structure (described in Core Audio Data
+        Types Reference) is always in device time, not in audio queue time. Audio queue time is
+        relative to the audio queue's start time. The associated audio device has to be running
+        for the AudioQueueDeviceTranslateTime function to provide a result.
+    @param      inAQ
+        The queue whose audio device is to perform the requested time translation.
+    @param      inTime
+        A pointer to a structure containing the time to be translated.
+    @param      outTime
+        A pointer to the the translated time.
+    @result
+        An OSStatus result code.
+}
+function AudioQueueDeviceTranslateTime( inAQ: AudioQueueRef; const (*var*) inTime: AudioTimeStamp; var outTime: AudioTimeStamp ): OSStatus; external name '_AudioQueueDeviceTranslateTime';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueDeviceGetNearestStartTime
+    @abstract   Obtains an audio device's start time that is closest to a requested start time.
+    @discussion
+    @param      inAQ
+        The audio queue whose device's nearest start time you want to obtain.
+    @param      ioRequestedStartTime
+        On entry, points to the requested start time. On return, points to the actual start time.
+    @param      inFlags
+        Reserved for future use. Pass 0.
+    @result
+        An OSStatus result code.
+}
+function AudioQueueDeviceGetNearestStartTime( inAQ: AudioQueueRef; var ioRequestedStartTime: AudioTimeStamp; inFlags: UInt32 ): OSStatus; external name '_AudioQueueDeviceGetNearestStartTime';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+//#pragma /mark -
+//#pragma /mark Offline Rendering
+//=============================================================================
+//  Offline Rendering
+//=============================================================================
+
+{!
+    @function   AudioQueueSetOfflineRenderFormat
+    @abstract   Specify an audio format to which the queue will perform subsequent offline rendering,
+                or disable offline rendering.
+    @discussion
+                An output queue's audio playback can be redirected for capture to an audio file,
+                to support an export function, for example. AudioQueueSetOfflineRenderFormat switches
+                a queue between normal and offline rendering modes.
+    @param      inAQ
+        The output queue whose offline rendering mode is to be changed.
+    @param      inFormat
+        The desired format for offline rendering. Pass NULL to disable offline rendering and return the
+        queue to normal output to an audio device. This format must be linear PCM and (if not mono)
+        interleaved.
+    @param      inLayout
+        The desired channel layout for offline rendering; also NULL when disabling offline rendering.
+    @result
+        An OSStatus result code.
+}
+function AudioQueueSetOfflineRenderFormat( inAQ: AudioQueueRef; {const} inFormat: AudioStreamBasicDescriptionPtr {* __nullable}; {const} inLayout: AudioChannelLayout {* __nullable} ): OSStatus; external name '_AudioQueueSetOfflineRenderFormat';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueOfflineRender
+    @abstract   Obtain a buffer of audio output from a queue in offline rendering mode.
+    @discussion
+    @param      inAQ
+        The output queue from which to obtain output.
+    @param      inTimestamp
+        The point in time corresponding to the beginning of the output buffer. Only mSampleTime
+        is used. mFlags must include kAudioTimeStampSampleTimeValid.
+    @param      ioBuffer
+        The buffer into which the queue will render.
+    @param      inNumberFrames
+        The number of frames of audio to render. Note that fewer frames than requested may be returned.
+        This can happen if insufficient data was enqueued.
+    @result
+        An OSStatus result code.
+}
+function AudioQueueOfflineRender( inAQ: AudioQueueRef; const (*var*) inTimestamp: AudioTimeStamp; ioBuffer: AudioQueueBufferRef; inNumberFrames: UInt32 ): OSStatus; external name '_AudioQueueOfflineRender';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+//#pragma /mark -
+//#pragma /mark Processing Taps
+//=============================================================================
+//  Processing Taps
+//=============================================================================
+
+
+{!
+    @function   AudioQueueProcessingTapNew
+    @abstract   Create a new processing tap
+    @discussion
+                This function creates a processing tap on a given audio queue. A
+                processing tap can only be established (or removed) on an audio queue that is
+                stopped (paused is not sufficient). The processing tap will then be used to
+                process either decoded data in the case of an output queue, or input data
+                (before it is encoded) in the case of an input queue.
+
+                The processing is performed on audio either before or after any effects or other
+                processing (varispeed, etc) is applied by the audio queue, depending on inFlags.
+    
+    @param      inAQ    
+                    The audio queue from which to create the processing tap
+    @param      inCallback
+                    A callback which the queue will call to process the audio
+    @param      inClientData
+                    Client data provided to the callback
+    @param      inFlags
+                    Flags that are used to control aspects of the processing tap.
+                    Valid flags are:
+                        - kAudioQueueProcessingTap_PreEffects: processing is done before any
+                            further effects are applied by the audio queue to the audio
+                        - kAudioQueueProcessingTap_PostEffects: processing is done after all
+                            processing is done, including that of other taps.
+                        - kAudioQueueProcessingTap_Siphon
+    @param      outMaxFrames
+                    The maximum number of sample frames that can be requested of a processing
+                    tap at any one time. Typically this will be approximately 50 msec of audio
+                    (2048 samples @ 44.1kHz)
+    @param      outProcessingFormat
+                    The format in which the client will receive the audio data to be processed.
+                    This will always be the same sample rate as the client format and usually
+                    the same number of channels as the client format of the audio queue. (NOTE:
+                    the number of channels may be different in some cases if the client format
+                    has some channel count restrictions, for instance the client provides 5.1
+                    AAC, but the decoder can only produce stereo). The channel order, if the
+                    same as the client format, will be the same as the client channel order. If
+                    the channel count is changed, it will be to either 1 (mono) or 2 (stereo, in
+                    which case the first channel is left, the second right).
+
+                    If the data is not in a convenient format for the client to process in, then
+                    the client should convert the data to and from that format. This is the most
+                    efficient mechanism to use (as the audio queue can chose a format that is
+                    most efficient from its playback (or recording) requirement.
+    @param      outAQTap
+                    The processing tap object.
+                    
+    @result     An OSStatus result code.
+}
+function AudioQueueProcessingTapNew( inAQ: AudioQueueRef; inCallback: AudioQueueProcessingTapCallback; inClientData: UnivPtr {__nullable}; inFlags: AudioQueueProcessingTapFlags; var outMaxFrames: UInt32; var outProcessingFormat: AudioStreamBasicDescription; var outAQTap: AudioQueueProcessingTapRef {__nullable * __nonnull} ): OSStatus; external name '_AudioQueueProcessingTapNew';
+(* API_AVAILABLE(macos(10.7), ios(6.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueProcessingTapDispose
+    @abstract   Dispose a processing tap object
+    @discussion 
+                As with AudioQueueProcessingTapNew, this call can only be made on an
+                audio queue that is stopped (paused is not sufficient)
+    
+    @param      inAQTap
+                    The processing tap to dispose.
+
+   @result     An OSStatus result code.
+}
+function AudioQueueProcessingTapDispose( inAQTap: AudioQueueProcessingTapRef ): OSStatus; external name '_AudioQueueProcessingTapDispose';
+(* API_AVAILABLE(macos(10.7), ios(6.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueProcessingTapGetSourceAudio
+    @abstract   Used by a processing tap to retrieve source audio.
+    @discussion 
+        This function may only be called from the processing tap's callback.
+    
+    @param      inAQTap
+                    the processing tap
+    @param      inNumberFrames
+                    the number of frames the processing tap requires for its processing
+    @param      ioTimeStamp
+                    On an input audio queue, the timestamp is returned from this function.
+                    On an output audio queue, the caller must provide a continuous timestamp.
+    @param      outFlags
+                    flags to describe state about the input requested, e.g.
+                    discontinuity/complete
+    @param      outNumberFrames
+                    the number of source frames that have been provided by the parent audio
+                    queue. This can be less than the number of requested frames specified in
+                    inNumberFrames
+    @param      ioData
+                    the audio buffer list which will contain the source data. The audio queue owns
+                    the buffer pointers if NULL pointers were provided (recommended). In this case
+                    the source buffers are only valid for the duration of the processing tap
+                    callback. If the buffer pointers are non-NULL, then they must be big enough to
+                    hold inNumberFrames, and the audio queue will copy its source data into those
+                    buffers.
+                    
+   @result     An OSStatus result code.
+}
+function AudioQueueProcessingTapGetSourceAudio( inAQTap: AudioQueueProcessingTapRef; inNumberFrames: UInt32; var ioTimeStamp: AudioTimeStamp; var outFlags: AudioQueueProcessingTapFlags; var outNumberFrames: UInt32; var ioData: AudioBufferList ): OSStatus; external name '_AudioQueueProcessingTapGetSourceAudio';
+(* API_AVAILABLE(macos(10.7), ios(6.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AudioQueueProcessingTapGetQueueTime
+    @abstract   Used by a processing tap to retrieve the queue's current time.
+    @discussion 
+        This function may only be called from the processing tap's callback, and only
+        for audio output queues. It must be called after calling
+        AudioQueueProcessingTapGetSourceAudio.
+    
+    @param      inAQTap
+                    the processing tap
+    @param      outQueueSampleTime
+                    the current sample time of the audio queue. This will appear to be stationary
+                    if the queue is paused.
+    @param      outQueueFrameCount
+                    the number of sample frames of queue time corresponding to the current chunk of
+                    audio being processed by the tap. This will differ from the frame count passed
+                    to the tap if the queue's playback rate is currently other than 1.0, due to the
+                    use of time compression/expansion. The frame count can also be 0 if the queue is
+                    paused.
+                    
+   @result     An OSStatus result code.
+}
+function AudioQueueProcessingTapGetQueueTime( inAQTap: AudioQueueProcessingTapRef; var outQueueSampleTime: Float64; var outQueueFrameCount: UInt32 ): OSStatus; external name '_AudioQueueProcessingTapGetQueueTime';
+(* API_AVAILABLE(macos(10.8), ios(6.0), watchos(2.0), tvos(9.0)) *)
+
+
+//CF_ASSUME_NONNULL_END
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+
+end.
+{$endc} {not MACOSALLINCLUDE}

+ 527 - 0
packages/univint/src/AudioServices.pas

@@ -0,0 +1,527 @@
+{!
+	@file		AudioServices.h
+	@framework	AudioToolbox.framework
+	@copyright	(c) 2006-2015 by Apple, Inc., all rights reserved.
+    @abstract   API's for general high level audio services.
+
+    @discussion
+
+    AudioServices provides a means to play audio for things such as UI sound effects.
+}
+{  Pascal Translation: Jonas Maebe <[email protected]>, July 2019 }
+{
+    Modified for use with Free Pascal
+    Version 308
+    Please report any bugs to <[email protected]>
+}
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+{$mode macpas}
+{$modeswitch cblocks}
+{$packenum 1}
+{$macro on}
+{$inline on}
+{$calling mwpascal}
+
+unit AudioServices;
+interface
+{$setc UNIVERSAL_INTERFACES_VERSION := $0400}
+{$setc GAP_INTERFACES_VERSION := $0308}
+
+{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
+    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
+{$endc}
+
+{$ifc defined CPUPOWERPC and defined CPUI386}
+	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
+{$endc}
+{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
+	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
+{$endc}
+
+{$ifc not defined __ppc__ and defined CPUPOWERPC32}
+	{$setc __ppc__ := 1}
+{$elsec}
+	{$setc __ppc__ := 0}
+{$endc}
+{$ifc not defined __ppc64__ and defined CPUPOWERPC64}
+	{$setc __ppc64__ := 1}
+{$elsec}
+	{$setc __ppc64__ := 0}
+{$endc}
+{$ifc not defined __i386__ and defined CPUI386}
+	{$setc __i386__ := 1}
+{$elsec}
+	{$setc __i386__ := 0}
+{$endc}
+{$ifc not defined __x86_64__ and defined CPUX86_64}
+	{$setc __x86_64__ := 1}
+{$elsec}
+	{$setc __x86_64__ := 0}
+{$endc}
+{$ifc not defined __arm__ and defined CPUARM}
+	{$setc __arm__ := 1}
+{$elsec}
+	{$setc __arm__ := 0}
+{$endc}
+{$ifc not defined __arm64__ and defined CPUAARCH64}
+  {$setc __arm64__ := 1}
+{$elsec}
+  {$setc __arm64__ := 0}
+{$endc}
+
+{$ifc defined cpu64}
+  {$setc __LP64__ := 1}
+{$elsec}
+  {$setc __LP64__ := 0}
+{$endc}
+
+
+{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
+	{$error Conflicting definitions for __ppc__ and __i386__}
+{$endc}
+
+{$ifc defined __ppc__ and __ppc__}
+	{$setc TARGET_CPU_PPC := TRUE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __ppc64__ and __ppc64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := TRUE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __i386__ and __i386__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := TRUE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __x86_64__ and __x86_64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := TRUE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __arm__ and __arm__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := TRUE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := TRUE}
+{$elifc defined __arm64__ and __arm64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := TRUE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := TRUE}
+{$elsec}
+	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
+{$endc}
+
+{$ifc defined __LP64__ and __LP64__ }
+  {$setc TARGET_CPU_64 := TRUE}
+{$elsec}
+  {$setc TARGET_CPU_64 := FALSE}
+{$endc}
+
+{$ifc defined FPC_BIG_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
+{$elifc defined FPC_LITTLE_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
+{$elsec}
+	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
+{$endc}
+{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
+{$setc CALL_NOT_IN_CARBON := FALSE}
+{$setc OLDROUTINENAMES := FALSE}
+{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
+{$setc OPAQUE_UPP_TYPES := TRUE}
+{$setc OTCARBONAPPLICATION := TRUE}
+{$setc OTKERNEL := FALSE}
+{$setc PM_USE_SESSION_APIS := TRUE}
+{$setc TARGET_API_MAC_CARBON := TRUE}
+{$setc TARGET_API_MAC_OS8 := FALSE}
+{$setc TARGET_API_MAC_OSX := TRUE}
+{$setc TARGET_CARBON := TRUE}
+{$setc TARGET_CPU_68K := FALSE}
+{$setc TARGET_CPU_MIPS := FALSE}
+{$setc TARGET_CPU_SPARC := FALSE}
+{$setc TARGET_OS_UNIX := FALSE}
+{$setc TARGET_OS_WIN32 := FALSE}
+{$setc TARGET_RT_MAC_68881 := FALSE}
+{$setc TARGET_RT_MAC_CFM := FALSE}
+{$setc TARGET_RT_MAC_MACHO := TRUE}
+{$setc TYPED_FUNCTION_POINTERS := TRUE}
+{$setc TYPE_BOOL := FALSE}
+{$setc TYPE_EXTENDED := FALSE}
+{$setc TYPE_LONGLONG := TRUE}
+uses MacTypes,CFBase,CFRunLoop,AudioHardware,AudioHardwareService,CoreFoundation;
+{$endc} {not MACOSALLINCLUDE}
+
+{$ALIGN POWER}
+
+
+//==================================================================================================
+//#pragma mark    Includes
+
+
+//==================================================================================================
+//CF_ASSUME_NONNULL_BEGIN
+
+
+//==================================================================================================
+//#pragma mark    AudioServices Error Constants
+
+{!
+    @enum           AudioServices error codes
+    @abstract       Error codes returned from the AudioServices portion of the API.
+    @constant       kAudioServicesNoError
+                        No error has occurred
+    @constant       kAudioServicesUnsupportedPropertyError 
+                        The property is not supported.
+    @constant       kAudioServicesBadPropertySizeError 
+                        The size of the property data was not correct.
+    @constant       kAudioServicesBadSpecifierSizeError 
+                        The size of the specifier data was not correct.
+    @constant       kAudioServicesSystemSoundUnspecifiedError 
+                        A SystemSound unspecified error has occurred.
+    @constant       kAudioServicesSystemSoundClientTimedOutError 
+                        The SystemSound client message timed out
+    @constant       kAudioServicesSystemSoundExceededMaximumDurationError
+                        The SystemSound's duration exceeded the allowable threshold
+}
+const
+	kAudioServicesNoError = 0;
+	kAudioServicesUnsupportedPropertyError = FourCharCode('pty?');
+	kAudioServicesBadPropertySizeError = FourCharCode('!siz');
+	kAudioServicesBadSpecifierSizeError = FourCharCode('!spc');
+	kAudioServicesSystemSoundUnspecifiedError = -1500;
+	kAudioServicesSystemSoundClientTimedOutError = -1501;
+	kAudioServicesSystemSoundExceededMaximumDurationError = -1502; 
+
+//==================================================================================================
+//#pragma mark    AudioServices Types
+
+{!
+    @typedef        SystemSoundID
+    @abstract       SystemSoundIDs are created by the System Sound client application
+                    for playback of a provided AudioFile.
+}
+type
+	SystemSoundID = UInt32;
+	SystemSoundIDPtr = ^SystemSoundID;
+
+{!
+    @typedef        AudioServicesPropertyID
+    @abstract       Type used for specifying an AudioServices property.
+}
+type
+	AudioServicesPropertyID = UInt32;
+	AudioServicesPropertyIDPtr = ^AudioServicesPropertyID;
+
+{!
+    @typedef        AudioServicesSystemSoundCompletionProc
+    @abstract       A function to be executed when a SystemSoundID finishes playing.
+    @discussion     AudioServicesSystemSoundCompletionProc may be provided by client application to be
+                    called when a SystemSoundID has completed playback.
+    @param          ssID
+                        The SystemSoundID that completed playback
+    @param          userData
+                        Client application user data
+}
+type
+	AudioServicesSystemSoundCompletionProc = procedure( ssID: SystemSoundID; clientData: UnivPtr {__nullable} );
+
+//==================================================================================================
+//#pragma mark    AudioServices Constants
+
+{!
+    @enum           AudioServices constants
+    @abstract       Constants for use with System Sound portion of the AudioServices APIs.
+    @constant       kSystemSoundID_UserPreferredAlert 
+                        Use this constant with the play sound APIs to
+                        playback the alert sound selected by the User in System Preferences.
+    @constant       kSystemSoundID_FlashScreen
+                        Use this constant with the play sound APIs to flash the screen
+                        - Desktop systems only
+}
+const
+	kSystemSoundID_UserPreferredAlert = $00001000;
+	kSystemSoundID_FlashScreen = $00000FFE; 
+        // this has been renamed to be consistent
+	kUserPreferredAlert = kSystemSoundID_UserPreferredAlert; 
+
+
+//==================================================================================================
+//#pragma mark    AudioServices Properties
+
+{!
+    @enum           AudioServices property codes
+    @abstract       These are the property codes used with the AudioServices API.
+    @constant       kAudioServicesPropertyIsUISound
+                        a UInt32 where 1 means that the SystemSoundID passed in the
+                        inSpecifier parameter will respect the 'Play user interface sounds effects'
+                        check box in System Preferences and be silent when the user turns off UI
+                        sounds. This property is set to 1 by default. Set to 0 if it is desired for
+                        an SystemSoundID to always be heard when passed to AudioServicesPlaySystemSound(), 
+                        regardless of user's setting in the Sound Preferences.
+    @constant       kAudioServicesPropertyCompletePlaybackIfAppDies 
+                        a UInt32 where 1 means that the SystemSoundID passed in the
+                        inSpecifier parameter will finish playing even if the client application goes away.
+}
+const
+	kAudioServicesPropertyIsUISound = FourCharCode('isui');
+	kAudioServicesPropertyCompletePlaybackIfAppDies = FourCharCode('ifdi'); 
+
+//==================================================================================================
+//#pragma mark    AudioServices Functions
+
+{!
+    @functiongroup  AudioServices
+}
+
+{!
+    @function       AudioServicesCreateSystemSoundID
+    @abstract       Allows the application to designate an audio file for playback by the System Sound server.
+    @discussion     Returned SystemSoundIDs are passed to AudioServicesPlayAlertSoundWithCompletion() 
+                    and AudioServicesPlaySystemSoundWithCompletion() to be played.
+ 
+                    The maximum supported duration for a system sound is 30 secs.
+    @param          inFileURL
+                        A CFURLRef for an AudioFile.
+    @param          outSystemSoundID
+                        Returns a SystemSoundID.
+}
+function AudioServicesCreateSystemSoundID( inFileURL: CFURLRef; var outSystemSoundID: SystemSoundID ): OSStatus; external name '_AudioServicesCreateSystemSoundID';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+	
+{!
+    @function       AudioServicesDisposeSystemSoundID
+    @abstract       Allows the System Sound server to dispose any resources needed for the provided
+                    SystemSoundID.
+    @discussion     Allows the application to tell the System Sound server that the resources for the
+                    associated audio file are no longer required.
+    @param          inSystemSoundID
+                        A SystemSoundID that the application no longer needs to use.
+}
+function AudioServicesDisposeSystemSoundID( inSystemSoundID: SystemSoundID ): OSStatus; external name '_AudioServicesDisposeSystemSoundID';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function       AudioServicesPlayAlertSoundWithCompletion
+    @abstract       Play an alert sound
+    @discussion     Play the sound designated by the provided SystemSoundID with alert sound behavior.
+    @param          inSystemSoundID
+                        The SystemSoundID to be played. On the desktop the kSystemSoundID_UserPreferredAlert
+                        constant can be passed in to play back the alert sound selected by the user
+                        in System Preferences. On iOS there is no preferred user alert sound.
+    @param          inCompletionBlock
+                        The completion block gets executed for every attempt to play a system sound irrespective
+                        of success or failure. The callbacks are issued on a serial queue and the client is
+                        responsible for handling thread safety.
+}
+type
+  TCompletionBlock = reference to procedure; cdecl;
+
+procedure AudioServicesPlayAlertSoundWithCompletion(inSystemSoundID: SystemSoundID; inCompletionBlock: TCompletionBlock); external name '_AudioServicesPlayAlertSoundWithCompletion';
+(* API_AVAILABLE(macos(10.11), ios(9.0), watchos(2.0), tvos(9.0)) *)
+                                                                
+{!
+    @function       AudioServicesPlaySystemSoundWithCompletion
+    @abstract       Play a system sound
+    @discussion     Play the sound designated by the provided SystemSoundID.
+    @param          inSystemSoundID
+                        The SystemSoundID to be played.
+    @param          inCompletionBlock
+                        The completion block gets executed for every attempt to play a system sound irrespective 
+                        of success or failure. The callbacks are issued on a serial queue and the client is 
+                        responsible for handling thread safety.
+}
+procedure AudioServicesPlaySystemSoundWithCompletion(inSystemSoundID: SystemSoundID; inCompletionBlock: TCompletionBlock); external name '_AudioServicesPlaySystemSoundWithCompletion';
+(* API_AVAILABLE(macos(10.11), ios(9.0), watchos(2.0), tvos(9.0)) *)
+                                                                
+{!
+    @function       AudioServicesGetPropertyInfo
+    @abstract       Get information about the size of an AudioServices property and whether it can
+                    be set.
+    @param          inPropertyID
+                        a AudioServicesPropertyID constant.
+    @param          inSpecifierSize
+                        The size of the specifier data.
+    @param          inSpecifier
+                        A specifier is a buffer of data used as an input argument to some of the
+                        properties.
+    @param          outPropertyDataSize
+                        The size in bytes of the current value of the property. In order to get the
+                        property value, you will need a buffer of this size.
+    @param          outWritable
+                        Will be set to 1 if writable, or 0 if read only.
+    @result         returns kAudioServicesNoError if successful.
+}                            
+function AudioServicesGetPropertyInfo( inPropertyID: AudioServicesPropertyID; inSpecifierSize: UInt32; {const} inSpecifier: UnivPtr {__nullable}; outPropertyDataSize: UInt32Ptr {* __nullable}; outWritable: BooleanPtr {* __nullable} ): OSStatus; external name '_AudioServicesGetPropertyInfo';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function       AudioServicesGetProperty
+    @abstract       Retrieve the indicated property data
+    @param          inPropertyID
+                        a AudioServicesPropertyID constant.
+    @param          inSpecifierSize
+                        The size of the specifier data.
+    @param          inSpecifier
+                        A specifier is a buffer of data used as an input argument to some of the
+                        properties.
+    @param          ioPropertyDataSize
+                        On input, the size of the outPropertyData buffer. On output the number of
+                        bytes written to the buffer.
+    @param          outPropertyData
+                        The buffer in which to write the property data. May be NULL if caller only
+                        wants ioPropertyDataSize to be filled with the amount that would have been
+                        written.
+    @result         returns kAudioServicesNoError if successful.
+}                        
+function AudioServicesGetProperty( inPropertyID: AudioServicesPropertyID; inSpecifierSize: UInt32; {const} inSpecifier: UnivPtr {__nullable}; var ioPropertyDataSize: UInt32; outPropertyData: UnivPtr {__nullable} ): OSStatus; external name '_AudioServicesGetProperty';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function       AudioServicesSetProperty
+    @abstract       Set the indicated property data
+    @param          inPropertyID
+                        a AudioServicesPropertyID constant.
+    @param          inSpecifierSize
+                        The size of the specifier data.
+    @param          inSpecifier
+                        A specifier is a buffer of data used as an input argument to some of the
+                        properties.
+    @param          inPropertyDataSize
+                        The size of the inPropertyData buffer.
+    @param          inPropertyData
+                        The buffer containing the property data.
+    @result         returns kAudioServicesNoError if successful.
+}
+function AudioServicesSetProperty( inPropertyID: AudioServicesPropertyID; inSpecifierSize: UInt32; {const} inSpecifier: UnivPtr {__nullable}; inPropertyDataSize: UInt32; inPropertyData: {const} UnivPtr ): OSStatus; external name '_AudioServicesSetProperty';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+                                                                
+{!
+    This function will be deprecated in a future release. Use AudioServicesPlayAlertSoundWithCompletion instead.
+ 
+    @function       AudioServicesPlayAlertSound
+    @abstract       Play an Alert Sound
+    @discussion     Play the provided SystemSoundID with AlertSound behavior.
+    @param          inSystemSoundID
+                        A SystemSoundID for the System Sound server to play. On the desktop you
+                        can pass the kSystemSoundID_UserPreferredAlert constant to playback the alert sound 
+                        selected by the user in System Preferences. On iOS there is no preferred user alert sound.
+}
+procedure AudioServicesPlayAlertSound( inSystemSoundID: SystemSoundID ); external name '_AudioServicesPlayAlertSound';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+                                                                
+{!
+    This function will be deprecated in a future release. Use AudioServicesPlaySystemSoundWithCompletion instead.
+ 
+    @function       AudioServicesPlaySystemSound
+    @abstract       Play the sound designated by the provided SystemSoundID.
+    @discussion     A SystemSoundID indicating the desired System Sound to be played.
+    @param          inSystemSoundID
+                        A SystemSoundID for the System Sound server to play.
+}
+procedure AudioServicesPlaySystemSound( inSystemSoundID: SystemSoundID ); external name '_AudioServicesPlaySystemSound';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+                                                                
+{!
+    This function will be deprecated in a future release. Use AudioServicesPlayAlertSoundWithCompletion 
+    or AudioServicesPlaySystemSoundWithCompletion instead.
+ 
+    @function       AudioServicesAddSystemSoundCompletion
+    @abstract       Call the provided Completion Routine when provided SystemSoundID
+                    finishes playing.
+    @discussion     Once set, the System Sound server will send a message to the System Sound client
+                    indicating which SystemSoundID has finished playing.
+    @param          inSystemSoundID
+                        The SystemSoundID to associate with the provided completion
+                        routine.
+    @param          inRunLoop
+                        A CFRunLoopRef indicating the desired run loop the completion routine should
+                        be run on. Pass NULL to use the main run loop.
+    @param          inRunLoopMode
+                        A CFStringRef indicating the run loop mode for the runloop where the
+                        completion routine will be executed. Pass NULL to use kCFRunLoopDefaultMode.
+    @param          inCompletionRoutine
+                        An AudioServicesSystemSoundCompletionProc to be called when the provided
+                        SystemSoundID has completed playing in the server.
+    @param          inClientData
+                        A void* to pass client data to the completion routine.
+}
+function AudioServicesAddSystemSoundCompletion( inSystemSoundID: SystemSoundID; inRunLoop: CFRunLoopRef {__nullable}; inRunLoopMode: CFStringRef {__nullable}; inCompletionRoutine: AudioServicesSystemSoundCompletionProc; inClientData: UnivPtr {__nullable} ): OSStatus; external name '_AudioServicesAddSystemSoundCompletion';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    This function will be deprecated in a future release. Use AudioServicesPlayAlertSoundWithCompletion
+    or AudioServicesPlaySystemSoundWithCompletion instead.
+ 
+    @function       AudioServicesRemoveSystemSoundCompletion
+    @abstract       Disassociate any completion proc for the specified SystemSoundID
+    @discussion     Tells the SystemSound client to remove any completion proc associated with the
+                    provided SystemSoundID
+    @param          inSystemSoundID
+                        The SystemSoundID for which completion routines should be
+                        removed.
+}
+procedure AudioServicesRemoveSystemSoundCompletion( inSystemSoundID: SystemSoundID ); external name '_AudioServicesRemoveSystemSoundCompletion';
+(* API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) *)
+
+//CF_ASSUME_NONNULL_END
+    
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+
+end.
+{$endc} {not MACOSALLINCLUDE}

+ 8 - 16
packages/univint/src/AudioUnitCarbonViews.pas

@@ -1,15 +1,8 @@
-{
-     File:       AudioUnitCarbonView.h
- 
-     Contains:   AudioUnitCarbonView Interfaces
- 
-     Copyright:  © 2002-2008 by Apple, Inc., all rights reserved.
- 
-     Bugs?:      For bug reports, consult the following page on
-                 the World Wide Web:
- 
-                     http://bugs.freepascal.org
- 
+{!
+	@file		AudioUnitCarbonView.h
+ 	@framework	AudioToolbox.framework
+ 	@copyright	(c) 2000-2015 Apple, Inc. All rights reserved.
+	@abstract	Deprecated interfaces for using Carbon-based views of Audio Units.
 }
 {	  Pascal Translation:  Gorazd Krosl <[email protected]>, October 2009 }
 
@@ -21,6 +14,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}
@@ -307,9 +301,9 @@ type
 	@param		outControl
 					The Carbon control which contains the entire user interface for the view.
 }
-
+{$ifc not TARGET_CPU_64}
 function AudioUnitCarbonViewCreate( inView: AudioUnitCarbonView; inAudioUnit: AudioUnit; inWindow: WindowRef; inParentControl: ControlRef; const inLocation: Float32PointPtr; const inSize: Float32PointPtr; var outControl: ControlRef ): OSStatus; external name '_AudioUnitCarbonViewCreate';
-(* __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_NA) *)
+(* API_DEPRECATED("no longer supported", macos(10.2, 10.11)) API_UNAVAILABLE(ios, watchos, tvos) *)
 
 {!
 	@function	AudioUnitCarbonViewSetEventListener
@@ -324,8 +318,6 @@ function AudioUnitCarbonViewCreate( inView: AudioUnitCarbonView; inAudioUnit: Au
 	@param		inUserData
 					A user data pointer passed to the callback.
 }
-//#ifndef __LP64__
-{$ifc not TARGET_CPU_64}
 function AudioUnitCarbonViewSetEventListener( inView: AudioUnitCarbonView; inCallback: AudioUnitCarbonViewEventListener; inUserData: UnivPtr ): OSStatus; external name '_AudioUnitCarbonViewSetEventListener';
 (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_4, __IPHONE_NA, __IPHONE_NA) *)
 {$endc}

+ 351 - 143
packages/univint/src/AudioUnitParameters.pas

@@ -1,18 +1,12 @@
-{
-     File:       AudioUnitParameters.h
- 
-     Contains:   Parameter constants for Apple AudioUnits
- 
-     Copyright:  (c) 2002-2008 by Apple, Inc., all rights reserved.
- 
-     Bugs?:      For bug reports, consult the following page on
-                 the World Wide Web:
- 
-                     http://bugs.freepascal.org
- 
+{!
+	@file		AudioUnitParameters.h
+ 	@framework	AudioToolbox.framework
+ 	@copyright	(c) 2000-2015 Apple, Inc. All rights reserved.
+	@abstract	Constants for the parameters of Apple audio units.
 }
 {  Pascal Translation:  Gorazd Krosl <[email protected]>, October 2009 }
 {  Pascal Translation Update: Jonas Maebe <[email protected]>, October 2012 }
+{  Pascal Translation Update: Jonas Maebe <[email protected]>, July 2019 }
 
 {
     Modified for use with Free Pascal
@@ -22,6 +16,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}
@@ -224,30 +219,30 @@ MIDI messages, that should be supported in Group scope by MIDI capable AUs.
 Group scope parameter IDs from 0 < 512 are reserved for mapping MIDI controllers.
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }
 const
-	kAUGroupParameterID_Volume = 7;	// value 0 < 128
-	kAUGroupParameterID_Sustain = 64; 	// value 0-63 (off), 64-127 (on)
-	kAUGroupParameterID_Sostenuto = 66; 	// value 0-63 (off), 64-127 (on)
-	kAUGroupParameterID_AllNotesOff = 123;	// value ignored
-	kAUGroupParameterID_ModWheel = 1;	// value 0 < 128
-	kAUGroupParameterID_PitchBend = $E0;	// value -8192 - 8191
-	kAUGroupParameterID_AllSoundOff = 120;	// value ignored
-	kAUGroupParameterID_ResetAllControllers = 121;	// value ignored
-	kAUGroupParameterID_Pan = 10;	// value 0 < 128
-	kAUGroupParameterID_Foot = 4;	// value 0 < 128
-	kAUGroupParameterID_ChannelPressure = $D0;	// value 0 < 128
-	kAUGroupParameterID_KeyPressure = $A0;	// values 0 < 128
-	kAUGroupParameterID_Expression = 11;	// value 0 < 128
-	kAUGroupParameterID_DataEntry = 6;	// value 0 < 128
-
-	kAUGroupParameterID_Volume_LSB = kAUGroupParameterID_Volume + 32;		// value 0 < 128
-	kAUGroupParameterID_ModWheel_LSB = kAUGroupParameterID_ModWheel + 32;	// value 0 < 128
-	kAUGroupParameterID_Pan_LSB = kAUGroupParameterID_Pan + 32;			// value 0 < 128
-	kAUGroupParameterID_Foot_LSB = kAUGroupParameterID_Foot + 32;		// value 0 < 128
-	kAUGroupParameterID_Expression_LSB = kAUGroupParameterID_Expression + 32;	// value 0 < 128
-	kAUGroupParameterID_DataEntry_LSB = kAUGroupParameterID_DataEntry + 32;	// value 0 < 128
+	kAUGroupParameterID_Volume = 7; 	// value 0 < 128
+	kAUGroupParameterID_Sustain = 64;  	// value 0-63 (off), 64-127 (on)
+	kAUGroupParameterID_Sostenuto = 66;  	// value 0-63 (off), 64-127 (on)
+	kAUGroupParameterID_AllNotesOff = 123; 	// value ignored
+	kAUGroupParameterID_ModWheel = 1; 	// value 0 < 128
+	kAUGroupParameterID_PitchBend = $E0; 	// value -8192 - 8191
+	kAUGroupParameterID_AllSoundOff = 120; 	// value ignored
+	kAUGroupParameterID_ResetAllControllers = 121; 	// value ignored
+	kAUGroupParameterID_Pan = 10; 	// value 0 < 128
+	kAUGroupParameterID_Foot = 4; 	// value 0 < 128
+	kAUGroupParameterID_ChannelPressure = $D0; 	// value 0 < 128
+	kAUGroupParameterID_KeyPressure = $A0; 	// values 0 < 128
+	kAUGroupParameterID_Expression = 11; 	// value 0 < 128
+	kAUGroupParameterID_DataEntry = 6; 	// value 0 < 128
+
+	kAUGroupParameterID_Volume_LSB = kAUGroupParameterID_Volume + 32; 		// value 0 < 128
+	kAUGroupParameterID_ModWheel_LSB = kAUGroupParameterID_ModWheel + 32; 	// value 0 < 128
+	kAUGroupParameterID_Pan_LSB = kAUGroupParameterID_Pan + 32; 			// value 0 < 128
+	kAUGroupParameterID_Foot_LSB = kAUGroupParameterID_Foot + 32; 		// value 0 < 128
+	kAUGroupParameterID_Expression_LSB = kAUGroupParameterID_Expression + 32; 	// value 0 < 128
+	kAUGroupParameterID_DataEntry_LSB = kAUGroupParameterID_DataEntry + 32; 	// value 0 < 128
 	
-	kAUGroupParameterID_KeyPressure_FirstKey = 256;	// value 0 < 128
-	kAUGroupParameterID_KeyPressure_LastKey = 383;	// value 0 < 128	
+	kAUGroupParameterID_KeyPressure_FirstKey = 256; 	// value 0 < 128
+	kAUGroupParameterID_KeyPressure_LastKey = 383; 	// value 0 < 128
 { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Supporting the kAUGroupParameterID_KeyPressure parameter indicates to hosts that your audio unit
 supports polyphonic "aftertouch" key pressure. 
@@ -274,7 +269,6 @@ When displaying to the user information about a parameter, a host application sh
 get the parameter information from the audio unit itself.
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }
 
-{$ifc not TARGET_OS_IPHONE}
 // Parameters for all Panner AudioUnits
 const
 // Global, Linear, 0->1, 1
@@ -291,11 +285,71 @@ const
         // Global, Meters, 0.01->1000, 1
 	kPannerParam_CoordScale = 4;	
         // Global, Meters, 0.01->1000, 1
-	kPannerParam_RefDistance = 5;
-{$endc} {not TARGET_OS_IPHONE}
+	kPannerParam_RefDistance = 5; 
+
 
 //#pragma mark Apple Specific
 
+// Parameters for the AUSpatialMixer unit
+const
+// Input, Degrees, -180->180, 0
+	kSpatialMixerParam_Azimuth = 0; 
+    
+    // Input, Degrees, -90->90, 0
+	kSpatialMixerParam_Elevation = 1; 
+    
+    // Input, Metres, 0->10000, 0
+	kSpatialMixerParam_Distance = 2; 
+    
+    // Input/Output, dB, -120->20, 0
+	kSpatialMixerParam_Gain = 3; 
+	
+    // Input, rate scaler	0.5 -> 2.0
+	kSpatialMixerParam_PlaybackRate = 4; 
+    
+    // bus enable : 0.0 or 1.0
+	kSpatialMixerParam_Enable = 5; 
+    
+    // Minimum input gain constraint : 0.0 -> 1.0
+	kSpatialMixerParam_MinGain = 6; 
+    
+    // Maximum input gain constraint : 0.0 -> 1.0
+	kSpatialMixerParam_MaxGain = 7; 
+	
+    // Input, Dry/Wet equal-power blend, %	  0.0 -> 100.0
+	kSpatialMixerParam_ReverbBlend = 8; 
+    
+    // Global, dB,		-40.0 -> +40.0
+	kSpatialMixerParam_GlobalReverbGain = 9; 
+	
+    // Input, Lowpass filter attenuation at 5KHz :		decibels -100.0dB -> 0.0dB
+    // smaller values make both direct and reverb sound more muffled; a value of 0.0 indicates no filtering
+    // Occlusion is a filter applied to the sound prior to the reverb send
+	kSpatialMixerParam_OcclusionAttenuation = 10; 
+	
+    // Input, Lowpass filter attenuation at 5KHz :		decibels -100.0dB -> 0.0dB
+    // smaller values make direct sound more muffled; a value of 0.0 indicates no filtering
+    // Obstruction is a filter applied to the "direct" part of the sound (so is post reverb send)
+	kSpatialMixerParam_ObstructionAttenuation = 11; 
+
+// Reverb parameters applicable to AUSpatialMixer
+const
+// Global, Hertz, 10.0 -> 20000.0, 800.0
+	kReverbParam_FilterFrequency = 14; 
+    
+    // Global, Octaves, 0.05 -> 4.0, 3.0
+	kReverbParam_FilterBandwidth = 15; 
+    
+    // Global, Decibels, -18.0 -> +18.0, 0.0
+	kReverbParam_FilterGain = 16; 
+    
+    // Global, Indexed, 0->kNumAUNBandEQFilterTypes-1, 0
+	kReverbParam_FilterType = 17;        // only available for AUSpatialMixer
+    
+    // Global, Boolean, 0->1, 1
+	kReverbParam_FilterEnable = 18;         // only available for AUSpatialMixer
+
+
 // Parameters for the AUMixer3D unit
 const
 // Input, Degrees, -180->180, 0
@@ -313,7 +367,7 @@ const
 		// Input, rate scaler	0.5 -> 2.0
 	k3DMixerParam_PlaybackRate = 4;
 
-{$ifc not TARGET_OS_IPHONE}
+{$ifc TARGET_OS_MAC}
 		// Desktop specific 3D mixer parameters
 
 // Input, Dry/Wet equal-power blend, %	  0.0 -> 100.0
@@ -348,40 +402,45 @@ const
 	k3DMixerParam_PrePeakHoldLevel = 2000;
 	k3DMixerParam_PostAveragePower = 3000;
 	k3DMixerParam_PostPeakHoldLevel = 4000;
-{$endc} { not TARGET_OS_IPHONE }
+{$endc} { TARGET_OS_MAC }
 
 // Parameters for the AUMultiChannelMixer unit
 // these are available for both desktop and iphone
 const
-// Global, Linear Gain, 0->1, 1
-	kMultiChannelMixerParam_Volume = 0;
+// Global, Linear Gain, 0->1, 1. (the volume value can actually be any finite number, including negative.)
+	kMultiChannelMixerParam_Volume = 0; 
 		// Global, Boolean, 0->1, 1
-	kMultiChannelMixerParam_Enable = 1;
-		// Global, Pan
-	kMultiChannelMixerParam_Pan = 2;			// -1 - 0 - 1, only valid when output is not mono
-													// relationship to mix matrix: last one in wins
+	kMultiChannelMixerParam_Enable = 1; 
+		// Global, Pan, -1->1, 0
+	kMultiChannelMixerParam_Pan = 2; 			// -1 - 0 - 1, only valid when output is not mono
+													// setting kAudioUnitProperty_MatrixLevels overrides any
+													// previously set kMultiChannelMixerParam_Pan and vice versa
 
-		// read-only
+		// read-only, Input or Output scope.
 	// these report level in dB, as do the other mixers
 	kMultiChannelMixerParam_PreAveragePower = 1000;
 	kMultiChannelMixerParam_PrePeakHoldLevel = 2000;
 	kMultiChannelMixerParam_PostAveragePower = 3000;
 	kMultiChannelMixerParam_PostPeakHoldLevel = 4000;
 
-// Music Device
-// Parameters for the AUSampler unit
+// Parameters for the AUMatrixMixer unit
 const
-// Global, dB, -90->12, 0
-	kAUSamplerParam_Gain = 900;
-    
-		// Global, Semitones, -24->24, 0
-	kAUSamplerParam_CoarseTuning = 901;
+	kMatrixMixerParam_Volume = 0;
+	kMatrixMixerParam_Enable = 1; 
+	
+		// read-only
+	// these report level in dB, as do the other mixers
+	kMatrixMixerParam_PreAveragePower = 1000;
+	kMatrixMixerParam_PrePeakHoldLevel = 2000;
+	kMatrixMixerParam_PostAveragePower = 3000;
+	kMatrixMixerParam_PostPeakHoldLevel = 4000; 
 
-		// Global, Cents, -99->99, 0
-	kAUSamplerParam_FineTuning = 902;
+	// these report linear levels - for "expert" use only.
+	kMatrixMixerParam_PreAveragePowerLinear = 5000;
+	kMatrixMixerParam_PrePeakHoldLevelLinear = 6000;
+	kMatrixMixerParam_PostAveragePowerLinear = 7000;
+	kMatrixMixerParam_PostPeakHoldLevelLinear = 8000; 
 
-		// Global, -1.0->1.0, 0
-	kAUSamplerParam_Pan = 903;
 
 // Output Units
 // Parameters for the AudioDeviceOutput, DefaultOutputUnit, and SystemOutputUnit units
@@ -392,21 +451,45 @@ const
 // Parameters for the AUTimePitch, AUTimePitch (offline), AUPitch units
 const
 	kTimePitchParam_Rate = 0;
-{$ifc not TARGET_OS_IPHONE}
 	kTimePitchParam_Pitch = 1;
-	kTimePitchParam_EffectBlend = 2;		// only for the AUPitch unit
-{$endif} {TARGET_OS_IPHONE}
+	kTimePitchParam_EffectBlend = 2; 		// only for the AUPitch unit
 
 // Parameters for AUNewTimePitch
 const
-// Global, rate, 1/32 -> 32.0, 1.0
-	kNewTimePitchParam_Rate = 0;
+// rate control.
+		// Global, rate, 1/32 -> 32.0, 1.0
+	kNewTimePitchParam_Rate = 0; 
+	
+		// pitch shift in cents.
 		// Global, Cents, -2400 -> 2400, 1.0
-	kNewTimePitchParam_Pitch = 1;
+	kNewTimePitchParam_Pitch = 1; 
+	
+		// Overlap is the number of overlapped spectral windows that are used to produce the output.
+		// The value of overlap is directly proportional to CPU cost. More overlaps can make smooth
+		// passages sound smoother. For percussive sound, a lower overlap may be better.
 		// Global, generic, 3.0 -> 32.0, 8.0
-	kNewTimePitchParam_Overlap = 4;
+	kNewTimePitchParam_Overlap = 4; 
+	
+		// Peak locking enforces phase coherence of spectral peaks.
+		// Peak locking adds some expense but results in a less "phasey"
+		// or reverberant sound, sometimes also called loss of presence.
+		// However the flip side is that it can sound more stuttery for some content.
 		// Global, Boolean, 0->1, 1
-	kNewTimePitchParam_EnablePeakLocking = 6;
+	kNewTimePitchParam_EnablePeakLocking = 6; 
+
+// Parameters for the AUSampler unit
+const
+// Global, dB, -90->12, 0
+	kAUSamplerParam_Gain = 900; 
+
+		// Global, Semitones, -24->24, 0
+	kAUSamplerParam_CoarseTuning = 901; 
+
+		// Global, Cents, -99->99, 0
+	kAUSamplerParam_FineTuning = 902; 
+
+		// Global, -1.0->1.0, 0
+	kAUSamplerParam_Pan = 903; 
 
 // Effect units
 // The values for some effect unit parameters depend on the audio unit's sample rate.
@@ -476,6 +559,10 @@ const
 	kLimiterParam_PreGain = 2;
 
 // Parameters for the AUDynamicsProcessor unit
+// Note that the dynamics processor does not have fixed compression ratios.
+// Instead, kDynamicsProcessorParam_HeadRoom adjusts the amount of compression.
+// Lower kDynamicsProcessorParam_HeadRoom values results in higher compression.
+// The compression ratio is automatically adjusted to not exceed kDynamicsProcessorParam_Threshold + kDynamicsProcessorParam_HeadRoom values.
 const
 // Global, dB, -40->20, -20
 	kDynamicsProcessorParam_Threshold = 0;
@@ -552,9 +639,156 @@ const
 		// Global, Percent, 0 -> 100, 50
 	kDistortionParam_FinalMix = 15;
 
+// Parameters for the AUDelay unit
+const
+// Global, EqPow Crossfade, 0->100, 50
+	kDelayParam_WetDryMix = 0; 
+		
+		// Global, Secs, 0->2, 1
+	kDelayParam_DelayTime = 1; 
+		
+		// Global, Percent, -100->100, 50
+	kDelayParam_Feedback = 2; 
+		
+		// Global, Hz, 10->(SampleRate/2), 15000
+	kDelayParam_LopassCutoff = 3; 
+
+// Parameters for the AUNBandEQ unit
+// Note that the parameter IDs listed correspond to band 0 (zero) of the unit. The parameter IDs for
+// higher bands can be obtained by adding the zero-indexed band number to the corresponding band 0
+// parameter ID up to the number of bands minus one, where the number of bands is described by the
+// AUNBandEQ property kAUNBandEQProperty_NumberOfBands. For example, the parameter ID corresponding
+// to the filter type of band 4 would be kAUNBandEQParam_FilterType + 3.
+// kAUNBandEQParam_GlobalsGain is an overall gain and does not have a band.
+const
+// Global, dB, -96->24, 0
+	kAUNBandEQParam_GlobalGain = 0; 
+	
+    // Global, Boolean, 0 or 1, 1
+	kAUNBandEQParam_BypassBand = 1000; 
+	
+    // Global, Indexed, 0->kNumAUNBandEQFilterTypes-1, 0
+	kAUNBandEQParam_FilterType = 2000; 
+	
+    // Global, Hz, 20->(SampleRate/2), 1000
+	kAUNBandEQParam_Frequency = 3000; 
+	
+    // Global, dB, -96->24, 0
+	kAUNBandEQParam_Gain = 4000; 
+	
+    // Global, octaves, 0.05->5.0, 0.5
+	kAUNBandEQParam_Bandwidth = 5000; 
+
+{!
+ @enum			AUNBandEQ filter types
+ @discussion		Constants available as values for the kAUNBandEQParam_FilterType parameter defined above
+ 
+ @constant		kAUNBandEQFilterType_Parametric
+ Parametric filter based on Butterworth analog prototype. Uses parameterization where
+ the bandwidth is specifed as the relationship of the upper bandedge frequency to the
+ lower bandedge frequency in octaves, where the upper and lower bandedge frequencies are
+ the respective frequencies above and below the center frequency at which the gain is
+ equal to half the peak gain.
+ Applicable parameters:
+ - kAUNBandEQParam_Frequency (center frequency)
+ - kAUNBandEQParam_Gain (peak gain)
+ - kAUNBandEQParam_Bandwidth
+ 
+ @constant		kAUNBandEQFilterType_2ndOrderButterworthLowPass
+ Simple Butterworth 2nd order low pass filter
+ Applicable parameters:
+ - kAUNBandEQParam_Frequency (-3 dB cutoff frequency)
+ 
+ @constant		kAUNBandEQFilterType_2ndOrderButterworthHighPass
+ Simple Butterworth 2nd order high pass filter
+ Applicable parameters:
+ - kAUNBandEQParam_Frequency (-3 dB cutoff frequency)
+ 
+ @constant		kAUNBandEQFilterType_ResonantLowPass
+ Low pass filter with resonance support (via bandwidth parameter)
+ Applicable parameters:
+ - kAUNBandEQParam_Frequency (-3 dB cutoff frequency)
+ - kAUNBandEQParam_Bandwidth
+ 
+ @constant		kAUNBandEQFilterType_ResonantHighPass
+ High pass filter with resonance support (via bandwidth parameter)
+ Applicable parameters:
+ - kAUNBandEQParam_Frequency (-3 dB cutoff frequency)
+ - kAUNBandEQParam_Bandwidth
+ 
+ @constant		kAUNBandEQFilterType_BandPass
+ Band pass filter
+ Applicable parameters:
+ - kAUNBandEQParam_Frequency (center frequency)
+ - kAUNBandEQParam_Bandwidth
+ 
+ @constant		kAUNBandEQFilterType_BandStop
+ Band stop filter (aka "notch filter")
+ Applicable parameters:
+ - kAUNBandEQParam_Frequency (center frequency)
+ - kAUNBandEQParam_Bandwidth
+ 
+ @constant		kAUNBandEQFilterType_LowShelf
+ Low shelf filter
+ Applicable parameters:
+ - kAUNBandEQParam_Frequency (center frequency)
+ - kAUNBandEQParam_Gain (shelf gain)
+ 
+ @constant		kAUNBandEQFilterType_HighShelf
+ High shelf filter
+ Applicable parameters:
+ - kAUNBandEQParam_Frequency (center frequency)
+ - kAUNBandEQParam_Gain (shelf gain)
+ 
+ @constant		kAUNBandEQFilterType_ResonantLowShelf
+ Low shelf filter with resonance support (via bandwidth parameter)
+ Applicable parameters:
+ - kAUNBandEQParam_Frequency (center frequency)
+ - kAUNBandEQParam_Gain (shelf gain)
+ - kAUNBandEQParam_Bandwidth
+ 
+ @constant		kAUNBandEQFilterType_ResonantHighShelf
+ High shelf filter with resonance support (via bandwidth parameter)
+ Applicable parameters:
+ - kAUNBandEQParam_Frequency (center frequency)
+ - kAUNBandEQParam_Gain (shelf gain)
+ - kAUNBandEQParam_Bandwidth
+ 
+ }
+const
+	kAUNBandEQFilterType_Parametric = 0;
+	kAUNBandEQFilterType_2ndOrderButterworthLowPass = 1;
+	kAUNBandEQFilterType_2ndOrderButterworthHighPass = 2;
+	kAUNBandEQFilterType_ResonantLowPass = 3;
+	kAUNBandEQFilterType_ResonantHighPass = 4;
+	kAUNBandEQFilterType_BandPass = 5;
+	kAUNBandEQFilterType_BandStop = 6;
+	kAUNBandEQFilterType_LowShelf = 7;
+	kAUNBandEQFilterType_HighShelf = 8;
+	kAUNBandEQFilterType_ResonantLowShelf = 9;
+	kAUNBandEQFilterType_ResonantHighShelf = 10;
+	kNumAUNBandEQFilterTypes = 11; 
+
+
+// Parameters for the AURoundTripAACParam unit
+const
+// Global, indexed : AAC, HE-AAC, HE-AACv2
+	kRoundTripAACParam_Format = 0; 
+	
+		// Global, indexed
+	kRoundTripAACParam_EncodingStrategy = 1; 
+
+		// Global, indexed
+	kRoundTripAACParam_RateOrQuality = 2; 
+
+		// These are deprecated:
+	kRoundTripAACParam_BitRate = 1;
+	kRoundTripAACParam_Quality = 2;
+	kRoundTripAACParam_CompressedFormatSampleRate = 3; 
+
 //#pragma mark Apple Specific - Desktop
 
-{$ifc not TARGET_OS_IPHONE}
+{$ifc TARGET_OS_MAC}
 
 // Some parameters for the AUGraphicEQ unit
 const
@@ -603,30 +837,7 @@ const
 	kReverbParam_ModulationRate = 12;
 
 		// Global, Genr, 0.0 -> 1.0, 0.2
-	kReverbParam_ModulationDepth = 13;
-
-		// Global, Hertz, 10.0 -> 20000.0, 800.0
-	kReverbParam_FilterFrequency = 14;
-
-		// Global, Octaves, 0.05 -> 4.0, 3.0
-	kReverbParam_FilterBandwidth = 15;
-
-		// Global, Decibels, -18.0 -> +18.0, 0.0
-	kReverbParam_FilterGain = 16;
-
-// Parameters for the AUDelay unit
-const
-// Global, EqPow Crossfade, 0->100, 50
-	kDelayParam_WetDryMix = 0;
-		
-		// Global, Secs, 0->2, 1
-	kDelayParam_DelayTime = 1;
-		
-		// Global, Percent, -100->100, 50
-	kDelayParam_Feedback = 2;
-		
-		// Global, Hz, 10->(SampleRate/2), 15000
-	kDelayParam_LopassCutoff = 3;
+	kReverbParam_ModulationDepth = 13; 
 
 // Parameters for the AUMultibandCompressor unit
 const
@@ -732,7 +943,24 @@ const
 		// Global, Hertz, 10 -> (SampleRate/2), 100
 	kMultibandFilter_HighFrequency = 13;
 		// Global, dB, -18 -> +18, 0
-	kMultibandFilter_HighGain = 14;
+	kMultibandFilter_HighGain = 14; 
+
+// Parameters for AURogerBeep
+const
+// Global, dB, -80 -> 0, -6
+	kRogerBeepParam_InGateThreshold = 0; 
+		// Global, Milliseconds, 0 -> 1000, 1000
+	kRogerBeepParam_InGateThresholdTime = 1; 
+		// Global, dB, -80 -> 0, -6
+	kRogerBeepParam_OutGateThreshold = 2; 
+		// Global, Milliseconds, 0 -> 1000, 1000
+	kRogerBeepParam_OutGateThresholdTime = 3; 	
+		// Global, indexed, 0 -> 2, 2
+	kRogerBeepParam_Sensitivity = 4; 	
+		// Global, indexed, 0 -> 2, 0
+	kRogerBeepParam_RogerType = 5; 
+		// Global, dB, -80 -> 20, -6
+	kRogerBeepParam_RogerGain = 6; 
 
 // Mixer Units
 
@@ -753,25 +981,7 @@ const
 	kStereoMixerParam_PreAveragePower = 1000;
 	kStereoMixerParam_PrePeakHoldLevel = 2000;
 	kStereoMixerParam_PostAveragePower = 3000;
-	kStereoMixerParam_PostPeakHoldLevel = 4000;
-
-// Parameters for the AUMatrixMixer unit
-const
-	kMatrixMixerParam_Volume = 0;
-	kMatrixMixerParam_Enable = 1;
-	
-		// read-only
-	// these report level in dB, as do the other mixers
-	kMatrixMixerParam_PreAveragePower = 1000;
-	kMatrixMixerParam_PrePeakHoldLevel = 2000;
-	kMatrixMixerParam_PostAveragePower = 3000;
-	kMatrixMixerParam_PostPeakHoldLevel = 4000;
-
-	// these report linear levels - for "expert" use only.
-	kMatrixMixerParam_PreAveragePowerLinear = 5000;
-	kMatrixMixerParam_PrePeakHoldLevelLinear = 6000;
-	kMatrixMixerParam_PostAveragePowerLinear = 7000;
-	kMatrixMixerParam_PostPeakHoldLevelLinear = 8000;
+	kStereoMixerParam_PostPeakHoldLevel = 4000; 
 
 // Parameters for the AUNetReceive unit
 const
@@ -793,24 +1003,7 @@ const
 	kAUNetStatus_Overflow = 2;
 	kAUNetStatus_Underflow = 3;
 	kAUNetStatus_Connecting = 4;
-	kAUNetStatus_Listening = 5;
-
-// Parameters for AURogerBeep
-const
-// Global, dB, -80 -> 0, -6
-	kRogerBeepParam_InGateThreshold = 0;
-		// Global, Milliseconds, 0 -> 1000, 1000
-	kRogerBeepParam_InGateThresholdTime = 1;
-		// Global, dB, -80 -> 0, -6
-	kRogerBeepParam_OutGateThreshold = 2;
-		// Global, Milliseconds, 0 -> 1000, 1000
-	kRogerBeepParam_OutGateThresholdTime = 3;
-		// Global, indexed, 0 -> 2, 2
-	kRogerBeepParam_Sensitivity = 4;
-		// Global, indexed, 0 -> 2, 0
-	kRogerBeepParam_RogerType = 5;
-		// Global, dB, -80 -> 20, -6
-	kRogerBeepParam_RogerGain = 6;
+	kAUNetStatus_Listening = 5; 
 
 // Music Device
 // Parameters for the DLSMusicDevice unit - defined and reported in the global scope
@@ -849,23 +1042,38 @@ const
 // See the MusicDevice.h header file for more about using the extended control semantics 
 // of this API.	
 
-// Parameters for the AURoundTripAACParam unit
+
+// `Analog' AudioUnits
+
+
+// Parameters for the AURandom unit
 const
-// Global, indexed : AAC, AAC HE, AAC HEv2, AAC ELD
-	kRoundTripAACParam_Format = 0;
-	
-		// Global, indexed
-	kRoundTripAACParam_EncodingStrategy = 1;
+	kRandomParam_BoundA = 0;
+	kRandomParam_BoundB = 1;
+	kRandomParam_Curve = 2; 
+{$endc} {TARGET_OS_MAC}
 
-		// Global, indexed
-	kRoundTripAACParam_RateOrQuality = 2;
-	
-		// These are deprecated:
-	kRoundTripAACParam_BitRate = 1;
-	kRoundTripAACParam_Quality = 2;
-	kRoundTripAACParam_CompressedFormatSampleRate = 3;
-{$endc} {not TARGET_OS_IPHONE}
+//#pragma mark Apple Specific - iOS
+{$ifc TARGET_OS_IPHONE}
 
+// Parameters for the iOS reverb unit
+const
+// Global, CrossFade, 0->100, 100
+	kReverb2Param_DryWetMix = 0; 
+		// Global, Decibels, -20->20, 0
+	kReverb2Param_Gain = 1; 
+		
+		// Global, Secs, 0.0001->1.0, 0.008
+	kReverb2Param_MinDelayTime = 2; 
+		// Global, Secs, 0.0001->1.0, 0.050
+	kReverb2Param_MaxDelayTime = 3; 
+		// Global, Secs, 0.001->20.0, 1.0
+	kReverb2Param_DecayTimeAt0Hz = 4; 
+		// Global, Secs, 0.001->20.0, 0.5
+	kReverb2Param_DecayTimeAtNyquist = 5; 
+		// Global, Integer, 1->1000
+	kReverb2Param_RandomizeReflections = 6; 
+{$endc} {TARGET_OS_IPHONE}
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 
 end.

File diff suppressed because it is too large
+ 331 - 228
packages/univint/src/AudioUnitProperties.pas


+ 648 - 0
packages/univint/src/AudioUnitUtilities.pas

@@ -0,0 +1,648 @@
+{!
+	@file		AudioUnitUtilities.h
+	@framework	AudioToolbox.framework
+	@copyright	(c) 2002-2015 by Apple, Inc., all rights reserved.
+	@abstract	Higher-level utility functions for the use of AudioUnit clients.
+
+    @discussion
+
+	The AU Parameter Listener is designed to provide notifications when an Audio Unit's parameters
+	or other state changes.  It makes it unnecessary for UI components to continually poll an Audio
+	Unit to determine if a parameter value has been changed. In order for this notification
+	mechanism to work properly, parameter values should be changed using the AUParameterSet call
+	(discussed below). This also makes it unnecessary for an Audio Unit to provide and support a
+	notification mechanism, particularly as AudioUnitSetParameter may be received by an Audio Unit
+	during the render process.
+
+	The AUEventListener API's extend the AUParameterListener API's by supporting event types
+	other than parameter changes. Events, including parameter changes are delivered serially to the 
+	listener, preserving the time order of the events and parameter changes.
+
+	There are also some utilities for converting between non-linear and linear value ranges. These
+	are useful for displaying a non-linear parameter (such as one whose units are in Hertz or
+	decibels) using a linear control mechanism, such as a slider, to ensure that the user has a
+	wider perceived range of control over the parameter value.
+}
+{  Pascal Translation: Jonas Maebe <[email protected]>, July 2019 }
+{
+    Modified for use with Free Pascal
+    Version 308
+    Please report any bugs to <[email protected]>
+}
+
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+{$mode macpas}
+{$modeswitch cblocks}
+{$packenum 1}
+{$macro on}
+{$inline on}
+{$calling mwpascal}
+
+unit AudioUnitUtilities;
+interface
+{$setc UNIVERSAL_INTERFACES_VERSION := $0400}
+{$setc GAP_INTERFACES_VERSION := $0308}
+
+{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
+    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
+{$endc}
+
+{$ifc defined CPUPOWERPC and defined CPUI386}
+	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
+{$endc}
+{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
+	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
+{$endc}
+
+{$ifc not defined __ppc__ and defined CPUPOWERPC32}
+	{$setc __ppc__ := 1}
+{$elsec}
+	{$setc __ppc__ := 0}
+{$endc}
+{$ifc not defined __ppc64__ and defined CPUPOWERPC64}
+	{$setc __ppc64__ := 1}
+{$elsec}
+	{$setc __ppc64__ := 0}
+{$endc}
+{$ifc not defined __i386__ and defined CPUI386}
+	{$setc __i386__ := 1}
+{$elsec}
+	{$setc __i386__ := 0}
+{$endc}
+{$ifc not defined __x86_64__ and defined CPUX86_64}
+	{$setc __x86_64__ := 1}
+{$elsec}
+	{$setc __x86_64__ := 0}
+{$endc}
+{$ifc not defined __arm__ and defined CPUARM}
+	{$setc __arm__ := 1}
+{$elsec}
+	{$setc __arm__ := 0}
+{$endc}
+{$ifc not defined __arm64__ and defined CPUAARCH64}
+  {$setc __arm64__ := 1}
+{$elsec}
+  {$setc __arm64__ := 0}
+{$endc}
+
+{$ifc defined cpu64}
+  {$setc __LP64__ := 1}
+{$elsec}
+  {$setc __LP64__ := 0}
+{$endc}
+
+
+{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
+	{$error Conflicting definitions for __ppc__ and __i386__}
+{$endc}
+
+{$ifc defined __ppc__ and __ppc__}
+	{$setc TARGET_CPU_PPC := TRUE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __ppc64__ and __ppc64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := TRUE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __i386__ and __i386__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := TRUE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __x86_64__ and __x86_64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := TRUE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+{$ifc defined(iphonesim)}
+ 	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
+{$elsec}
+	{$setc TARGET_OS_MAC := TRUE}
+	{$setc TARGET_OS_IPHONE := FALSE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+{$endc}
+	{$setc TARGET_OS_EMBEDDED := FALSE}
+{$elifc defined __arm__ and __arm__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := TRUE}
+	{$setc TARGET_CPU_ARM64 := FALSE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := TRUE}
+{$elifc defined __arm64__ and __arm64__}
+	{$setc TARGET_CPU_PPC := FALSE}
+	{$setc TARGET_CPU_PPC64 := FALSE}
+	{$setc TARGET_CPU_X86 := FALSE}
+	{$setc TARGET_CPU_X86_64 := FALSE}
+	{$setc TARGET_CPU_ARM := FALSE}
+	{$setc TARGET_CPU_ARM64 := TRUE}
+	{ will require compiler define when/if other Apple devices with ARM cpus ship }
+	{$setc TARGET_OS_MAC := FALSE}
+	{$setc TARGET_OS_IPHONE := TRUE}
+	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
+	{$setc TARGET_OS_EMBEDDED := TRUE}
+{$elsec}
+	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
+{$endc}
+
+{$ifc defined __LP64__ and __LP64__ }
+  {$setc TARGET_CPU_64 := TRUE}
+{$elsec}
+  {$setc TARGET_CPU_64 := FALSE}
+{$endc}
+
+{$ifc defined FPC_BIG_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
+{$elifc defined FPC_LITTLE_ENDIAN}
+	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
+	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
+{$elsec}
+	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
+{$endc}
+{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
+{$setc CALL_NOT_IN_CARBON := FALSE}
+{$setc OLDROUTINENAMES := FALSE}
+{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
+{$setc OPAQUE_UPP_TYPES := TRUE}
+{$setc OTCARBONAPPLICATION := TRUE}
+{$setc OTKERNEL := FALSE}
+{$setc PM_USE_SESSION_APIS := TRUE}
+{$setc TARGET_API_MAC_CARBON := TRUE}
+{$setc TARGET_API_MAC_OS8 := FALSE}
+{$setc TARGET_API_MAC_OSX := TRUE}
+{$setc TARGET_CARBON := TRUE}
+{$setc TARGET_CPU_68K := FALSE}
+{$setc TARGET_CPU_MIPS := FALSE}
+{$setc TARGET_CPU_SPARC := FALSE}
+{$setc TARGET_OS_UNIX := FALSE}
+{$setc TARGET_OS_WIN32 := FALSE}
+{$setc TARGET_RT_MAC_68881 := FALSE}
+{$setc TARGET_RT_MAC_CFM := FALSE}
+{$setc TARGET_RT_MAC_MACHO := TRUE}
+{$setc TYPED_FUNCTION_POINTERS := TRUE}
+{$setc TYPE_BOOL := FALSE}
+{$setc TYPE_EXTENDED := FALSE}
+{$setc TYPE_LONGLONG := TRUE}
+uses MacTypes,CFBase,CFRunLoop,AUComponent;
+{$endc} {not MACOSALLINCLUDE}
+
+{$ALIGN POWER}
+
+
+
+//CF_ASSUME_NONNULL_BEGIN
+
+
+{ ============================================================================= }
+
+{!
+    @enum       
+    @constant   kAUParameterListener_AnyParameter
+                    A wildcard value for an AudioUnitParameterID. Note that this is
+                    only valid when sending a notification (with AUParameterListenerNotify),
+                    not when registering to receive one.
+}
+const
+	kAUParameterListener_AnyParameter = $FFFFFFFF; 
+
+{!
+    @enum       AudioUnitEventType
+    
+    @abstract   Types of Audio Unit Events.
+    
+    @constant   kAudioUnitEvent_ParameterValueChange
+                    The event is a change to a parameter value
+    @constant   kAudioUnitEvent_BeginParameterChangeGesture
+                    The event signifies a gesture (e.g. mouse-down) beginning a potential series of
+                    related parameter value change events.
+    @constant   kAudioUnitEvent_EndParameterChangeGesture
+                    The event signifies a gesture (e.g. mouse-up) ending a series of related
+                    parameter value change events.
+    @constant   kAudioUnitEvent_PropertyChange
+                    The event is a change to a property value.
+}
+type
+	AudioUnitEventType = UInt32;
+	AudioUnitEventTypePtr = ^AudioUnitEventType;
+const
+	kAudioUnitEvent_ParameterValueChange = 0;
+	kAudioUnitEvent_BeginParameterChangeGesture = 1;
+	kAudioUnitEvent_EndParameterChangeGesture = 2;
+	kAudioUnitEvent_PropertyChange = 3; 
+
+{ ============================================================================= }
+
+{!
+    @typedef        AUParameterListenerRef
+    @abstract       An object which receives notifications of Audio Unit parameter value changes.
+    @discussion
+}
+type
+	AUListenerBase = record end;
+	AUParameterListenerRef = ^AUListenerBase;
+    // opaque
+    // old-style listener, may not be passed to new functions
+
+{!
+    @typedef        AUEventListenerRef
+    @abstract       An object which receives Audio Unit events.
+    @discussion     An AUEventListenerRef may be passed to API's taking an AUEventListenerRef
+                    as an argument.
+}
+type
+	AUEventListenerRef = AUParameterListenerRef;
+    // new-style listener, can be passed to both old and new functions
+
+{!
+    @struct     AudioUnitEvent
+    @abstract   Describes a change to an Audio Unit's state.
+    @field      mEventType
+        The type of event.
+    @field      mArgument
+        Specifies the parameter or property which has changed.
+}  
+type
+	AudioUnitEvent = record
+		mEventType: AudioUnitEventType;
+		mArgument: record
+			case byte of
+				0: (mParameter: AudioUnitParameter); // for parameter value change, begin and end gesture
+		  		1: (mProperty: AudioUnitProperty);  // for kAudioUnitEvent_PropertyChange
+		end
+	end;
+	AudioUnitEventPtr = ^AudioUnitEvent;
+
+
+{!
+    @typedef    AUParameterListenerProc
+    @abstract   A function called when a parameter value changes.
+    @param  inUserData
+                The value passed to AUListenerCreate when the callback function was installed.
+    @param  inObject
+                The object which generated the parameter change.
+    @param  inParameter
+                Signifies the parameter whose value changed.
+    @param  inValue
+                The parameter's new value.
+}
+type
+	AUParameterListenerProc = procedure( inUserData: UnivPtr {__nullable}; inObject: UnivPtr {__nullable}; const (*var*) inParameter: AudioUnitParameter; inValue: AudioUnitParameterValue );
+
+{!
+    @typedef    AUEventListenerProc
+    @abstract   A function called when an Audio Unit event occurs.
+    @param  inUserData
+                The value passed to AUListenerCreate when the callback function was installed.
+    @param  inObject
+                The object which generated the parameter change.
+    @param  inEvent
+                The event which occurred.
+    @param  inEventHostTime
+                The host time at which the event occurred.
+    @param  inParameterValue
+                If the event is parameter change, the parameter's new value (otherwise, undefined).
+}
+type
+	AUEventListenerProc = procedure( inUserData: UnivPtr {__nullable}; inObject: UnivPtr {__nullable}; const (*var*) inEvent: AudioUnitEvent; inEventHostTime: UInt64; inParameterValue: AudioUnitParameterValue );
+
+
+{ ============================================================================= }
+
+{!
+    @functiongroup  AUListener
+}
+
+
+{!
+    @function   AUListenerCreate
+    @abstract   Create an object for fielding notifications when AudioUnit parameter values change.
+    @param      inProc
+                    Function called when the parameter's value changes.
+    @param      inUserData
+                    A reference value for the use of the callback function.
+    @param      inRunLoop
+                    The run loop on which the callback is called.  If NULL,
+                    CFRunLoopGetCurrent() is used.
+    @param      inRunLoopMode
+                    The run loop mode in which the callback's underlying run loop source will be
+                    attached.  If NULL, kCFRunLoopDefaultMode is used.
+    @param      inNotificationInterval
+                    The minimum time interval, in seconds, at which the callback will be called.
+                    If multiple parameter value changes occur within this time interval, the
+                    listener will only receive a notification for the last value change that
+                    occurred before the callback.  If inNotificationInterval is 0, the inRunLoop
+                    and inRunLoopMode arguments are ignored, and the callback will be issued
+                    immediately, on the thread on which the parameter was changed.
+    @param      outListener
+                    On successful return, an AUParameterListenerRef.
+    @discussion 
+        Note that only parameter changes issued through AUParameterSet will generate
+        notifications to listeners; thus, in most cases, AudioUnit clients should use
+        AUParameterSet in preference to AudioUnitSetParameter.
+}
+function AUListenerCreate( inProc: AUParameterListenerProc; inUserData: UnivPtr; inRunLoop: CFRunLoopRef {__nullable}; inRunLoopMode: CFStringRef {__nullable}; inNotificationInterval: Float32; var outListener: AUParameterListenerRef {__nullable * __nonnull} ): OSStatus; external name '_AUListenerCreate';
+(* API_AVAILABLE(macos(10.2), ios(6.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AUListenerDispose
+    @abstract   Dispose a parameter listener object.
+    @param      inListener
+                    The parameter listener to dispose.
+    @discussion 
+}
+function AUListenerDispose( inListener: AUParameterListenerRef ): OSStatus; external name '_AUListenerDispose';
+(* API_AVAILABLE(macos(10.2), ios(6.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AUListenerAddParameter
+    @abstract   Connect a parameter to a listener.
+    @param      inListener
+                    The parameter listener which will receive the callback.
+    @param      inObject
+                    The object which is interested in the value of the parameter.  This will be
+                    passed as the inObject parameter to the listener callback function when the
+                    parameter changes.
+    @param      inParameter
+                    The parameter whose value changes are to generate callbacks.
+    @discussion 
+        Associates an arbitrary object (often a user interface widget) with an
+        AudioUnitParameter, and delivers notifications to the specified listener, telling it
+        that the object needs to be informed of the parameter's value change.
+}
+function AUListenerAddParameter( inListener: AUParameterListenerRef; inObject: UnivPtr {__nullable}; const (*var*) inParameter: AudioUnitParameter ): OSStatus; external name '_AUListenerAddParameter';
+(* API_AVAILABLE(macos(10.2), ios(6.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AUListenerRemoveParameter
+    @abstract   Remove a parameter/listener connection.
+    @param      inListener
+                    The parameter listener to stop receiving callbacks.
+    @param      inObject
+                    The object which is no longer interested in the value of the parameter.
+    @param      inParameter
+                    The parameter whose value changes are to stop generating callbacks.
+    @discussion 
+}
+function AUListenerRemoveParameter( inListener: AUParameterListenerRef; inObject: UnivPtr {__nullable}; const (*var*) inParameter: AudioUnitParameter ): OSStatus; external name '_AUListenerRemoveParameter';
+(* API_AVAILABLE(macos(10.2), ios(6.0), watchos(2.0), tvos(9.0)) *)
+
+
+{!
+    @function   AUParameterSet
+    @abstract   Set an AudioUnit parameter value and notify listeners.
+    @param      inSendingListener
+                    A parameter listener generating the change and which does not want to
+                    receive a callback as a result of it. May be NULL.
+    @param      inSendingObject
+                    The object generating the change and which does not want to receive a
+                    callback as a result of it. NULL is treated specially when inListener is
+                    non-null; it signifies that none of the specified listener's objects will
+                    receive notifications.
+    @param      inParameter
+                    The parameter being changed.
+    @param      inValue
+                    The new value of the parameter.
+	@param		inBufferOffsetInFrames
+					The offset into the next rendered buffer at which the parameter change will take
+					effect.
+    @discussion 
+        Calls AudioUnitSetParameter, and performs/schedules notification callbacks to all
+        parameter listeners, for that parameter -- except that no callback will be generated to
+        the inListener/inObject pair.
+}
+function AUParameterSet( inSendingListener: AUParameterListenerRef {__nullable}; inSendingObject: UnivPtr {__nullable}; const (*var*) inParameter: AudioUnitParameter; inValue: AudioUnitParameterValue; inBufferOffsetInFrames: UInt32 ): OSStatus; external name '_AUParameterSet';
+(* API_AVAILABLE(macos(10.2), ios(6.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AUParameterListenerNotify
+    @abstract   Notify listeners of a past parameter change.
+    @param      inSendingListener
+                    A parameter listener generating the change and which does not want to
+                    receive a callback as a result of it. May be NULL.
+    @param      inSendingObject
+                    The object generating the change and which does not want to receive a
+                    callback as a result of it. NULL is treated specially when inListener is
+                    non-null; it signifies that none of the specified listener's objects will
+                    receive notifications.
+    @param      inParameter
+                    The parameter which was changed.
+    @discussion 
+        Performs and schedules the notification callbacks of AUParameterSet, without
+        actually setting an AudioUnit parameter value.
+        
+        Clients scheduling ramped parameter changes to AudioUnits must make this call
+        dynamically during playback in order for AudioUnitViews to be updated.  When the view's
+        listener receives a notification, it will be passed the current value of the parameter.
+
+        A special meaning is applied if the mParameterID value of inParameter is equal to
+        kAUParameterListener_AnyParameter. In this case, ANY listener for ANY parameter value
+        changes on the specified AudioUnit will be notified of the current value of that
+        parameter.
+}
+function AUParameterListenerNotify( inSendingListener: AUParameterListenerRef {__nullable}; inSendingObject: UnivPtr {__nullable}; const (*var*) inParameter: AudioUnitParameter ): OSStatus; external name '_AUParameterListenerNotify';
+(* API_AVAILABLE(macos(10.2), ios(6.0), watchos(2.0), tvos(9.0)) *)
+
+{ ============================================================================= }
+
+{!
+    @functiongroup  AUEventListener
+}
+
+
+{!
+    @function   AUEventListenerCreate
+    @abstract   Creates an Audio Unit event listener.
+    @param      inProc
+                    Function called when an event occurs.
+    @param      inUserData
+                    A reference value for the use of the callback function.
+    @param      inRunLoop
+                    The run loop on which the callback is called.  If NULL,
+                    CFRunLoopGetCurrent() is used.
+    @param      inRunLoopMode
+                    The run loop mode in which the callback's underlying run loop source will be
+                    attached.  If NULL, kCFRunLoopDefaultMode is used.
+    @param      inNotificationInterval
+                    The minimum time interval, in seconds, at which the callback will be called.
+    @param      inValueChangeGranularity
+                    Determines how parameter value changes occurring within this interval are
+                    queued; when an event follows a previous one by a smaller time interval than
+                    the granularity, then the listener will only be notified for the second
+                    parameter change.
+    @param      outListener
+                    On successful return, an AUEventListenerRef.
+    
+    @discussion
+        See the discussion of AUEventListenerCreateWithDispatchQueue.
+}
+function AUEventListenerCreate( inProc: AUEventListenerProc; inUserData: UnivPtr {__nullable}; inRunLoop: CFRunLoopRef {__nullable}; inRunLoopMode: CFStringRef {__nullable}; inNotificationInterval: Float32 { seconds }; inValueChangeGranularity: Float32 { seconds }; var outListener: AUEventListenerRef {__nullable * __nonnull} ): OSStatus; external name '_AUEventListenerCreate';
+(* API_AVAILABLE(macos(10.3), ios(6.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AUEventListenerAddEventType
+    @abstract   Begin delivering a particular type of events to a listener.
+    @param      inListener
+                    The parameter listener which will receive the events.
+    @param      inObject
+                    The object which is interested in the value of the parameter.  This will be
+                    passed as the inObject parameter to the listener callback function when the
+                    parameter changes.
+    @param      inEvent
+                    The type of event to listen for.
+    @result     An OSStatus error code.
+}
+function AUEventListenerAddEventType( inListener: AUEventListenerRef; inObject: UnivPtr {__nullable}; const (*var*) inEvent: AudioUnitEvent ): OSStatus; external name '_AUEventListenerAddEventType';
+(* API_AVAILABLE(macos(10.3), ios(6.0), watchos(2.0), tvos(9.0)) *)
+    
+{!
+    @function   AUEventListenerRemoveEventType
+    @abstract   Stop delivering a particular type of events to a listener.
+    @param      inListener
+                    The parameter listener to stop receiving events.
+    @param      inObject
+                    The object which is no longer interested in the value of the parameter.
+    @param      inEvent
+                    The type of event to stop listening for.
+    @result     An OSStatus error code.
+}
+function AUEventListenerRemoveEventType( inListener: AUEventListenerRef; inObject: UnivPtr {__nullable}; const (*var*) inEvent: AudioUnitEvent ): OSStatus; external name '_AUEventListenerRemoveEventType';
+(* API_AVAILABLE(macos(10.3), ios(6.0), watchos(2.0), tvos(9.0)) *)           
+
+{!
+    @function   AUEventListenerNotify
+    @abstract   Deliver an AudioUnitEvent to all listeners registered to receive it.
+    @discussion This is only to be used for notifications about parameter changes (and gestures).
+                It can not be used for notifying changes to property values as these are 
+                internal to an audio unit and should not be issued outside of the audio unit itself.
+    @param      inSendingListener
+                    A parameter listener generating the change and which does not want to
+                    receive a callback as a result of it. May be NULL.
+    @param      inSendingObject
+                    The object generating the change and which does not want to receive a
+                    callback as a result of it. NULL is treated specially when inListener is
+                    non-null; it signifies that none of the specified listener's objects will
+                    receive notifications.
+    @param      inEvent
+                    The event to be delivered.
+    @result     An OSStatus error code.
+}
+function AUEventListenerNotify( inSendingListener: AUEventListenerRef {__nullable}; inSendingObject: UnivPtr {__nullable}; const (*var*) inEvent: AudioUnitEvent ): OSStatus; external name '_AUEventListenerNotify';
+(* API_AVAILABLE(macos(10.3), ios(6.0), watchos(2.0), tvos(9.0)) *)
+                                    
+{ ============================================================================= }
+
+{!
+    @functiongroup  Parameter value utilities
+}
+
+
+{!
+    @function   AUParameterValueFromLinear
+    @abstract   Converts a linear value to a parameter value according to the parameter's units.
+    
+    @param      inLinearValue
+                    The linear value (0.0-1.0) to convert.
+    @param      inParameter
+                    The parameter, including its Audio Unit, that will define the conversion of
+                    the supplied linear value to a value that is natural to that parameter.
+    @result
+                The converted parameter value, in the parameter's natural units.
+    @discussion 
+}
+function AUParameterValueFromLinear( inLinearValue: Float32 { // 0-1 }; const (*var*) inParameter: AudioUnitParameter ): AudioUnitParameterValue; external name '_AUParameterValueFromLinear';
+(* API_AVAILABLE(macos(10.2), ios(6.0), watchos(2.0), tvos(9.0)) *)
+
+{!
+    @function   AUParameterValueToLinear
+    @abstract   Converts a parameter value to a linear value according to the parameter's units.
+    
+    @param      inParameterValue
+                    The value in the natural units of the specified parameter.
+        
+    @param      inParameter
+                    The parameter, including its Audio Unit, that will define the conversion of
+                    the supplied parameter value to a corresponding linear value.
+    @result
+                A number 0.0-1.0.
+    @discussion 
+}
+function AUParameterValueToLinear( inParameterValue: AudioUnitParameterValue; const (*var*) inParameter: AudioUnitParameter ): Float32; external name '_AUParameterValueToLinear';
+(* API_AVAILABLE(macos(10.2), ios(6.0), watchos(2.0), tvos(9.0)) *)
+                                        // returns 0-1
+
+{!
+    @function   AUParameterFormatValue
+    @abstract   Format a parameter value into a string.
+    @param      inParameterValue
+                    The parameter value to be formatted.
+    @param      inParameter
+                    The Audio Unit, scope, element, and parameter whose value this is.
+    @param      inTextBuffer
+                    The character array to receive the formatted text.  Should be at least 32
+                    characters.
+    @param      inDigits
+                    The resolution of the string (see example above).
+    @result
+                <tt>inTextBuffer</tt>
+    @discussion 
+        Formats a floating point value into a string.  Computes a power of 10 to which the value
+        will be rounded and displayed as follows:  if the the parameter is logarithmic (Hertz),
+        the number of significant digits is inDigits - pow10(inParameterValue) + 1.  Otherwise,
+        it is inDigits - pow10(maxValue - minValue) + 1.
+
+        Example for inDigits=3:
+<pre>
+        pow10   range           digits after decimal place display
+        -2      .0100-.0999     4
+        -1      .100-.999       3
+        0       1.00-9.99       2
+        1       10.0-99.9       1
+        2       100-999         0
+        3       1000-9990       -1
+        4       10000-99900     -2</pre>
+}                              
+function AUParameterFormatValue( inParameterValue: Float64; const (*var*) inParameter: AudioUnitParameter; var inTextBuffer: char; inDigits: UInt32 ): CStringPtr; external name '_AUParameterFormatValue';
+(* API_AVAILABLE(macos(10.2), ios(6.0), watchos(2.0), tvos(9.0)) *)
+
+
+//CF_ASSUME_NONNULL_END
+{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
+
+end.
+{$endc} {not MACOSALLINCLUDE}

+ 1 - 0
packages/univint/src/AuthSession.pas

@@ -33,6 +33,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/Authorization.pas

@@ -33,6 +33,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AuthorizationDB.pas

@@ -32,6 +32,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AuthorizationPlugin.pas

@@ -32,6 +32,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/AuthorizationTags.pas

@@ -33,6 +33,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/BackupCore.pas

@@ -19,6 +19,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFArray.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFAttributedString.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFBag.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFBase.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFBinaryHeap.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFBitVector.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFBundle.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFByteOrders.pas

@@ -12,6 +12,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFCalendar.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFCharacterSet.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFData.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFDate.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFDateFormatter.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFDictionary.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFError.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFFTPStream.pas

@@ -23,6 +23,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFFileDescriptor.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFFileSecurity.pas

@@ -12,6 +12,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFHTTPAuthentication.pas

@@ -23,6 +23,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFHTTPMessage.pas

@@ -24,6 +24,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFHTTPStream.pas

@@ -24,6 +24,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFHost.pas

@@ -23,6 +23,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFLocale.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFMachPort.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFMessagePort.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFNetDiagnostics.pas

@@ -23,6 +23,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFNetServices.pas

@@ -24,6 +24,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFNetworkErrorss.pas

@@ -23,6 +23,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

+ 1 - 0
packages/univint/src/CFNotificationCenter.pas

@@ -9,6 +9,7 @@
 
 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 {$mode macpas}
+{$modeswitch cblocks}
 {$packenum 1}
 {$macro on}
 {$inline on}

Some files were not shown because too many files changed in this diff