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.

974 lines
58KB

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