diamond
MIDI arpeggiator in Ruby

Features
-
Classic arpeggiator functions
-
Uses unimidi for cross-platform compatibility
-
Run as a background thread for live coding
-
Sync to and from MIDI clock
-
Sync between multiple Diamond instances
-
Preset and user-definable pattern algorithms
Installation
gem install diamond
Requirements
Ruby 1.9.2 or JRuby in 1.9 mode
Gem Dependencies:
midi-eye, midi-message, topaz, and unimidi
these will install automatically with the gem
Usage
require "diamond"
First, select a MIDI output using unimidi. (more about this…)
@output = UniMIDI::Output.first.open
The Arpeggiator has a number of optional parameters. For this example, here's a straightforward setup
opts = {
:gate => 90,
:interval => 7,
:midi => @output,
:pattern => Diamond::Pattern["UpDown"],
:range => 4,
:rate => 8
}
Create an Arpeggiator object, passing in a tempo value and the options above. In this case the tempo will be 138 BPM
arp = Diamond::Arpeggiator.new(138, opts)
Of course, an arpeggiator needs notes to work with. As you might expect, it's easy to 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.
arp << chord # same as add
arp.add("C5")
# etc
Now start the arpeggiator. By default, the arpeggiator will run in a background thread so if you are working in irb this will allow you to live code, sync it other arpeggiators, or just run another foreground process. (To start in the foreground, just pass :focus => true to Arpeggiator#start)
arp.start
All of the arpeggiator options can be controlled on the on the fly
arp.rate = 16
arp.gate = 20
arp.remove(["C5", "A4"])
This screencast video shows Diamond being live coded in this way. (Read how this is done)
Check out these posts and examples for more…
Posts:
Examples:
(more…)
Other Documentation
Author
-
Ari Russo <ari.russo at gmail.com>
License
Apache 2.0, See the file LICENSE
Copyright © 2011 Ari Russo