micromidi

A Ruby DSL for MIDI

Features

Installation

gem install micromidi

Requirements

Ruby 1.9.2+ or JRuby in 1.9 mode

Requires midi-eye, midi-message and unimidi. These should install automatically with the gem.

Usage

Here are some basic examples that use Unimidi inputs and outputs. (read more here about selecting an output…)

require "micromidi"

@i = UniMIDI::Input.first.open
@o = UniMIDI::Output.first.open

Here is an example that plays some arpeggios

MIDI.using($o) do

  5.times do |oct|
    octave oct
    %w{C E G B}.each { |n| play n 0.5 }
  end

end

While this next example is running, all input is sent directly to the output except for notes; notes that are received are only sent to the output if their octave is between 1 and 3. Output is also printed to the console by passing in $stdout.

MIDI.using(@i, @o, $stdout) do

  thru_except :note { |msg| only(msg, :octave, (1..3)) }

  join

end

I've written up a few posts explaining how these examples work in much greater detail

Documentation

Author

License

Apache 2.0, See the file LICENSE

Copyright © 2011 Ari Russo