diff options
author | David Robillard <d@drobilla.net> | 2015-04-09 21:36:36 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2015-04-09 21:36:36 +0000 |
commit | df7f539225918cfa809fd5939b813e483cb11d7c (patch) | |
tree | 5018ac04c80c120778efc39cad17163a80badeb5 /src/server/internals/Note.cpp | |
parent | 85a945468c6b065ee43ce1dc2f6e4c03eb9fe3c3 (diff) | |
download | ingen-df7f539225918cfa809fd5939b813e483cb11d7c.tar.gz ingen-df7f539225918cfa809fd5939b813e483cb11d7c.tar.bz2 ingen-df7f539225918cfa809fd5939b813e483cb11d7c.zip |
Fix multiple note triggers on the same sample.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5671 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server/internals/Note.cpp')
-rw-r--r-- | src/server/internals/Note.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp index 88fb1cd1..feb3890f 100644 --- a/src/server/internals/Note.cpp +++ b/src/server/internals/Note.cpp @@ -277,6 +277,11 @@ NoteNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity, F key->voice = voice_num; key->time = time; + // Check if we just triggered this voice at the same time + // (Double note-on at the same sample on the same voice) + const bool double_trigger = (voice->state == Voice::State::ACTIVE && + voice->time == time); + // Trigger voice voice->state = Voice::State::ACTIVE; voice->note = note_num; @@ -289,8 +294,10 @@ NoteNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity, F _num_port->set_voice_value(context, voice_num, time, (float)note_num); _vel_port->set_voice_value(context, voice_num, time, velocity / 127.0f); _gate_port->set_voice_value(context, voice_num, time, 1.0f); - _trig_port->set_voice_value(context, voice_num, time, 1.0f); - _trig_port->set_voice_value(context, voice_num, time + 1, 0.0f); + if (!double_trigger) { + _trig_port->set_voice_value(context, voice_num, time, 1.0f); + _trig_port->set_voice_value(context, voice_num, time + 1, 0.0f); + } assert(key->state == Key::State::ON_ASSIGNED); assert(voice->state == Voice::State::ACTIVE); |