Hi there,
The next time you have trailing notes droning on, you can run midi_all_notes_off
by itself in a separate tab to end them all. (See the note at the bottom for an explanation of what’s going on.)
I believe you’re looking for the sustain
option for midi
, which specifies how long a note should be held for. The default value of sustain
if you omit it is 1 beat, which is equal to the time between successive calls to midi :Eb3
or midi :F3
in your code. That’s why they sound continuous. Try specifying a sustain
time shorter than the time between successive calls of the note, in order to have a gap between successive triggers of the note. (E.g. midi :Eb3, sustain: 0.25
.)
If you’ve reduced the sustain
time to less than the sleep
time, and your notes still sound continuous, consider decreasing the release of your external synth’s ADSR envelope. As I pointed out in a previous post, the ADSR envelope is not controlled by the MIDI on and off signals which are sent by midi
. Rather, the attack, decay, and sustain portions of the envelope are triggered after the MIDI on signal, and the release portion of the envelope is triggered after the MIDI off signal.
Cheers!
Note: Based on my diagram, it can be seen that if no MIDI off signal is sent out, a note will simply remain on forever. I suspect that this is what is causing your issues with hanging notes when you stop your program. Given that there is no gap between notes in your original code, there will always be a note still playing when you stop the program. Thus, you hear hanging notes.