Audacity 3.2.0
VST3Wrapper.h
Go to the documentation of this file.
1#pragma once
2
3#include <pluginterfaces/base/smartpointer.h>
4#include <pluginterfaces/vst/ivstaudioprocessor.h>
5#include <pluginterfaces/vst/ivstparameterchanges.h>
6#include <public.sdk/source/vst/hosting/module.h>
7
8#include "EffectInterface.h"
9
10class VST3Wrapper;
11
12namespace Steinberg
13{
14 class IPlugFrame;
15 class IPlugView;
16}
17
18namespace Steinberg
19{
20 namespace Vst
21 {
22 class IComponentHandler;
23 class IConnectionPoint;
24 class IEditController;
25 class IParameterChanges;
26 }
27}
28
29class SingleInputParameterValue final : public Steinberg::Vst::IParamValueQueue
30{
31 Steinberg::Vst::ParamID mParameterId{};
32 Steinberg::Vst::ParamValue mValue;
33public:
34
35 SingleInputParameterValue() { FUNKNOWN_CTOR }
36 ~SingleInputParameterValue() { FUNKNOWN_DTOR }
37
38 void Set(Steinberg::Vst::ParamID id, const Steinberg::Vst::ParamValue value);
39
40 Steinberg::tresult PLUGIN_API addPoint(Steinberg::int32 sampleOffset, Steinberg::Vst::ParamValue value,
41 Steinberg::int32& index) override;
42
43 Steinberg::Vst::ParamID PLUGIN_API getParameterId() override;
44
45 Steinberg::tresult PLUGIN_API getPoint(Steinberg::int32 index, Steinberg::int32& sampleOffset,
46 Steinberg::Vst::ParamValue& value) override;
47
48 Steinberg::int32 PLUGIN_API getPointCount() override;
49
50 DECLARE_FUNKNOWN_METHODS
51};
52
54{
56 VST3::Hosting::Module& mModule;
57public:
58 Steinberg::IPtr<Steinberg::Vst::IAudioProcessor> mAudioProcessor;
59 Steinberg::Vst::ProcessSetup mSetup;
60 Steinberg::IPtr<Steinberg::Vst::IComponent> mEffectComponent;
61 Steinberg::IPtr<Steinberg::Vst::IEditController> mEditController;
62 Steinberg::IPtr<Steinberg::Vst::IConnectionPoint> mComponentConnectionProxy;
63 Steinberg::IPtr<Steinberg::Vst::IConnectionPoint> mControllerConnectionProxy;
64 Steinberg::IPtr<Steinberg::Vst::IComponentHandler> mComponentHandler;
65
66 VST3Wrapper(VST3::Hosting::Module& module, VST3::UID effectUID);
68
69 VST3Wrapper(const VST3Wrapper&) = delete;
73
74 VST3::Hosting::Module& GetModule() const { return mModule; }
75
76 bool IsActive() const noexcept;
77
81 void StoreSettings(EffectSettings&) const;
82
83 bool LoadPreset(Steinberg::IBStream* fileStream);
84 bool SavePreset(Steinberg::IBStream* fileStream) const;
85
88 Steinberg::Vst::SampleRate sampleRate,
89 Steinberg::int32 processMode,
90 Steinberg::int32 maxSamplesPerBlock);
95
98
99 //Used to send EffectSettings changes to the IAudioProcessor, while effect is inactive(!)
100
103 void FlushParameters(EffectSettings& settings, bool* hasChanges = nullptr);
104
105 //Intialize first, before calling to Process. It's safe to it use from another thread
106 size_t Process(const float* const* inBlock, float* const* outBlock, size_t blockLen);
107
108 void SuspendProcessing();
109 void ResumeProcessing();
110
112 void EndParameterEdit();
113
114 Steinberg::int32 GetLatencySamples() const;
115
117
118 static void LoadSettings(const CommandParameters& parms, EffectSettings& settings);
119 static void SaveSettings(const EffectSettings& settings, CommandParameters& parms);
122 static void SaveUserPreset(const EffectDefinitionInterface& effect, const RegistryPath& name, const EffectSettings& settings);
123
124 static void CopySettingsContents(const EffectSettings& src, EffectSettings& dst);
125
126 std::function<void (Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue)> ParamChangedHandler;
127
128private:
129
130 //Reads runtime data changes to apply them during next processing pass
132
133 bool mActive {false};
134 const VST3::UID mEffectUID;
135
136 std::vector<std::pair<Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue>> mParameters;
137 //A preallocated array of Steinberg::Vst::IParameterValueQueue
138 //used as a view to an actual parameter changes that reside
139 //in VST3EffectSettings structure, dynamically assigned during
140 //processing
141 std::unique_ptr<SingleInputParameterValue[]> mParameterQueues;
142};
const TranslatableString name
Definition: Distortion.cpp:74
std::optional< std::unique_ptr< EffectSettingsAccess::Message > > OptionalMessage
wxString RegistryPath
Definition: Identifier.h:218
static Settings & settings()
Definition: TrackInfo.cpp:87
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the SettingsVis...
EffectDefinitionInterface is a ComponentInterface that adds some basic read-only information about ef...
Steinberg::int32 PLUGIN_API getPointCount() override
void Set(Steinberg::Vst::ParamID id, const Steinberg::Vst::ParamValue value)
Steinberg::Vst::ParamValue mValue
Definition: VST3Wrapper.h:32
Steinberg::Vst::ParamID PLUGIN_API getParameterId() override
Steinberg::tresult PLUGIN_API getPoint(Steinberg::int32 index, Steinberg::int32 &sampleOffset, Steinberg::Vst::ParamValue &value) override
Steinberg::tresult PLUGIN_API addPoint(Steinberg::int32 sampleOffset, Steinberg::Vst::ParamValue value, Steinberg::int32 &index) override
Steinberg::Vst::ParamID mParameterId
Definition: VST3Wrapper.h:31
void SuspendProcessing()
void BeginParameterEdit(EffectSettingsAccess &access)
size_t Process(const float *const *inBlock, float *const *outBlock, size_t blockLen)
VST3Wrapper & operator=(const VST3Wrapper &)=delete
void ResumeProcessing()
static EffectSettings MakeSettings()
bool LoadPreset(Steinberg::IBStream *fileStream)
Steinberg::IPtr< Steinberg::Vst::IConnectionPoint > mControllerConnectionProxy
Definition: VST3Wrapper.h:63
bool SavePreset(Steinberg::IBStream *fileStream) const
void ProcessBlockStart(const EffectSettings &settings)
Prepares effect to process next block with changes written to the settings object.
Steinberg::IPtr< Steinberg::Vst::IEditController > mEditController
Definition: VST3Wrapper.h:61
Steinberg::IPtr< Steinberg::Vst::IComponent > mEffectComponent
Definition: VST3Wrapper.h:60
VST3::Hosting::Module & GetModule() const
Definition: VST3Wrapper.h:74
static void SaveUserPreset(const EffectDefinitionInterface &effect, const RegistryPath &name, const EffectSettings &settings)
Steinberg::IPtr< Steinberg::Vst::IComponentHandler > mComponentHandler
Definition: VST3Wrapper.h:64
Steinberg::int32 GetLatencySamples() const
VST3Wrapper(const VST3Wrapper &)=delete
void FetchSettings(EffectSettings &)
Fetch state from settings object, may change internal runtime data.
static void SaveSettings(const EffectSettings &settings, CommandParameters &parms)
std::unique_ptr< SingleInputParameterValue[]> mParameterQueues
Definition: VST3Wrapper.h:141
std::function< void(Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue)> ParamChangedHandler
Definition: VST3Wrapper.h:126
static void CopySettingsContents(const EffectSettings &src, EffectSettings &dst)
VST3::Hosting::Module & mModule
Definition: VST3Wrapper.h:56
bool IsActive() const noexcept
bool Initialize(EffectSettings &settings, Steinberg::Vst::SampleRate sampleRate, Steinberg::int32 processMode, Steinberg::int32 maxSamplesPerBlock)
Initializes effect for processing using settings.
VST3Wrapper(VST3::Hosting::Module &module, VST3::UID effectUID)
void StoreSettings(EffectSettings &) const
Saves current state inside settings object, clears all runtime data.
static void LoadSettings(const CommandParameters &parms, EffectSettings &settings)
Steinberg::IPtr< Steinberg::Vst::IConnectionPoint > mComponentConnectionProxy
Definition: VST3Wrapper.h:62
Steinberg::IPtr< Steinberg::Vst::IAudioProcessor > mAudioProcessor
Definition: VST3Wrapper.h:58
VST3Wrapper(VST3Wrapper &&)=delete
void ConsumeChanges(const EffectSettings &settings)
void EndParameterEdit()
Steinberg::Vst::ProcessSetup mSetup
Definition: VST3Wrapper.h:59
std::vector< std::pair< Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue > > mParameters
Definition: VST3Wrapper.h:136
void FlushParameters(EffectSettings &settings, bool *hasChanges=nullptr)
const VST3::UID mEffectUID
Definition: VST3Wrapper.h:134
EffectSettings mDefaultSettings
Definition: VST3Wrapper.h:55
void Finalize(EffectSettings *settings)
static OptionalMessage LoadUserPreset(const EffectDefinitionInterface &effect, const RegistryPath &name, EffectSettings &settings)
VST3Wrapper & operator=(VST3Wrapper &&)=delete
STL namespace.
Externalized state of a plug-in.