summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-09-09 18:08:21 +0000
committerDavid Robillard <d@drobilla.net>2007-09-09 18:08:21 +0000
commitc13e988094bca2c19b0676f8cfd60f3cff2f4a57 (patch)
tree97c6c948914175778b54b64b0d336b8452ddbc1b /src
parent360cff412ea44e86c8481e781c19d401724f4abb (diff)
downloadingen-c13e988094bca2c19b0676f8cfd60f3cff2f4a57.tar.gz
ingen-c13e988094bca2c19b0676f8cfd60f3cff2f4a57.tar.bz2
ingen-c13e988094bca2c19b0676f8cfd60f3cff2f4a57.zip
Possible fix for crash on weird MIDI note input.
git-svn-id: http://svn.drobilla.net/lad/ingen@701 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/libs/engine/MidiNoteNode.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/libs/engine/MidiNoteNode.cpp b/src/libs/engine/MidiNoteNode.cpp
index d8db7100..e4ad4f87 100644
--- a/src/libs/engine/MidiNoteNode.cpp
+++ b/src/libs/engine/MidiNoteNode.cpp
@@ -221,14 +221,19 @@ MidiNoteNode::note_off(uchar note_num, FrameTime time, SampleCount nframes, Fram
if (key->state == Key::ON_ASSIGNED) {
// Assigned key, turn off voice and key
- assert(_voices[key->voice].state == Voice::ACTIVE);
- assert(_voices[key->voice].note == note_num);
- key->state = Key::OFF;
-
- if ( ! _sustain)
- free_voice(key->voice, time, nframes, start, end);
- else
- _voices[key->voice].state = Voice::HOLDING;
+ if (_voices[key->voice].state == Voice::ACTIVE) {
+ assert(_voices[key->voice].note == note_num);
+
+ if ( ! _sustain)
+ free_voice(key->voice, time, nframes, start, end);
+ else
+ _voices[key->voice].state = Voice::HOLDING;
+
+ } else {
+#ifndef NDEBUG
+ cerr << "WARNING: Assigned key, but voice not active" << endl;
+#endif
+ }
}
key->state = Key::OFF;