Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler Class Reference
Inheritance diagram for anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler:
[legend]
Collaboration diagram for anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler:
[legend]

Public Member Functions

 ComponentHandler (VST3Wrapper &wrapper)
 
virtual ~ComponentHandler ()
 
void LoadCurrentParamValues ()
 
void SetAccess (EffectSettingsAccess *access)
 
EffectSettingsAccessGetAccess ()
 
void BeginStateChange (EffectSettings &settings)
 
void EndStateChange ()
 
void FlushCache (EffectSettings &settings)
 
void ResetCache ()
 
void NotifyParamChange (Steinberg::Vst::ParamID id, Steinberg::Vst::ParamValue valueNormalized)
 
Steinberg::tresult PLUGIN_API beginEdit (Steinberg::Vst::ParamID id) override
 
Steinberg::tresult PLUGIN_API performEdit (Steinberg::Vst::ParamID id, Steinberg::Vst::ParamValue valueNormalized) override
 
Steinberg::tresult PLUGIN_API endEdit (Steinberg::Vst::ParamID id) override
 
Steinberg::tresult PLUGIN_API restartComponent (Steinberg::int32 flags) override
 

Private Attributes

VST3WrappermWrapper
 
EffectSettingsAccessmAccess {nullptr}
 
const std::thread::id mThreadId
 
EffectSettingsmStateChangeSettings {nullptr}
 
std::map< Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue > mParametersCache
 
std::map< Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue > mCurrentParamValues
 

Detailed Description

Definition at line 244 of file VST3Wrapper.cpp.

Constructor & Destructor Documentation

◆ ComponentHandler()

anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::ComponentHandler ( VST3Wrapper wrapper)
inline

Definition at line 257 of file VST3Wrapper.cpp.

258 : mThreadId(std::this_thread::get_id()), mWrapper(wrapper)
259 {
260 FUNKNOWN_CTOR;
261 }

◆ ~ComponentHandler()

virtual anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::~ComponentHandler ( )
inlinevirtual

Definition at line 262 of file VST3Wrapper.cpp.

262{ FUNKNOWN_DTOR; }

Member Function Documentation

◆ beginEdit()

Steinberg::tresult PLUGIN_API anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::beginEdit ( Steinberg::Vst::ParamID  id)
inlineoverride

Definition at line 337 of file VST3Wrapper.cpp.

337{ return Steinberg::kResultOk; }

◆ BeginStateChange()

void anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::BeginStateChange ( EffectSettings settings)
inline

Definition at line 286 of file VST3Wrapper.cpp.

287 {
289 }
static Settings & settings()
Definition: TrackInfo.cpp:51

References settings().

Here is the call graph for this function:

◆ endEdit()

Steinberg::tresult PLUGIN_API anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::endEdit ( Steinberg::Vst::ParamID  id)
inlineoverride

Definition at line 363 of file VST3Wrapper.cpp.

363{ return Steinberg::kResultOk; }

◆ EndStateChange()

void anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::EndStateChange ( )
inline

Definition at line 291 of file VST3Wrapper.cpp.

292 {
293 assert(mStateChangeSettings != nullptr);
295 mStateChangeSettings = nullptr;
296 }

◆ FlushCache()

void anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::FlushCache ( EffectSettings settings)
inline

Definition at line 298 of file VST3Wrapper.cpp.

299 {
300 if(mParametersCache.empty())
301 return;
302
303 auto& vst3settings = GetSettings(settings);
304 for(auto& p : mParametersCache)
305 vst3settings.parameterChanges[p.first] = p.second;
306 mParametersCache.clear();
307 }
std::map< Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue > mParametersCache
VST3EffectSettings & GetSettings(EffectSettings &settings)

References anonymous_namespace{VST3Wrapper.cpp}::GetSettings(), and settings().

Here is the call graph for this function:

◆ GetAccess()

EffectSettingsAccess * anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::GetAccess ( )
inline

Definition at line 284 of file VST3Wrapper.cpp.

284{ return mAccess; }

◆ LoadCurrentParamValues()

void anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::LoadCurrentParamValues ( )
inline

Definition at line 264 of file VST3Wrapper.cpp.

