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.

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