Jay McGavren's Journal

2009-08-15

MIDIator...

Well, that was easy. Heard about MIDIator (a MIDI event generator for Ruby) on a Confreaks talk, and since I already had MIDI Patchbay and SimpleSynth installed from prior attempts to get things working, I gave it a shot.

Here’s some code that hooks it into a Rinda tuplespace:

require 'rinda/rinda'
require 'rubygems'
require 'midiator'

MY_URI = ARGV[0] || "druby://127.0.0.1:9999"
DRb.start_service
space = Rinda::TupleSpaceProxy.new(DRbObject.new(nil, MY_URI))

midi = MIDIator::Interface.new
midi.autodetect_driver

loop do
  key, value = space.take([/Integer/, Integer])
  midi.play value, 0.01
end

And here’s what it sounds like in action. I’m sure a better/more skilled controller would make it sound less, uh, horrible. :) Boy, it sure processes those events fast…

comments powered by Disqus