265 {
266 const auto paramsCount = mWrapper.mEditController->getParameterCount();
267
268 for (int i = 0; i < paramsCount; ++i)
269 {
270 using Steinberg::Vst::ParameterInfo;
271 ParameterInfo info {};
272 mWrapper.mEditController->getParameterInfo(i, info);
273
274 if ((info.flags & ParameterInfo::kIsReadOnly) != 0)
275 continue;
276
277 mCurrentParamValues[info.id] =
278 mWrapper.mEditController->getParamNormalized(info.id);
279 }
280 }
Steinberg::IPtr< Steinberg::Vst::IEditController > mEditController
Definition: VST3Wrapper.h:70
std::map< Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue > mCurrentParamValues

References VST3Wrapper::mEditController.

◆ NotifyParamChange()

void anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::NotifyParamChange ( Steinberg::Vst::ParamID  id,
Steinberg::Vst::ParamValue  valueNormalized 
)
inline

Definition at line 314 of file VST3Wrapper.cpp.

316 {
317 auto it = mCurrentParamValues.find(id);
318
319 if (it == mCurrentParamValues.end())
320 return;
321
322 // Tolerance to avoid unnecessary updates
323 // Waves plugins constantly update several parameters
324 // with very small changes in the values without any
325 // user input
326 constexpr auto epsilon = Steinberg::Vst::ParamValue(1e-5);
327
328 if (std::abs(it->second - valueNormalized) < epsilon)
329 return;
330
331 it->second = valueNormalized;
332
334 mWrapper.ParamChangedHandler(id, valueNormalized);
335 }
std::function< void(Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue)> ParamChangedHandler
Definition: VST3Wrapper.h:143

References VST3Wrapper::ParamChangedHandler.

◆ performEdit()

Steinberg::tresult PLUGIN_API anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::performEdit ( Steinberg::Vst::ParamID  id,
Steinberg::Vst::ParamValue  valueNormalized 
)
inlineoverride

Definition at line 339 of file VST3Wrapper.cpp.

340 {
341 if(std::this_thread::get_id() != mThreadId)
342 return Steinberg::kResultFalse;
343
344 NotifyParamChange(id, valueNormalized);
345
346 if(mStateChangeSettings != nullptr || !mWrapper.IsActive())
347 // Collecting edit callbacks from the plug-in, in response to changes
348 // of complete state, while doing FetchSettings() (which may be delayed...)
349 mParametersCache[id] = valueNormalized;
350 else if(mAccess)
351 {
353 {
354 auto& vst3settings = GetSettings(settings);
355 vst3settings.parameterChanges[id] = valueNormalized;
356 return nullptr;
357 });
358 }
359
360 return Steinberg::kResultOk;
361 }
int id
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
bool IsActive() const noexcept
void NotifyParamChange(Steinberg::Vst::ParamID id, Steinberg::Vst::ParamValue valueNormalized)
Externalized state of a plug-in.

References anonymous_namespace{VST3Wrapper.cpp}::GetSettings(), id, VST3Wrapper::IsActive(), and settings().

Here is the call graph for this function:

◆ ResetCache()

void anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::ResetCache ( )
inline

Definition at line 309 of file VST3Wrapper.cpp.

310 {
311 mParametersCache.clear();
312 }

◆ restartComponent()

Steinberg::tresult PLUGIN_API anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::restartComponent ( Steinberg::int32  flags)
inlineoverride

Definition at line 365 of file VST3Wrapper.cpp.

365{ return Steinberg::kNotImplemented; }

◆ SetAccess()

void anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::SetAccess ( EffectSettingsAccess access)
inline

Definition at line 282 of file VST3Wrapper.cpp.

282{ mAccess = access; }

Member Data Documentation

◆ mAccess

EffectSettingsAccess* anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::mAccess {nullptr}
private

Definition at line 247 of file VST3Wrapper.cpp.

◆ mCurrentParamValues

std::map<Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue> anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::mCurrentParamValues
private

Definition at line 253 of file VST3Wrapper.cpp.

◆ mParametersCache

std::map<Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue> anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::mParametersCache
private

Definition at line 252 of file VST3Wrapper.cpp.

◆ mStateChangeSettings

EffectSettings* anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::mStateChangeSettings {nullptr}
private

Definition at line 251 of file VST3Wrapper.cpp.

◆ mThreadId

const std::thread::id anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::mThreadId
private

Definition at line 249 of file VST3Wrapper.cpp.

◆ mWrapper

VST3Wrapper& anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::mWrapper
private

Definition at line 246 of file VST3Wrapper.cpp.


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