Announcing MIDIator

October 20th, 2008

I was just looking at my FeedBurner statistics and noticed that my feed readership has gone up by approximately 100 in the past year. Then I looked at my blog and realized I hadn’t posted anything Ruby-related in 2008. Then I remembered that I’m a Ruby programmer and decided to release some software for the express purpose of blogging an announcement.

Okay, not really. Well. The last part is mostly a lie. I guess. On to the point.

Background

Earlier this year a small publishing concern called Apress (that you may have heard of!) published a most interesting book. It was Practical Ruby Projects, by the lovely and talented Topher Cyll. There’s a link on his page if you want to get it.

Practical Ruby Projects is the book that I have always wanted to write. I would have called it Stupid Ruby Tricks myself, but that’s neither here nor there. The subtitle is “Ideas for the Eclectic Programmer”, and that really gives you an idea of the flavor of what’s inside.

The second chapter is entitled “Making Music with Ruby”, and is a gentle introduction into writing code that can play music. The chapter is based around building an app that can play songs written in simple notation. One of the really awesome things that Topher did, though, was to supply code to interface with the MIDI subsystems on Windows, Linux, and OSX.

Around this same time, Giles Bowkett’s sweet project Archaeopteryx was starting to take off. Giles had also taken both code and inspiration from Practical Ruby Projects, but he had only grabbed the OSX parts. That’s fine, I thought, because I’m on a mac and it works for me.

Then, people started complaining. Not really complaining, but definitely whinging about wanting to play with Archaeopteryx but being stuck on inferior platforms. There was also an issue with the fact that Giles demos Archaeopteryx hooked up to Reason, and Reason costs like $500. You don’t have to use Reason, though, as Shay Arnett so deftly demonstrated at the Hoedown. I have more to say about this, but you’re going to have to wait for RubyConf.

Aaaaaanyway, I decided that I was going to take Topher’s code and bundle it up for you, the masses, to consume. This was made possible in large part by Apress’s total awesomeness in releasing all the code from Practical Ruby Projects under the MIT license. I took his code, refactored it a little bit, wrote some specs and examples, and published it as MIDIator.

How Can

First, install as normal:

$ sudo gem install midiator

Next, do this:

1
2
3
4
5
6
require 'rubygems'
require 'midiator'

midi = MIDIator::Interface.new
midi.autodetect_driver
midi.play( 84, 0.5 )

Thanks to Tobi Reif for pointing out the error in the above example!

You should hear a half-second of middle C. Now, to be fair, I’m leaving out all the information about how to get a working MIDI setup on your machine. I’ll be blogging about that later, though, so if you don’t know how just keep your eyes peeled.

Where Can I…

You can get MIDIator at GitHub or RubyForge, or install it via gems as shown above.

Future blog posts about MIDIator will be tagged, so you can use this link to get all the news that’s fit to blag.

You can read the RDoc at RubyForge.

Stay Tuned!

There’s more coming. In the next few days I’ll be showing you how to get MIDI working on your system. Then I’ll be speaking at RubyConf with Giles and Yossef Mendelssohn. I’ll definitely post some stuff related to my talk around the conference, but you’re going to have to wait for the really fun stuff.

7 Responses to “Announcing MIDIator”

  1. Tobi Says:

    $ sudo gem install midiator Successfully installed midiator-0.1.1 [...] $ ruby require ‘rubygems’ require ‘midiator’

    midi = MIDIator.new midi.autodetect_driver midi.play( 82, 0.5 ) -:4: undefined method `new’ for MIDIator:Module (NoMethodError) $

  2. misuba Says:

    Tobi: it looks like you want MIDIator::Interface.new, not MIDIator.new.

  3. Macario Says:

    Hi, is there a way to send controll data such as knobs?

    Thanks for the gem!

  4. Ben Bleything Says:

    Macario: Not yet, but I plan on adding that. Stay tuned!

  5. leethal Says:

    Eagerly awaiting an explanation of how to make the MIDI go where you want it to go.

  6. Saimon Moore Says:

    Hi Ben,

    I’ve been playing around with midiator and have a very simple shoes-based piano app I wrote for my daughter.

    Currently I’m using SimpleSynth (osx midi synth) to actually hear sound but I’d like to package the app up so I can send it to friends. Do you know of any midi synth library (that perhaps SimpleSynth is based on) I could use? I’m on osx so that’s my main platform but it would be cool to have something for win and linux too.

    Note: I have no idea whatsoever about music, midi synthesizers so if I’m talking crap let me know.

  7. alt2254 Says:

    leethal: I you install midiyoke or maple, you can change your default midi device to one of the ports they provide, and then use that port as the input to your midi software.

Sorry, comments are closed for this article.