28#if (JUCE_PLUGINHOST_ARA && (JUCE_PLUGINHOST_VST3 || JUCE_PLUGINHOST_AU) && (JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX)) || DOXYGEN
31JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE (
"-Wgnu-zero-variadic-macro-arguments")
33#include <ARA_API/ARAInterface.h>
34#include <ARA_Library/Dispatch/ARAHostDispatch.h>
36JUCE_END_IGNORE_WARNINGS_GCC_LIKE
66 ARA::Host::DocumentController& dc;
87template <
typename A,
typename B>
88struct ConversionFunctions
90 static_assert (
sizeof (A) <=
sizeof (B),
91 "It is only possible to convert between types of the same size");
93 static B toHostRef (A value)
98 static A fromHostRef (B value)
113template <
typename Base,
typename PtrIn>
114class ManagedARAHandle
120 ManagedARAHandle (ARA::Host::DocumentController& dc, Ptr ptr) noexcept
121 : handle (ptr, Deleter { dc }) {}
124 auto& getDocumentController()
const {
return handle.get_deleter().documentController; }
127 Ptr getPluginRef()
const {
return handle.get(); }
132 void operator() (Ptr ptr)
const noexcept
134 const ARAEditGuard
guard (documentController);
135 Base::destroy (documentController, ptr);
138 ARA::Host::DocumentController& documentController;
161class AudioSource :
public ManagedARAHandle<AudioSource, ARA::ARAAudioSourceRef>
170 static constexpr auto getEmptyProperties() {
return makeARASizedStruct (&ARA::ARAAudioSourceProperties::merits64BitSamples); }
183 AudioSource (ARA::ARAAudioSourceHostRef
hostRef,
184 ARA::Host::DocumentController& dc,
185 const ARA::ARAAudioSourceProperties& props);
188 ~AudioSource() =
default;
197 void update (
const ARA::ARAAudioSourceProperties& props);
203 void enableAudioSourceSamplesAccess (
bool);
210 static void destroy (ARA::Host::DocumentController&, Ptr);
229class AudioModification :
public ManagedARAHandle<AudioModification, ARA::ARAAudioModificationRef>
238 static constexpr auto getEmptyProperties()
240 return makeARASizedStruct (&ARA::ARAAudioModificationProperties::persistentID);
254 AudioModification (ARA::ARAAudioModificationHostRef
hostRef,
255 ARA::Host::DocumentController& dc,
257 const ARA::ARAAudioModificationProperties& props);
266 void update (
const ARA::ARAAudioModificationProperties& props);
269 auto& getAudioSource()
const {
return source; }
276 static void destroy (ARA::Host::DocumentController&, Ptr);
287struct DeletionListener
290 virtual ~DeletionListener() =
default;
293 virtual void removeListener (DeletionListener&
other)
noexcept = 0;
321 static constexpr auto getEmptyProperties()
323 return makeARASizedStruct (&ARA::ARAPlaybackRegionProperties::color);
326 PlaybackRegion (ARA::ARAPlaybackRegionHostRef
hostRef,
327 ARA::Host::DocumentController& dc,
328 AudioModification& m,
329 const ARA::ARAPlaybackRegionProperties& props);
340 void update (
const ARA::ARAPlaybackRegionProperties& props);
349 void addListener (DeletionListener& x);
352 auto& getAudioModification()
const;
355 ARA::ARAPlaybackRegionRef getPluginRef()
const noexcept;
356 DeletionListener& getDeletionListener()
const noexcept;
361 std::unique_ptr<Impl> impl;
389 static constexpr auto getEmptyProperties()
391 return makeARASizedStruct (&ARA::ARAMusicalContextProperties::color);
405 MusicalContext (ARA::ARAMusicalContextHostRef
hostRef,
406 ARA::Host::DocumentController& dc,
407 const ARA::ARAMusicalContextProperties& props);
416 void update (
const ARA::ARAMusicalContextProperties& props);
423 static void destroy (ARA::Host::DocumentController&, Ptr);
442class RegionSequence :
public ManagedARAHandle<RegionSequence, ARA::ARARegionSequenceRef>
451 static constexpr auto getEmptyProperties()
453 return makeARASizedStruct (&ARA::ARARegionSequenceProperties::color);
467 RegionSequence (ARA::ARARegionSequenceHostRef hostRef,
468 ARA::Host::DocumentController& dc,
469 const ARA::ARARegionSequenceProperties& props);
478 void update (
const ARA::ARARegionSequenceProperties& props);
485 static void destroy (ARA::Host::DocumentController&, Ptr);
537template <
typename RendererRef,
typename Interface>
538class PlaybackRegionRegistry
541 PlaybackRegionRegistry() =
default;
543 PlaybackRegionRegistry (RendererRef rendererRefIn,
const Interface* interfaceIn)
544 : registry (
std::
make_unique<Registry> (rendererRefIn, interfaceIn))
553 void add (PlaybackRegion& region) { registry->add (region); }
560 void remove (PlaybackRegion& region) { registry->remove (region); }
563 bool isValid() {
return registry->isValid(); }
566 class Registry :
private DeletionListener
569 Registry (RendererRef rendererRefIn,
const Interface* interfaceIn)
570 : rendererRef (rendererRefIn), rendererInterface (interfaceIn)
574 Registry (
const Registry&) =
delete;
575 Registry (Registry&&) noexcept = delete;
577 Registry& operator= (const Registry&) = delete;
578 Registry& operator= (Registry&&) noexcept = delete;
582 for (
const auto& region : regions)
583 doRemoveListener (*region.first);
586 bool isValid() {
return rendererRef !=
nullptr && rendererInterface !=
nullptr; }
588 void add (PlaybackRegion& region)
591 rendererInterface->addPlaybackRegion (rendererRef, region.getPluginRef());
593 regions.emplace (®ion.getDeletionListener(), region.getPluginRef());
594 region.addListener (*
this);
597 void remove (PlaybackRegion& region)
599 doRemoveListener (region.getDeletionListener());
603 void doRemoveListener (DeletionListener& listener)
noexcept
605 listener.removeListener (*
this);
606 removeListener (listener);
609 void removeListener (DeletionListener& listener)
noexcept override
611 const auto it = regions.find (&listener);
613 if (it == regions.end())
620 rendererInterface->removePlaybackRegion (rendererRef, it->second);
625 RendererRef rendererRef =
nullptr;
626 const Interface* rendererInterface =
nullptr;
663class PlugInExtensionInstance
final
670 PlugInExtensionInstance() =
default;
677 explicit PlugInExtensionInstance (
const ARA::ARAPlugInExtensionInstance* instanceIn)
678 : instance (instanceIn)
689 PlaybackRendererInterface getPlaybackRendererInterface()
const;
698 EditorRendererInterface getEditorRendererInterface()
const;
703 bool isValid() const noexcept {
return instance !=
nullptr; }
706 const ARA::ARAPlugInExtensionInstance* instance =
nullptr;
729 const String& documentName,
750 ARA::ARAPlugInInstanceRoleFlags knownRoles,
751 ARA::ARAPlugInInstanceRoleFlags assignedRoles);
Reference counting helper class to ensure that the DocumentController is in editable state.
Encapsulates an ARAFactory pointer and makes sure that it remains in a valid state for the lifetime o...
Wrapper class for ARA::Host::DocumentController.
ARA::Host::DocumentController & getDocumentController() const
Returns the underlying ARA::Host::DocumentController reference.
static std::unique_ptr< ARAHostDocumentController > create(ARAFactoryWrapper factory, const String &documentName, std::unique_ptr< ARA::Host::AudioAccessControllerInterface > audioAccessController, std::unique_ptr< ARA::Host::ArchivingControllerInterface > archivingController, std::unique_ptr< ARA::Host::ContentAccessControllerInterface > contentAccessController=nullptr, std::unique_ptr< ARA::Host::ModelUpdateControllerInterface > modelUpdateController=nullptr, std::unique_ptr< ARA::Host::PlaybackControllerInterface > playbackController=nullptr)
Factory function.
ARAHostModel::PlugInExtensionInstance bindDocumentToPluginInstance(AudioPluginInstance &instance, ARA::ARAPlugInInstanceRoleFlags knownRoles, ARA::ARAPlugInInstanceRoleFlags assignedRoles)
Binds the ARAHostDocumentController and its enclosed document to a plugin instance.
Base class for an active instance of a plugin.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
void createARAFactoryAsync(AudioPluginInstance &instance, std::function< void(ARAFactoryWrapper)> cb)
Calls the provided callback with an ARAFactoryWrapper object obtained from the provided AudioPluginIn...