|
Post by midijam on Feb 8, 2022 19:53:02 GMT
Thread For Hold Notes 
|
|
|
Post by uncledave on Feb 8, 2022 22:00:33 GMT
Here's a StreamByter script to automatically sustain played notes until other notes are played. Notes struck together are held as a chord, until another chord is played. Stopping the last note or chord requires introducing a CC or other input to treat as an "all stop" command. Here is the earlier discussion on this topic. #HoldChord # Notes are sustained until other notes are played. # Notes struck in a short time will be treated as a chord and # sustained together. We cannot tell from the keyboard when # sustained notes should end. Presently using Play/Pause and # CC64 (sustain) off. Could just use a long delay after the note # was played, but how long?
# There's one little catch in case a new note is the same as one # that was being sustained. The Note Off messages sent to end # the previous chord are sent (by StreamByter) after the new # NoteOn message, causing the new note to be chopped. This # script delays the first Note On by a few ms, so the messages # will reach the synth in the correct order.
If load Set Name HCHORD Alias $500 chordDelay # time for chord notes, ms Alias 1 enableChord # change to 0 for no chords
# J0 holds the count, followed by the notes Alias J00 noteCount Alias J10 chordFlag Alias J11 holdChannel # channel used by notes Ass J00 = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Ass J10 = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Ass K0 = chordDelay
# note that the count is set to zero by the loop Sub AllNotesOff theChannel Mat I10 = 80 + theChannel While J0 >= 1 Snd I10 JJ0 0 Mat J0 = J0 - 1 End End
Sub ResetAll theChannel Mat I10 = B0 + theChannel Snd I10 $120 0 # all notes off Ass noteCount = 0 End
Sub SaveNote theNote Ass I10 = J0 Ass I11 = 1 # ignore duplicate notes While I10 >= 1 If JI10 == theNote Ass I11 = 0 End Mat I10 = I10 - 1 End If I11 == 1 Mat J0 = J0 + 1 Ass JJ0 = theNote End End End # Initialization ———————————————————————————
If MT == 80 # ignore note off Ass holdChannel = MC Block End
If MT == 90 # handle note on Ass holdChannel = MC Ass I01 = M1 # save the note If chordFlag == 0 # not in a chord If noteCount > 0 AllNotesOff MC # delay first note to handle possible double strike Snd M0 M1 M2 +D10 Block End Ass chordFlag = enableChord # this note is start of possible chord Snd F0 7D 01 10 F7 +I +DK0 # start chord timer End SaveNote I01 End
If MT == B0 # use sustain Off (CC64) to silence notes If M1 == $64 0 ResetAll holdChannel Block End End
If M0 == F0 7D 01 # handle system messages If M3 == 10 # chord has timed out. Next note will kill the others. Ass chordFlag = 0 End If M3 >= 7A # use Play/Pause to silence notes ResetAll holdChannel End End
|
|
|
Post by midijam on Feb 8, 2022 22:29:56 GMT
Would be fine to see this in "code boutique" uncledave! I was searching for that kind of code there. I think you need to give a permission to Nic, If you agree.
|
|
|
Post by uncledave on Feb 8, 2022 23:42:13 GMT
Would be fine to see this in "code boutique" uncledave! I was searching for that kind of code there. I think you need to give a permission to Nic, If you agree. Hey, no problem. I think Nic has to ask, though. This is his sandbox, even though he lets us play in it.
|
|