Created
November 25, 2008 04:26
-
-
Save aberant/28780 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
require 'rubygems' | |
require 'midiator' | |
include MIDIator::Notes | |
# don't ask, just be a good sheep.. | |
# http://www.ruby-forum.com/topic/123503 | |
Kernel::require "serialport.so" | |
#params for serial port | |
port_str = "/dev/tty.usbserial-A6006eSL" #may be different for you | |
baud_rate = 9600 | |
data_bits = 8 | |
stop_bits = 1 | |
parity = SerialPort::NONE | |
sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity) | |
midi = MIDIator::Interface.new | |
midi.autodetect_driver | |
puts "begin" | |
begin | |
while true | |
resp = sp.getc | |
puts "Got MIDI note: #{resp}" | |
midi.play resp | |
end | |
ensure | |
puts "cleaning up!" | |
sp.close | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment