Ensure plugin CC does not Reset all controllers

This commit is contained in:
Jean Pierre Cimalando 2021-04-30 09:56:07 +02:00
parent 9d8e184d05
commit 13dfddae64
2 changed files with 27 additions and 12 deletions

View file

@ -645,7 +645,7 @@ sfizz_lv2_handle_atom_object(sfizz_plugin_t *self, int delay, const LV2_Atom_Obj
if (cc != -1) {
if (atom->type == self->atom_float_uri && atom->size == sizeof(float)) {
float value = *(const float *)LV2_ATOM_BODY_CONST(atom);
sfizz_send_hdcc(self->synth, delay, cc, value);
sfizz_automate_hdcc(self->synth, delay, cc, value);
self->cc_current[cc] = value;
self->ccauto[cc] = absl::nullopt;
}
@ -711,13 +711,28 @@ sfizz_lv2_process_midi_event(sfizz_plugin_t *self, const LV2_Atom_Event *ev)
{
unsigned cc = msg[1];
float value = float(msg[2]) * (1.0f / 127.0f);
sfizz_send_hdcc(self->synth,
(int)ev->time.frames,
(int)cc,
value);
self->cc_current[cc] = value;
self->ccauto[cc] = value;
self->have_ccauto = true;
switch (cc)
{
default:
{
sfizz_automate_hdcc(self->synth,
(int)ev->time.frames,
(int)cc,
value);
self->cc_current[cc] = value;
self->ccauto[cc] = value;
self->have_ccauto = true;
}
break;
case LV2_MIDI_CTL_ALL_NOTES_OFF:
// TODO implemented as all-sound-off
sfizz_all_sound_off(self->synth);
break;
case LV2_MIDI_CTL_ALL_SOUNDS_OFF:
sfizz_all_sound_off(self->synth);
break;
}
}
break;
#endif
@ -1416,7 +1431,7 @@ restore(LV2_Handle instance,
absl::optional<float> value = cc_values[cc];
if (value) {
// Set CC in the synth
sfizz_send_hdcc(self->synth, 0, int(cc), *value);
sfizz_automate_hdcc(self->synth, 0, int(cc), *value);
// Mark CCs for automation with state values
self->ccauto[cc] = *value;
self->have_ccauto = true;

View file

@ -442,7 +442,7 @@ void SfizzVstProcessor::playOrderedParameter(int32 sampleOffset, Vst::ParamID id
default:
if (id >= kPidCC0 && id <= kPidCCLast) {
int32 ccNumber = static_cast<int32>(id - kPidCC0);
synth.hdcc(sampleOffset, ccNumber, value);
synth.automateHdcc(sampleOffset, ccNumber, value);
_state.controllers[ccNumber] = value;
}
break;
@ -518,7 +518,7 @@ void SfizzVstProcessor::processMessagesFromUi()
synth.noteOn(0, data[1] & 0x7f, data[2] & 0x7f);
break;
case 0xb0:
synth.cc(0, data[1] & 0x7f, data[2] & 0x7f);
synth.automateHdcc(0, data[1] & 0x7f, (data[2] & 0x7f) / 127.0f);
break;
case 0xe0:
synth.pitchWheel(0, (data[2] << 7) + data[1] - 8192);
@ -713,7 +713,7 @@ void SfizzVstProcessor::loadSfzFileOrDefault(const std::string& filePath, bool i
for (uint32 cc = 0; cc < sfz::config::numCCs; ++cc) {
if (absl::optional<float> value = oldControllers[cc]) {
newControllers[cc] = *value;
synth.hdcc(0, int(cc), *value);
synth.automateHdcc(0, int(cc), *value);
}
}
}