Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
VST3Instance Class Reference

#include <VST3Instance.h>

Inheritance diagram for VST3Instance:
[legend]
Collaboration diagram for VST3Instance:
[legend]

Public Member Functions

 VST3Instance (const PerTrackEffect &effect, VST3::Hosting::Module &module, const VST3::Hosting::ClassInfo &effectClassInfo)
 
 ~VST3Instance () override
 
 VST3Instance (const VST3Instance &)=delete
 
VST3Instanceoperator= (const VST3Instance &)=delete
 
size_t GetTailSize () const override
 
bool RealtimeAddProcessor (EffectSettings &settings, EffectOutputs *pOutputs, unsigned numChannels, float sampleRate) override
 
bool RealtimeFinalize (EffectSettings &settings) noexcept override
 
bool RealtimeInitialize (EffectSettings &settings, double sampleRate) override
 
bool RealtimeProcessStart (MessagePackage &package) override
 settings are possibly changed, since last call, by an asynchronous dialog More...
 
size_t RealtimeProcess (size_t group, EffectSettings &settings, const float *const *inBuf, float *const *outBuf, size_t numSamples) override
 
bool RealtimeProcessEnd (EffectSettings &settings) noexcept override
 settings can be updated to let a dialog change appearance at idle More...
 
bool RealtimeResume () override
 
bool RealtimeSuspend () override
 
SampleCount GetLatency (const EffectSettings &settings, double sampleRate) const override
 
bool ProcessFinalize () noexcept override
 
bool ProcessInitialize (EffectSettings &settings, double sampleRate, ChannelNames chanMap) override
 
size_t GetBlockSize () const override
 
size_t SetBlockSize (size_t maxBlockSize) override
 
size_t ProcessBlock (EffectSettings &settings, const float *const *inBlock, float *const *outBlock, size_t blockLen) override
 Called for destructive effect computation. More...
 
VST3WrapperGetWrapper ()
 
unsigned GetAudioOutCount () const override
 How many output buffers to allocate at once. More...
 
unsigned GetAudioInCount () const override
 How many input buffers to allocate at once. More...
 
void ReloadUserOptions ()
 
- Public Member Functions inherited from PerTrackEffect::Instance
 Instance (const PerTrackEffect &processor)
 
 ~Instance () override
 
bool Process (EffectSettings &settings) final
 Uses the other virtual functions of this class. More...
 
bool ProcessInitialize (EffectSettings &settings, double sampleRate, ChannelNames chanMap) override
 
bool ProcessFinalize () noexcept override
 
- Public Member Functions inherited from EffectInstanceEx
virtual bool Init ()
 Call once to set up state for whole list of tracks to be processed. More...
 
virtual bool Process (EffectSettings &settings)=0
 Actually do the effect here. More...
 
 ~EffectInstanceEx () override
 
- Public Member Functions inherited from EffectInstance
virtual ~EffectInstance ()
 
virtual size_t GetBlockSize () const =0
 
virtual size_t SetBlockSize (size_t maxBlockSize)=0
 
virtual unsigned GetAudioInCount () const =0
 How many input buffers to allocate at once. More...
 
virtual unsigned GetAudioOutCount () const =0
 How many output buffers to allocate at once. More...
 
virtual bool RealtimeInitialize (EffectSettings &settings, double sampleRate)
 
virtual bool RealtimeAddProcessor (EffectSettings &settings, EffectOutputs *pOutputs, unsigned numChannels, float sampleRate)
 
virtual bool RealtimeSuspend ()
 
virtual bool RealtimeResume ()
 
virtual std::unique_ptr< MessageMakeMessage () const
 Called on the main thread, in which the result may be cloned. More...
 
virtual bool UsesMessages () const noexcept
 
virtual bool RealtimeProcessStart (MessagePackage &package)
 settings are possibly changed, since last call, by an asynchronous dialog More...
 
virtual size_t RealtimeProcess (size_t group, EffectSettings &settings, const float *const *inBuf, float *const *outBuf, size_t numSamples)
 
