Skip to content

Commit

Permalink
Apply param changes when presets change
Browse files Browse the repository at this point in the history
A diff from IRC user CrystalMath which notifies the LV2
parameter set when the editor initiatest a patch change.

Closes surge-synthesizer#1176
  • Loading branch information
baconpaul committed Sep 17, 2019
1 parent e97a827 commit b39cea9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/common/SurgeSynthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2137,6 +2137,9 @@ DWORD WINAPI loadPatchInBackgroundThread(LPVOID lpParam)
synth->patchid_queue = -1;
synth->allNotesOff();
synth->loadPatch(patchid);
#if TARGET_LV2
synth->getParent()->patchChanged();
#endif
synth->halt_engine = false;
return 0;
}
Expand All @@ -2149,6 +2152,9 @@ void SurgeSynthesizer::processThreadunsafeOperations()
if (patchid_queue >= 0)
{
loadPatch(patchid_queue);
#if TARGET_LV2
getParent()->patchChanged();
#endif
patchid_queue = -1;
}

Expand Down
14 changes: 14 additions & 0 deletions src/lv2/SurgeLv2Wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ void SurgeLv2Wrapper::setParameterAutomated(int externalparam, float value)
_editor->setParameterAutomated(externalparam, value);
}

void SurgeLv2Wrapper::patchChanged(void)
{
if( _editor == nullptr ) return;

SurgeSynthesizer *s = _synthesizer.get();

for (unsigned int i = 0; i < n_total_params; i++)
{
unsigned index = s->remapExternalApiToInternalId(i);
float value = s->getParameter01(index);
_editor->setParameterAutomated(i, value);
}
}

LV2_Handle SurgeLv2Wrapper::instantiate(const LV2_Descriptor* descriptor,
double sample_rate,
const char* bundle_path,
Expand Down
1 change: 1 addition & 0 deletions src/lv2/SurgeLv2Wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class SurgeLv2Wrapper
// PluginLayer
void updateDisplay();
void setParameterAutomated(int externalparam, float value);
void patchChanged(void);

private:
static LV2_Handle instantiate(const LV2_Descriptor* descriptor,
Expand Down

0 comments on commit b39cea9

Please sign in to comment.