MTK: a Music Tool Kit for Ruby

MTK is a Ruby library and custom domain-specific language (DSL) for generating musical material.

MTK is flexible: You may use the custom music-generating language without writing any Ruby code, or you may avoid the custom language and only program in Ruby, or anywhere in between.


  • A minimalist syntax (DSL) for generating musical patterns
  • Read and write MIDI files
  • Record and output realtime MIDI signals
  • Sequence MIDI-compatible event streams
  • Manipulate musical objects like pitch, duration, and intensity
  • Generate deterministic and non-deterministic music via flexible patterns such as looping sequences and random choices

Getting Started

MTK works with Ruby 1.9, Ruby 2.0, and JRuby 1.7+.

JRuby is recommended for Windows users.

  1. Install

    gem install mtk

    Or for JRuby:

    jgem install jmtk
  2. Learn the command-line interface:

    mtk --help

    Or for JRuby:

    jmtk --help
  3. Learn the MTK syntax with the interactive tutorial by running

    mtk -t

    Or for JRuby

    jmtk -t
  4. Check out examples:

  5. Read the MTK Ruby library documentation

About this project

This project is developed by Adam Murray (

It is a free and open source project licensed under a permissive BSD-style license. I simply ask for credit by including my copyright in derivative works.

You can learn more about the development of this project at the development notes page.