Diamond

MIDI arpeggiator in Ruby

diamond

Features

  • Classic arpeggiator functionality
  • OSC and MIDI remote control
  • MIDI clock IO
  • Suited to live coding
  • Multiplex clocks and arpeggiators
  • Preset and curstom arpeggio pattern algorithms

Installation

gem install diamond

or with Bundler, add this to your Gemfile

gem "diamond"

Usage

require "diamond"

First, select a MIDI output using unimidi. (more about that...)

@output = UniMIDI::Output.gets

The Diamond arpeggiator has a number of optional parameters. For this example, here's a straightforward setup

options = { 
  :gate => 90, 
  :interval => 7,
  :midi => @output,
  :pattern => "UpDown",
  :range => 4,     
  :rate => 8
}

arpeggiator = Diamond::Arpeggiator.new(options) 

Create a clock object, passing in a tempo value. In this case the tempo will be 138 BPM

clock = Diamond::Clock.new(138)

Point the clock to the arpeggiator

clock << arpeggiator

Of course, an arpeggiator needs notes to work with. You can use a MIDI input for that. (see example). However, again for the sake of simplicity here's a chord in Ruby

chord = ["C3", "G3", "Bb3", "A4"]

Use Arpeggiator#add and Arpeggiator#remove to change the notes that the arpeggiator sees. (Arpeggiator#<< is the same as add)

arpeggiator.add(chord)   
arpeggiator << "C5"

Now we'll start the clock and arpeggiator.

Note that by default, the clock will run in a background thread. If you're working in a PRY/IRB/etc this will allow you to continue to code while the arpeggiator runs. To start in the foreground, pass :focus => true to Clock#start.

clock.start

All of the arpeggiator options can be controlled on the on the fly

arpeggiator.rate = 16
arpeggiator.gate = 20  
arpeggiator.remove("C5", "A4")

This screencast video shows Diamond being live coded in this way. (Note that the API has changed a bit since 2011 when the video was made).

This blog post explains what is happening in the video.

Posts

Examples

More...

Other Documentation

Author

License

Apache 2.0, See the file LICENSE

Copyright (c) 2011-2014 Ari Russo