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.

965 lines
57KB

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