virtual void RealtimePassThrough (size_t group, EffectSettings &settings, const float *const *inBuf, size_t numSamples)
 Called instead of RealtimeProcess when the effect is bypassed. Default implementation does nothing. More...
 
virtual bool RealtimeProcessEnd (EffectSettings &settings) noexcept
 settings can be updated to let a dialog change appearance at idle More...
 
virtual bool RealtimeFinalize (EffectSettings &settings) noexcept
 
virtual size_t GetTailSize () const
 
virtual SampleCount GetLatency (const EffectSettings &settings, double sampleRate) const
 
virtual bool NeedsDither () const
 
virtual bool ProcessInitialize (EffectSettings &settings, double sampleRate, ChannelNames chanMap)=0
 
virtual bool ProcessFinalize () noexcept=0
 
virtual size_t ProcessBlock (EffectSettings &settings, const float *const *inBlock, float *const *outBlock, size_t blockLen)=0
 Called for destructive effect computation. More...
 

Private Attributes

std::unique_ptr< VST3WrappermWrapper
 
size_t mUserBlockSize { 8192 }
 
size_t mProcessingBlockSize { 8192 }
 
bool mUseLatency { true }
 
sampleCount mInitialDelay { 0 }
 
bool mRecruited { false }
 
std::vector< std::unique_ptr< VST3Instance > > mProcessors
 

Additional Inherited Members

- Public Types inherited from EffectInstance
using Message = EffectSettingsAccess::Message
 
using SampleCount = uint64_t
 
- Protected Attributes inherited from PerTrackEffect::Instance
const PerTrackEffectmProcessor
 

Detailed Description

Definition at line 28 of file VST3Instance.h.

Constructor & Destructor Documentation

◆ VST3Instance() [1/2]

VST3Instance::VST3Instance ( const PerTrackEffect effect,
VST3::Hosting::Module &  module,
const VST3::Hosting::ClassInfo &  effectClassInfo 
)

Definition at line 35 of file VST3Instance.cpp.

36 : Instance(effect)
37{
39 mWrapper = std::make_unique<VST3Wrapper>(module, effectClassInfo);
40 mWrapper->InitializeComponents();
41}
Instance(const PerTrackEffect &processor)
void ReloadUserOptions()
std::unique_ptr< VST3Wrapper > mWrapper
Definition: VST3Instance.h:31

References mWrapper, and ReloadUserOptions().

Here is the call graph for this function:

◆ ~VST3Instance()

VST3Instance::~VST3Instance ( )
overridedefault

◆ VST3Instance() [2/2]

VST3Instance::VST3Instance ( const VST3Instance )
delete

Member Function Documentation

◆ GetAudioInCount()

unsigned VST3Instance::GetAudioInCount ( ) const
overridevirtual

How many input buffers to allocate at once.

If the instance processes channels independently, this can return 1 The result is not necessarily well defined before RealtimeInitialize

Implements EffectInstance.

Definition at line 183 of file VST3Instance.cpp.

184{
185 //setupProcessing should be called first
186 return CountChannels(
187 mWrapper->mEffectComponent,
188 Steinberg::Vst::kAudio,
189 Steinberg::Vst::kInput,
190 Steinberg::Vst::kMain
191 );
192}
unsigned CountChannels(Steinberg::Vst::IComponent *component, const Steinberg::Vst::MediaTypes mediaType, const Steinberg::Vst::BusDirection busDirection, const Steinberg::Vst::BusType busType)

References anonymous_namespace{VST3Instance.cpp}::CountChannels(), and mWrapper.

Here is the call graph for this function:

◆ GetAudioOutCount()

unsigned VST3Instance::GetAudioOutCount ( ) const
overridevirtual

How many output buffers to allocate at once.

The result is not necessarily well defined before RealtimeInitialize

Implements EffectInstance.

Definition at line 194 of file VST3Instance.cpp.

