Created
July 22, 2009 20:40
-
-
Save adamjmurray/152255 to your computer and use it in GitHub Desktop.
This file contains 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 characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment