The three rules of Ruby Quiz:
1. Please do not post any solutions or spoiler discussion for this quiz until
48 hours have passed from the time on this message.
2. Support Ruby Quiz by submitting ideas as often as you can:
3. Enjoy!
Suggestion: A [QUIZ] in the subject of emails about the problem helps everyone
on Ruby Talk follow the discussion. Please reply to the original quiz message,
if you can.
···
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
by Ross Bamford
One for the music lovers this week - can your computer play guitar? Basically,
the aim of this week's quiz is to implement a Ruby program that will 'read'
guitar tablature, and generate a rendition of that tablature in some sound
format.
In case you're unfamiliar with tablature, it's a form of written guitar music
that's easier to learn and often more convenient than real sheet music. It
doesn't carry nearly as much information about a piece, but it provides a good
starting point and is an easy way to record key bits you don't want to forget.
Also, it's quite amenable to ASCII formatting. It looks like this:
e>-----------------------------0-1-3-|
B>-----------------------0-1-3-------|
G>-------------------0-2-------------|
D>-------------0-2-3-----------------|
A>-------0-2-3-----------------------|
E>-0-1-3-----------------------------|
e>1-0--------------------------------|
B>----3-1-0--------------------------|
G>----------2-0----------------------|
D>--------------3-2-0----------------|
A>--------------------3-2-0----------|
E>--------------------------3-1-0----|
The six horizontal lines represent the six strings of the guitar (the thickest
string, the sixth, being the bottom line) with time progressing left to right,
top to bottom. The numbers on the strings show the fret at which that string
should be held when the string is played.
You can find a bit more about tableture at Wikipedia [1], and a tutorial at
guitar.about.com [2]. You'll also find lots of (non-commercial use only) tabs at
OLGA [3].
What you need to do
===================
Firstly, you'll need to select some tabs to work with. You might try OLGA, or
google around a bit. Unfortunately, the quality of freely available tabs is very
variable, so you might prefer to bug your musician friends for something you can
use. Also, a few simple scales and other bits are included with the quiz [4].
Once that's done, you'll need to choose a guitar. This quiz includes a free
guitar [4] that supports the bare minimum you need to play simple tabs, with
output to MIDI format (thanks to midilib [5]). To use this guitar, you'll need
midilib installed (it's available as a Gem). See guitar.rb for more info.
The aim is that your program will play the guitar, and then dump the midi. You
may accept any commandline parameters you wish, and should output the midi data
to stdout.
If you don't have anything to listen with, check out TiMidity++ [6].
Oh man, this guitar blows!
==========================
If you're a guitarist, or you surfed a few tabs, you'll notice immediately that
the provided guitar is actually pretty useless. Firstly, it only has nine frets
(an odd number, I admit). And sure, you can hit the notes, but that's all -
there's a world of stuff it can't support: bends, hammer-on/pull-off, letting
notes to ring, harmonics, the list goes on.
A lot of this could be supported by MIDI, if only you had a better guitar. Some
people build their own guitars, and for extra credit in this quiz, that's
exactly what you should do: extend or rewrite the Guitar class to support a
full-size neck, and as many tabbable effects as you can.
Things to bear in mind
======================
* As mentioned, tab quality on the 'net is variable - don't expect your
favourite song to sound exactly right. Often, tabs provide more of a
starting point than an accurate transcript.
* Timing is one of the most important qualities in a piece of music, but
tablature sadly lacks any notion of it. For that reason you shouldn't
worry too much about it, though it's nice if you can provide a way
to specify tempo and timing for a given tab on the command line.
* ASCII tabs are often hand-written, and vary slightly in their formatting
and the different characters used. Try to be liberal in what you accept.
---------
[1] http://en.wikipedia.org/wiki/Tablature
[2] http://guitar.about.com/library/blhowtoreadtab.htm
[3] http://www.olga.net/dynamic/browse.php?setPrintable=0&local=main
[4] http://rubyquiz.com/tab_player.zip
[5] http://midilib.rubyforge.org/
[6] http://timidity.sourceforge.net/