The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

972 lines
57KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. class ARADocumentControllerSpecialisation::ARADocumentControllerImpl : public ARADocumentController,
  21. private juce::Timer
  22. {
  23. public:
  24. ARADocumentControllerImpl (const ARA::PlugIn::PlugInEntry* entry,
  25. const ARA::ARADocumentControllerHostInstance* instance,
  26. ARADocumentControllerSpecialisation* spec)
  27. : ARADocumentController (entry, instance), specialisation (spec)
  28. {
  29. }
  30. template <typename PlaybackRenderer_t = ARAPlaybackRenderer>
  31. std::vector<PlaybackRenderer_t*> const& getPlaybackRenderers() const noexcept
  32. {
  33. return ARA::PlugIn::DocumentController::getPlaybackRenderers<PlaybackRenderer_t>();
  34. }
  35. template <typename EditorRenderer_t = ARAEditorRenderer>
  36. std::vector<EditorRenderer_t*> const& getEditorRenderers() const noexcept
  37. {
  38. return ARA::PlugIn::DocumentController::getEditorRenderers<EditorRenderer_t>();
  39. }
  40. template <typename EditorView_t = ARAEditorView>
  41. std::vector<EditorView_t*> const& getEditorViews() const noexcept
  42. {
  43. return ARA::PlugIn::DocumentController::getEditorViews<EditorView_t>();
  44. }
  45. auto getSpecialisation() { return specialisation; }
  46. protected:
  47. //==============================================================================
  48. bool doRestoreObjectsFromStream (ARAInputStream& input, const ARARestoreObjectsFilter* filter) noexcept
  49. {
  50. return specialisation->doRestoreObjectsFromStream (input, filter);
  51. }
  52. bool doStoreObjectsToStream (ARAOutputStream& output, const ARAStoreObjectsFilter* filter) noexcept
  53. {
  54. return specialisation->doStoreObjectsToStream (output, filter);
  55. }
  56. //==============================================================================
  57. // Model object creation
  58. ARA::PlugIn::Document* doCreateDocument () noexcept override;
  59. ARA::PlugIn::MusicalContext* doCreateMusicalContext (ARA::PlugIn::Document* document, ARA::ARAMusicalContextHostRef hostRef) noexcept override;
  60. ARA::PlugIn::RegionSequence* doCreateRegionSequence (ARA::PlugIn::Document* document, ARA::ARARegionSequenceHostRef hostRef) noexcept override;
  61. ARA::PlugIn::AudioSource* doCreateAudioSource (ARA::PlugIn::Document* document, ARA::ARAAudioSourceHostRef hostRef) noexcept override;
  62. ARA::PlugIn::AudioModification* doCreateAudioModification (ARA::PlugIn::AudioSource* audioSource, ARA::ARAAudioModificationHostRef hostRef, const ARA::PlugIn::AudioModification* optionalModificationToClone) noexcept override;
  63. ARA::PlugIn::PlaybackRegion* doCreatePlaybackRegion (ARA::PlugIn::AudioModification* modification, ARA::ARAPlaybackRegionHostRef hostRef) noexcept override;
  64. //==============================================================================
  65. // Plugin role implementation
  66. friend class ARAPlaybackRegionReader;
  67. ARA::PlugIn::PlaybackRenderer* doCreatePlaybackRenderer() noexcept override;
  68. ARA::PlugIn::EditorRenderer* doCreateEditorRenderer() noexcept override;
  69. ARA::PlugIn::EditorView* doCreateEditorView() noexcept override;
  70. //==============================================================================
  71. // ARAAudioSource content access
  72. bool doIsAudioSourceContentAvailable (const ARA::PlugIn::AudioSource* audioSource,
  73. ARA::ARAContentType type) noexcept override;
  74. ARA::ARAContentGrade doGetAudioSourceContentGrade (const ARA::PlugIn::AudioSource* audioSource,
  75. ARA::ARAContentType type) noexcept override;
  76. ARA::PlugIn::ContentReader* doCreateAudioSourceContentReader (ARA::PlugIn::AudioSource* audioSource,
  77. ARA::ARAContentType type,
  78. const ARA::ARAContentTimeRange* range) noexcept override;
  79. //==============================================================================
  80. // ARAAudioModification content access
  81. bool doIsAudioModificationContentAvailable (const ARA::PlugIn::AudioModification* audioModification,
  82. ARA::ARAContentType type) noexcept override;
  83. ARA::ARAContentGrade doGetAudioModificationContentGrade (const ARA::PlugIn::AudioModification* audioModification,
  84. ARA::ARAContentType type) noexcept override;
  85. ARA::PlugIn::ContentReader* doCreateAudioModificationContentReader (ARA::PlugIn::AudioModification* audioModification,
  86. ARA::ARAContentType type,
  87. const ARA::ARAContentTimeRange* range) noexcept override;
  88. //==============================================================================
  89. // ARAPlaybackRegion content access
  90. bool doIsPlaybackRegionContentAvailable (const ARA::PlugIn::PlaybackRegion* playbackRegion,
  91. ARA::ARAContentType type) noexcept override;
  92. ARA::ARAContentGrade doGetPlaybackRegionContentGrade (const ARA::PlugIn::PlaybackRegion* playbackRegion,
  93. ARA::ARAContentType type) noexcept override;
  94. ARA::PlugIn::ContentReader* doCreatePlaybackRegionContentReader (ARA::PlugIn::PlaybackRegion* playbackRegion,
  95. ARA::ARAContentType type,
  96. const ARA::ARAContentTimeRange* range) noexcept override;
  97. //==============================================================================
  98. // ARAAudioSource analysis
  99. bool doIsAudioSourceContentAnalysisIncomplete (const ARA::PlugIn::AudioSource* audioSource,
  100. ARA::ARAContentType type) noexcept override;
  101. void doRequestAudioSourceContentAnalysis (ARA::PlugIn::AudioSource* audioSource,
  102. std::vector<ARA::ARAContentType> const& contentTypes) noexcept override;
  103. //==============================================================================
  104. // Analysis Algorithm selection
  105. ARA::ARAInt32 doGetProcessingAlgorithmsCount() noexcept override;
  106. const ARA::ARAProcessingAlgorithmProperties* doGetProcessingAlgorithmProperties (ARA::ARAInt32 algorithmIndex) noexcept override;
  107. ARA::ARAInt32 doGetProcessingAlgorithmForAudioSource (const ARA::PlugIn::AudioSource* audioSource) noexcept override;
  108. void doRequestProcessingAlgorithmForAudioSource (ARA::PlugIn::AudioSource* audioSource,
  109. ARA::ARAInt32 algorithmIndex) noexcept override;
  110. #ifndef DOXYGEN
  111. //==============================================================================
  112. bool doRestoreObjectsFromArchive (ARA::PlugIn::HostArchiveReader* archiveReader, const ARA::PlugIn::RestoreObjectsFilter* filter) noexcept override;
  113. bool doStoreObjectsToArchive (ARA::PlugIn::HostArchiveWriter* archiveWriter, const ARA::PlugIn::StoreObjectsFilter* filter) noexcept override;
  114. //==============================================================================
  115. // Document notifications
  116. void willBeginEditing() noexcept override;
  117. void didEndEditing() noexcept override;
  118. void willNotifyModelUpdates() noexcept override;
  119. void didNotifyModelUpdates() noexcept override;
  120. void willUpdateDocumentProperties (ARA::PlugIn::Document* document, ARADocument::PropertiesPtr newProperties) noexcept override;
  121. void didUpdateDocumentProperties (ARA::PlugIn::Document* document) noexcept override;
  122. void didAddMusicalContextToDocument (ARA::PlugIn::Document* document, ARA::PlugIn::MusicalContext* musicalContext) noexcept override;
  123. void willRemoveMusicalContextFromDocument (ARA::PlugIn::Document* document, ARA::PlugIn::MusicalContext* musicalContext) noexcept override;
  124. void didReorderMusicalContextsInDocument (ARA::PlugIn::Document* document) noexcept override;
  125. void didAddRegionSequenceToDocument (ARA::PlugIn::Document* document, ARA::PlugIn::RegionSequence* regionSequence) noexcept override;
  126. void willRemoveRegionSequenceFromDocument (ARA::PlugIn::Document* document, ARA::PlugIn::RegionSequence* regionSequence) noexcept override;
  127. void didReorderRegionSequencesInDocument (ARA::PlugIn::Document* document) noexcept override;
  128. void didAddAudioSourceToDocument (ARA::PlugIn::Document* document, ARA::PlugIn::AudioSource* audioSource) noexcept override;
  129. void willRemoveAudioSourceFromDocument (ARA::PlugIn::Document* document, ARA::PlugIn::AudioSource* audioSource) noexcept override;
  130. void willDestroyDocument (ARA::PlugIn::Document* document) noexcept override;
  131. //==============================================================================
  132. // MusicalContext notifications
  133. void willUpdateMusicalContextProperties (ARA::PlugIn::MusicalContext* musicalContext, ARAMusicalContext::PropertiesPtr newProperties) noexcept override;
  134. void didUpdateMusicalContextProperties (ARA::PlugIn::MusicalContext* musicalContext) noexcept override;
  135. void doUpdateMusicalContextContent (ARA::PlugIn::MusicalContext* musicalContext, const ARA::ARAContentTimeRange* range, ARA::ContentUpdateScopes flags) noexcept override;
  136. void didAddRegionSequenceToMusicalContext (ARA::PlugIn::MusicalContext* musicalContext, ARA::PlugIn::RegionSequence* regionSequence) noexcept override;
  137. void willRemoveRegionSequenceFromMusicalContext (ARA::PlugIn::MusicalContext* musicalContext, ARA::PlugIn::RegionSequence* regionSequence) noexcept override;
  138. void didReorderRegionSequencesInMusicalContext (ARA::PlugIn::MusicalContext* musicalContext) noexcept override;
  139. void willDestroyMusicalContext (ARA::PlugIn::MusicalContext* musicalContext) noexcept override;
  140. //==============================================================================
  141. // RegionSequence notifications, typically not overridden further
  142. void willUpdateRegionSequenceProperties (ARA::PlugIn::RegionSequence* regionSequence, ARARegionSequence::PropertiesPtr newProperties) noexcept override;
  143. void didUpdateRegionSequenceProperties (ARA::PlugIn::RegionSequence* regionSequence) noexcept override;
  144. void didAddPlaybackRegionToRegionSequence (ARA::PlugIn::RegionSequence* regionSequence, ARA::PlugIn::PlaybackRegion* playbackRegion) noexcept override;
  145. void willRemovePlaybackRegionFromRegionSequence (ARA::PlugIn::RegionSequence* regionSequence, ARA::PlugIn::PlaybackRegion* playbackRegion) noexcept override;
  146. void willDestroyRegionSequence (ARA::PlugIn::RegionSequence* regionSequence) noexcept override;
  147. //==============================================================================
  148. // AudioSource notifications
  149. void willUpdateAudioSourceProperties (ARA::PlugIn::AudioSource* audioSource, ARAAudioSource::PropertiesPtr newProperties) noexcept override;
  150. void didUpdateAudioSourceProperties (ARA::PlugIn::AudioSource* audioSource) noexcept override;
  151. void doUpdateAudioSourceContent (ARA::PlugIn::AudioSource* audioSource, const ARA::ARAContentTimeRange* range, ARA::ContentUpdateScopes flags) noexcept override;
  152. void willEnableAudioSourceSamplesAccess (ARA::PlugIn::AudioSource* audioSource, bool enable) noexcept override;
  153. void didEnableAudioSourceSamplesAccess (ARA::PlugIn::AudioSource* audioSource, bool enable) noexcept override;
  154. void didAddAudioModificationToAudioSource (ARA::PlugIn::AudioSource* audioSource, ARA::PlugIn::AudioModification* audioModification) noexcept override;
  155. void willRemoveAudioModificationFromAudioSource (ARA::PlugIn::AudioSource* audioSource, ARA::PlugIn::AudioModification* audioModification) noexcept override;
  156. void willDeactivateAudioSourceForUndoHistory (ARA::PlugIn::AudioSource* audioSource, bool deactivate) noexcept override;
  157. void didDeactivateAudioSourceForUndoHistory (ARA::PlugIn::AudioSource* audioSource, bool deactivate) noexcept override;
  158. void willDestroyAudioSource (ARA::PlugIn::AudioSource* audioSource) noexcept override;
  159. //==============================================================================
  160. // AudioModification notifications
  161. void willUpdateAudioModificationProperties (ARA::PlugIn::AudioModification* audioModification, ARAAudioModification::PropertiesPtr newProperties) noexcept override;
  162. void didUpdateAudioModificationProperties (ARA::PlugIn::AudioModification* audioModification) noexcept override;
  163. void didAddPlaybackRegionToAudioModification (ARA::PlugIn::AudioModification* audioModification, ARA::PlugIn::PlaybackRegion* playbackRegion) noexcept override;
  164. void willRemovePlaybackRegionFromAudioModification (ARA::PlugIn::AudioModification* audioModification, ARA::PlugIn::PlaybackRegion* playbackRegion) noexcept override;
  165. void willDeactivateAudioModificationForUndoHistory (ARA::PlugIn::AudioModification* audioModification, bool deactivate) noexcept override;
  166. void didDeactivateAudioModificationForUndoHistory (ARA::PlugIn::AudioModification* audioModification, bool deactivate) noexcept override;
  167. void willDestroyAudioModification (ARA::PlugIn::AudioModification* audioModification) noexcept override;
  168. //==============================================================================
  169. // PlaybackRegion notifications
  170. void willUpdatePlaybackRegionProperties (ARA::PlugIn::PlaybackRegion* playbackRegion, ARAPlaybackRegion::PropertiesPtr newProperties) noexcept override;
  171. void didUpdatePlaybackRegionProperties (ARA::PlugIn::PlaybackRegion* playbackRegion) noexcept override;
  172. void willDestroyPlaybackRegion (ARA::PlugIn::PlaybackRegion* playbackRegion) noexcept override;
  173. //==============================================================================
  174. // juce::Timer overrides
  175. void timerCallback() override;
  176. public:
  177. //==============================================================================
  178. /** @internal */
  179. void internalNotifyAudioSourceAnalysisProgressStarted (ARAAudioSource* audioSource) override;
  180. /** @internal */
  181. void internalNotifyAudioSourceAnalysisProgressUpdated (ARAAudioSource* audioSource, float progress) override;
  182. /** @internal */
  183. void internalNotifyAudioSourceAnalysisProgressCompleted (ARAAudioSource* audioSource) override;
  184. /** @internal */
  185. void internalDidUpdateAudioSourceAnalysisProgress (ARAAudioSource* audioSource,
  186. ARAAudioSource::ARAAnalysisProgressState state,
  187. float progress) override;
  188. //==============================================================================
  189. /** @internal */
  190. void internalNotifyAudioSourceContentChanged (ARAAudioSource* audioSource,
  191. ARAContentUpdateScopes scopeFlags,
  192. bool notifyARAHost) override;
  193. /** @internal */
  194. void internalNotifyAudioModificationContentChanged (ARAAudioModification* audioModification,
  195. ARAContentUpdateScopes scopeFlags,
  196. bool notifyARAHost) override;
  197. /** @internal */
  198. void internalNotifyPlaybackRegionContentChanged (ARAPlaybackRegion* playbackRegion,
  199. ARAContentUpdateScopes scopeFlags,
  200. bool notifyARAHost) override;
  201. #endif
  202. private:
  203. //==============================================================================
  204. ARADocumentControllerSpecialisation* specialisation;
  205. std::atomic<bool> internalAnalysisProgressIsSynced { true };
  206. ScopedJuceInitialiser_GUI libraryInitialiser;
  207. int activeAudioSourcesCount = 0;
  208. //==============================================================================
  209. template <typename ModelObject, typename Function, typename... Ts>
  210. void notifyListeners (Function ModelObject::Listener::* function, ModelObject* modelObject, Ts... ts)
  211. {
  212. (specialisation->*function) (modelObject, ts...);
  213. modelObject->notifyListeners ([&] (auto& l)
  214. {
  215. try
  216. {
  217. (l.*function) (modelObject, ts...);
  218. }
  219. catch (...)
  220. {
  221. }
  222. });
  223. }
  224. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ARADocumentControllerImpl)
  225. };
  226. ARA::PlugIn::DocumentController* ARADocumentControllerSpecialisation::getDocumentController() noexcept
  227. {
  228. return documentController.get();
  229. }
  230. //==============================================================================
  231. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::internalNotifyAudioSourceAnalysisProgressStarted (ARAAudioSource* audioSource)
  232. {
  233. if (audioSource->internalAnalysisProgressTracker.updateProgress (ARA::kARAAnalysisProgressStarted, 0.0f))
  234. internalAnalysisProgressIsSynced.store (false, std::memory_order_release);
  235. DocumentController::notifyAudioSourceAnalysisProgressStarted (audioSource);
  236. }
  237. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::internalNotifyAudioSourceAnalysisProgressUpdated (ARAAudioSource* audioSource,
  238. float progress)
  239. {
  240. if (audioSource->internalAnalysisProgressTracker.updateProgress (ARA::kARAAnalysisProgressUpdated, progress))
  241. internalAnalysisProgressIsSynced.store (false, std::memory_order_release);
  242. DocumentController::notifyAudioSourceAnalysisProgressUpdated (audioSource, progress);
  243. }
  244. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::internalNotifyAudioSourceAnalysisProgressCompleted (ARAAudioSource* audioSource)
  245. {
  246. if (audioSource->internalAnalysisProgressTracker.updateProgress (ARA::kARAAnalysisProgressCompleted, 1.0f))
  247. internalAnalysisProgressIsSynced.store (false, std::memory_order_release);
  248. DocumentController::notifyAudioSourceAnalysisProgressCompleted (audioSource);
  249. }
  250. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::internalDidUpdateAudioSourceAnalysisProgress (ARAAudioSource* audioSource,
  251. ARAAudioSource::ARAAnalysisProgressState state,
  252. float progress)
  253. {
  254. specialisation->didUpdateAudioSourceAnalysisProgress (audioSource, state, progress);
  255. }
  256. //==============================================================================
  257. ARADocumentControllerSpecialisation* ARADocumentControllerSpecialisation::getSpecialisedDocumentControllerImpl (ARA::PlugIn::DocumentController* dc)
  258. {
  259. return static_cast<ARADocumentControllerImpl*> (dc)->getSpecialisation();
  260. }
  261. ARADocument* ARADocumentControllerSpecialisation::getDocumentImpl()
  262. {
  263. return documentController->getDocument();
  264. }
  265. //==============================================================================
  266. // some helper macros to ease repeated declaration & implementation of notification functions below:
  267. JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wgnu-zero-variadic-macro-arguments")
  268. // no notification arguments
  269. #define OVERRIDE_TO_NOTIFY_1(function, ModelObjectType, modelObject) \
  270. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::function (ARA::PlugIn::ModelObjectType* modelObject) noexcept \
  271. { \
  272. notifyListeners (&ARA##ModelObjectType::Listener::function, static_cast<ARA##ModelObjectType*> (modelObject)); \
  273. }
  274. // single notification argument, model object version
  275. #define OVERRIDE_TO_NOTIFY_2(function, ModelObjectType, modelObject, ArgumentType, argument) \
  276. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::function (ARA::PlugIn::ModelObjectType* modelObject, ARA::PlugIn::ArgumentType argument) noexcept \
  277. { \
  278. notifyListeners (&ARA##ModelObjectType::Listener::function, static_cast<ARA##ModelObjectType*> (modelObject), static_cast<ARA##ArgumentType> (argument)); \
  279. }
  280. // single notification argument, non-model object version
  281. #define OVERRIDE_TO_NOTIFY_3(function, ModelObjectType, modelObject, ArgumentType, argument) \
  282. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::function (ARA::PlugIn::ModelObjectType* modelObject, ArgumentType argument) noexcept \
  283. { \
  284. notifyListeners (&ARA##ModelObjectType::Listener::function, static_cast<ARA##ModelObjectType*> (modelObject), argument); \
  285. }
  286. //==============================================================================
  287. ARA::PlugIn::Document* ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doCreateDocument() noexcept
  288. {
  289. auto* document = specialisation->doCreateDocument();
  290. // Your Document subclass must inherit from juce::ARADocument
  291. jassert (dynamic_cast<ARADocument*> (document));
  292. return document;
  293. }
  294. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::willBeginEditing() noexcept
  295. {
  296. notifyListeners (&ARADocument::Listener::willBeginEditing, static_cast<ARADocument*> (getDocument()));
  297. }
  298. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::didEndEditing() noexcept
  299. {
  300. notifyListeners (&ARADocument::Listener::didEndEditing, static_cast<ARADocument*> (getDocument()));
  301. if (isTimerRunning() && (activeAudioSourcesCount == 0))
  302. stopTimer();
  303. else if (! isTimerRunning() && (activeAudioSourcesCount > 0))
  304. startTimerHz (20);
  305. }
  306. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::willNotifyModelUpdates() noexcept
  307. {
  308. notifyListeners (&ARADocument::Listener::willNotifyModelUpdates, static_cast<ARADocument*> (getDocument()));
  309. }
  310. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::didNotifyModelUpdates() noexcept
  311. {
  312. notifyListeners (&ARADocument::Listener::didNotifyModelUpdates, static_cast<ARADocument*> (getDocument()));
  313. }
  314. //==============================================================================
  315. bool ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doRestoreObjectsFromArchive (ARA::PlugIn::HostArchiveReader* archiveReader,
  316. const ARA::PlugIn::RestoreObjectsFilter* filter) noexcept
  317. {
  318. ARAInputStream reader (archiveReader);
  319. return doRestoreObjectsFromStream (reader, filter);
  320. }
  321. bool ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doStoreObjectsToArchive (ARA::PlugIn::HostArchiveWriter* archiveWriter,
  322. const ARA::PlugIn::StoreObjectsFilter* filter) noexcept
  323. {
  324. ARAOutputStream writer (archiveWriter);
  325. return doStoreObjectsToStream (writer, filter);
  326. }
  327. //==============================================================================
  328. OVERRIDE_TO_NOTIFY_3 (willUpdateDocumentProperties, Document, document, ARADocument::PropertiesPtr, newProperties)
  329. OVERRIDE_TO_NOTIFY_1 (didUpdateDocumentProperties, Document, document)
  330. OVERRIDE_TO_NOTIFY_2 (didAddMusicalContextToDocument, Document, document, MusicalContext*, musicalContext)
  331. OVERRIDE_TO_NOTIFY_2 (willRemoveMusicalContextFromDocument, Document, document, MusicalContext*, musicalContext)
  332. OVERRIDE_TO_NOTIFY_1 (didReorderMusicalContextsInDocument, Document, document)
  333. OVERRIDE_TO_NOTIFY_2 (didAddRegionSequenceToDocument, Document, document, RegionSequence*, regionSequence)
  334. OVERRIDE_TO_NOTIFY_2 (willRemoveRegionSequenceFromDocument, Document, document, RegionSequence*, regionSequence)
  335. OVERRIDE_TO_NOTIFY_1 (didReorderRegionSequencesInDocument, Document, document)
  336. OVERRIDE_TO_NOTIFY_2 (didAddAudioSourceToDocument, Document, document, AudioSource*, audioSource)
  337. OVERRIDE_TO_NOTIFY_2 (willRemoveAudioSourceFromDocument, Document, document, AudioSource*, audioSource)
  338. OVERRIDE_TO_NOTIFY_1 (willDestroyDocument, Document, document)
  339. //==============================================================================
  340. ARA::PlugIn::MusicalContext* ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doCreateMusicalContext (ARA::PlugIn::Document* document,
  341. ARA::ARAMusicalContextHostRef hostRef) noexcept
  342. {
  343. return specialisation->doCreateMusicalContext (static_cast<ARADocument*> (document), hostRef);
  344. }
  345. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doUpdateMusicalContextContent (ARA::PlugIn::MusicalContext* musicalContext,
  346. const ARA::ARAContentTimeRange*,
  347. ARA::ContentUpdateScopes flags) noexcept
  348. {
  349. notifyListeners (&ARAMusicalContext::Listener::doUpdateMusicalContextContent,
  350. static_cast<ARAMusicalContext*> (musicalContext),
  351. flags);
  352. }
  353. OVERRIDE_TO_NOTIFY_3 (willUpdateMusicalContextProperties, MusicalContext, musicalContext, ARAMusicalContext::PropertiesPtr, newProperties)
  354. OVERRIDE_TO_NOTIFY_1 (didUpdateMusicalContextProperties, MusicalContext, musicalContext)
  355. OVERRIDE_TO_NOTIFY_2 (didAddRegionSequenceToMusicalContext, MusicalContext, musicalContext, RegionSequence*, regionSequence)
  356. OVERRIDE_TO_NOTIFY_2 (willRemoveRegionSequenceFromMusicalContext, MusicalContext, musicalContext, RegionSequence*, regionSequence)
  357. OVERRIDE_TO_NOTIFY_1 (didReorderRegionSequencesInMusicalContext, MusicalContext, musicalContext)
  358. OVERRIDE_TO_NOTIFY_1 (willDestroyMusicalContext, MusicalContext, musicalContext)
  359. //==============================================================================
  360. ARA::PlugIn::RegionSequence* ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doCreateRegionSequence (ARA::PlugIn::Document* document, ARA::ARARegionSequenceHostRef hostRef) noexcept
  361. {
  362. return specialisation->doCreateRegionSequence (static_cast<ARADocument*> (document), hostRef);
  363. }
  364. OVERRIDE_TO_NOTIFY_3 (willUpdateRegionSequenceProperties, RegionSequence, regionSequence, ARARegionSequence::PropertiesPtr, newProperties)
  365. OVERRIDE_TO_NOTIFY_1 (didUpdateRegionSequenceProperties, RegionSequence, regionSequence)
  366. OVERRIDE_TO_NOTIFY_2 (didAddPlaybackRegionToRegionSequence, RegionSequence, regionSequence, PlaybackRegion*, playbackRegion)
  367. OVERRIDE_TO_NOTIFY_2 (willRemovePlaybackRegionFromRegionSequence, RegionSequence, regionSequence, PlaybackRegion*, playbackRegion)
  368. OVERRIDE_TO_NOTIFY_1 (willDestroyRegionSequence, RegionSequence, regionSequence)
  369. //==============================================================================
  370. ARA::PlugIn::AudioSource* ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doCreateAudioSource (ARA::PlugIn::Document* document, ARA::ARAAudioSourceHostRef hostRef) noexcept
  371. {
  372. ++activeAudioSourcesCount;
  373. return specialisation->doCreateAudioSource (static_cast<ARADocument*> (document), hostRef);
  374. }
  375. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doUpdateAudioSourceContent (ARA::PlugIn::AudioSource* audioSource,
  376. const ARA::ARAContentTimeRange*,
  377. ARA::ContentUpdateScopes flags) noexcept
  378. {
  379. notifyListeners (&ARAAudioSource::Listener::doUpdateAudioSourceContent, static_cast<ARAAudioSource*> (audioSource), flags);
  380. }
  381. OVERRIDE_TO_NOTIFY_3 (willUpdateAudioSourceProperties, AudioSource, audioSource, ARAAudioSource::PropertiesPtr, newProperties)
  382. OVERRIDE_TO_NOTIFY_1 (didUpdateAudioSourceProperties, AudioSource, audioSource)
  383. OVERRIDE_TO_NOTIFY_3 (willEnableAudioSourceSamplesAccess, AudioSource, audioSource, bool, enable)
  384. OVERRIDE_TO_NOTIFY_3 (didEnableAudioSourceSamplesAccess, AudioSource, audioSource, bool, enable)
  385. OVERRIDE_TO_NOTIFY_2 (didAddAudioModificationToAudioSource, AudioSource, audioSource, AudioModification*, audioModification)
  386. OVERRIDE_TO_NOTIFY_2 (willRemoveAudioModificationFromAudioSource, AudioSource, audioSource, AudioModification*, audioModification)
  387. OVERRIDE_TO_NOTIFY_3 (willDeactivateAudioSourceForUndoHistory, AudioSource, audioSource, bool, deactivate)
  388. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::didDeactivateAudioSourceForUndoHistory (ARA::PlugIn::AudioSource* audioSource,
  389. bool deactivate) noexcept
  390. {
  391. activeAudioSourcesCount += (deactivate ? -1 : 1);
  392. notifyListeners (&ARAAudioSource::Listener::didDeactivateAudioSourceForUndoHistory,
  393. static_cast<ARAAudioSource*> (audioSource),
  394. deactivate);
  395. }
  396. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::willDestroyAudioSource (ARA::PlugIn::AudioSource* audioSource) noexcept
  397. {
  398. if (! audioSource->isDeactivatedForUndoHistory())
  399. --activeAudioSourcesCount;
  400. notifyListeners (&ARAAudioSource::Listener::willDestroyAudioSource, static_cast<ARAAudioSource*> (audioSource));
  401. }
  402. //==============================================================================
  403. ARA::PlugIn::AudioModification* ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doCreateAudioModification (ARA::PlugIn::AudioSource* audioSource,
  404. ARA::ARAAudioModificationHostRef hostRef,
  405. const ARA::PlugIn::AudioModification* optionalModificationToClone) noexcept
  406. {
  407. return specialisation->doCreateAudioModification (static_cast<ARAAudioSource*> (audioSource),
  408. hostRef,
  409. static_cast<const ARAAudioModification*> (optionalModificationToClone));
  410. }
  411. OVERRIDE_TO_NOTIFY_3 (willUpdateAudioModificationProperties, AudioModification, audioModification, ARAAudioModification::PropertiesPtr, newProperties)
  412. OVERRIDE_TO_NOTIFY_1 (didUpdateAudioModificationProperties, AudioModification, audioModification)
  413. OVERRIDE_TO_NOTIFY_2 (didAddPlaybackRegionToAudioModification, AudioModification, audioModification, PlaybackRegion*, playbackRegion)
  414. OVERRIDE_TO_NOTIFY_2 (willRemovePlaybackRegionFromAudioModification, AudioModification, audioModification, PlaybackRegion*, playbackRegion)
  415. OVERRIDE_TO_NOTIFY_3 (willDeactivateAudioModificationForUndoHistory, AudioModification, audioModification, bool, deactivate)
  416. OVERRIDE_TO_NOTIFY_3 (didDeactivateAudioModificationForUndoHistory, AudioModification, audioModification, bool, deactivate)
  417. OVERRIDE_TO_NOTIFY_1 (willDestroyAudioModification, AudioModification, audioModification)
  418. //==============================================================================
  419. ARA::PlugIn::PlaybackRegion* ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doCreatePlaybackRegion (ARA::PlugIn::AudioModification* modification,
  420. ARA::ARAPlaybackRegionHostRef hostRef) noexcept
  421. {
  422. return specialisation->doCreatePlaybackRegion (static_cast<ARAAudioModification*> (modification), hostRef);
  423. }
  424. OVERRIDE_TO_NOTIFY_3 (willUpdatePlaybackRegionProperties, PlaybackRegion, playbackRegion, ARAPlaybackRegion::PropertiesPtr, newProperties)
  425. OVERRIDE_TO_NOTIFY_1 (didUpdatePlaybackRegionProperties, PlaybackRegion, playbackRegion)
  426. OVERRIDE_TO_NOTIFY_1 (willDestroyPlaybackRegion, PlaybackRegion, playbackRegion)
  427. //==============================================================================
  428. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::internalNotifyAudioSourceContentChanged (ARAAudioSource* audioSource,
  429. ARAContentUpdateScopes scopeFlags,
  430. bool notifyARAHost)
  431. {
  432. if (notifyARAHost)
  433. DocumentController::notifyAudioSourceContentChanged (audioSource, scopeFlags);
  434. notifyListeners (&ARAAudioSource::Listener::doUpdateAudioSourceContent, audioSource, scopeFlags);
  435. }
  436. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::internalNotifyAudioModificationContentChanged (ARAAudioModification* audioModification,
  437. ARAContentUpdateScopes scopeFlags,
  438. bool notifyARAHost)
  439. {
  440. if (notifyARAHost)
  441. DocumentController::notifyAudioModificationContentChanged (audioModification, scopeFlags);
  442. notifyListeners (&ARAAudioModification::Listener::didUpdateAudioModificationContent, audioModification, scopeFlags);
  443. }
  444. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::internalNotifyPlaybackRegionContentChanged (ARAPlaybackRegion* playbackRegion,
  445. ARAContentUpdateScopes scopeFlags,
  446. bool notifyARAHost)
  447. {
  448. if (notifyARAHost)
  449. DocumentController::notifyPlaybackRegionContentChanged (playbackRegion, scopeFlags);
  450. notifyListeners (&ARAPlaybackRegion::Listener::didUpdatePlaybackRegionContent, playbackRegion, scopeFlags);
  451. }
  452. //==============================================================================
  453. JUCE_END_IGNORE_WARNINGS_GCC_LIKE
  454. #undef OVERRIDE_TO_NOTIFY_1
  455. #undef OVERRIDE_TO_NOTIFY_2
  456. #undef OVERRIDE_TO_NOTIFY_3
  457. //==============================================================================
  458. ARADocument* ARADocumentControllerSpecialisation::doCreateDocument()
  459. {
  460. return new ARADocument (static_cast<ARADocumentControllerImpl*> (getDocumentController()));
  461. }
  462. ARAMusicalContext* ARADocumentControllerSpecialisation::doCreateMusicalContext (ARADocument* document,
  463. ARA::ARAMusicalContextHostRef hostRef)
  464. {
  465. return new ARAMusicalContext (static_cast<ARADocument*> (document), hostRef);
  466. }
  467. ARARegionSequence* ARADocumentControllerSpecialisation::doCreateRegionSequence (ARADocument* document,
  468. ARA::ARARegionSequenceHostRef hostRef)
  469. {
  470. return new ARARegionSequence (static_cast<ARADocument*> (document), hostRef);
  471. }
  472. ARAAudioSource* ARADocumentControllerSpecialisation::doCreateAudioSource (ARADocument* document,
  473. ARA::ARAAudioSourceHostRef hostRef)
  474. {
  475. return new ARAAudioSource (static_cast<ARADocument*> (document), hostRef);
  476. }
  477. ARAAudioModification* ARADocumentControllerSpecialisation::doCreateAudioModification (
  478. ARAAudioSource* audioSource,
  479. ARA::ARAAudioModificationHostRef hostRef,
  480. const ARAAudioModification* optionalModificationToClone)
  481. {
  482. return new ARAAudioModification (static_cast<ARAAudioSource*> (audioSource),
  483. hostRef,
  484. static_cast<const ARAAudioModification*> (optionalModificationToClone));
  485. }
  486. ARAPlaybackRegion*
  487. ARADocumentControllerSpecialisation::doCreatePlaybackRegion (ARAAudioModification* modification,
  488. ARA::ARAPlaybackRegionHostRef hostRef)
  489. {
  490. return new ARAPlaybackRegion (static_cast<ARAAudioModification*> (modification), hostRef);
  491. }
  492. //==============================================================================
  493. ARA::PlugIn::PlaybackRenderer* ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doCreatePlaybackRenderer() noexcept
  494. {
  495. return specialisation->doCreatePlaybackRenderer();
  496. }
  497. ARA::PlugIn::EditorRenderer* ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doCreateEditorRenderer() noexcept
  498. {
  499. return specialisation->doCreateEditorRenderer();
  500. }
  501. ARA::PlugIn::EditorView* ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doCreateEditorView() noexcept
  502. {
  503. return specialisation->doCreateEditorView();
  504. }
  505. bool ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doIsAudioSourceContentAvailable (const ARA::PlugIn::AudioSource* audioSource,
  506. ARA::ARAContentType type) noexcept
  507. {
  508. return specialisation->doIsAudioSourceContentAvailable (audioSource, type);
  509. }
  510. ARA::ARAContentGrade ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doGetAudioSourceContentGrade (const ARA::PlugIn::AudioSource* audioSource,
  511. ARA::ARAContentType type) noexcept
  512. {
  513. return specialisation->doGetAudioSourceContentGrade (audioSource, type);
  514. }
  515. ARA::PlugIn::ContentReader* ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doCreateAudioSourceContentReader (ARA::PlugIn::AudioSource* audioSource,
  516. ARA::ARAContentType type,
  517. const ARA::ARAContentTimeRange* range) noexcept
  518. {
  519. return specialisation->doCreateAudioSourceContentReader (audioSource, type, range);
  520. }
  521. bool ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doIsAudioModificationContentAvailable (const ARA::PlugIn::AudioModification* audioModification,
  522. ARA::ARAContentType type) noexcept
  523. {
  524. return specialisation->doIsAudioModificationContentAvailable (audioModification, type);
  525. }
  526. ARA::ARAContentGrade ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doGetAudioModificationContentGrade (const ARA::PlugIn::AudioModification* audioModification,
  527. ARA::ARAContentType type) noexcept
  528. {
  529. return specialisation->doGetAudioModificationContentGrade (audioModification, type);
  530. }
  531. ARA::PlugIn::ContentReader* ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doCreateAudioModificationContentReader (ARA::PlugIn::AudioModification* audioModification,
  532. ARA::ARAContentType type,
  533. const ARA::ARAContentTimeRange* range) noexcept
  534. {
  535. return specialisation->doCreateAudioModificationContentReader (audioModification, type, range);
  536. }
  537. bool ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doIsPlaybackRegionContentAvailable (const ARA::PlugIn::PlaybackRegion* playbackRegion,
  538. ARA::ARAContentType type) noexcept
  539. {
  540. return specialisation->doIsPlaybackRegionContentAvailable (playbackRegion, type);
  541. }
  542. ARA::ARAContentGrade
  543. ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doGetPlaybackRegionContentGrade (const ARA::PlugIn::PlaybackRegion* playbackRegion,
  544. ARA::ARAContentType type) noexcept
  545. {
  546. return specialisation->doGetPlaybackRegionContentGrade (playbackRegion, type);
  547. }
  548. ARA::PlugIn::ContentReader* ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doCreatePlaybackRegionContentReader (ARA::PlugIn::PlaybackRegion* playbackRegion,
  549. ARA::ARAContentType type,
  550. const ARA::ARAContentTimeRange* range) noexcept
  551. {
  552. return specialisation->doCreatePlaybackRegionContentReader (playbackRegion, type, range);
  553. }
  554. bool ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doIsAudioSourceContentAnalysisIncomplete (const ARA::PlugIn::AudioSource* audioSource,
  555. ARA::ARAContentType type) noexcept
  556. {
  557. return specialisation->doIsAudioSourceContentAnalysisIncomplete (audioSource, type);
  558. }
  559. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doRequestAudioSourceContentAnalysis (ARA::PlugIn::AudioSource* audioSource,
  560. std::vector<ARA::ARAContentType> const& contentTypes) noexcept
  561. {
  562. specialisation->doRequestAudioSourceContentAnalysis (audioSource, contentTypes);
  563. }
  564. ARA::ARAInt32 ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doGetProcessingAlgorithmsCount() noexcept
  565. {
  566. return specialisation->doGetProcessingAlgorithmsCount();
  567. }
  568. const ARA::ARAProcessingAlgorithmProperties* ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doGetProcessingAlgorithmProperties (ARA::ARAInt32 algorithmIndex) noexcept
  569. {
  570. return specialisation->doGetProcessingAlgorithmProperties (algorithmIndex);
  571. }
  572. ARA::ARAInt32 ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doGetProcessingAlgorithmForAudioSource (const ARA::PlugIn::AudioSource* audioSource) noexcept
  573. {
  574. return specialisation->doGetProcessingAlgorithmForAudioSource (audioSource);
  575. }
  576. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::doRequestProcessingAlgorithmForAudioSource (ARA::PlugIn::AudioSource* audioSource,
  577. ARA::ARAInt32 algorithmIndex) noexcept
  578. {
  579. return specialisation->doRequestProcessingAlgorithmForAudioSource (audioSource, algorithmIndex);
  580. }
  581. //==============================================================================
  582. // Helper code for ARADocumentControllerSpecialisation::ARADocumentControllerImpl::timerCallback() to
  583. // rewire the host-related ARA SDK's progress tracker to our internal update mechanism.
  584. namespace ModelUpdateControllerProgressAdapter
  585. {
  586. using namespace ARA;
  587. static void ARA_CALL notifyAudioSourceAnalysisProgress (ARAModelUpdateControllerHostRef /*controllerHostRef*/,
  588. ARAAudioSourceHostRef audioSourceHostRef, ARAAnalysisProgressState state, float value) noexcept
  589. {
  590. auto audioSource = reinterpret_cast<ARAAudioSource*> (audioSourceHostRef);
  591. audioSource->getDocumentController<ARADocumentController>()->internalDidUpdateAudioSourceAnalysisProgress (audioSource, state, value);
  592. audioSource->notifyListeners ([&] (ARAAudioSource::Listener& l) { l.didUpdateAudioSourceAnalysisProgress (audioSource, state, value); });
  593. }
  594. static void ARA_CALL notifyAudioSourceContentChanged (ARAModelUpdateControllerHostRef, ARAAudioSourceHostRef,
  595. const ARAContentTimeRange*, ARAContentUpdateFlags) noexcept
  596. {
  597. jassertfalse; // not to be called - this adapter only forwards analysis progress
  598. }
  599. static void ARA_CALL notifyAudioModificationContentChanged (ARAModelUpdateControllerHostRef, ARAAudioModificationHostRef,
  600. const ARAContentTimeRange*, ARAContentUpdateFlags) noexcept
  601. {
  602. jassertfalse; // not to be called - this adapter only forwards analysis progress
  603. }
  604. static void ARA_CALL notifyPlaybackRegionContentChanged (ARAModelUpdateControllerHostRef, ARAPlaybackRegionHostRef,
  605. const ARAContentTimeRange*, ARAContentUpdateFlags) noexcept
  606. {
  607. jassertfalse; // not to be called - this adapter only forwards analysis progress
  608. }
  609. static ARA::PlugIn::HostModelUpdateController* get()
  610. {
  611. static const auto modelUpdateControllerInterface = makeARASizedStruct (&ARA::ARAModelUpdateControllerInterface::notifyPlaybackRegionContentChanged,
  612. ModelUpdateControllerProgressAdapter::notifyAudioSourceAnalysisProgress,
  613. ModelUpdateControllerProgressAdapter::notifyAudioSourceContentChanged,
  614. ModelUpdateControllerProgressAdapter::notifyAudioModificationContentChanged,
  615. ModelUpdateControllerProgressAdapter::notifyPlaybackRegionContentChanged);
  616. static const auto instance = makeARASizedStruct (&ARA::ARADocumentControllerHostInstance::playbackControllerInterface,
  617. nullptr,
  618. nullptr,
  619. nullptr,
  620. nullptr,
  621. nullptr,
  622. nullptr,
  623. nullptr,
  624. &modelUpdateControllerInterface,
  625. nullptr,
  626. nullptr);
  627. static auto progressAdapter = ARA::PlugIn::HostModelUpdateController { &instance };
  628. return &progressAdapter;
  629. }
  630. }
  631. void ARADocumentControllerSpecialisation::ARADocumentControllerImpl::timerCallback()
  632. {
  633. if (! internalAnalysisProgressIsSynced.exchange (true, std::memory_order_release))
  634. for (auto& audioSource : getDocument()->getAudioSources())
  635. audioSource->internalAnalysisProgressTracker.notifyProgress (ModelUpdateControllerProgressAdapter::get(),
  636. reinterpret_cast<ARA::ARAAudioSourceHostRef> (audioSource));
  637. }
  638. //==============================================================================
  639. ARAInputStream::ARAInputStream (ARA::PlugIn::HostArchiveReader* reader)
  640. : archiveReader (reader),
  641. size ((int64) reader->getArchiveSize())
  642. {}
  643. int ARAInputStream::read (void* destBuffer, int maxBytesToRead)
  644. {
  645. const auto bytesToRead = std::min ((int64) maxBytesToRead, size - position);
  646. if (bytesToRead > 0 && ! archiveReader->readBytesFromArchive ((ARA::ARASize) position, (ARA::ARASize) bytesToRead,
  647. static_cast<ARA::ARAByte*> (destBuffer)))
  648. {
  649. failure = true;
  650. return 0;
  651. }
  652. position += bytesToRead;
  653. return (int) bytesToRead;
  654. }
  655. bool ARAInputStream::setPosition (int64 newPosition)
  656. {
  657. position = jlimit ((int64) 0, size, newPosition);
  658. return true;
  659. }
  660. bool ARAInputStream::isExhausted()
  661. {
  662. return position >= size;
  663. }
  664. ARAOutputStream::ARAOutputStream (ARA::PlugIn::HostArchiveWriter* writer)
  665. : archiveWriter (writer)
  666. {}
  667. bool ARAOutputStream::write (const void* dataToWrite, size_t numberOfBytes)
  668. {
  669. if (! archiveWriter->writeBytesToArchive ((ARA::ARASize) position, numberOfBytes, (const ARA::ARAByte*) dataToWrite))
  670. return false;
  671. position += numberOfBytes;
  672. return true;
  673. }
  674. bool ARAOutputStream::setPosition (int64 newPosition)
  675. {
  676. position = newPosition;
  677. return true;
  678. }
  679. //==============================================================================
  680. ARADocumentControllerSpecialisation::ARADocumentControllerSpecialisation (
  681. const ARA::PlugIn::PlugInEntry* entry,
  682. const ARA::ARADocumentControllerHostInstance* instance)
  683. : documentController (std::make_unique<ARADocumentControllerImpl> (entry, instance, this))
  684. {
  685. }
  686. ARADocumentControllerSpecialisation::~ARADocumentControllerSpecialisation() = default;
  687. ARAPlaybackRenderer* ARADocumentControllerSpecialisation::doCreatePlaybackRenderer()
  688. {
  689. return new ARAPlaybackRenderer (getDocumentController());
  690. }
  691. ARAEditorRenderer* ARADocumentControllerSpecialisation::doCreateEditorRenderer()
  692. {
  693. return new ARAEditorRenderer (getDocumentController());
  694. }
  695. ARAEditorView* ARADocumentControllerSpecialisation::doCreateEditorView()
  696. {
  697. return new ARAEditorView (getDocumentController());
  698. }
  699. bool ARADocumentControllerSpecialisation::doIsAudioSourceContentAvailable (const ARA::PlugIn::AudioSource* audioSource,
  700. ARA::ARAContentType type)
  701. {
  702. juce::ignoreUnused (audioSource, type);
  703. return false;
  704. }
  705. ARA::ARAContentGrade ARADocumentControllerSpecialisation::doGetAudioSourceContentGrade (const ARA::PlugIn::AudioSource* audioSource,
  706. ARA::ARAContentType type)
  707. {
  708. // Overriding doIsAudioSourceContentAvailable() requires overriding
  709. // doGetAudioSourceContentGrade() accordingly!
  710. jassertfalse;
  711. juce::ignoreUnused (audioSource, type);
  712. return ARA::kARAContentGradeInitial;
  713. }
  714. ARA::PlugIn::ContentReader* ARADocumentControllerSpecialisation::doCreateAudioSourceContentReader (ARA::PlugIn::AudioSource* audioSource,
  715. ARA::ARAContentType type,
  716. const ARA::ARAContentTimeRange* range)
  717. {
  718. // Overriding doIsAudioSourceContentAvailable() requires overriding
  719. // doCreateAudioSourceContentReader() accordingly!
  720. jassertfalse;
  721. juce::ignoreUnused (audioSource, type, range);
  722. return nullptr;
  723. }
  724. bool ARADocumentControllerSpecialisation::doIsAudioModificationContentAvailable (const ARA::PlugIn::AudioModification* audioModification,
  725. ARA::ARAContentType type)
  726. {
  727. juce::ignoreUnused (audioModification, type);
  728. return false;
  729. }
  730. ARA::ARAContentGrade ARADocumentControllerSpecialisation::doGetAudioModificationContentGrade (const ARA::PlugIn::AudioModification* audioModification,
  731. ARA::ARAContentType type)
  732. {
  733. // Overriding doIsAudioModificationContentAvailable() requires overriding
  734. // doGetAudioModificationContentGrade() accordingly!
  735. jassertfalse;
  736. juce::ignoreUnused (audioModification, type);
  737. return ARA::kARAContentGradeInitial;
  738. }
  739. ARA::PlugIn::ContentReader* ARADocumentControllerSpecialisation::doCreateAudioModificationContentReader (ARA::PlugIn::AudioModification* audioModification,
  740. ARA::ARAContentType type,
  741. const ARA::ARAContentTimeRange* range)
  742. {
  743. // Overriding doIsAudioModificationContentAvailable() requires overriding
  744. // doCreateAudioModificationContentReader() accordingly!
  745. jassertfalse;
  746. juce::ignoreUnused (audioModification, type, range);
  747. return nullptr;
  748. }
  749. bool ARADocumentControllerSpecialisation::doIsPlaybackRegionContentAvailable (const ARA::PlugIn::PlaybackRegion* playbackRegion,
  750. ARA::ARAContentType type)
  751. {
  752. juce::ignoreUnused (playbackRegion, type);
  753. return false;
  754. }
  755. ARA::ARAContentGrade ARADocumentControllerSpecialisation::doGetPlaybackRegionContentGrade (const ARA::PlugIn::PlaybackRegion* playbackRegion,
  756. ARA::ARAContentType type)
  757. {
  758. // Overriding doIsPlaybackRegionContentAvailable() requires overriding
  759. // doGetPlaybackRegionContentGrade() accordingly!
  760. jassertfalse;
  761. juce::ignoreUnused (playbackRegion, type);
  762. return ARA::kARAContentGradeInitial;
  763. }
  764. ARA::PlugIn::ContentReader* ARADocumentControllerSpecialisation::doCreatePlaybackRegionContentReader (ARA::PlugIn::PlaybackRegion* playbackRegion,
  765. ARA::ARAContentType type,
  766. const ARA::ARAContentTimeRange* range)
  767. {
  768. // Overriding doIsPlaybackRegionContentAvailable() requires overriding
  769. // doCreatePlaybackRegionContentReader() accordingly!
  770. jassertfalse;
  771. juce::ignoreUnused (playbackRegion, type, range);
  772. return nullptr;
  773. }
  774. bool ARADocumentControllerSpecialisation::doIsAudioSourceContentAnalysisIncomplete (const ARA::PlugIn::AudioSource* audioSource,
  775. ARA::ARAContentType type)
  776. {
  777. juce::ignoreUnused (audioSource, type);
  778. return false;
  779. }
  780. void ARADocumentControllerSpecialisation::doRequestAudioSourceContentAnalysis (ARA::PlugIn::AudioSource* audioSource,
  781. std::vector<ARA::ARAContentType> const& contentTypes)
  782. {
  783. juce::ignoreUnused (audioSource, contentTypes);
  784. }
  785. ARA::ARAInt32 ARADocumentControllerSpecialisation::doGetProcessingAlgorithmsCount() { return 0; }
  786. const ARA::ARAProcessingAlgorithmProperties*
  787. ARADocumentControllerSpecialisation::doGetProcessingAlgorithmProperties (ARA::ARAInt32 algorithmIndex)
  788. {
  789. juce::ignoreUnused (algorithmIndex);
  790. return nullptr;
  791. }
  792. ARA::ARAInt32 ARADocumentControllerSpecialisation::doGetProcessingAlgorithmForAudioSource (const ARA::PlugIn::AudioSource* audioSource)
  793. {
  794. // doGetProcessingAlgorithmForAudioSource() must be implemented if the supported
  795. // algorithm count is greater than zero.
  796. if (getDocumentController()->getProcessingAlgorithmsCount() > 0)
  797. jassertfalse;
  798. juce::ignoreUnused (audioSource);
  799. return 0;
  800. }
  801. void ARADocumentControllerSpecialisation::doRequestProcessingAlgorithmForAudioSource (ARA::PlugIn::AudioSource* audioSource,
  802. ARA::ARAInt32 algorithmIndex)
  803. {
  804. // doRequestProcessingAlgorithmForAudioSource() must be implemented if the supported
  805. // algorithm count is greater than zero.
  806. if (getDocumentController()->getProcessingAlgorithmsCount() > 0)
  807. jassertfalse;
  808. juce::ignoreUnused (audioSource, algorithmIndex);
  809. }
  810. } // namespace juce