195{
196 //setupProcessing should be called first
197 return CountChannels(
198 mWrapper->mEffectComponent,
199 Steinberg::Vst::kAudio,
200 Steinberg::Vst::kOutput,
201 Steinberg::Vst::kMain
202 );
203}

References anonymous_namespace{VST3Instance.cpp}::CountChannels(), and mWrapper.

Here is the call graph for this function:

◆ GetBlockSize()

size_t VST3Instance::GetBlockSize ( ) const
overridevirtual

Implements EffectInstance.

Definition at line 160 of file VST3Instance.cpp.

161{
163}
size_t mProcessingBlockSize
Definition: VST3Instance.h:34

References mProcessingBlockSize.

◆ GetLatency()

auto VST3Instance::GetLatency ( const EffectSettings settings,
double  sampleRate 
) const
overridevirtual

Default implementation returns 0

Reimplemented from EffectInstance.

Definition at line 133 of file VST3Instance.cpp.

135{
136 if(mUseLatency)
138 return 0;
139}
bool mUseLatency
Definition: VST3Instance.h:35
sampleCount mInitialDelay
Definition: VST3Instance.h:36
long long as_long_long() const
Definition: SampleCount.h:48

◆ GetTailSize()

size_t VST3Instance::GetTailSize ( ) const
overridevirtual

Function that has not yet found a use Correct definitions of it will likely depend on settings and state

Reimplemented from EffectInstance.

Definition at line 45 of file VST3Instance.cpp.

46{
47 return Instance::GetTailSize();
48}

◆ GetWrapper()

VST3Wrapper & VST3Instance::GetWrapper ( )

Definition at line 178 of file VST3Instance.cpp.

179{
180 return *mWrapper;
181}

References mWrapper.

◆ operator=()

VST3Instance & VST3Instance::operator= ( const VST3Instance )
delete

◆ ProcessBlock()

size_t VST3Instance::ProcessBlock ( EffectSettings settings,
const float *const *  inBlock,
float *const *  outBlock,
size_t  blockLen 
)
overridevirtual

Called for destructive effect computation.

Implements EffectInstance.

Definition at line 172 of file VST3Instance.cpp.

174{
175 return mWrapper->Process(inBlock, outBlock, blockLen);
176}

References mWrapper.

◆ ProcessFinalize()

bool VST3Instance::ProcessFinalize ( )
overridevirtualnoexcept

Called at end of destructive processing, for each (mono/stereo) track Default implementation does nothing, returns true This may be called during stack unwinding:

Reimplemented from PerTrackEffect::Instance.

Definition at line 141 of file VST3Instance.cpp.

142{
143 return GuardedCall<bool>([&]
144 {
145 mWrapper->Finalize(nullptr);
146 return true;
147 });
148}

References mWrapper.

◆ ProcessInitialize()

bool VST3Instance::ProcessInitialize ( EffectSettings settings,
double  sampleRate,
ChannelNames  chanMap 
)
overridevirtual

Called at start of destructive processing, for each (mono/stereo) track Default implementation does nothing, returns true

Parameters
chanMapnull or array terminated with ChannelNameEOL. Do not retain the pointer
Postcondition
GetAudioInCount() and GetAudioOutCount() are well defined

Reimplemented from PerTrackEffect::Instance.

Definition at line 150 of file VST3Instance.cpp.

151{
152 if(mWrapper->Initialize(settings, sampleRate, Steinberg::Vst::kOffline, mProcessingBlockSize))
153 {
154 mInitialDelay = mWrapper->GetLatencySamples();
155 return true;
156 }
157 return false;;
158}
static Settings & settings()
Definition: TrackInfo.cpp:51

References mInitialDelay, mProcessingBlockSize, mWrapper, anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, and settings().

Here is the call graph for this function:

◆ RealtimeAddProcessor()

bool VST3Instance::RealtimeAddProcessor ( EffectSettings settings,
EffectOutputs pOutputs,
unsigned  numChannels,
float  sampleRate 
)
overridevirtual
Returns
success Default implementation does nothing, returns true

