| 242 | Steinberg::Vst::IParameterChanges::iid); |
| 243 | |
| 244 | class ComponentHandler : public Steinberg::Vst::IComponentHandler |
| 245 | { |
| 246 | VST3Wrapper& mWrapper; |
| 247 | EffectSettingsAccess* mAccess{nullptr}; |
| 248 | //Used to prevent calls from non-UI thread |
| 249 | const std::thread::id mThreadId; |
| 250 | |
| 251 | EffectSettings* mStateChangeSettings {nullptr}; |
| 252 | std::map<Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue> mParametersCache; |
| 253 | std::map<Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue> mCurrentParamValues; |
| 254 | |
| 255 | public: |
| 256 | |
| 257 | ComponentHandler(VST3Wrapper& wrapper) |
| 258 | : mThreadId(std::this_thread::get_id()), mWrapper(wrapper) |
| 259 | { |
| 260 | FUNKNOWN_CTOR; |
| 261 | } |
| 262 | virtual ~ComponentHandler() { FUNKNOWN_DTOR; } |
| 263 | |
| 264 | void LoadCurrentParamValues() |
| 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 | } |
| 281 | |
| 282 | void SetAccess(EffectSettingsAccess* access) { mAccess = access; } |
| 283 | |
| 284 | EffectSettingsAccess* GetAccess() { return mAccess; } |
| 285 | |
| 286 | void BeginStateChange(EffectSettings& settings) |
| 287 | { |
| 288 | mStateChangeSettings = &settings; |
| 289 | } |
| 290 | |
| 291 | void EndStateChange() |
| 292 | { |
| 293 | assert(mStateChangeSettings != nullptr); |
| 294 | FlushCache(*mStateChangeSettings); |
| 295 | mStateChangeSettings = nullptr; |
| 296 | } |
| 297 | |
| 298 | void FlushCache(EffectSettings& settings) |
| 299 | { |
| 300 | if(mParametersCache.empty()) |
| 301 | return; |
no outgoing calls
no test coverage detected