Building a Velato program

The Velato language is music-based and encoded as a MIDI file read by the compiler. This "Hello, World!" example was built using the GUIDO Notation System, with gmn2midi to convert text into MIDI files. It's a very intuitive notation system but now pretty dated. I would suggest using LilyPond, which is more powerful and more widely used, or if you want to bypass MIDI entirely, there's Velato.js by Erik Erwitt. In GUIDO, notes are represented in the format G0/2, where G is the note, 0 is the octave (equivalent to octave 5 in MIDI), and /2 represents a half-note. If the octave is not provided for a note, it uses the previous note's octave -- same for note durations. Rests are underscores. Comments are Pascal-style (* *) and can be used to track commands within the .gmn file.

Writing "Hello, World!"

Okay, let's start with printing the 'H' character to the screen. The Velato command to print a character is Major 6th, Major 5th. If we're writing in C, this is the progression C A G (we always have to start commands with the command root note, which, in this case, is C, as we're starting the program with it).Looking at the expression list in this post, The expression for a char value is 3rd, 4th. The first 3rd could be major or minor, but since we've used E already, we'll use that, as opposed to E& (which is the GUIDO representation of E-flat). This we follow with the ASCII value of 'H'. This happens to be 72 (there's a list here), which we represent as "a d#" (we get this from the number of half-steps up from the command root, starting up a half-step, and excluding the Perfect 5th -- it's probably easier to just write it out once and refer to it, like the chart in the last post, here). Unfortunately, we ended up using a d# (equivalent to e&) after all. We can make this more palatable by making it part of a chord, either by combining it with the notes ahead or behind it, or with notes in additional tracks which are not part of the program.We end the integer with a Perfect 5th, which is G. This gives us the complete command:

[ c a g e f a d# g ]

Click to hear actual midi fileAfter creating a .mid file with gmn2midi, we use Vlt to compile, and see this abstract syntax tree. This helps us verify that we used the correct notes, and didn't end up with some command we didn't intend:


Now, let's make it sound a bit better. We can turn this into several chords: a C6 and an F7. Since we're at the end of a command, we can add a C after (that's our command root), which will be interpreted as No-ops. In Guido, we use curly brackets to indicate notes played together -- the notes of the chord are seperated by comma.This would give us this:

[ {c-1/4, a1, g0, e } { f/4, a, d#1} _/8 { g0/4., c1 } ]

midi fileThis is an equivalent command (both print the letter 'H'), but the second is a bit more musical. In addition to creating chords, I've also spread the notes into several octaves and altered the rhythma bit.Next, let's change the command root note to an F. We do this with a Major 2nd interval, followed by the new root note. In this case:

c d f

Now we write the next command (to print 'e'), starting from F instead of C. The first part of the command is the same, only transposed:

f d c a b&

In ASCII, 'e' is 101, which is g f# g -- we end with a Perfect 5th to indicate the end of an integer, so that's a "c" again. The whole command is:

f d c a b& g f# g c

We can combine this with the previous command ('c d f') and make it a bit more musical:

c0/16 d1 f {f-1/8, d1, c0, a} {b&1/4, g-1, f#0} _/8 { g0/4., c1}

entire song so farIt's not going to win us any awards for composition yet, but at least it sounds intentional, instead of a bunch of random notes.Let's change the command root to B& for a bit of a change, and print the next character, the first 'l'.The two commands are:

f g b& (* change of command root *)
b& g f d e& c b a& f (* print 'l' *)

Or, once we change the rhythm and octaves:

f0/16 g1 b& (* change of command root *)
{b&-1/8, g1, f0, d} 
{e&1/4, c0, b0} a&1/8 {f/4, b&} b&0 (* print 'l' *)

entire song so farThe rest of the notes are selected using the same technique. We're not going to win any Grammys with our final program, but it's at least somewhat musical (in a free-form jazz sorta way) instead of random notes. With more time and effort, the song could be further composed into something more pleasing. I'll post any further re-workings of the song here.Complete "Hello, World" program midi fileGUIDO source for complete program Here's the program as sheet music. Keep in mind that this set of notes is *not* the actual program; if a MIDI file is created from this progression of notes, the concurrent notes might be interpreted in a different order in the file, and create an invalid program.