Reimplemented from EffectInstance.

Definition at line 50 of file VST3Instance.cpp.

52{
53 if (!mRecruited) {
54 // Assign self to the first processor
55 mRecruited = true;
56 return true;
57 }
58 // Assign another instance with independent state to other processors
59 auto &effect = static_cast<const PerTrackEffect&>(mProcessor);
60 auto uProcessor =
61 std::make_unique<VST3Instance>(effect, mWrapper->GetModule(), mWrapper->GetEffectClassInfo());
62 if (!uProcessor->RealtimeInitialize(settings, sampleRate))
63 return false;
64 mProcessors.push_back(move(uProcessor));
65 return true;
66}
const PerTrackEffect & mProcessor
Base class for many of the effects in Audacity.
std::vector< std::unique_ptr< VST3Instance > > mProcessors
Definition: VST3Instance.h:39

References PerTrackEffect::Instance::mProcessor, mProcessors, mRecruited, mWrapper, anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, and settings().

Here is the call graph for this function:

◆ RealtimeFinalize()

bool VST3Instance::RealtimeFinalize ( EffectSettings settings)
overridevirtualnoexcept
Returns
success Default implementation does nothing, returns true

Reimplemented from EffectInstance.

Definition at line 68 of file VST3Instance.cpp.

69{
70return GuardedCall<bool>([&]{
71 mRecruited = false;
72 mWrapper->Finalize(&settings);
73 for (auto &pProcessor : mProcessors)
74 pProcessor->mWrapper->Finalize(nullptr);
75 mProcessors.clear();
76 return true;
77});
78}

References settings().

Here is the call graph for this function:

◆ RealtimeInitialize()

bool VST3Instance::RealtimeInitialize ( EffectSettings settings,
double  sampleRate 
)
overridevirtual
Returns
success
Postcondition
GetAudioInCount() and GetAudioOutCount() are well defined

Default implementation does nothing, returns false (so assume realtime is not supported). Other member functions related to realtime return true or zero, but will not be called, unless a derived class overrides RealtimeInitialize.

Reimplemented from EffectInstance.

Definition at line 80 of file VST3Instance.cpp.

81{
82 if(mWrapper->Initialize(settings, sampleRate, Steinberg::Vst::kRealtime, mProcessingBlockSize))
83 {
84 mInitialDelay = mWrapper->GetLatencySamples();
85 return true;
86 }
87 return false;
88}

References mInitialDelay, mProcessingBlockSize, mWrapper, anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, and settings().

Here is the call graph for this function:

◆ RealtimeProcess()

size_t VST3Instance::RealtimeProcess ( size_t  group,
EffectSettings settings,
const float *const *  inBuf,
float *const *  outBuf,
size_t  numSamples 
)
overridevirtual
Returns
success Default implementation does nothing, returns 0

Reimplemented from EffectInstance.

Definition at line 90 of file VST3Instance.cpp.

92{
93 if (!mRecruited)
94 // unexpected!
95 return 0;
96 if (group == 0)
97 return mWrapper->Process(inBuf, outBuf, numSamples);
98 else if (--group < mProcessors.size())
99 return mProcessors[group]->mWrapper->Process(inBuf, outBuf, numSamples);
100 return 0;
101}

References mProcessors, mRecruited, and mWrapper.

◆ RealtimeProcessEnd()

bool VST3Instance::RealtimeProcessEnd ( EffectSettings settings)
overridevirtualnoexcept

settings can be updated to let a dialog change appearance at idle

Returns
success Default implementation does nothing, returns true

Reimplemented from EffectInstance.

Definition at line 103 of file VST3Instance.cpp.

104{
105 return true;
106}

◆ RealtimeProcessStart()

bool VST3Instance::RealtimeProcessStart ( MessagePackage package)
overridevirtual

settings are possibly changed, since last call, by an asynchronous dialog

Returns
success Default implementation does nothing, returns true

Reimplemented from EffectInstance.

Definition at line 108 of file VST3Instance.cpp.

