clef¶ ↑
An Interactive Music Experience Beyond Your Wildest Imagination!¶ ↑
By Mister Teejay VanSlyke!¶ ↑
Getting Started!¶ ↑
Clef is an interactive music programming language. To install, type
sudo gem install teejayvanslyke-clef # that's me!
Clef is a client-server application. Ooooh. It’s so fancy. That means you’ll want to type
clef_server
in one terminal window, and
clef
in another!
Like Rockband, but requiring slightly more talent™¶ ↑
The most atomic unit of operation in Clef is a note. Notes are represented by the regular expression +[A-Ga-g][0-9]+, but that’s gosh darned confusing. How about some examples?
C-4 C#4 D-4 D#4 E-4 F-4 F#4 G-4 G#4 A-4 A#4 B-4 et cetera
There are no flats in Clef. Who needs ‘em?
There are, however rests. Rests are an important concept in Clef; as you’ll see in a moment, Clef doesn’t understand note duration … yet. So, in order to play notes at a specific meter, use rests appropriately:
$>> [C-4 ___] => [C-4 ___]
A rest is denoted by one or more consecutive underscore in a sequence. Clef will adjust your sloppiness to three underscores after evaluating your input.
Mr Teejay’s Opus¶ ↑
A note alone is boring. That’s why Clef’s main unit of operation is the sequence. Sequences are strings of notes – it’s like a party!
[E-4 D-4 C-4 D-4 C-4 C-4 C-4]
Sequences are surrounded by square brackets ([]) with notes delimited by spaces.
But not everyone plays the flute. It’d be swell if we could live in harmony!
That’s what arrangements are for!
[(E-4 C-3) D-4 C-4 D-4 (C-4 C-3) (C-4 C-3) (C-4 C-3)]
Arrangements are sequences in which multiple notes are played simultaneously.
How exciting!
TEH THREE R’S!¶ ↑
Music is mathematical. That’s why there are only two Beatles left. One? I lost count.
Clef is able to manipulate your arrangements using common household binary operators:
$>> [ C-4 ] + 2 => [D-4] $>> [ C-4 ] & [ E-4 ] & [ G-4 ] => [(C-4 E-4 G-4)] $>> [ C-4 ] * 2 => [C-4 C-4] $>> [ C-4 ] / 2 => [C-4 ___]
Wowzas!
Come on Bring The Noise¶ ↑
Music is so lame if you can’t hear it. There was a brief movement toward _silence art_ in the late eighteenth century, but that’s likely a discussion for another README§. Its failure is why we decided it would be prudent to allow you to hear your creations.
§ Not true
Clef uses the sexy Ruby MIDI library Midiator to conduct its MIDI business.
If Clef isn’t outputting sound, check your devices. It’s probably user error.
Or, it might be my fault.
ANYWAY¶ ↑
Clef allows manipulation of MIDI channels as objects. These objects are named +@0 - @15+ . They’re also semantically identical to arrangements as described above. That means that
$>> @0 = [ C-4 D-4 E-4 ] => [C-4 D-4 E-4]
will start playing the sequence [C-4 D-4 E-4]
on MIDI channel 1 (us ‘puter programmers start counting at 0).
Likewise,
$>> @1 = [(C-4 E-4 G-4)] => [(C-4 E-4 G-4)]
will play a C major chord on channel 2.
Building complex projects¶ ↑
Clef’s include system smells a bit like Python. Clef will look for files in your current working directory with the extension .clef
:
-- Include jazz.clef $>> include jazz => Loaded <jazz> -- Include jazz/scales.clef $>> include jazz.scales => Loaded <jazz.scales> -- Include jazz/scales/pentatonic.clef $>> include jazz.scales.pentatonic => Loaded <jazz.scales.pentatonic>
Oh snap! It’s experimental?!¶ ↑
Yup, I fooled you. That’s all I’ve implemented so far. If you’re totally stoked about Clef, you can contribute in one or two of two ways:
-
ONE: Play with it and report issues!
-
TWO: Contact me with pull requests of your _totally stellar_ features!
Special Thanks!¶ ↑
-
Jeremy Voorhis wrote a mean Ruby scheduler called Gamelan.
-
Ben Bleything wrote a stellar cross-platform Ruby MIDI library called Midiator
-
Jeremy Voorhis also gave me a tour of his music.rb project, by which Clef was inspired.
Copyright¶ ↑
Copyright © 2009 teejayvanslyke. See LICENSE for details.