Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

MIDI messages, objectified in Ruby

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 TODO

MIDI Message

MIDI messages, objectified in Ruby


  • Flexible API to accommodate various sources and destinations of MIDI data

  • Simple OO approach to System Exclusive data and devices

  • YAML dictionary of MIDI constants


gem install midi-message


require 'midi-message'

include MIDIMessage

Basic Messages

There are a few ways to create a new MIDI message. Here are some examples, 64, 64)

NoteOn["E4"].new(0, 100)

with(:channel => 0, :velocity => 100) { note_on("E4") }

Those expressions all evaluate to the same object

 @data=[64, 64],
 @status=[9, 0],
 @verbose_name="Note On: E4">

SysEx Messages

As with any kind of message, you can begin with raw data, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7)

Or in a more object oriented way

synth =, :model_id => 0x42, :device_id => 0x10)[0x40, 0x7F, 0x00], 0x00, :node => synth)

A Node represents a device that you're sending a message to (eg. your Yamaha DX7 is a Node). Sysex messages can either be a Command or Request

You can use the Node to instantiate a message

synth.command([0x40, 0x7F, 0x00], 0x00)

One way or another, you will wind up with a pair of objects like this

@address=[64, 0, 127],


The parse method will take any valid message data and return the object representation

MIDIMessage.parse(0x90, 0x40, 0x40)

  #<MIDIMessage::NoteOn:0x9c1c240 ..>

MIDIMessage.parse(0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7)

  #<MIDIMessage::SystemExclusive::Command:0x9c1e57c ..>

Check out nibbler for more advanced parsing

API Documentation



Apache 2.0, See the file LICENSE

Copyright © 2011-2012 Ari Russo

Something went wrong with that request. Please try again.