Skip to content

Commit cfd17d7

Browse files
authored
Apply structural-param side effects on host automation (#366)
Audio-thread CLAP param events updated the param value but skipped the reapplyControlSettings / resetSoloState dispatch that the UI path runs, so automating play mode, polyphony, MPE, sample rate strategy, the output filters, bit rate, or solo silently failed to reconfigure the engine. Extract the side-effect block into handleAudioThreadParamSideEffects and call it from both the UI message path and the CLAP event path. Match the UI path's int-vs-float discipline so discrete params snap before the side-effect call sees them. Assisted-By: Claude Opus 4.7
1 parent 2ee4e3e commit cfd17d7

3 files changed

Lines changed: 36 additions & 27 deletions

File tree

doc/12_roadmap.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
I have a lot of ideas for a '1.2' version of six sines. Not 2.0. Still compatible. But expanded. Here's my rough list
44

5-
## THings which came in after mostly done
6-
7-
- Reset Controls when automated for clap edge for things like sample rate
8-
95
## Modulation
106
- Clamp targets
117
- LFO -> M etc... depth as an additive and attenuation target

src/synth/synth.cpp

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -698,26 +698,7 @@ void Synth::processUIQueue(const clap_output_events_t *outq)
698698
dest->value = uiM->value;
699699
}
700700

701-
/*
702-
* Some params have other side effects
703-
*/
704-
if (dest->meta.id == patch.output.playMode.meta.id ||
705-
dest->meta.id == patch.output.polyLimit.meta.id ||
706-
dest->meta.id == patch.output.pianoModeActive.meta.id ||
707-
dest->meta.id == patch.output.mpeActive.meta.id ||
708-
dest->meta.id == patch.output.sampleRateStrategy.meta.id ||
709-
dest->meta.id == patch.output.resampleEngine.meta.id ||
710-
dest->meta.id == patch.output.lowpass.meta.id ||
711-
dest->meta.id == patch.output.highpass.meta.id ||
712-
dest->meta.id == patch.output.bitRateAdjust.meta.id)
713-
{
714-
reapplyControlSettings();
715-
}
716-
717-
if (dest->adhocFeatures & Param::AdHocFeatureValues::SOLO)
718-
{
719-
resetSoloState();
720-
}
701+
handleAudioThreadParamSideEffects(dest);
721702

722703
auto d = patch.dirty;
723704
if (!d)
@@ -1075,14 +1056,45 @@ void Synth::handleParamValue(Param *p, uint32_t pid, float value)
10751056
p = patch.paramMap.at(pid);
10761057
}
10771058

1078-
// p->value = value;
1079-
p->lag.setTarget(value);
1080-
paramLagSet.addToActive(p);
1059+
// Mirror the UI path (SET_PARAM): only FLOATs lag; discrete params snap so
1060+
// that handleAudioThreadParamSideEffects sees the new value, not the old.
1061+
if (p->meta.type == md_t::FLOAT)
1062+
{
1063+
p->lag.setTarget(value);
1064+
paramLagSet.addToActive(p);
1065+
}
1066+
else
1067+
{
1068+
p->value = value;
1069+
}
1070+
1071+
handleAudioThreadParamSideEffects(p);
10811072

10821073
AudioToUIMsg au = {AudioToUIMsg::UPDATE_PARAM, pid, value};
10831074
audioToUi.push(au);
10841075
}
10851076

1077+
void Synth::handleAudioThreadParamSideEffects(Param *dest)
1078+
{
1079+
if (dest->meta.id == patch.output.playMode.meta.id ||
1080+
dest->meta.id == patch.output.polyLimit.meta.id ||
1081+
dest->meta.id == patch.output.pianoModeActive.meta.id ||
1082+
dest->meta.id == patch.output.mpeActive.meta.id ||
1083+
dest->meta.id == patch.output.sampleRateStrategy.meta.id ||
1084+
dest->meta.id == patch.output.resampleEngine.meta.id ||
1085+
dest->meta.id == patch.output.lowpass.meta.id ||
1086+
dest->meta.id == patch.output.highpass.meta.id ||
1087+
dest->meta.id == patch.output.bitRateAdjust.meta.id)
1088+
{
1089+
reapplyControlSettings();
1090+
}
1091+
1092+
if (dest->adhocFeatures & Param::AdHocFeatureValues::SOLO)
1093+
{
1094+
resetSoloState();
1095+
}
1096+
}
1097+
10861098
void Synth::pushFullUIRefresh()
10871099
{
10881100
for (const auto *p : patch.params)

src/synth/synth.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ struct Synth
522522

523523
void reapplyControlSettings();
524524
void resetSoloState();
525+
void handleAudioThreadParamSideEffects(Param *dest);
525526

526527
sst::cpputils::active_set_overlay<Param> paramLagSet;
527528

0 commit comments

Comments
 (0)