109{
110 auto &settings = package.settings;
111 mWrapper->ProcessBlockStart(settings);
112 for (auto &pProcessor : mProcessors)
113 pProcessor->mWrapper->ProcessBlockStart(settings);
114 return true;
115}

References mProcessors, mWrapper, EffectInstance::MessagePackage::settings, and settings().

Here is the call graph for this function:

◆ RealtimeResume()

bool VST3Instance::RealtimeResume ( )
overridevirtual
Returns
success Default implementation does nothing, returns true

Reimplemented from EffectInstance.

Definition at line 117 of file VST3Instance.cpp.

118{
119 mWrapper->ResumeProcessing();
120 for (auto &pProcessor : mProcessors)
121 pProcessor->mWrapper->ResumeProcessing();
122 return true;
123}

References mProcessors, and mWrapper.

◆ RealtimeSuspend()

bool VST3Instance::RealtimeSuspend ( )
overridevirtual
Returns
success Default implementation does nothing, returns true

Reimplemented from EffectInstance.

Definition at line 125 of file VST3Instance.cpp.

126{
127 mWrapper->SuspendProcessing();
128 for (auto &pProcessor : mProcessors)
129 pProcessor->mWrapper->SuspendProcessing();
130 return true;
131}

References mProcessors, and mWrapper.

◆ ReloadUserOptions()

void VST3Instance::ReloadUserOptions ( )

Definition at line 205 of file VST3Instance.cpp.

206{
207 // Reinitialize configuration settings
208 int userBlockSize;
210 wxT("BufferSize"), userBlockSize, 8192);
211 mUserBlockSize = std::max( 1, userBlockSize );
213 wxT("UseLatency"), mUseLatency, true);
214
216}
wxT("CloseDown"))
size_t SetBlockSize(size_t maxBlockSize) override
size_t mUserBlockSize
Definition: VST3Instance.h:33
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)

References PluginSettings::GetConfig(), PerTrackEffect::Instance::mProcessor, mUseLatency, mUserBlockSize, SetBlockSize(), PluginSettings::Shared, and wxT().

Referenced by VST3Instance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetBlockSize()

size_t VST3Instance::SetBlockSize ( size_t  maxBlockSize)
overridevirtual

Implements EffectInstance.

Definition at line 165 of file VST3Instance.cpp.

166{
168 static_cast<Steinberg::int32>(std::min(maxBlockSize, mUserBlockSize));
170}
int min(int a, int b)

References anonymous_namespace{StaffPadTimeAndPitch.cpp}::maxBlockSize, min(), mProcessingBlockSize, and mUserBlockSize.

Referenced by ReloadUserOptions().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mInitialDelay

sampleCount VST3Instance::mInitialDelay { 0 }
private

Definition at line 36 of file VST3Instance.h.

Referenced by ProcessInitialize(), and RealtimeInitialize().

◆ mProcessingBlockSize

size_t VST3Instance::mProcessingBlockSize { 8192 }
private

Definition at line 34 of file VST3Instance.h.

Referenced by GetBlockSize(), ProcessInitialize(), RealtimeInitialize(), and SetBlockSize().

◆ mProcessors

std::vector<std::unique_ptr<VST3Instance> > VST3Instance::mProcessors
private

◆ mRecruited

bool VST3Instance::mRecruited { false }
private

Definition at line 38 of file VST3Instance.h.

Referenced by RealtimeAddProcessor(), and RealtimeProcess().

◆ mUseLatency

bool VST3Instance::mUseLatency { true }
private

Definition at line 35 of file VST3Instance.h.

Referenced by ReloadUserOptions().

◆ mUserBlockSize

size_t VST3Instance::mUserBlockSize { 8192 }
private

Definition at line 33 of file VST3Instance.h.

Referenced by ReloadUserOptions(), and SetBlockSize().

◆ mWrapper

std::unique_ptr<VST3Wrapper> VST3Instance::mWrapper
private

The documentation for this class was generated from the following files: