ARAAudioUnit.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. //------------------------------------------------------------------------------
  2. //! \file ARAAudioUnit.h
  3. //! integrates ARA into Audio Unit plug-ins
  4. //! \project ARA API Specification
  5. //! \copyright Copyright (c) 2012-2021, Celemony Software GmbH, All Rights Reserved.
  6. //! Developed in cooperation with PreSonus Software Ltd.
  7. //! \license Licensed under the Apache License, Version 2.0 (the "License");
  8. //! you may not use this file except in compliance with the License.
  9. //! You may obtain a copy of the License at
  10. //!
  11. //! http://www.apache.org/licenses/LICENSE-2.0
  12. //!
  13. //! Unless required by applicable law or agreed to in writing, software
  14. //! distributed under the License is distributed on an "AS IS" BASIS,
  15. //! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. //! See the License for the specific language governing permissions and
  17. //! limitations under the License.
  18. //------------------------------------------------------------------------------
  19. #ifndef ARAAudioUnit_h
  20. #define ARAAudioUnit_h
  21. #include "ARAInterface.h"
  22. #include "MacTypes.h"
  23. #if defined(__cplusplus)
  24. namespace ARA
  25. {
  26. extern "C"
  27. {
  28. #endif
  29. #if defined(__clang__)
  30. _Pragma("GCC diagnostic push")
  31. _Pragma("GCC diagnostic ignored \"-Wfour-char-constants\"")
  32. #endif
  33. //! @defgroup Companion_APIs Companion APIs
  34. //! @{
  35. /***************************************************************************************************/
  36. //! @defgroup Audio_Unit Audio Unit
  37. //! ARA support for Audio Units is mostly based on private Audio Unit properties. The input/output
  38. //! pattern for the associated property data structs is similar to struct AudioUnitParameterStringFromValue
  39. //! in the Audio Unit API.
  40. //! To be able to detect potential collisions if some host or Audio Unit uses the same private property
  41. //! for non-ARA communication, the actual ARA data is embedded into a property data struct that also
  42. //! contains an ARA magic number. For this magic number to work properly for all host/plug-in combinations,
  43. //! it's crucial that hosts set it on input and check it after output, and that plug-ins check it
  44. //! before writing to the property struct.
  45. //! @{
  46. //! Integration with the system-wide Audio Unit cache.
  47. //! Since the introduction of the Audio Component APIs in macOS 10.10 Yosemite, a system-wide cache
  48. //! of all installed Audio Units allows hosts to defer opening any Audio Unit until the user explicitly
  49. //! requests this. To support this optimization also when ARA is used, plug-ins must be marked as
  50. //! ARA-compatible at the Audio Component level by including the tag "ARA" in their Info.plist file,
  51. //! like in this example:
  52. //! \code{.xml}
  53. //! <key>AudioComponents</key>
  54. //! <array>
  55. //! <dict>
  56. //! ...
  57. //! <key>manufacturer</key>
  58. //! <string>Demo</string>
  59. //! <key>subtype</key>
  60. //! <string>Test</string>
  61. //! <key>type</key>
  62. //! <string>aufx</string>
  63. //! ...
  64. //! <key>tags</key>
  65. //! <array>
  66. //! <string>Effect</string>
  67. //! ...
  68. //! <string>ARA</string>
  69. //! </array>
  70. //! </dict>
  71. //! </array>
  72. //! \endcode
  73. #define /*ARA_ADDENDUM(2_0_Final)*/ kARAAudioComponentTag "ARA"
  74. //! Property data for kAudioUnitProperty_ARAFactory.
  75. typedef struct ARAAudioUnitFactory
  76. {
  77. //! Input/output: token to identify the property is actually used for ARA.
  78. OSType inOutMagicNumber;
  79. //! Output: pointer to the factory associated with the Audio Unit.
  80. const ARAFactory * outFactory;
  81. } ARAAudioUnitFactory;
  82. //! Property data for kAudioUnitProperty_ARAPlugInExtensionBindingWithRoles.
  83. typedef struct ARAAudioUnitPlugInExtensionBinding
  84. {
  85. //! Input/output: token to identify the property is actually used for ARA.
  86. OSType inOutMagicNumber;
  87. //! Input: document controller of the model graph that the Audio Unit shall be bound to.
  88. ARADocumentControllerRef inDocumentControllerRef;
  89. //! Output: the entry point for the plug-in.
  90. const ARAPlugInExtensionInstance * outPlugInExtension;
  91. //! Input: all roles that the host considered in its implementation and will explicitly
  92. //! assign to some plug-in instance(s).
  93. //! Being an ARA 2.0 addition, this field is only available
  94. //! if kAudioUnitProperty_ARAPlugInExtensionBindingWithRoles is used.
  95. ARA_ADDENDUM(2_0_Draft) ARAPlugInInstanceRoleFlags knownRoles;
  96. //! Input: roles assigned to this specific plug-in instance.
  97. //! Being an ARA 2.0 addition, this field is only available
  98. //! if kAudioUnitProperty_ARAPlugInExtensionBindingWithRoles is used.
  99. ARA_ADDENDUM(2_0_Draft) ARAPlugInInstanceRoleFlags assignedRoles;
  100. } ARAAudioUnitPlugInExtensionBinding;
  101. enum
  102. {
  103. //! This value must be placed in the magicNumber fields of the ARA properties.
  104. kARAAudioUnitMagic = 'Ara!'
  105. };
  106. enum
  107. {
  108. //! kAudioUnitScope_Global, read-only, property data is ARAAudioUnitFactory:
  109. //! query the ARA factory associated with the given plug-in.
  110. kAudioUnitProperty_ARAFactory = 'AraF'
  111. };
  112. enum ARA_DEPRECATED(2_0_Draft)
  113. {
  114. //! kAudioUnitScope_Global, read-only, property data is ARAAudioUnitPlugInExtensionBinding:
  115. //! bind the Audio Unit instance to an ARA document controller, switching it from "normal"
  116. //! operation to ARA mode, and exposing the ARA plug-in extension.
  117. //! Note that since ARA 2.0, this property has been deprecated and replaced with
  118. //! kAudioUnitProperty_ARAPlugInExtensionBindingWithRoles.
  119. //! This deprecated call is equivalent to the new call with no known roles set, however all
  120. //! ARA 1.x hosts are in fact using all instances with playback renderer, edit renderer and
  121. //! editor view role enabled, so plug-ins implementing ARA 1 backwards compatibility can
  122. //! safely assume those three roles to be enabled if this call was made.
  123. //! Same call order rules as kAudioUnitProperty_ARAPlugInExtensionBindingWithRoles apply.
  124. kAudioUnitProperty_ARAPlugInExtensionBinding = 'AraB',
  125. };
  126. enum ARA_ADDENDUM(2_0_Draft)
  127. {
  128. //! ARA 2 extended version of kAudioUnitProperty_ARAPlugInExtensionBinding:
  129. //! kAudioUnitScope_Global, read-only, property data is ARAAudioUnitPlugInExtensionBinding:
  130. //! bind the Audio Unit instance to an ARA document controller, switching it from "normal"
  131. //! operation to ARA mode with the assigned roles, and exposing the ARA plug-in extension.
  132. //! This may be done only once during the lifetime of the Audio Unit, before initializing it via
  133. //! kAudioUnitInitializeSelect or setting its state via the properties ClassInfo, PresentPreset
  134. //! or CurrentPreset or before creating any of the custom views for Audio Unit.
  135. //! The ARA document controller must remain valid as long as the plug-in is in use - rendering,
  136. //! showing its UI, etc. However, when tearing down the plug-in, the actual order for deleting
  137. //! the Audio Unit and for deleting ARA document controller is undefined.
  138. //! Plug-ins must handle both potential destruction orders to allow for a simpler reference
  139. //! counting implementation on the host side.
  140. kAudioUnitProperty_ARAPlugInExtensionBindingWithRoles = 'AraE'
  141. };
  142. //! @}
  143. //! @}
  144. #if defined(__GNUC__)
  145. _Pragma("GCC diagnostic pop")
  146. #endif
  147. #if defined(__cplusplus)
  148. } // extern "C"
  149. } // namespace ARA
  150. #endif
  151. #endif // ARAAudioUnit_h