Gem Version Build Status

Ruby wrapper for RtMidi, a cross-platform C++ library for realtime MIDI input and output.


  • List MIDI I/O ports
  • Send MIDI messages to output ports
  • Receive messages on input ports

In other words, everything you'd want from a low-level MIDI library. It's still your responsibility to interpret the MIDI message byte streams!

Supported Platforms:

  • OS X
  • Windows
  • Linux


To install, you need gcc and g++ on your PATH.

On Windows, you can use Visual Studio's cl.exe compiler instead.

Here's the recommended approach for your system:

OS X Setup

  • Install XCode via the Apple AppStore.
  • Open XCode's Preferences and install "Command Line Tools" in the Downloads tab.

See this stackoverflow discussion for help.

Windows Setup

with Visual Studio (cl.exe)

  • Install Visual Studio (Tested with Visual C++ 2010 Express. Any recent version with a C++ compiler should work.)
  • Use the "Visual Studio Command Prompt" to install

with MinGW (gcc/g++)

  • Install MinGW
  • During installation, on the "Select Components" screen, install the following:
    • C Compiler
    • C++ Compiler
    • MSYS Basic System
    • MinGW Developer ToolKit
  • Use the the MinGW Shell (MSYS) to install

Note: when installing under MinGW, this library may not work outside of MinGW. If that is a problem for you, use Visual Studio to install.

Linux Setup

Install JACK or ALSA.

This should work on Ubuntu:

sudo apt-get install g++
sudo apt-get install jackd
sudo apt-get install libjack-dev


Assuming you have Ruby installed, and are ready to compile C++ code with gcc, this part is easy:

gem install rtmidi


See the following examples:

Use the arbitrary MIDI IO to handle channel messages, SysEx, timing, and/or active sensing messages. If you only need channel messages (notes, modulation/CC, pitch bend, aftertouch), it's recommended you follow the channel IO examples.



Pull requests are welcome. The following must work:

  • rake test shows all unit tests are passing
  • Build and test the gem manually:
    • gem build rtmidi.gemspec
    • gem install rtmidi-#{version}.gem
    • the examples can be run successfully against this version of the gem (ruby examples/**)


  • 0.3 - Support for arbitrary MIDI messages including SysEx
  • 0.2.2 - Compilable with Visual Studio on Windows
  • 0.2.1 - Linux support (thanks to @quark-zju)
  • 0.2 - First stable release