Min_Time_ms = 10 noted_notes = {} rem_durat = {} function OnNote(channel, pitch, velocity) chan_x = channel -- chan_x is delayed by Min_Time_ms but short notes < Min_Time_ms are deleted Note(16, pitch, velocity) -- channel 16 is not delayed but contains short notes < Min_Time_ms noted_notes[pitch] = velocity end function OnFrame(notes) for i, note in ipairs(notes) do if note.duration > Min_Time_ms and noted_notes[note.pitch] > 0 then -- Note(chan_x, note.pitch, 0) Note(chan_x, note.pitch, noted_notes[note.pitch]) -- Note On end if noted_notes[note.pitch] == 0 and rem_durat[note.pitch] == 0 then rem_durat[note.pitch] = note.duration end if noted_notes[note.pitch] == 0 and (note.duration - rem_durat[note.pitch]) > Min_Time_ms then -- Note(chan_x, note.pitch, 0) rem_durat[note.pitch] = 0 Note(chan_x, note.pitch, noted_notes[note.pitch]) -- Note Off end end end function OnStart(info) -- assign a description to be displayed in the header info.description = "This machine will delete short notes with a length < Min_Time_ms" info.link = "http://jamorigin.com/midi-machine" -- create knob widgets in the user interface Knob("Min_Time_ms", 0, 0, 100, 5) for i = 1, 127 do rem_durat[i] = 0 end -- for i = 1, 127 do end