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 214 of file VST3Wrapper.cpp.

Constructor & Destructor Documentation

◆ ComponentHandler()

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

Definition at line 227 of file VST3Wrapper.cpp.

228 : mThreadId(std::this_thread::get_id()), mWrapper(wrapper)
229 {
230 FUNKNOWN_CTOR;
231 }

◆ ~ComponentHandler()

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

Definition at line 232 of file VST3Wrapper.cpp.

232{ FUNKNOWN_DTOR; }

Member Function Documentation

◆ beginEdit()

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

Definition at line 310 of file VST3Wrapper.cpp.

310{ return Steinberg::kResultOk; }

◆ BeginStateChange()

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

Definition at line 259 of file VST3Wrapper.cpp.

260 {
262 }
static Settings & settings()
Definition: TrackInfo.cpp:87

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 336 of file VST3Wrapper.cpp.

336{ return Steinberg::kResultOk; }

◆ EndStateChange()

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

Definition at line 264 of file VST3Wrapper.cpp.

265 {
266 assert(mStateChangeSettings != nullptr);
268 mStateChangeSettings = nullptr;
269 }

◆ FlushCache()

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

Definition at line 271 of file VST3Wrapper.cpp.

272 {
273 if(mParametersCache.empty())
274 return;
275
276 auto& vst3settings = GetSettings(settings);
277 for(auto& p : mParametersCache)
278 vst3settings.parameterChanges[p.first] = p.second;
279 mParametersCache.clear();
280 }
std::map< Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue > mParametersCache
VST3EffectSettings & GetSettings(EffectSettings &settings)
Definition: VST3Wrapper.cpp:80

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 257 of file VST3Wrapper.cpp.

257{ return mAccess; }

◆ LoadCurrentParamValues()

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

Definition at line 234 of file VST3Wrapper.cpp.

235 {
236 const auto paramsCount = mWrapper.mEditController->getParameterCount();
237
238 for (int i = 0; i < paramsCount; ++i)
239 {
240 using Steinberg::Vst::ParameterInfo;
241 ParameterInfo info {};
242 mWrapper.mEditController->getParameterInfo(i, info);
243
244 if (info.flags & (ParameterInfo::kIsHidden | ParameterInfo::kIsProgramChange))
245 continue;
246
247 if ((info.flags & ParameterInfo::kCanAutomate) == 0)
248 continue;
249
250 mCurrentParamValues[info.id] =
251 mWrapper.mEditController->getParamNormalized(info.id);
252 }
253 }
Steinberg::IPtr< Steinberg::Vst::IEditController > mEditController
Definition: VST3Wrapper.h:61
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 287 of file VST3Wrapper.cpp.

289 {
290 auto it = mCurrentParamValues.find(id);
291
292 if (it == mCurrentParamValues.end())
293 return;
294
295 // Tolerance to avoid unnecessary updates
296 // Waves plugins constantly update several parameters
297 // with very small changes in the values without any
298 // user input
299 constexpr auto epsilon = Steinberg::Vst::ParamValue(1e-5);
300
301 if (std::abs(it->second - valueNormalized) < epsilon)
302 return;
303
304 it->second = valueNormalized;
305
307 mWrapper.ParamChangedHandler(id, valueNormalized);
308 }
std::function< void(Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue)> ParamChangedHandler
Definition: VST3Wrapper.h:126

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 312 of file VST3Wrapper.cpp.

313 {
314 if(std::this_thread::get_id() != mThreadId)
315 return Steinberg::kResultFalse;
316
317 NotifyParamChange(id, valueNormalized);
318
319 if(mStateChangeSettings != nullptr || !mWrapper.IsActive())
320 // Collecting edit callbacks from the plug-in, in response to changes
321 // of complete state, while doing FetchSettings() (which may be delayed...)
322 mParametersCache[id] = valueNormalized;
323 else if(mAccess)
324 {
326 {
327 auto& vst3settings = GetSettings(settings);
328 vst3settings.parameterChanges[id] = valueNormalized;
329 return nullptr;
330 });
331 }
332
333 return Steinberg::kResultOk;
334 }
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 282 of file VST3Wrapper.cpp.

283 {
284 mParametersCache.clear();
285 }

◆ restartComponent()

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

Definition at line 338 of file VST3Wrapper.cpp.

338{ return Steinberg::kNotImplemented; }

◆ SetAccess()

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

Definition at line 255 of file VST3Wrapper.cpp.

255{ mAccess = access; }

Member Data Documentation

◆ mAccess

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

Definition at line 217 of file VST3Wrapper.cpp.

◆ mCurrentParamValues

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

Definition at line 223 of file VST3Wrapper.cpp.

◆ mParametersCache

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

Definition at line 222 of file VST3Wrapper.cpp.

◆ mStateChangeSettings

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

Definition at line 221 of file VST3Wrapper.cpp.

◆ mThreadId

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

Definition at line 219 of file VST3Wrapper.cpp.

◆ mWrapper

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

Definition at line 216 of file VST3Wrapper.cpp.


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