summaryrefslogtreecommitdiff
path: root/libs/evoral/src/SMF.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-02-19 16:54:21 -0500
committerDavid Robillard <d@drobilla.net>2015-02-19 18:38:30 -0500
commit450291adfca22a41fb63f8792fd588cede35b463 (patch)
tree20fbbb4c53e2534dc16c62d425113025677fb636 /libs/evoral/src/SMF.cpp
parent6fb4bd578ef30fc65c06b98c32a3278d9c443696 (diff)
Fix record/import of note ons with velocity 0.
Best to just do this as early as possible to avoid having to deal with this situation all over the code. Also fixes violation of LV2 MIDI specification, which requires no such events are delivered to plugins.
Diffstat (limited to 'libs/evoral/src/SMF.cpp')
-rw-r--r--libs/evoral/src/SMF.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/libs/evoral/src/SMF.cpp b/libs/evoral/src/SMF.cpp
index 42c5369b76..edf33c23f2 100644
--- a/libs/evoral/src/SMF.cpp
+++ b/libs/evoral/src/SMF.cpp
@@ -287,6 +287,11 @@ SMF::read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf, event_id_t* no
}
memcpy(*buf, event->midi_buffer, size_t(event_size));
*size = event_size;
+ if ((*buf)[0] == 0x90 && (*buf)[2] == 0) {
+ /* normalize note on with velocity 0 to proper note off */
+ (*buf)[0] = 0x80; /* note off */
+ (*buf)[2] = 0x40; /* default velocity */
+ }
if (!midi_event_is_valid(*buf, *size)) {
cerr << "WARNING: SMF ignoring illegal MIDI event" << endl;