From eecb43c9c40c9e22d86e8bdc31852dc51e9de39e Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Fri, 11 Oct 2024 14:14:58 -0400 Subject: [PATCH] AUV2 Param refresh AUV2 cached param info so the rescan messages were used by hosts who then got a stale cache. Fix this by rebuilding the info cache when a rescan occurs. --- src/detail/auv2/parameter.cpp | 6 +++++ src/detail/auv2/parameter.h | 2 ++ src/wrapasauv2.cpp | 41 ++++++++++++++++++++++++++--------- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/detail/auv2/parameter.cpp b/src/detail/auv2/parameter.cpp index 8f9a1852..b268430c 100644 --- a/src/detail/auv2/parameter.cpp +++ b/src/detail/auv2/parameter.cpp @@ -10,6 +10,12 @@ Parameter::Parameter(clap_param_info_t &clap_param) _cfstring = CFStringCreateWithCString(NULL, _info.name, kCFStringEncodingUTF8); } +void Parameter::resetInfo(const clap_param_info_t &i) +{ + _info = i; + CFRelease(_cfstring); + _cfstring = CFStringCreateWithCString(NULL, _info.name, kCFStringEncodingUTF8); +} Parameter::~Parameter() { CFRelease(_cfstring); diff --git a/src/detail/auv2/parameter.h b/src/detail/auv2/parameter.h index 1f8d4c15..829638fa 100644 --- a/src/detail/auv2/parameter.h +++ b/src/detail/auv2/parameter.h @@ -45,6 +45,8 @@ class Parameter return _cfstring; } + void resetInfo(const clap_param_info_t& i); + private: clap_param_info_t _info; CFStringRef _cfstring; diff --git a/src/wrapasauv2.cpp b/src/wrapasauv2.cpp index 730960ab..0fbf2c23 100644 --- a/src/wrapasauv2.cpp +++ b/src/wrapasauv2.cpp @@ -338,9 +338,18 @@ void WrapAsAUV2::setupParameters(const clap_plugin_t* plugin, const clap_plugin_ double result; if (p->get_value(_plugin->_plugin, paraminfo.id, &result)) { - // creating the mapping object and insert it into the tree - // this will also create Clumps if necessary - _parametertree[paraminfo.id] = std::make_unique(paraminfo); + // If the parametre is already created, just restate its info + auto piter = _parametertree.find(paraminfo.id); + if (piter == _parametertree.end()) + { + // creating the mapping object and insert it into the tree + // this will also create Clumps if necessary + _parametertree[paraminfo.id] = std::make_unique(paraminfo); + } + else + { + piter->second->resetInfo(paraminfo); + } Globals()->SetParameter(paraminfo.id, result); } } @@ -356,35 +365,47 @@ OSStatus WrapAsAUV2::GetParameterList(AudioUnitScope inScope, AudioUnitParameter void WrapAsAUV2::param_rescan(clap_param_rescan_flags flags) { + // Re-call setup parameters which will just reset info if the param exists + setupParameters(_plugin->_plugin, _plugin->_ext._params); + // if ( flags & CLAP_PARAM_RESCAN_ALL) // TODO: check out how differentiated we can do this { - PropertyChanged(kAudioUnitProperty_ParameterInfo, kAudioUnitScope_Global, 0); PropertyChanged(kAudioUnitProperty_ParameterList, kAudioUnitScope_Global, 0); + PropertyChanged(kAudioUnitProperty_ParameterInfo, kAudioUnitScope_Global, 0); + PropertyChanged(kAudioUnitProperty_ClassInfo, kAudioUnitScope_Global, 0); return; } + // This code doesn't actually do what we want but leave it hear for the comment + // above and future investigation #if 0 AudioUnitEvent myEvent; myEvent.mArgument.mProperty.mAudioUnit = GetComponentInstance(); myEvent.mArgument.mProperty.mScope = kAudioUnitScope_Global; myEvent.mArgument.mProperty.mElement = 0; myEvent.mEventType = kAudioUnitEvent_PropertyChange; - + { - for ( auto& i : _parametertree) + for (auto& i : _parametertree) { - if ( i.second->info().flags & CLAP_PARAM_IS_AUTOMATABLE) + *of << "Considering param" << std::endl; + if (i.second->info().flags & CLAP_PARAM_IS_AUTOMATABLE) { + *of << "which is automatable" << std::endl; myEvent.mArgument.mProperty.mElement = i.second->info().id; - - if ( flags & CLAP_PARAM_RESCAN_INFO) + + if (flags & CLAP_PARAM_RESCAN_INFO) { + *of << "rescan info" << std::endl; myEvent.mArgument.mProperty.mPropertyID = kAudioUnitProperty_ParameterInfo; AUEventListenerNotify(NULL, NULL, &myEvent); + myEvent.mArgument.mProperty.mPropertyID = kAudioUnitProperty_ParameterIDName; + AUEventListenerNotify(NULL, NULL, &myEvent); } - if ( flags & CLAP_PARAM_RESCAN_TEXT ) + if (flags & CLAP_PARAM_RESCAN_TEXT) { + *of << "wrescan text" << std::endl; myEvent.mArgument.mProperty.mPropertyID = kAudioUnitProperty_ParameterValueStrings; AUEventListenerNotify(NULL, NULL, &myEvent); }