Created
July 22, 2009 20:40
-
-
Save adamjmurray/152255 to your computer and use it in GitHub Desktop.
Revisions
-
adamjmurray created this gist
Jul 22, 2009 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ # Make MIDIator cleanup at program termination: class MIDIator::Driver alias orig_init initialize alias orig_note_on note_on alias orig_note_off note_off def initialize(*params) orig_init(*params) @held_notes = Hash.new {|hash,key| hash[key]={} } at_exit do @held_notes.each do |channel,notes| notes.each do |note,velocity| orig_note_off(note, channel, velocity) end end close end end def note_on( note, channel, velocity ) orig_note_on( note, channel, velocity ) @held_notes[channel][note] = velocity end def note_off( note, channel, velocity = 0 ) orig_note_off( note, channel, velocity ) @held_notes[channel].delete(note) end end