summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/MidiNoteNode.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-10-13 22:47:24 +0000
committerDavid Robillard <d@drobilla.net>2007-10-13 22:47:24 +0000
commitc42dc3251f0c04e73c37f21989ebef97860ace34 (patch)
tree14f54ceef6b2bf6bbb4ed4f2101f6eda8761f1f0 /src/libs/engine/MidiNoteNode.cpp
parent1c92f8782006264e94dd25a650841f72f91650cf (diff)
downloadingen-c42dc3251f0c04e73c37f21989ebef97860ace34.tar.gz
ingen-c42dc3251f0c04e73c37f21989ebef97860ace34.tar.bz2
ingen-c42dc3251f0c04e73c37f21989ebef97860ace34.zip
Fix crash on destroying LADSPA nodes.
Tolerate MIDI with double notes (ie two note-ons with no note-off in between). git-svn-id: http://svn.drobilla.net/lad/ingen@884 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/MidiNoteNode.cpp')
-rw-r--r--src/libs/engine/MidiNoteNode.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libs/engine/MidiNoteNode.cpp b/src/libs/engine/MidiNoteNode.cpp
index c90f44ae..128b7a13 100644
--- a/src/libs/engine/MidiNoteNode.cpp
+++ b/src/libs/engine/MidiNoteNode.cpp
@@ -195,6 +195,11 @@ MidiNoteNode::note_on(uchar note_num, uchar velocity, FrameTime time, ProcessCon
Voice* voice = NULL;
uint32_t voice_num = 0;
+ if (key->state != Key::OFF) {
+ cerr << "[MidiNoteNode] Double note. Who be sendin dem crazy midis?" << endl;
+ return;
+ }
+
// Look for free voices
for (uint32_t i=0; i < _polyphony; ++i) {
if ((*_voices)[i].state == Voice::Voice::FREE) {
@@ -225,8 +230,8 @@ MidiNoteNode::note_on(uchar note_num, uchar velocity, FrameTime time, ProcessCon
// Update stolen key, if applicable
if (voice->state == Voice::Voice::ACTIVE) {
- assert(_keys[voice->note].voice == voice_num);
assert(_keys[voice->note].state == Key::ON_ASSIGNED);
+ assert(_keys[voice->note].voice == voice_num);
_keys[voice->note].state = Key::Key::ON_UNASSIGNED;
//cerr << "[MidiNoteNode] Stole voice " << voice_num << endl;
}