Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Osc pre 132: fixes for #7579 and #7626; VST3 automation parameter changes echoed to OSC. #7632

Merged
merged 6 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions resources/surge-shared/oscspecification.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,10 @@
not how messages are to be formatted for OSC).
</p>
<p style="margin-top: 28px;">
<b>OSC Output</b>: All parameter, patch, tuning and modulation mapping changes made on Surge
XT are reported to
OSC out, if OSC output is enabled.
Parameters are reported in the ranges given under "Appropriate Values" (0.0 - 1.0 for
'float' parameters), followed by a
displayable string.
<b>OSC Output</b>: Parameter, patch, tuning and modulation mapping changes
made on Surge XT are reported to OSC out, if OSC output is enabled.
Parameters are reported in the ranges given under "Appropriate Values"
(0.0 - 1.0 for 'float' parameters), followed by a displayable string.
Errors are reported (when feasible) to "/error".
</p>
<div style="margin: 16px 0 8px 0" ;>
Expand Down Expand Up @@ -1537,6 +1535,7 @@ <h3>Sent to OSC client whenever a parameter is queried using '/q/param' or
<tr>
<td>/doc/&lt;parameter address&gt;</td>
<td>description</td>
<td>type</td>
<td>minimum value</td>
<td>maximum value</td>
</tr>
Expand Down
3 changes: 2 additions & 1 deletion src/surge-xt/SurgeSynthEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@ void SurgeSynthEditor::endParameterEdit(Parameter *p)
auto par = processor.paramsByID[processor.surge->idForParameter(p)];
par->inEditGesture = false;
par->endChangeGesture();
processor.paramChangeToListeners(p);
if (fireListenersOnEndEdit)
processor.paramChangeToListeners(p);
}

void SurgeSynthEditor::beginMacroEdit(long macroNum)
Expand Down
2 changes: 2 additions & 0 deletions src/surge-xt/SurgeSynthEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class SurgeSynthEditor : public juce::AudioProcessorEditor,
int midiKeyboardOctave{5};
float midiKeyboardVelocity{127.f / 127.f}; // see issue #6409

bool fireListenersOnEndEdit{true};

std::unique_ptr<juce::Component> pitchwheel, modwheel, suspedal;
std::unique_ptr<juce::MidiKeyboardComponent> keyboard;
std::unique_ptr<juce::Label> tempoLabel, sustainLabel;
Expand Down
43 changes: 18 additions & 25 deletions src/surge-xt/SurgeSynthProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ void SurgeSynthProcessor::paramChangeToListeners(Parameter *p, bool isSpecialCas
int diff = (int)f0 ^ (int)f1;
if (diff != 0) // should always be true
{
unsigned i = 1, pos = 1;
unsigned i = 1, pos = 0;
while (pos <= n_fx_slots)
{
if (i & diff)
Expand Down Expand Up @@ -878,22 +878,20 @@ void SurgeSynthProcessor::processBlockOSC()
{
float pval = om.fval;
if (om.param->valtype == vt_int)
pval = Parameter::intScaledToFloat(pval, om.param->val_max.i, om.param->val_min.i);
pval =
Parameter::intScaledToFloat(om.fval, om.param->val_max.i, om.param->val_min.i);

if (pval != om.param->val.f)
{
surge->setParameter01(surge->idForParameter(om.param), pval, true);
surge->storage.getPatch().isDirty = true;
surge->setParameter01(surge->idForParameter(om.param), pval, true);
surge->storage.getPatch().isDirty = true;

// Special cases: A few control types require a rebuild and
// SGE Value Callbacks would do it as would the VST3 param handler
// so put them here for now. Bit of a hack...
auto ct = om.param->ctrltype;
if (ct == ct_bool_solo || ct == ct_bool_mute || ct == ct_scenesel)
surge->refresh_editor = true;
else
surge->queueForRefresh(om.param->id);
}
// Special cases: A few control types require a rebuild and
// SGE Value Callbacks would do it as would the VST3 param handler
// so put them here for now. Bit of a hack...
auto ct = om.param->ctrltype;
if (ct == ct_bool_solo || ct == ct_bool_mute || ct == ct_scenesel)
surge->refresh_editor = true;
else
surge->queueForRefresh(om.param->id);
}
break;

Expand Down Expand Up @@ -940,16 +938,12 @@ void SurgeSynthProcessor::processBlockOSC()
newDisabledMask = curmask & msk;
}
else // set selected bit to one
{
newDisabledMask = curmask | msk;
}

surge->storage.getPatch().fx_disable.val.i = newDisabledMask;
if (surge->fx_suspend_bitmask != newDisabledMask)
{
surge->fx_suspend_bitmask = newDisabledMask;
surge->storage.getPatch().isDirty = true;
surge->queueForRefresh(om.param->id);
}
surge->fx_suspend_bitmask = newDisabledMask;
surge->storage.getPatch().isDirty = true;
surge->refresh_editor = true;
}
break;

Expand Down Expand Up @@ -1709,8 +1703,7 @@ void SurgeParamToJuceParamAdapter::setValue(float f)
if (!matches && !inEditGesture)
{
s->setParameter01(s->idForParameter(p), f, true);
// Probably OSC needs this
// ssp->paramChangeToListeners(p);
ssp->paramChangeToListeners(p);
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/surge-xt/SurgeSynthProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,13 @@ class SurgeSynthProcessor : public juce::AudioProcessor,
int scene{0}, index{0};

oscToAudio() {}
explicit oscToAudio(oscToAudio_type omtype, Parameter *p, float f, int i, char c0, char c1,
bool on, int32_t noteid, int scene, int index)
: type(omtype), param(p), fval(f), ival(i), char0(c0), char1(c1), on(on),
noteid(noteid), scene(scene), index(index)
{
}

oscToAudio(oscToAudio_type omtype, char c0, char c1, int i)
: type(omtype), char0(c0), char1(c1), ival(i)
{
Expand Down
2 changes: 2 additions & 0 deletions src/surge-xt/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,7 @@ void SurgeGUIEditor::idle()
}
}

juceEditor->fireListenersOnEndEdit = false;
for (int s = 0; s < n_scenes; ++s)
{
for (int o = 0; o < n_oscs; ++o)
Expand Down Expand Up @@ -1317,6 +1318,7 @@ void SurgeGUIEditor::idle()
juceEditor->endParameterEdit(&par);
}
}
juceEditor->fireListenersOnEndEdit = true;
}

void SurgeGUIEditor::toggle_mod_editing()
Expand Down
5 changes: 3 additions & 2 deletions src/surge-xt/osc/OpenSoundControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,6 @@ void OpenSoundControl::oscMessageReceived(const juce::OSCMessage &message)

fxslot = std::distance(std::begin(fxslot_shortoscname), found);
int selected_mask = 1 << fxslot;

if (querying)
{
int deac_mask = synth->storage.getPatch().fx_disable.val.i;
Expand Down Expand Up @@ -729,7 +728,9 @@ void OpenSoundControl::oscMessageReceived(const juce::OSCMessage &message)
}

// Send packet to audio thread
sspPtr->oscRingBuf.push(SurgeSynthProcessor::oscToAudio(selected_mask, onoff));
sspPtr->oscRingBuf.push(
SurgeSynthProcessor::oscToAudio(SurgeSynthProcessor::FX_DISABLE, nullptr, 0.0,
selected_mask, 0, 0, onoff > 0, 0, 0, 0));
}
}

Expand Down