Handle 0-vel noteons as noteoffs

This commit is contained in:
Paul Ferrand 2020-05-05 22:34:46 +02:00
parent b0c84ad99a
commit 5ee3e92848
2 changed files with 8 additions and 6 deletions

View file

@ -495,28 +495,27 @@ sfizz_lv2_process_midi_event(sfizz_plugin_t *self, const LV2_Atom_Event *ev)
switch (lv2_midi_message_type(msg))
{
case LV2_MIDI_MSG_NOTE_ON:
// LV2_DEBUG("[process_midi] Received note on %d/%d at time %ld\n", msg[0], msg[1], ev->time.frames);
if (msg[2] == 0)
goto noteoff; // 0 velocity note-ons should be forbidden but just in case...
sfizz_send_note_on(self->synth,
(int)ev->time.frames,
(int)msg[1],
msg[2]);
break;
case LV2_MIDI_MSG_NOTE_OFF:
// LV2_DEBUG("[process_midi] Received note off %d/%d at time %ld\n", msg[0], msg[1], ev->time.frames);
case LV2_MIDI_MSG_NOTE_OFF: noteoff:
sfizz_send_note_off(self->synth,
(int)ev->time.frames,
(int)msg[1],
msg[2]);
break;
case LV2_MIDI_MSG_CONTROLLER:
// LV2_DEBUG("[process_midi] Received CC %d/%d at time %ld\n", msg[0], msg[1], ev->time.frames);
sfizz_send_cc(self->synth,
(int)ev->time.frames,
(int)msg[1],
msg[2]);
break;
case LV2_MIDI_MSG_BENDER:
// LV2_DEBUG("[process_midi] Received pitch bend %d on channel %d at time %ld\n", PITCH_BUILD_AND_CENTER(msg[1], msg[2]), MIDI_CHANNEL(msg[0]), ev->time.frames);
sfizz_send_pitch_wheel(self->synth,
(int)ev->time.frames,
PITCH_BUILD_AND_CENTER(msg[1], msg[2]));

View file

@ -284,7 +284,10 @@ void SfizzVstProcessor::processEvents(Vst::IEventList& events)
switch (e.type) {
case Vst::Event::kNoteOnEvent:
synth.noteOn(e.sampleOffset, e.noteOn.pitch, convertVelocityFromFloat(e.noteOn.velocity));
if (e.noteOn.velocity == 0.0f)
synth.noteOff(e.sampleOffset, e.noteOn.pitch, 0);
else
synth.noteOn(e.sampleOffset, e.noteOn.pitch, convertVelocityFromFloat(e.noteOn.velocity));
break;
case Vst::Event::kNoteOffEvent:
synth.noteOff(e.sampleOffset, e.noteOff.pitch, convertVelocityFromFloat(e.noteOff.velocity));