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 <pluginterfaces/vst/ivstprocesscontext.h>
7#include <public.sdk/source/vst/hosting/module.h>
8
9#include "EffectInterface.h"
10
11class VST3Wrapper;
12
13namespace Steinberg
14{
15 class IPlugFrame;
16 class IPlugView;
17}
18
19namespace Steinberg
20{
21 namespace Vst
22 {
23 class IComponentHandler;
24 class IConnectionPoint;
25 class IEditController;
26 class IParameterChanges;
27 }
28}
29
30class SingleInputParameterValue final : public Steinberg::Vst::IParamValueQueue
31{
32 Steinberg::Vst::ParamID mParameterId{};
33 Steinberg::Vst::ParamValue mValue;
34public:
35
36 SingleInputParameterValue() { FUNKNOWN_CTOR }
37 ~SingleInputParameterValue() { FUNKNOWN_DTOR }
38
39 void Set(Steinberg::Vst::ParamID id, const Steinberg::Vst::ParamValue value);
40
41 Steinberg::tresult PLUGIN_API addPoint(Steinberg::int32 sampleOffset, Steinberg::Vst::ParamValue value,
42 Steinberg::int32& index) override;
43
44 Steinberg::Vst::ParamID PLUGIN_API getParameterId() override;
45
46 Steinberg::tresult PLUGIN_API getPoint(Steinberg::int32 index, Steinberg::int32& sampleOffset,
47 Steinberg::Vst::ParamValue& value) override;
48
49 Steinberg::int32 PLUGIN_API getPointCount() override;
50
51 DECLARE_FUNKNOWN_METHODS
52};
53
54class VST3_API VST3Wrapper
55{
57 VST3::Hosting::Module& mModule;
58 const VST3::Hosting::ClassInfo& mEffectClassInfo;
59public:
60
62 {
63 wxString id;
64 wxString displayName;
65 };
66
67 Steinberg::IPtr<Steinberg::Vst::IAudioProcessor> mAudioProcessor;
68 Steinberg::Vst::ProcessSetup mSetup;
69 Steinberg::IPtr<Steinberg::Vst::IComponent> mEffectComponent;
70 Steinberg::IPtr<Steinberg::Vst::IEditController> mEditController;
71 Steinberg::IPtr<Steinberg::Vst::IConnectionPoint> mComponentConnectionProxy;
72 Steinberg::IPtr<Steinberg::Vst::IConnectionPoint> mControllerConnectionProxy;
73 Steinberg::IPtr<Steinberg::Vst::IComponentHandler> mComponentHandler;
74
75 VST3Wrapper(VST3::Hosting::Module& module, const VST3::Hosting::ClassInfo& effectClassInfo);
77
78 VST3Wrapper(const VST3Wrapper&) = delete;
82
84 void InitializeComponents();
85
86 VST3::Hosting::Module& GetModule() const { return mModule; }
87 const VST3::Hosting::ClassInfo& GetEffectClassInfo() const;
88
89 bool IsActive() const noexcept;
90
92 void FetchSettings(EffectSettings&);
94 void StoreSettings(EffectSettings&) const;
95
96 void LoadPreset(const wxString& presetId);
97 void SavePresetToFile(const wxString& filepath) const;
98
101 Steinberg::Vst::SampleRate sampleRate,
102 Steinberg::int32 processMode,
103 Steinberg::int32 maxSamplesPerBlock);
107 void Finalize(EffectSettings* settings);
108
110 void ProcessBlockStart(const EffectSettings& settings);
111
112 //Used to send EffectSettings changes to the IAudioProcessor, while effect is inactive(!)
113
116 void FlushParameters(EffectSettings& settings, bool* hasChanges = nullptr);
117
118 //Intialize first, before calling to Process. It's safe to it use from another thread
119 size_t Process(const float* const* inBlock, float* const* outBlock, size_t blockLen);
120
121 void SuspendProcessing();
122 void ResumeProcessing();
123
124 void BeginParameterEdit(EffectSettingsAccess& access);
125 void EndParameterEdit();
126
129 std::vector<FactoryPresetDesc> FindFactoryPresets() const;
130
131 Steinberg::int32 GetLatencySamples() const;
132
133 static EffectSettings MakeSettings();
134
135 static void LoadSettings(const CommandParameters& parms, EffectSettings& settings);
136 static void SaveSettings(const EffectSettings& settings, CommandParameters& parms);
137 static OptionalMessage LoadUserPreset(
139 static void SaveUserPreset(const EffectDefinitionInterface& effect, const RegistryPath& name, const EffectSettings& settings);
140
141 static void CopySettingsContents(const EffectSettings& src, EffectSettings& dst);
142
143 std::function<void (Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue)> ParamChangedHandler;
144
145private:
146
147 bool LoadPresetFromStream(Steinberg::IBStream* fileStream);
148 bool SavePresetToStream(Steinberg::IBStream* fileStream) const;
149
150 //Reads runtime data changes to apply them during next processing pass
151 void ConsumeChanges(const EffectSettings& settings);
152
153 bool mActive {false};
154
155 std::vector<std::pair<Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue>> mParameters;
156 //A preallocated array of Steinberg::Vst::IParameterValueQueue
157 //used as a view to an actual parameter changes that reside
158 //in VST3EffectSettings structure, dynamically assigned during
159 //processing
160 std::unique_ptr<SingleInputParameterValue[]> mParameterQueues;
161
162 Steinberg::Vst::ProcessContext mProcessContext { };
163};
std::optional< std::unique_ptr< EffectSettingsAccess::Message > > OptionalMessage
wxString RegistryPath
Definition: Identifier.h:218
wxString name
Definition: TagsEditor.cpp:166
static Settings & settings()
Definition: TrackInfo.cpp:51
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:33
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:32
VST3Wrapper & operator=(const VST3Wrapper &)=delete
Steinberg::IPtr< Steinberg::Vst::IConnectionPoint > mControllerConnectionProxy
Definition: VST3Wrapper.h:72
Steinberg::IPtr< Steinberg::Vst::IEditController > mEditController
Definition: VST3Wrapper.h:70
Steinberg::IPtr< Steinberg::Vst::IComponent > mEffectComponent
Definition: VST3Wrapper.h:69
VST3::Hosting::Module & GetModule() const
Definition: VST3Wrapper.h:86
Steinberg::IPtr< Steinberg::Vst::IComponentHandler > mComponentHandler
Definition: VST3Wrapper.h:73
VST3Wrapper(const VST3Wrapper &)=delete
const VST3::Hosting::ClassInfo & mEffectClassInfo
Definition: VST3Wrapper.h:58
std::unique_ptr< SingleInputParameterValue[]> mParameterQueues
Definition: VST3Wrapper.h:160
VST3::Hosting::Module & mModule
Definition: VST3Wrapper.h:57
Steinberg::IPtr< Steinberg::Vst::IConnectionPoint > mComponentConnectionProxy
Definition: VST3Wrapper.h:71
Steinberg::IPtr< Steinberg::Vst::IAudioProcessor > mAudioProcessor
Definition: VST3Wrapper.h:67
VST3Wrapper(VST3Wrapper &&)=delete
Steinberg::Vst::ProcessSetup mSetup
Definition: VST3Wrapper.h:68
std::vector< std::pair< Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue > > mParameters
Definition: VST3Wrapper.h:155
EffectSettings mDefaultSettings
Definition: VST3Wrapper.h:56
VST3Wrapper & operator=(VST3Wrapper &&)=delete
STL namespace.
Externalized state of a plug-in.