28#if (JUCE_PLUGINHOST_ARA && (JUCE_PLUGINHOST_VST3 || JUCE_PLUGINHOST_AU) && (JUCE_MAC || JUCE_WINDOWS)) || DOXYGEN
33#include <ARA_API/ARAInterface.h>
34#include <ARA_Library/Dispatch/ARAHostDispatch.h>
62 explicit ARAEditGuard (ARA::Host::DocumentController& dcIn);
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");
95 return readUnaligned<B> (&
value);
98 static A fromHostRef (B
value)
100 return readUnaligned<A> (&
value);
111template <
typename Base,
typename PtrIn>
112class ManagedARAHandle
118 ManagedARAHandle (ARA::Host::DocumentController& dc, Ptr ptr)
noexcept
119 : handle (ptr, Deleter { dc }) {}
122 auto& getDocumentController()
const {
return handle.get_deleter().documentController; }
125 Ptr getPluginRef()
const {
return handle.get(); }
130 void operator() (Ptr ptr)
const noexcept
132 const ARAEditGuard guard (documentController);
133 Base::destroy (documentController, ptr);
136 ARA::Host::DocumentController& documentController;
139 std::unique_ptr<std::remove_pointer_t<Ptr>, Deleter> handle;
159class AudioSource :
public ManagedARAHandle<AudioSource, ARA::ARAAudioSourceRef>
168 static constexpr auto getEmptyProperties() {
return makeARASizedStruct (&ARA::ARAAudioSourceProperties::merits64BitSamples); }
181 AudioSource (ARA::ARAAudioSourceHostRef hostRef,
182 ARA::Host::DocumentController& dc,
183 const ARA::ARAAudioSourceProperties& props);
186 ~AudioSource() =
default;
195 void update (
const ARA::ARAAudioSourceProperties& props);
201 void enableAudioSourceSamplesAccess (
bool);
208 static void destroy (ARA::Host::DocumentController&, Ptr);
227class AudioModification :
public ManagedARAHandle<AudioModification, ARA::ARAAudioModificationRef>
236 static constexpr auto getEmptyProperties()
252 AudioModification (ARA::ARAAudioModificationHostRef hostRef,
253 ARA::Host::DocumentController& dc,
255 const ARA::ARAAudioModificationProperties& props);
264 void update (
const ARA::ARAAudioModificationProperties& props);
267 auto& getAudioSource()
const {
return source; }
274 static void destroy (ARA::Host::DocumentController&, Ptr);
283struct DeletionListener
286 virtual ~DeletionListener() =
default;
289 virtual void removeListener (DeletionListener& other)
noexcept = 0;
317 static constexpr auto getEmptyProperties()
322 PlaybackRegion (ARA::ARAPlaybackRegionHostRef hostRef,
323 ARA::Host::DocumentController& dc,
324 AudioModification&
m,
325 const ARA::ARAPlaybackRegionProperties& props);
336 void update (
const ARA::ARAPlaybackRegionProperties& props);
345 void addListener (DeletionListener&
x);
348 auto& getAudioModification()
const;
357 std::unique_ptr<Impl> impl;
376class MusicalContext : public ManagedARAHandle<MusicalContext, ARA::ARAMusicalContextRef>
385 static constexpr auto getEmptyProperties()
401 MusicalContext (ARA::ARAMusicalContextHostRef hostRef,
402 ARA::Host::DocumentController& dc,
403 const ARA::ARAMusicalContextProperties& props);
412 void update (
const ARA::ARAMusicalContextProperties& props);
419 static void destroy (ARA::Host::DocumentController&, Ptr);
438class RegionSequence :
public ManagedARAHandle<RegionSequence, ARA::ARARegionSequenceRef>
447 static constexpr auto getEmptyProperties()
463 RegionSequence (ARA::ARARegionSequenceHostRef hostRef,
464 ARA::Host::DocumentController& dc,
465 const ARA::ARARegionSequenceProperties& props);
474 void update (
const ARA::ARARegionSequenceProperties& props);
481 static void destroy (ARA::Host::DocumentController&, Ptr);
533template <
typename RendererRef,
typename Interface>
534class PlaybackRegionRegistry
537 PlaybackRegionRegistry() =
default;
539 PlaybackRegionRegistry (RendererRef rendererRefIn,
const Interface* interfaceIn)
540 : registry (std::make_unique<Registry> (rendererRefIn, interfaceIn))
549 void add (PlaybackRegion& region) { registry->add (region); }
556 void remove (PlaybackRegion& region) { registry->remove (region); }
559 bool isValid() {
return registry->isValid(); }
562 class Registry :
private DeletionListener
565 Registry (RendererRef rendererRefIn,
const Interface* interfaceIn)
566 : rendererRef (rendererRefIn), rendererInterface (interfaceIn)
570 Registry (
const Registry&) =
delete;
571 Registry (Registry&&)
noexcept = delete;
573 Registry& operator= (
const Registry&) = delete;
574 Registry& operator= (Registry&&)
noexcept = delete;
578 for (
const auto& region : regions)
579 doRemoveListener (*region.first);
582 bool isValid() {
return rendererRef !=
nullptr && rendererInterface !=
nullptr; }
584 void add (PlaybackRegion& region)
587 rendererInterface->addPlaybackRegion (rendererRef, region.getPluginRef());
589 regions.emplace (®ion.getDeletionListener(), region.getPluginRef());
590 region.addListener (*
this);
593 void remove (PlaybackRegion& region)
595 doRemoveListener (region.getDeletionListener());
599 void doRemoveListener (DeletionListener& listener)
noexcept
601 listener.removeListener (*
this);
602 removeListener (listener);
605 void removeListener (DeletionListener& listener)
noexcept override
607 const auto it = regions.find (&listener);
609 if (it == regions.end())
616 rendererInterface->removePlaybackRegion (rendererRef, it->second);
621 RendererRef rendererRef =
nullptr;
622 const Interface* rendererInterface =
nullptr;
623 std::map<DeletionListener*, ARA::ARAPlaybackRegionRef> regions;
626 std::unique_ptr<Registry> registry;
638using PlaybackRendererInterface = PlaybackRegionRegistry<ARA::ARAPlaybackRendererRef, ARA::ARAPlaybackRendererInterface>;
649using EditorRendererInterface = PlaybackRegionRegistry<ARA::ARAEditorRendererRef, ARA::ARAEditorRendererInterface>;
657class PlugInExtensionInstance
final
664 PlugInExtensionInstance() =
default;
671 explicit PlugInExtensionInstance (
const ARA::ARAPlugInExtensionInstance* instanceIn)
672 : instance (instanceIn)
683 PlaybackRendererInterface getPlaybackRendererInterface()
const;
692 EditorRendererInterface getEditorRendererInterface()
const;
697 bool isValid()
const noexcept {
return instance !=
nullptr; }
700 const ARA::ARAPlugInExtensionInstance* instance =
nullptr;
714class ARAHostDocumentController
final
721 static std::unique_ptr<ARAHostDocumentController>
722 create (ARAFactoryWrapper factory,
723 const String& documentName,
724 std::unique_ptr<ARA::Host::AudioAccessControllerInterface> audioAccessController,
725 std::unique_ptr<ARA::Host::ArchivingControllerInterface> archivingController,
726 std::unique_ptr<ARA::Host::ContentAccessControllerInterface> contentAccessController =
nullptr,
727 std::unique_ptr<ARA::Host::ModelUpdateControllerInterface> modelUpdateController =
nullptr,
728 std::unique_ptr<ARA::Host::PlaybackControllerInterface> playbackController =
nullptr);
730 ~ARAHostDocumentController();
733 ARA::Host::DocumentController& getDocumentController()
const;
743 ARAHostModel::PlugInExtensionInstance bindDocumentToPluginInstance (AudioPluginInstance& instance,
744 ARA::ARAPlugInInstanceRoleFlags knownRoles,
745 ARA::ARAPlugInInstanceRoleFlags assignedRoles);
749 std::unique_ptr<Impl> impl;
751 explicit ARAHostDocumentController (std::unique_ptr<Impl>&& implIn);
763void createARAFactoryAsync (AudioPluginInstance& instance, std::function<
void (ARAFactoryWrapper)> cb);
#define noexcept
Definition DistrhoDefines.h:72
#define final
Definition DistrhoDefines.h:74
unsigned * m
Definition inflate.c:1559
unsigned s
Definition inflate.c:1555
unsigned x[BMAX+1]
Definition inflate.c:1586
static PuglViewHint int value
Definition pugl.h:1708
#define JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE(...)
Definition juce_CompilerWarnings.h:181
#define JUCE_END_IGNORE_WARNINGS_GCC_LIKE
Definition juce_CompilerWarnings.h:182
#define A(x)
Definition lice_arc.cpp:13
Definition carla_juce.cpp:31
constexpr Obj makeARASizedStruct(Member Obj::*member, Ts &&... ts)
Definition juce_ARACommon.h:79
void add(SampleFrame *dst, const SampleFrame *src, int frames)
Add samples from src to dst.
Definition MixHelpers.cpp:135
#define const
Definition zconf.h:137