Skip to content

Commit

Permalink
AUV2 Param refresh (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul authored Oct 11, 2024
1 parent e6a09e9 commit bf887a8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/detail/auv2/parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/detail/auv2/parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class Parameter
return _cfstring;
}

void resetInfo(const clap_param_info_t& i);

private:
clap_param_info_t _info;
CFStringRef _cfstring;
Expand Down
41 changes: 31 additions & 10 deletions src/wrapasauv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Clap::AUv2::Parameter>(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<Clap::AUv2::Parameter>(paraminfo);
}
else
{
piter->second->resetInfo(paraminfo);
}
Globals()->SetParameter(paraminfo.id, result);
}
}
Expand All @@ -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);
}
Expand Down

0 comments on commit bf887a8

Please sign in to comment.