Skip to content

Commit

Permalink
Fix a collection of scene mod small problems (surge-synthesizer#5207)
Browse files Browse the repository at this point in the history
There were a collection of problems in the new UI along with
the cross-scene stuff mostly involving mistakes around whether
a modulator was cross-scene or not. So

1. Make sure to always assigne macros and other non-split sources
   from an artificial scene 0
2. When iterating to show menus and clear, make sure you show
   all the targets for non-split sources
3. Read appropriate scene split state when activating items,
   which means an SLFO -> global in scene A didn't stay 'lit' in
   scene b

Closes surge-synthesizer#5180
Closes surge-synthesizer#5191
  • Loading branch information
baconpaul authored Oct 5, 2021
1 parent 5900e6f commit 74182de
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 17 deletions.
6 changes: 4 additions & 2 deletions src/common/SurgeSynthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2660,8 +2660,9 @@ void SurgeSynthesizer::updateUsedState()
for (int i = 0; i < n; i++)
{
int id = modlist->at(i).source_id;
assert((id > 0) && (id < n_modsources));
modsourceused[id] = true;
if (!isModulatorDistinctPerScene((modsources)id) ||
modlist->at(i).source_scene == scene)
modsourceused[id] = true;
}
}
}
Expand Down Expand Up @@ -2864,6 +2865,7 @@ void SurgeSynthesizer::clearModulation(long ptag, modsources modsource, int mods
bool SurgeSynthesizer::setModulation(long ptag, modsources modsource, int modsourceScene, int index,
float val)
{

if (!isValidModulation(ptag, modsource))
return false;
float value = storage.getPatch().param_ptr[ptag]->set_modulation_f01(val);
Expand Down
45 changes: 30 additions & 15 deletions src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,20 +603,25 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c
Parameter *parameter = synth->storage.getPatch().param_ptr[md];

auto use_scene = 0;
bool allScenes = true;
if (this->synth->isModulatorDistinctPerScene(thisms))
{
allScenes = false;
use_scene = current_scene;
}

if (((md < n_global_params) || ((parameter->scene - 1) == activeScene)) &&
bool isGlobal = md < n_global_params;
bool isActiveScene = parameter->scene - 1 == activeScene;

if ((isGlobal || isActiveScene || allScenes) &&
synth->isAnyActiveModulation(md, thisms, use_scene))
{

auto indices = synth->getModulationIndicesBetween(md, thisms, use_scene);
auto hasIdx = synth->supportsIndexedModulator(use_scene, thisms);
char modtxt[TXT_SIZE];

for (auto modidx : indices)
{

if (first_destination)
{
contextMenu.addSeparator();
Expand Down Expand Up @@ -644,6 +649,14 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c
targetName = parameter->get_full_name();
}

if (allScenes && (!isGlobal && !isActiveScene))
{
char sn[2];
sn[0] = 'A' + (parameter->scene - 1);
sn[1] = 0;
targetName += std::string() + " (Scene " + sn + ")";
}

auto clearOp = [this, first_destination, md, n_total_md, thisms, modidx,
use_scene, bvf, control]() {
bool resetName = false; // Should I reset the name?
Expand Down Expand Up @@ -760,8 +773,15 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c

if (n_md > 1)
{
auto use_scene = 0;
bool allScenes = true;
if (this->synth->isModulatorDistinctPerScene(thisms))
{
allScenes = false;
use_scene = current_scene;
}
auto allThree = std::make_unique<Surge::Widgets::ModMenuForAllComponent>(
[this, thisms, n_total_md,
[this, thisms, use_scene, allScenes, n_total_md,
control](Surge::Widgets::ModMenuForAllComponent::AllAction action) {
switch (action)
{
Expand All @@ -770,10 +790,10 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c
for (int md = 0; md < n_total_md; md++)
{
int scene = synth->storage.getPatch().param_ptr[md]->scene;
if (scene == 0 || scene == current_scene + 1)
if (scene == 0 || allScenes || scene == current_scene + 1)
for (auto idx : synth->getModulationIndicesBetween(
md, thisms, current_scene))
synth->clearModulation(md, thisms, current_scene, idx);
md, thisms, use_scene))
synth->clearModulation(md, thisms, use_scene, idx);
}

refresh_mod();
Expand Down Expand Up @@ -1974,8 +1994,8 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c
auto indices = synth->getModulationIndicesBetween(
ptag, (modsources)ms, sc);
for (auto idx : indices)
synth->muteModulation(ptag, (modsources)ms, sc, idx,
false);
synth->clearModulation(ptag, (modsources)ms, sc,
idx, false);
}
}
}
Expand Down Expand Up @@ -2797,15 +2817,10 @@ void SurgeGUIEditor::valueChanged(Surge::GUI::IComponentTagValue *control)
// maybe setModValue here
}

auto sourceScene = 0; // midi and macros map as 'scene 0' always
if (modsource >= ms_lfo1 && modsource <= ms_slfo6)
{
sourceScene = current_scene; // just the LFOs split
}
synth->setModulation(ptag, thisms, current_scene, modsource_index, mv);
auto use_scene = 0;
if (this->synth->isModulatorDistinctPerScene(thisms))
use_scene = current_scene;
synth->setModulation(ptag, thisms, use_scene, modsource_index, mv);

mci->setModulationState(
synth->isModDestUsed(p->id),
Expand Down

0 comments on commit 74182de

Please sign in to comment.