songcode

Write ode by hand

Every Songcode track is a text file, and you can write one yourself from the first line. It costs nothing, and this post builds a track you can play as you read.

technologyideas4 min read

Every Songcode track is ode, a text file that plays. Most tracks start with a description: you say what you want and Songcode writes the code. You can also write the code yourself, from the first line, and a new project now offers that from the start.

Open a new project and, under the example prompts, press write it by hand. Songcode loads a starter loop that plays as it is: four bars in C minor, drums, a bass on the chord roots, keys on the full chords and a mix table, with a few comments that say what the rows do. Press play, then change a line. Nothing is saved until your first edit. The learn ode link beside the button opens Write ode by hand in the docs, which walks through that loop line by line.

Writing by hand costs nothing. The Songcode Audio Engine runs in your browser, so a track you type plays, saves, publishes and exports without a model key or a plan, and none of it counts toward weekly usage. What you write is yours, commercial use included.

This post builds a short track from four lines up. Every step plays here on the page, and each box is an editor: change a mark, press play, and you hear your version. You do not need an account for that.

A kick

ode
tempo 96
form loop 4

stem kick: analog {
  kick [x... .... x... ....]
}

The first line says the file is written in ode. tempo 96 sets 96 beats a minute, and form loop 4 makes the track a loop four bars long. Then comes a stem, which is one part of the track. It has a name (kick), a sound after the colon (analog, one of Songcode’s drum kits) and a block that says what it plays.

The row in square brackets is one bar of sixteen steps, read left to right. An x is a hit and a . is a rest, so this kick lands on the first and third beats. A row repeats until the form ends.

Drums

ode
tempo 96
form loop 4

stem kick: analog {
  kick [x... .... x.x. ....]
}

stem clap: analog {
  clap [.... x... .... x...]
}

stem hats: analog {
  hat [x.x. x.x. x.x. x.xx]
  velocity [90 40]
}

Two more stems use the same kit. The clap hits on beats two and four. The hats play every other step, with two quick ones at the end of the bar, and velocity sets how hard each one lands: the values 90 and 40 take turns, so the hats go loud, soft, loud. The kick has one more hit than before, in the third beat.

Chords and a bass

ode
tempo 96
key d minor
form loop 4
chords [Dm7 | Bbmaj7 | Gm7 | A7]

stem kick: analog {
  kick [x... .... x.x. ....]
}

stem clap: analog {
  clap [.... x... .... x...]
}

stem hats: analog {
  hat [x.x. x.x. x.x. x.xx]
  velocity [90 40]
}

stem bass: fingerbass {
  rhythm [x..x ..x. x... ..x.]
  tones  [root]
  octave 2
}

stem keys: epiano {
  rhythm [..x. .... ..x. ..x.]
  tones  [all]
  octave 3
}

key d minor and the chords row give the track its harmony, one chord a bar, and every pitched stem reads from it. The bass plays tones [root], the root of whichever chord is sounding, on the rhythm in its row. The keys play tones [all], the whole chord, on the offbeats. Change a chord in the row and both stems follow it.

A tune and a mix

ode
title "first ode"
tempo 96
key d minor
form loop 4
chords [Dm7 | Bbmaj7 | Gm7 | A7]

stem kick: analog {
  kick [x... .... x.x. ....]
}

stem clap: analog {
  clap [.... x... .... x...]
  reverb 20%
}

stem hats: analog {
  hat [x.x. x.x. x.x. x.xx]
  velocity [90 40]
  highpass 500hz
}

stem bass: fingerbass {
  rhythm [x..x ..x. x... ..x.]
  tones  [root]
  octave 2
}

stem keys: epiano {
  rhythm [..x. .... ..x. ..x.]
  tones  [all]
  octave 3
  reverb 30%
}

stem lead: vibraphone {
  line [mp a4/4 f4/8 a4 c5/4 a4 | bb4/2 d5/4 f5 |
        g4/4 bb4/8 d5 f5/4 e5/8 d5 | c#5/2 e5/2]
  delay 20%, time: 3/8
}

mix {
  kick  0db
  clap  -6db
  hats  -11db, pan: 15R
  bass  -4db
  keys  -10db, pan: 10L
  lead  -8db, pan: 10R
}

A line is a written melody: a pitch and a length for each note, where /4 is a quarter note and /8 an eighth. A length holds until the next one changes it, and | marks the bar lines, so Songcode can tell you when a bar comes up short. mp is the dynamic, as on a score. The lead plays through a delay set to a dotted eighth.

The mix table at the end sets each stem’s level in decibels and its place from left to right. That is a finished loop, about fifty lines long.

When something is wrong

Songcode reads the code every time it changes. A line it cannot read turns the status line red with the line number, the stem and the problem, and a word close to a real one gets a suggestion, such as clapp for clap. The broken stem goes quiet and the rest keep playing, so a typo never stops the track. While a track plays, update swaps in only the stems you changed, without a gap.

Where to learn the rest

The docs cover the whole language. The song format is the reference for the shape of a track: the plan at the top, stems, the arrange table that turns a loop into a song with sections, blocks that change a stem for part of the song, the mix table, lyrics and score blocks. Rows and settings lists everything that can go inside a stem. Sounds has every drum kit and instrument by name, and the code view explains editing while the music plays and what each error message means.

Two older posts go further into what the language can say. How to read a track walks through a full one line by line, and ode writes down how an instrument is played covers bowing, breath and the score words for styles of playing.

Hand and Songcode write the same file. A track Songcode wrote opens as code you can change line by line, and a moved note or a fader in the stems view is written back into the code, so you can start from either side and switch whenever you like.

What we would like to see

We built ode for people to read and write, as well as for Songcode. People who write ode are odists, and Songcode is the greatest odist of all, but we would love to see what everyone else does with it: a drum pattern worked out one step at a time, a piano piece written bar by bar in a score block, a loop that is three lines long and still good. A hand-written track publishes like any other, and its song page says it was written by hand. Anyone signed in can remix it. The Songcode Discord is open to everyone, and we would like to hear what you make there.

Songcode is in early access, so making an account takes an invite, which you can ask for on songco.de. The players in this post need no account at all.

Describe a song.
Get it in code.

open songcode