Audacity 3.2.0
VSTInstance.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 VSTInstance.h
6
7 Dominic Mazzoni
8
9 Paul Licameli split from VSTEffect.h
10
11**********************************************************************/
12
13#ifndef __AUDACITY_VST_INSTANCE__
14#define __AUDACITY_VST_INSTANCE__
15
16#include "PerTrackEffect.h"
17#include "VSTWrapper.h"
18
19#include <atomic>
20#include <vector>
21
22class VSTInstance;
23using VSTInstanceArray = std::vector < std::unique_ptr<VSTInstance> >;
24
25class VST_API VSTInstance final : public PerTrackEffect::Instance,
26 public VSTWrapper
27{
28public:
29
30 VSTInstance(const PerTrackEffect& effect,
31 const PluginPath& path,
32 size_t blockSize,
33 size_t userBlockSize,
34 bool useLatency
35 );
36
37 ~VSTInstance() override;
38
39
41 ChannelNames chanMap) override;
42
43 bool ProcessFinalize() noexcept override;
44
45 size_t SetBlockSize(size_t maxBlockSize) override;
46 size_t GetBlockSize() const override;
47
49 override;
51 unsigned numChannels, float sampleRate) override;
52 bool RealtimeFinalize(EffectSettings& settings) noexcept override;
53 bool RealtimeSuspend() override;
54 bool RealtimeResume() override;
55 bool UsesMessages() const noexcept override;
56 bool RealtimeProcessStart(MessagePackage& package) override;
57 size_t RealtimeProcess(size_t group, EffectSettings& settings,
58 const float* const* inbuf, float* const* outbuf, size_t numSamples)
59 override;
60 bool RealtimeProcessEnd(EffectSettings& settings) noexcept override;
61
62
63
64
66 const float* const* inBlock, float* const* outBlock, size_t blockLen) override;
67
69 const override;
70
71 bool IsReady();
72
73 unsigned GetAudioInCount() const override;
74
75 unsigned GetAudioOutCount() const override;
76
77 bool DoProcessInitialize(double sampleRate);
78
79 void PowerOn();
80 void PowerOff();
81
82 const bool mUseLatency;
83
84 size_t mBlockSize{ 8192 };
85
86 std::unique_ptr<Message> MakeMessage() const override;
87
88 std::unique_ptr<Message> MakeMessage(int id, double value) const;
89
90 // VSTUIWrapper overrides
91
92 void Automate(int index, float value) override;
93 void NeedIdle() override;
94 void SizeWindow(int w, int h) override;
95 void SetBufferDelay(int samples) override;
96
97 // The overrides above will forward calls to them to the corresponding
98 // overrides in the Validator which owns the instance - this sets it.
99 void SetOwningValidator(VSTUIWrapper* vi);
100
101 bool OnePresetWasLoadedWhilePlaying();
102
103 void DeferChunkApplication();
104
105 bool HasGUI() const { return mGui; }
106
107private:
108
109 void callProcessReplacing(
110 const float* const* inputs, float* const* outputs, int sampleframes);
111
113
114 bool mHasPower{ false };
115
116 size_t mUserBlockSize{ mBlockSize };
117
118 bool mReady{ false };
119
120 bool mRecruited{ false };
121
122 VSTUIWrapper* mpOwningValidator{};
123
124 std::atomic_bool mPresetLoadedWhilePlaying{ false };
125
127 std::vector<char> mChunkToSetAtIdleTime{};
128
129 void ApplyChunk(std::vector<char>& chunk);
130
131 bool ChunkMustBeAppliedInMainThread() const;
132
133 bool mIsMeldaPlugin{ false };
134};
135
136#endif
ChannelName
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
Definition: Identifier.h:214
static Settings & settings()
Definition: TrackInfo.cpp:51
std::vector< std::unique_ptr< VSTInstance > > VSTInstanceArray
Definition: VSTInstance.h:23
virtual unsigned GetAudioInCount() const =0
How many input buffers to allocate at once.
virtual bool RealtimeAddProcessor(EffectSettings &settings, EffectOutputs *pOutputs, unsigned numChannels, float sampleRate)
virtual size_t ProcessBlock(EffectSettings &settings, const float *const *inBlock, float *const *outBlock, size_t blockLen)=0
Called for destructive effect computation.
virtual bool RealtimeSuspend()
virtual bool RealtimeResume()
virtual size_t SetBlockSize(size_t maxBlockSize)=0
virtual bool RealtimeInitialize(EffectSettings &settings, double sampleRate)
virtual bool RealtimeProcessEnd(EffectSettings &settings) noexcept
settings can be updated to let a dialog change appearance at idle
virtual bool RealtimeFinalize(EffectSettings &settings) noexcept
virtual SampleCount GetLatency(const EffectSettings &settings, double sampleRate) const
virtual unsigned GetAudioOutCount() const =0
How many output buffers to allocate at once.
virtual std::unique_ptr< Message > MakeMessage() const
Called on the main thread, in which the result may be cloned.
virtual size_t GetBlockSize() const =0
virtual bool UsesMessages() const noexcept
uint64_t SampleCount
virtual bool RealtimeProcessStart(MessagePackage &package)
settings are possibly changed, since last call, by an asynchronous dialog
virtual size_t RealtimeProcess(size_t group, EffectSettings &settings, const float *const *inBuf, float *const *outBuf, size_t numSamples)
Hold values to send to effect output meters.
bool ProcessFinalize() noexcept override
bool ProcessInitialize(EffectSettings &settings, double sampleRate, ChannelNames chanMap) override
Base class for many of the effects in Audacity.
bool HasGUI() const
Definition: VSTInstance.h:105
VSTInstanceArray mSlaves
Definition: VSTInstance.h:112
std::mutex mDeferredChunkMutex
Definition: VSTInstance.h:126
const bool mUseLatency
Definition: VSTInstance.h:82
Externalized state of a plug-in.
virtual void SizeWindow(int w, int h)
Definition: VSTWrapper.cpp:643
virtual void Automate(int index, float value)
virtual void NeedIdle()
Definition: VSTWrapper.cpp:623
virtual void SetBufferDelay(int samples)
Definition: VSTWrapper.cpp:647