ARAPlugInDispatch.cpp 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. //------------------------------------------------------------------------------
  2. //! \file ARAPlugInDispatch.cpp
  3. //! C-to-C++ adapter for implementing ARA plug-ins
  4. //! \project ARA SDK Library
  5. //! \copyright Copyright (c) 2012-2021, Celemony Software GmbH, All Rights Reserved.
  6. //! \license Licensed under the Apache License, Version 2.0 (the "License");
  7. //! you may not use this file except in compliance with the License.
  8. //! You may obtain a copy of the License at
  9. //!
  10. //! http://www.apache.org/licenses/LICENSE-2.0
  11. //!
  12. //! Unless required by applicable law or agreed to in writing, software
  13. //! distributed under the License is distributed on an "AS IS" BASIS,
  14. //! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. //! See the License for the specific language governing permissions and
  16. //! limitations under the License.
  17. //------------------------------------------------------------------------------
  18. #include "ARAPlugInDispatch.h"
  19. namespace ARA {
  20. namespace PlugIn {
  21. /*******************************************************************************/
  22. // DocumentControllerDispatcher
  23. /*******************************************************************************/
  24. namespace DocumentControllerDispatcher
  25. {
  26. // Destruction
  27. static void ARA_CALL destroyDocumentController (ARADocumentControllerRef controllerRef) noexcept
  28. {
  29. fromRef (controllerRef)->destroyDocumentController ();
  30. }
  31. // Factory
  32. static const ARAFactory* ARA_CALL getFactory (ARADocumentControllerRef controllerRef) noexcept
  33. {
  34. return fromRef (controllerRef)->getFactory ();
  35. }
  36. // Update Management
  37. static void ARA_CALL beginEditing (ARADocumentControllerRef controllerRef) noexcept
  38. {
  39. fromRef (controllerRef)->beginEditing ();
  40. }
  41. static void ARA_CALL endEditing (ARADocumentControllerRef controllerRef) noexcept
  42. {
  43. fromRef (controllerRef)->endEditing ();
  44. }
  45. static void ARA_CALL notifyModelUpdates (ARADocumentControllerRef controllerRef) noexcept
  46. {
  47. fromRef (controllerRef)->notifyModelUpdates ();
  48. }
  49. // Archiving
  50. static ARABool ARA_CALL beginRestoringDocumentFromArchive (ARADocumentControllerRef controllerRef, ARAArchiveReaderHostRef /*archiveReaderHostRef*/) noexcept
  51. {
  52. // begin-/endRestoringDocumentFromArchive () is deprecated, but can be fully mapped to supported calls
  53. fromRef (controllerRef)->beginEditing ();
  54. return kARATrue;
  55. }
  56. static ARABool ARA_CALL endRestoringDocumentFromArchive (ARADocumentControllerRef controllerRef, ARAArchiveReaderHostRef archiveReaderHostRef) noexcept
  57. {
  58. // begin-/endRestoringDocumentFromArchive () is deprecated, but can be fully mapped to supported calls
  59. const auto result { fromRef (controllerRef)->restoreObjectsFromArchive (archiveReaderHostRef, nullptr) };
  60. fromRef (controllerRef)->endEditing ();
  61. return (result) ? kARATrue : kARAFalse;
  62. }
  63. static ARABool ARA_CALL storeDocumentToArchive (ARADocumentControllerRef controllerRef, ARAArchiveWriterHostRef archiveWriterHostRef) noexcept
  64. {
  65. // storeDocumentToArchive () is deprecated, but can be fully mapped to supported calls
  66. return (fromRef (controllerRef)->storeObjectsToArchive (archiveWriterHostRef, nullptr)) ? kARATrue : kARAFalse;
  67. }
  68. static ARABool ARA_CALL restoreObjectsFromArchive (ARADocumentControllerRef controllerRef, ARAArchiveReaderHostRef archiveReaderHostRef, const ARARestoreObjectsFilter* filter) noexcept
  69. {
  70. return (fromRef (controllerRef)->restoreObjectsFromArchive (archiveReaderHostRef, filter)) ? kARATrue : kARAFalse;
  71. }
  72. static ARABool ARA_CALL storeObjectsToArchive (ARADocumentControllerRef controllerRef, ARAArchiveWriterHostRef archiveWriterHostRef, const ARAStoreObjectsFilter* filter) noexcept
  73. {
  74. return (fromRef (controllerRef)->storeObjectsToArchive (archiveWriterHostRef, filter)) ? kARATrue : kARAFalse;
  75. }
  76. // Document Management
  77. static void ARA_CALL updateDocumentProperties (ARADocumentControllerRef controllerRef, const ARADocumentProperties* properties) noexcept
  78. {
  79. fromRef (controllerRef)->updateDocumentProperties (properties);
  80. }
  81. // Musical Context Management
  82. static ARAMusicalContextRef ARA_CALL createMusicalContext (ARADocumentControllerRef controllerRef, ARAMusicalContextHostRef hostRef, const ARAMusicalContextProperties* properties) noexcept
  83. {
  84. return fromRef (controllerRef)->createMusicalContext (hostRef, properties);
  85. }
  86. static void ARA_CALL updateMusicalContextProperties (ARADocumentControllerRef controllerRef, ARAMusicalContextRef musicalContext, const ARAMusicalContextProperties* properties) noexcept
  87. {
  88. fromRef (controllerRef)->updateMusicalContextProperties (musicalContext, properties);
  89. }
  90. static void ARA_CALL destroyMusicalContext (ARADocumentControllerRef controllerRef, ARAMusicalContextRef musicalContext) noexcept
  91. {
  92. fromRef (controllerRef)->destroyMusicalContext (musicalContext);
  93. }
  94. static void ARA_CALL updateMusicalContextContent (ARADocumentControllerRef controllerRef, ARAMusicalContextRef musicalContextRef, const ARAContentTimeRange* range, ARAContentUpdateFlags flags) noexcept
  95. {
  96. fromRef (controllerRef)->updateMusicalContextContent (musicalContextRef, range, flags);
  97. }
  98. // Region Sequence Management
  99. static ARARegionSequenceRef ARA_CALL createRegionSequence (ARADocumentControllerRef controllerRef, ARARegionSequenceHostRef hostRef, const ARARegionSequenceProperties* properties) noexcept
  100. {
  101. return fromRef (controllerRef)->createRegionSequence (hostRef, properties);
  102. }
  103. static void ARA_CALL updateRegionSequenceProperties (ARADocumentControllerRef controllerRef, ARARegionSequenceRef regionSequenceRef, const ARARegionSequenceProperties* properties) noexcept
  104. {
  105. fromRef (controllerRef)->updateRegionSequenceProperties (regionSequenceRef, properties);
  106. }
  107. static void ARA_CALL destroyRegionSequence (ARADocumentControllerRef controllerRef, ARARegionSequenceRef regionSequenceRef) noexcept
  108. {
  109. fromRef (controllerRef)->destroyRegionSequence (regionSequenceRef);
  110. }
  111. // Audio Source Management
  112. static ARAAudioSourceRef ARA_CALL createAudioSource (ARADocumentControllerRef controllerRef, ARAAudioSourceHostRef hostRef, const ARAAudioSourceProperties* properties) noexcept
  113. {
  114. return fromRef (controllerRef)->createAudioSource (hostRef, properties);
  115. }
  116. static void ARA_CALL updateAudioSourceProperties (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef, const ARAAudioSourceProperties* properties) noexcept
  117. {
  118. fromRef (controllerRef)->updateAudioSourceProperties (audioSourceRef, properties);
  119. }
  120. static void ARA_CALL updateAudioSourceContent (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef, const ARAContentTimeRange* range, ARAContentUpdateFlags flags) noexcept
  121. {
  122. fromRef (controllerRef)->updateAudioSourceContent (audioSourceRef, range, flags);
  123. }
  124. static void ARA_CALL enableAudioSourceSamplesAccess (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef, ARABool enable) noexcept
  125. {
  126. fromRef (controllerRef)->enableAudioSourceSamplesAccess (audioSourceRef, enable != kARAFalse);
  127. }
  128. static void ARA_CALL deactivateAudioSourceForUndoHistory (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef, ARABool enable) noexcept
  129. {
  130. fromRef (controllerRef)->deactivateAudioSourceForUndoHistory (audioSourceRef, enable != kARAFalse);
  131. }
  132. static void ARA_CALL destroyAudioSource (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef) noexcept
  133. {
  134. fromRef (controllerRef)->destroyAudioSource (audioSourceRef);
  135. }
  136. // Audio Modification Management
  137. static ARAAudioModificationRef ARA_CALL createAudioModification (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef,
  138. ARAAudioModificationHostRef hostRef, const ARAAudioModificationProperties* properties) noexcept
  139. {
  140. return fromRef (controllerRef)->createAudioModification (audioSourceRef, hostRef, properties);
  141. }
  142. static ARAAudioModificationRef ARA_CALL cloneAudioModification (ARADocumentControllerRef controllerRef, ARAAudioModificationRef audioModificationRef,
  143. ARAAudioModificationHostRef hostRef, const ARAAudioModificationProperties* properties) noexcept
  144. {
  145. return fromRef (controllerRef)->cloneAudioModification (audioModificationRef, hostRef, properties);
  146. }
  147. static void ARA_CALL updateAudioModificationProperties (ARADocumentControllerRef controllerRef, ARAAudioModificationRef audioModificationRef, const ARAAudioModificationProperties* properties) noexcept
  148. {
  149. fromRef (controllerRef)->updateAudioModificationProperties (audioModificationRef, properties);
  150. }
  151. static void ARA_CALL deactivateAudioModificationForUndoHistory (ARADocumentControllerRef controllerRef, ARAAudioModificationRef audioModificationRef, ARABool enable) noexcept
  152. {
  153. fromRef (controllerRef)->deactivateAudioModificationForUndoHistory (audioModificationRef, enable != kARAFalse);
  154. }
  155. static void ARA_CALL destroyAudioModification (ARADocumentControllerRef controllerRef, ARAAudioModificationRef audioModificationRef) noexcept
  156. {
  157. fromRef (controllerRef)->destroyAudioModification (audioModificationRef);
  158. }
  159. // Playback Region Management
  160. static ARAPlaybackRegionRef ARA_CALL createPlaybackRegion (ARADocumentControllerRef controllerRef, ARAAudioModificationRef audioModificationRef,
  161. ARAPlaybackRegionHostRef hostRef, const ARAPlaybackRegionProperties* properties) noexcept
  162. {
  163. return fromRef (controllerRef)->createPlaybackRegion (audioModificationRef, hostRef, properties);
  164. }
  165. static void ARA_CALL updatePlaybackRegionProperties (ARADocumentControllerRef controllerRef, ARAPlaybackRegionRef playbackRegionRef, const ARAPlaybackRegionProperties* properties) noexcept
  166. {
  167. fromRef (controllerRef)->updatePlaybackRegionProperties (playbackRegionRef, properties);
  168. }
  169. static void ARA_CALL destroyPlaybackRegion (ARADocumentControllerRef controllerRef, ARAPlaybackRegionRef playbackRegionRef) noexcept
  170. {
  171. fromRef (controllerRef)->destroyPlaybackRegion (playbackRegionRef);
  172. }
  173. static void ARA_CALL getPlaybackRegionHeadAndTailTime (ARADocumentControllerRef controllerRef, ARAPlaybackRegionRef playbackRegionRef,
  174. ARATimeDuration* headTime, ARATimeDuration* tailTime) noexcept
  175. {
  176. fromRef (controllerRef)->getPlaybackRegionHeadAndTailTime (playbackRegionRef, headTime, tailTime);
  177. }
  178. // Content Reader Management
  179. static ARABool ARA_CALL isAudioSourceContentAvailable (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef, ARAContentType type) noexcept
  180. {
  181. return (fromRef (controllerRef)->isAudioSourceContentAvailable (audioSourceRef, type)) ? kARATrue : kARAFalse;
  182. }
  183. static ARAContentGrade ARA_CALL getAudioSourceContentGrade (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef, ARAContentType type) noexcept
  184. {
  185. return fromRef (controllerRef)->getAudioSourceContentGrade (audioSourceRef, type);
  186. }
  187. static ARAContentReaderRef ARA_CALL createAudioSourceContentReader (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef,
  188. ARAContentType type, const ARAContentTimeRange* range) noexcept
  189. {
  190. return fromRef (controllerRef)->createAudioSourceContentReader (audioSourceRef, type, range);
  191. }
  192. static ARABool ARA_CALL isAudioModificationContentAvailable (ARADocumentControllerRef controllerRef, ARAAudioModificationRef audioModificationRef, ARAContentType type) noexcept
  193. {
  194. return (fromRef (controllerRef)->isAudioModificationContentAvailable (audioModificationRef, type)) ? kARATrue : kARAFalse;
  195. }
  196. static ARAContentGrade ARA_CALL getAudioModificationContentGrade (ARADocumentControllerRef controllerRef, ARAAudioModificationRef audioModificationRef, ARAContentType type) noexcept
  197. {
  198. return fromRef (controllerRef)->getAudioModificationContentGrade (audioModificationRef, type);
  199. }
  200. static ARAContentReaderRef ARA_CALL createAudioModificationContentReader (ARADocumentControllerRef controllerRef, ARAAudioModificationRef audioModificationRef,
  201. ARAContentType type, const ARAContentTimeRange* range) noexcept
  202. {
  203. return fromRef (controllerRef)->createAudioModificationContentReader (audioModificationRef, type, range);
  204. }
  205. static ARABool ARA_CALL isPlaybackRegionContentAvailable (ARADocumentControllerRef controllerRef, ARAPlaybackRegionRef playbackRegionRef, ARAContentType type) noexcept
  206. {
  207. return (fromRef (controllerRef)->isPlaybackRegionContentAvailable (playbackRegionRef, type)) ? kARATrue : kARAFalse;
  208. }
  209. static ARAContentGrade ARA_CALL getPlaybackRegionContentGrade (ARADocumentControllerRef controllerRef, ARAPlaybackRegionRef playbackRegionRef, ARAContentType type) noexcept
  210. {
  211. return fromRef (controllerRef)->getPlaybackRegionContentGrade (playbackRegionRef, type);
  212. }
  213. static ARAContentReaderRef ARA_CALL createPlaybackRegionContentReader (ARADocumentControllerRef controllerRef, ARAPlaybackRegionRef playbackRegionRef,
  214. ARAContentType type, const ARAContentTimeRange* range) noexcept
  215. {
  216. return fromRef (controllerRef)->createPlaybackRegionContentReader (playbackRegionRef, type, range);
  217. }
  218. static ARAInt32 ARA_CALL getContentReaderEventCount (ARADocumentControllerRef controllerRef, ARAContentReaderRef contentReaderRef) noexcept
  219. {
  220. return fromRef (controllerRef)->getContentReaderEventCount (contentReaderRef);
  221. }
  222. static const void* ARA_CALL getContentReaderDataForEvent (ARADocumentControllerRef controllerRef, ARAContentReaderRef contentReaderRef, ARAInt32 eventIndex) noexcept
  223. {
  224. return fromRef (controllerRef)->getContentReaderDataForEvent (contentReaderRef, eventIndex);
  225. }
  226. static void ARA_CALL destroyContentReader (ARADocumentControllerRef controllerRef, ARAContentReaderRef contentReaderRef) noexcept
  227. {
  228. fromRef (controllerRef)->destroyContentReader (contentReaderRef);
  229. }
  230. // Controlling Analysis
  231. static ARABool ARA_CALL isAudioSourceContentAnalysisIncomplete (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef, ARAContentType type) noexcept
  232. {
  233. return (fromRef (controllerRef)->isAudioSourceContentAnalysisIncomplete (audioSourceRef, type)) ? kARATrue : kARAFalse;
  234. }
  235. static void ARA_CALL requestAudioSourceContentAnalysis (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef,
  236. ARASize contentTypesCount, const ARAContentType contentTypes[]) noexcept
  237. {
  238. fromRef (controllerRef)->requestAudioSourceContentAnalysis (audioSourceRef, contentTypesCount, contentTypes);
  239. }
  240. static ARAInt32 ARA_CALL getProcessingAlgorithmsCount (ARADocumentControllerRef controllerRef) noexcept
  241. {
  242. return fromRef (controllerRef)->getProcessingAlgorithmsCount ();
  243. }
  244. static const ARAProcessingAlgorithmProperties* ARA_CALL getProcessingAlgorithmProperties (ARADocumentControllerRef controllerRef, ARAInt32 algorithmIndex) noexcept
  245. {
  246. return fromRef (controllerRef)->getProcessingAlgorithmProperties (algorithmIndex);
  247. }
  248. static ARAInt32 ARA_CALL getProcessingAlgorithmForAudioSource (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef) noexcept
  249. {
  250. return fromRef (controllerRef)->getProcessingAlgorithmForAudioSource (audioSourceRef);
  251. }
  252. static void ARA_CALL requestProcessingAlgorithmForAudioSource (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef, ARAInt32 algorithmIndex) noexcept
  253. {
  254. fromRef (controllerRef)->requestProcessingAlgorithmForAudioSource (audioSourceRef, algorithmIndex);
  255. }
  256. static ARABool ARA_CALL isLicensedForCapabilities (ARADocumentControllerRef controllerRef, ARABool runModalActivationDialogIfNeeded, ARASize contentTypesCount, const ARAContentType contentTypes[], ARAPlaybackTransformationFlags transformationFlags) noexcept
  257. {
  258. return (fromRef (controllerRef)->isLicensedForCapabilities ((runModalActivationDialogIfNeeded != kARAFalse), contentTypesCount, contentTypes, transformationFlags)) ? kARATrue : kARAFalse;
  259. }
  260. static ARABool ARA_CALL storeAudioSourceToAudioFileChunk (ARADocumentControllerRef controllerRef, ARAArchiveWriterHostRef archiveWriterHostRef, ARAAudioSourceRef audioSourceRef, ARAPersistentID* documentArchiveID, ARABool* openAutomatically) noexcept
  261. {
  262. bool autoOpen { false };
  263. const auto result {fromRef (controllerRef)->storeAudioSourceToAudioFileChunk (archiveWriterHostRef, audioSourceRef, documentArchiveID, &autoOpen) };
  264. *openAutomatically = (autoOpen) ? kARATrue : kARAFalse;
  265. return (result) ? kARATrue : kARAFalse;
  266. }
  267. static const ARADocumentControllerInterface* getInterface () noexcept
  268. {
  269. static const SizedStruct<ARA_STRUCT_MEMBER (ARADocumentControllerInterface, storeAudioSourceToAudioFileChunk)> ifc =
  270. {
  271. DocumentControllerDispatcher::destroyDocumentController,
  272. DocumentControllerDispatcher::getFactory,
  273. DocumentControllerDispatcher::beginEditing,
  274. DocumentControllerDispatcher::endEditing,
  275. DocumentControllerDispatcher::notifyModelUpdates,
  276. DocumentControllerDispatcher::beginRestoringDocumentFromArchive,
  277. DocumentControllerDispatcher::endRestoringDocumentFromArchive,
  278. DocumentControllerDispatcher::storeDocumentToArchive,
  279. DocumentControllerDispatcher::updateDocumentProperties,
  280. DocumentControllerDispatcher::createMusicalContext,
  281. DocumentControllerDispatcher::updateMusicalContextProperties,
  282. DocumentControllerDispatcher::updateMusicalContextContent,
  283. DocumentControllerDispatcher::destroyMusicalContext,
  284. DocumentControllerDispatcher::createAudioSource,
  285. DocumentControllerDispatcher::updateAudioSourceProperties,
  286. DocumentControllerDispatcher::updateAudioSourceContent,
  287. DocumentControllerDispatcher::enableAudioSourceSamplesAccess,
  288. DocumentControllerDispatcher::deactivateAudioSourceForUndoHistory,
  289. DocumentControllerDispatcher::destroyAudioSource,
  290. DocumentControllerDispatcher::createAudioModification,
  291. DocumentControllerDispatcher::cloneAudioModification,
  292. DocumentControllerDispatcher::updateAudioModificationProperties,
  293. DocumentControllerDispatcher::deactivateAudioModificationForUndoHistory,
  294. DocumentControllerDispatcher::destroyAudioModification,
  295. DocumentControllerDispatcher::createPlaybackRegion,
  296. DocumentControllerDispatcher::updatePlaybackRegionProperties,
  297. DocumentControllerDispatcher::destroyPlaybackRegion,
  298. DocumentControllerDispatcher::isAudioSourceContentAvailable,
  299. DocumentControllerDispatcher::isAudioSourceContentAnalysisIncomplete,
  300. DocumentControllerDispatcher::requestAudioSourceContentAnalysis,
  301. DocumentControllerDispatcher::getAudioSourceContentGrade,
  302. DocumentControllerDispatcher::createAudioSourceContentReader,
  303. DocumentControllerDispatcher::isAudioModificationContentAvailable,
  304. DocumentControllerDispatcher::getAudioModificationContentGrade,
  305. DocumentControllerDispatcher::createAudioModificationContentReader,
  306. DocumentControllerDispatcher::isPlaybackRegionContentAvailable,
  307. DocumentControllerDispatcher::getPlaybackRegionContentGrade,
  308. DocumentControllerDispatcher::createPlaybackRegionContentReader,
  309. DocumentControllerDispatcher::getContentReaderEventCount,
  310. DocumentControllerDispatcher::getContentReaderDataForEvent,
  311. DocumentControllerDispatcher::destroyContentReader,
  312. DocumentControllerDispatcher::createRegionSequence,
  313. DocumentControllerDispatcher::updateRegionSequenceProperties,
  314. DocumentControllerDispatcher::destroyRegionSequence,
  315. DocumentControllerDispatcher::getPlaybackRegionHeadAndTailTime,
  316. DocumentControllerDispatcher::restoreObjectsFromArchive,
  317. DocumentControllerDispatcher::storeObjectsToArchive,
  318. DocumentControllerDispatcher::getProcessingAlgorithmsCount,
  319. DocumentControllerDispatcher::getProcessingAlgorithmProperties,
  320. DocumentControllerDispatcher::getProcessingAlgorithmForAudioSource,
  321. DocumentControllerDispatcher::requestProcessingAlgorithmForAudioSource,
  322. DocumentControllerDispatcher::isLicensedForCapabilities,
  323. DocumentControllerDispatcher::storeAudioSourceToAudioFileChunk
  324. };
  325. return &ifc;
  326. }
  327. }
  328. /*******************************************************************************/
  329. // DocumentControllerInstance
  330. /*******************************************************************************/
  331. DocumentControllerInstance::DocumentControllerInstance (DocumentControllerInterface* documentController) noexcept
  332. : BaseType { toRef (documentController), DocumentControllerDispatcher::getInterface () }
  333. {}
  334. /*******************************************************************************/
  335. // PlaybackRendererDispatcher
  336. /*******************************************************************************/
  337. namespace PlaybackRendererDispatcher
  338. {
  339. static void ARA_CALL addPlaybackRegion (ARAPlaybackRendererRef playbackRendererRef, ARAPlaybackRegionRef playbackRegionRef) noexcept
  340. {
  341. fromRef (playbackRendererRef)->addPlaybackRegion (playbackRegionRef);
  342. }
  343. static void ARA_CALL removePlaybackRegion (ARAPlaybackRendererRef playbackRendererRef, ARAPlaybackRegionRef playbackRegionRef) noexcept
  344. {
  345. fromRef (playbackRendererRef)->removePlaybackRegion (playbackRegionRef);
  346. }
  347. static const ARAPlaybackRendererInterface* getInterface () noexcept
  348. {
  349. static const SizedStruct<ARA_STRUCT_MEMBER (ARAPlaybackRendererInterface, removePlaybackRegion)> ifc =
  350. {
  351. PlaybackRendererDispatcher::addPlaybackRegion,
  352. PlaybackRendererDispatcher::removePlaybackRegion
  353. };
  354. return &ifc;
  355. }
  356. }
  357. /*******************************************************************************/
  358. // EditorRendererDispatcher
  359. /*******************************************************************************/
  360. namespace EditorRendererDispatcher
  361. {
  362. static void ARA_CALL addPlaybackRegion (ARAEditorRendererRef editorRendererRef, ARAPlaybackRegionRef playbackRegionRef) noexcept
  363. {
  364. fromRef (editorRendererRef)->addPlaybackRegion (playbackRegionRef);
  365. }
  366. static void ARA_CALL removePlaybackRegion (ARAEditorRendererRef editorRendererRef, ARAPlaybackRegionRef playbackRegionRef) noexcept
  367. {
  368. fromRef (editorRendererRef)->removePlaybackRegion (playbackRegionRef);
  369. }
  370. static void ARA_CALL addRegionSequence (ARAEditorRendererRef editorRendererRef, ARARegionSequenceRef regionSequenceRef) noexcept
  371. {
  372. fromRef (editorRendererRef)->addRegionSequence (regionSequenceRef);
  373. }
  374. static void ARA_CALL removeRegionSequence (ARAEditorRendererRef editorRendererRef, ARARegionSequenceRef regionSequenceRef) noexcept
  375. {
  376. fromRef (editorRendererRef)->removeRegionSequence (regionSequenceRef);
  377. }
  378. static const ARAEditorRendererInterface* getInterface () noexcept
  379. {
  380. static const SizedStruct<ARA_STRUCT_MEMBER (ARAEditorRendererInterface, removeRegionSequence)> ifc =
  381. {
  382. EditorRendererDispatcher::addPlaybackRegion,
  383. EditorRendererDispatcher::removePlaybackRegion,
  384. EditorRendererDispatcher::addRegionSequence,
  385. EditorRendererDispatcher::removeRegionSequence
  386. };
  387. return &ifc;
  388. }
  389. }
  390. /*******************************************************************************/
  391. // EditorViewDispatcher
  392. /*******************************************************************************/
  393. namespace EditorViewDispatcher
  394. {
  395. static void ARA_CALL notifySelection (ARAEditorViewRef editorViewRef, const ARAViewSelection* selection) noexcept
  396. {
  397. fromRef (editorViewRef)->notifySelection (selection);
  398. }
  399. static void ARA_CALL notifyHideRegionSequences (ARAEditorViewRef editorViewRef, ARASize regionSequenceRefsCount, const ARARegionSequenceRef regionSequenceRefs[]) noexcept
  400. {
  401. fromRef (editorViewRef)->notifyHideRegionSequences (regionSequenceRefsCount, regionSequenceRefs);
  402. }
  403. static const ARAEditorViewInterface* getInterface () noexcept
  404. {
  405. static const SizedStruct<ARA_STRUCT_MEMBER (ARAEditorViewInterface, notifyHideRegionSequences)> ifc =
  406. {
  407. EditorViewDispatcher::notifySelection,
  408. EditorViewDispatcher::notifyHideRegionSequences
  409. };
  410. return &ifc;
  411. }
  412. }
  413. /*******************************************************************************/
  414. // ARA1PlugInExtensionDispatcher
  415. /*******************************************************************************/
  416. #if ARA_SUPPORT_VERSION_1
  417. ARA_MAP_REF (PlugInExtensionInstance, ARAPlugInExtensionRef)
  418. namespace ARA1PlugInExtensionDispatcher
  419. {
  420. static void ARA_CALL setPlaybackRegion (ARAPlugInExtensionRef plugInExtensionRef, ARAPlaybackRegionRef playbackRegionRef) noexcept
  421. {
  422. fromRef (plugInExtensionRef)->setPlaybackRegion (playbackRegionRef);
  423. }
  424. static void ARA_CALL removePlaybackRegion (ARAPlugInExtensionRef plugInExtensionRef, ARAPlaybackRegionRef playbackRegionRef) noexcept
  425. {
  426. fromRef (plugInExtensionRef)->removePlaybackRegion (playbackRegionRef);
  427. }
  428. static const ARAPlugInExtensionInterface* getInterface () noexcept
  429. {
  430. static const SizedStruct<ARA_STRUCT_MEMBER (ARAPlugInExtensionInterface, removePlaybackRegion)> ifc =
  431. {
  432. ARA1PlugInExtensionDispatcher::setPlaybackRegion,
  433. ARA1PlugInExtensionDispatcher::removePlaybackRegion
  434. };
  435. return &ifc;
  436. }
  437. }
  438. #endif
  439. /*******************************************************************************/
  440. // PlugInExtensionInstance
  441. /*******************************************************************************/
  442. PlugInExtensionInstance::PlugInExtensionInstance (PlaybackRendererInterface* playbackRenderer, EditorRendererInterface* editorRenderer, EditorViewInterface* editorView) noexcept
  443. #if ARA_SUPPORT_VERSION_1
  444. : BaseType { toRef (this), ARA1PlugInExtensionDispatcher::getInterface (),
  445. #else
  446. : BaseType { nullptr, nullptr,
  447. #endif
  448. toRef (playbackRenderer), (playbackRenderer) ? PlaybackRendererDispatcher::getInterface () : nullptr,
  449. toRef (editorRenderer), (editorRenderer) ? EditorRendererDispatcher::getInterface () : nullptr,
  450. toRef (editorView), (editorView) ? EditorViewDispatcher::getInterface () : nullptr }
  451. {}
  452. #if ARA_SUPPORT_VERSION_1
  453. void PlugInExtensionInstance::setPlaybackRegion (ARAPlaybackRegionRef playbackRegionRef) noexcept
  454. {
  455. if (_hasPlaybackRegion)
  456. removePlaybackRegion (_playbackRegionRef);
  457. if (getPlaybackRenderer ())
  458. getPlaybackRenderer ()->addPlaybackRegion (playbackRegionRef);
  459. if (getEditorRenderer ())
  460. getEditorRenderer ()->addPlaybackRegion (playbackRegionRef);
  461. _playbackRegionRef = playbackRegionRef;
  462. _hasPlaybackRegion = true;
  463. }
  464. void PlugInExtensionInstance::removePlaybackRegion (ARAPlaybackRegionRef playbackRegionRef) noexcept
  465. {
  466. if (getPlaybackRenderer ())
  467. getPlaybackRenderer ()->removePlaybackRegion (playbackRegionRef);
  468. if (getEditorRenderer ())
  469. getEditorRenderer ()->removePlaybackRegion (playbackRegionRef);
  470. _playbackRegionRef = nullptr;
  471. _hasPlaybackRegion = false;
  472. }
  473. #endif
  474. /*******************************************************************************/
  475. // AudioAccessController
  476. /*******************************************************************************/
  477. ARAAudioReaderHostRef HostAudioAccessController::createAudioReaderForSource (ARAAudioSourceHostRef audioSourceHostRef, bool use64BitSamples) noexcept
  478. {
  479. return getInterface ()->createAudioReaderForSource (getRef (), audioSourceHostRef, (use64BitSamples) ? kARATrue : kARAFalse);
  480. }
  481. bool HostAudioAccessController::readAudioSamples (ARAAudioReaderHostRef audioReaderHostRef,
  482. ARASamplePosition samplePosition, ARASampleCount samplesPerChannel, void* const buffers[]) noexcept
  483. {
  484. return (getInterface ()->readAudioSamples (getRef (), audioReaderHostRef, samplePosition, samplesPerChannel, buffers) != kARAFalse);
  485. }
  486. void HostAudioAccessController::destroyAudioReader (ARAAudioReaderHostRef audioReaderHostRef) noexcept
  487. {
  488. getInterface ()->destroyAudioReader (getRef (), audioReaderHostRef);
  489. }
  490. /*******************************************************************************/
  491. // ArchivingController
  492. /*******************************************************************************/
  493. ARASize HostArchivingController::getArchiveSize (ARAArchiveReaderHostRef archiveReaderHostRef) noexcept
  494. {
  495. return getInterface ()->getArchiveSize (getRef (), archiveReaderHostRef);
  496. }
  497. bool HostArchivingController::readBytesFromArchive (ARAArchiveReaderHostRef archiveReaderHostRef,
  498. ARASize position, ARASize length, ARAByte buffer[]) noexcept
  499. {
  500. return (getInterface ()->readBytesFromArchive (getRef (), archiveReaderHostRef, position, length, buffer) != kARAFalse);
  501. }
  502. bool HostArchivingController::writeBytesToArchive (ARAArchiveWriterHostRef archiveWriterHostRef,
  503. ARASize position, ARASize length, const ARAByte buffer[]) noexcept
  504. {
  505. return (getInterface ()->writeBytesToArchive (getRef (), archiveWriterHostRef, position, length, buffer) != kARAFalse);
  506. }
  507. void HostArchivingController::notifyDocumentArchivingProgress (float value) noexcept
  508. {
  509. getInterface ()->notifyDocumentArchivingProgress (getRef (), value);
  510. }
  511. void HostArchivingController::notifyDocumentUnarchivingProgress (float value) noexcept
  512. {
  513. getInterface ()->notifyDocumentUnarchivingProgress (getRef (), value);
  514. }
  515. ARAPersistentID HostArchivingController::getDocumentArchiveID (ARAArchiveReaderHostRef archiveReaderHostRef) noexcept
  516. {
  517. // getDocumentArchiveID() was added in the ARA 2.0 final release, so check its presence here to support older hosts
  518. if (getInterface ().implements<ARA_STRUCT_MEMBER (ARAArchivingControllerInterface, getDocumentArchiveID)> ())
  519. return getInterface ()->getDocumentArchiveID (getRef (), archiveReaderHostRef);
  520. return nullptr;
  521. }
  522. /*******************************************************************************/
  523. // ContentAccessController
  524. /*******************************************************************************/
  525. bool HostContentAccessController::isMusicalContextContentAvailable (ARAMusicalContextHostRef musicalContextHostRef, ARAContentType contentType) noexcept
  526. {
  527. return (getInterface ()->isMusicalContextContentAvailable (getRef (), musicalContextHostRef, contentType) != kARAFalse);
  528. }
  529. ARAContentGrade HostContentAccessController::getMusicalContextContentGrade (ARAMusicalContextHostRef musicalContextHostRef, ARAContentType contentType) noexcept
  530. {
  531. return getInterface ()->getMusicalContextContentGrade (getRef (), musicalContextHostRef, contentType);
  532. }
  533. ARAContentReaderHostRef HostContentAccessController::createMusicalContextContentReader (ARAMusicalContextHostRef musicalContextHostRef, ARAContentType contentType, const ARAContentTimeRange* range) noexcept
  534. {
  535. return getInterface ()->createMusicalContextContentReader (getRef (), musicalContextHostRef, contentType, range);
  536. }
  537. bool HostContentAccessController::isAudioSourceContentAvailable (ARAAudioSourceHostRef audioSourceHostRef, ARAContentType contentType) noexcept
  538. {
  539. return (getInterface ()->isAudioSourceContentAvailable (getRef (), audioSourceHostRef, contentType) != kARAFalse);
  540. }
  541. ARAContentGrade HostContentAccessController::getAudioSourceContentGrade (ARAAudioSourceHostRef audioSourceHostRef, ARAContentType contentType) noexcept
  542. {
  543. return getInterface ()->getAudioSourceContentGrade (getRef (), audioSourceHostRef, contentType);
  544. }
  545. ARAContentReaderHostRef HostContentAccessController::createAudioSourceContentReader (ARAAudioSourceHostRef audioSourceHostRef, ARAContentType contentType, const ARAContentTimeRange* range) noexcept
  546. {
  547. return getInterface ()->createAudioSourceContentReader (getRef (), audioSourceHostRef, contentType, range);
  548. }
  549. ARAInt32 HostContentAccessController::getContentReaderEventCount (ARAContentReaderHostRef contentReaderHostRef) noexcept
  550. {
  551. return getInterface ()->getContentReaderEventCount (getRef (), contentReaderHostRef);
  552. }
  553. const void* HostContentAccessController::getContentReaderDataForEvent (ARAContentReaderHostRef contentReaderHostRef, ARAInt32 eventIndex) noexcept
  554. {
  555. return getInterface ()->getContentReaderDataForEvent (getRef (), contentReaderHostRef, eventIndex);
  556. }
  557. void HostContentAccessController::destroyContentReader (ARAContentReaderHostRef contentReaderHostRef) noexcept
  558. {
  559. return getInterface ()->destroyContentReader (getRef (), contentReaderHostRef);
  560. }
  561. /*******************************************************************************/
  562. // ModelUpdateController
  563. /*******************************************************************************/
  564. void HostModelUpdateController::notifyAudioSourceAnalysisProgress (ARAAudioSourceHostRef audioSourceHostRef,
  565. ARAAnalysisProgressState state, float value) noexcept
  566. {
  567. getInterface ()->notifyAudioSourceAnalysisProgress (getRef (), audioSourceHostRef, state, value);
  568. }
  569. void HostModelUpdateController::notifyAudioSourceContentChanged (ARAAudioSourceHostRef audioSourceHostRef,
  570. const ARAContentTimeRange* range, ContentUpdateScopes scopeFlags) noexcept
  571. {
  572. getInterface ()->notifyAudioSourceContentChanged (getRef (), audioSourceHostRef, range, scopeFlags);
  573. }
  574. void HostModelUpdateController::notifyAudioModificationContentChanged (ARAAudioModificationHostRef audioModificationHostRef,
  575. const ARAContentTimeRange* range, ContentUpdateScopes scopeFlags) noexcept
  576. {
  577. getInterface ()->notifyAudioModificationContentChanged (getRef (), audioModificationHostRef, range, scopeFlags);
  578. }
  579. void HostModelUpdateController::notifyPlaybackRegionContentChanged (ARAPlaybackRegionHostRef playbackRegionHostRef,
  580. const ARAContentTimeRange* range, ContentUpdateScopes scopeFlags) noexcept
  581. {
  582. // notifyPlaybackRegionContentChanged was optional in the ARA 2.0 draft, so check its presence here to be safe
  583. if (getInterface ().implements<ARA_STRUCT_MEMBER (ARAModelUpdateControllerInterface, notifyPlaybackRegionContentChanged)> ())
  584. getInterface ()->notifyPlaybackRegionContentChanged (getRef (), playbackRegionHostRef, range, scopeFlags);
  585. }
  586. /*******************************************************************************/
  587. // PlaybackController
  588. /*******************************************************************************/
  589. void HostPlaybackController::requestStartPlayback () noexcept
  590. {
  591. getInterface ()->requestStartPlayback (getRef ());
  592. }
  593. void HostPlaybackController::requestStopPlayback () noexcept
  594. {
  595. getInterface ()->requestStopPlayback (getRef ());
  596. }
  597. void HostPlaybackController::requestSetPlaybackPosition (ARATimePosition timePosition) noexcept
  598. {
  599. getInterface ()->requestSetPlaybackPosition (getRef (), timePosition);
  600. }
  601. void HostPlaybackController::requestSetCycleRange (ARATimePosition startTime, ARATimeDuration duration) noexcept
  602. {
  603. getInterface ()->requestSetCycleRange (getRef (), startTime, duration);
  604. }
  605. void HostPlaybackController::requestEnableCycle (bool enable) noexcept
  606. {
  607. getInterface ()->requestEnableCycle (getRef (), (enable) ? kARATrue : kARAFalse);
  608. }
  609. } // namespace PlugIn
  610. } // namespace ARA