diff audio/ClipMixer.cpp @ 596:c99892f0c5c3

Proper handling for notes that end at the same frame as a subsequent note of the same pitch begins. The note-off needs to be associated with the prior note, not a spurious zero-duration version of the subsequent note.
author Chris Cannam
date Wed, 18 Apr 2018 15:19:09 +0100
parents b23bebfdfaba
children e2715204feaa
line wrap: on
line diff
--- a/audio/ClipMixer.cpp	Thu Mar 01 18:02:22 2018 +0000
+++ b/audio/ClipMixer.cpp	Wed Apr 18 15:19:09 2018 +0100
@@ -159,8 +159,13 @@
         bool ending = false;
 
         foreach (NoteEnd end, endingNotes) {
-            if (end.frequency == note.frequency && 
-                end.frameOffset >= start &&
+            if (end.frequency == note.frequency &&
+                // This is > rather than >= because if we have a
+                // note-off and a note-on at the same time, the
+                // note-off must be switching off an earlier note-on,
+                // not the current one (zero-duration notes are
+                // forbidden earlier in the pipeline)
+                end.frameOffset > start &&
                 end.frameOffset <= m_blockSize) {
                 ending = true;
                 durationHere = end.frameOffset;