2009-03-15 19:43:27 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
2009-09-17 18:21:00 +00:00
|
|
|
|
|
|
|
def note_on(delay, channel, note, volume)
|
2009-03-15 19:43:27 +00:00
|
|
|
# note on
|
2009-09-17 18:21:00 +00:00
|
|
|
putc delay
|
|
|
|
putc 0x90 + channel
|
|
|
|
putc note
|
|
|
|
putc volume
|
|
|
|
end
|
2009-03-15 19:43:27 +00:00
|
|
|
|
2009-09-17 18:21:00 +00:00
|
|
|
def note_off(delay, channel, note)
|
|
|
|
# note on
|
|
|
|
putc delay
|
|
|
|
putc 0x80 + channel
|
|
|
|
putc note
|
|
|
|
putc 0x00
|
|
|
|
end
|
2009-03-15 19:43:27 +00:00
|
|
|
|
2009-09-17 18:21:00 +00:00
|
|
|
def program_change(delay, channel, instrument)
|
|
|
|
putc delay
|
|
|
|
putc 0xc0 + channel
|
|
|
|
putc instrument
|
|
|
|
end
|
2009-03-15 19:43:27 +00:00
|
|
|
|
2009-09-17 18:21:00 +00:00
|
|
|
def end_of_track
|
2009-03-15 19:43:27 +00:00
|
|
|
putc 0x00
|
2009-09-17 18:21:00 +00:00
|
|
|
putc 0xff
|
|
|
|
putc 0x2f
|
|
|
|
putc 0x00
|
|
|
|
end
|
|
|
|
|
|
|
|
#program_change(0, 8, 36)
|
|
|
|
|
|
|
|
for i in 0...128
|
|
|
|
# note on
|
|
|
|
note_on(0xf, 8, i, 0x7b)
|
|
|
|
|
|
|
|
# note off
|
|
|
|
note_off(0xf, 8, i)
|
2009-03-15 19:43:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# end of track
|
|
|
|
|
2009-09-17 18:21:00 +00:00
|
|
|
end_of_track
|
2009-03-15 19:43:27 +00:00
|
|
|
|