Music
ARRANGEMENT · AUDIO · CREATE INSTRUMENT LAYER · ENVELOPE · FILTER · FILTERENVELOPE · FIXEDFREQ · FMENVELOPE · INSTRUMENT · LAYER · MUSIC · NAME · PAN · PATTERN · PERCUSSION · PITCHENVELOPE · PITCHENVELOPE · PLAY · SAMPLE · SET INSTRUMENT · SET INSTRUMENT LAYER · TEMPO · TIMESIG · TRACK · TREMOLO · UNISON · VIBRATO · VOLUME · WAVETABLE
ARRANGEMENT
The order the patterns play in, a PLAY line each.
ARRANGEMENT
...
END ARRANGEMENT
Example
SCREEN 320, 240
MUSIC "tune"
PATTERN "a"
TRACK !! channel(1) notes("o4 c e g")
END PATTERN
PATTERN "b"
TRACK !! channel(2) notes("o3 c")
END PATTERN
ARRANGEMENT
PLAY "a" !! repeat(2)
PLAY "a" !! with("b")
END ARRANGEMENT
END MUSIC
PRINT arrangementpattern("tune", 0), arrangementrepeat("tune", 0)
PRINT arrangementpattern("tune", 1)
Notes
Opens a block I run once. You can write it only inside MUSIC. Inside it you can write PLAY.
AUDIO
A recorded sound mixed under the pattern’s tracks: one loaded with LOADMP3 or LOADWAV.
AUDIO handle
Also documents: offset, pan, repeat, section, volume
Parameters
- handle AS STRING - The sound’s name.
After !!
- offset(seconds AS NUMBER) - Start this far into the pattern.
- pan(position AS NUMBER) - Where it sits, from left to right.
- repeat(on = TRUE) - Play it again until the pattern ends.
- section(span AS RANGE) - Only this part of it,
start ... finish, in seconds. - volume(level AS NUMBER) - How loud, from 0 to 100.
Example
SCREEN 320, 240
LOADWAV "explosion.wav", "boom"
MUSIC "intro"
PATTERN "open" !! length(4)
TRACK !! channel(1) notes("o4 c d e")
AUDIO "boom" !! volume(60) offset(0.5)
END PATTERN
END MUSIC
PRINT patternaudio("intro", "open"), patternaudiovolume("intro", "open")
Notes
You can write it only inside PATTERN.
CREATE INSTRUMENT LAYER
Adds a layer to an instrument.
CREATE INSTRUMENT LAYER number [, wave]
...
END CREATE INSTRUMENT LAYER
Also documents: detune, duty, feedback, fmdepth, fmtarget, harmonics, octave, volume
Parameters
- number AS NUMBER - The instrument’s number.
- wave AS STRING = NULL
After !!
- detune(cents AS NUMBER) - How far it is tuned from the note, in cents.
- duty(fraction AS NUMBER) - A pulse wave’s duty cycle.
- feedback(amount AS NUMBER) - How much it modulates itself.
- fmdepth(amount AS NUMBER) - How much it modulates it.
- fmtarget(layer AS NUMBER) - The layer this one modulates.
- harmonics(levels…) - A custom wave’s harmonics, loudest first.
- octave(shift AS NUMBER) - How many octaves up or down it plays.
- volume(level AS NUMBER) - How loud the layer is.
Example
SCREEN 320, 240
INSTRUMENT 200
LAYER "sine"
END LAYER
END INSTRUMENT
CREATE INSTRUMENT LAYER 200, "noise" !! volume(0.2)
END CREATE INSTRUMENT LAYER
PRINT instrumentlayercount(200), layerwave(200, 1)
Notes
Opens a block I run once. Inside it you can write FMENVELOPE, PITCHENVELOPE, SAMPLE, UNISON and WAVETABLE.
ENVELOPE
How each note rises, holds and fades.
ENVELOPE
Also documents: attack, decay, release, sustain
After !!
- attack(seconds AS NUMBER) - How long it takes to rise.
- decay(seconds AS NUMBER) - How long it takes to fall to the sustain level.
- release(seconds AS NUMBER) - How long it takes to fade once the note ends.
- sustain(level AS NUMBER) - The level it holds while the note is held, 0 to 1.
Example
SCREEN 320, 240
INSTRUMENT 200
ENVELOPE !! attack(0.05) decay(0.3) sustain(0.5) release(0.8)
LAYER "sawtooth"
END LAYER
END INSTRUMENT
PRINT instrumentattack(200), instrumentdecay(200)
PRINT instrumentsustain(200), instrumentrelease(200)
Notes
You can write it only inside INSTRUMENT or SET INSTRUMENT.
FILTER
Takes some of the sound away: the highs, the lows, or around a point.
FILTER kind
Also documents: cutoff, resonance
Parameters
- kind AS STRING - “lowpass”, “highpass”, “bandpass” or “notch”.
After !!
- cutoff(hz AS NUMBER) - Where it starts to cut, in Hz.
- resonance(amount AS NUMBER) - How much it rings at the cutoff.
Example
SCREEN 320, 240
INSTRUMENT 200
FILTER "lowpass" !! cutoff(600) resonance(2)
LAYER "sawtooth"
END LAYER
END INSTRUMENT
PLAY "t140 o3 i200 l8 c c g g" !! background
PRINT "a muffled sawtooth"
Notes
You can write it only inside INSTRUMENT or SET INSTRUMENT.
FILTERENVELOPE
How the filter’s cutoff moves over each note.
FILTERENVELOPE
Also documents: attack, decay, peak, release, sustain
After !!
- attack(seconds AS NUMBER) - How long it takes to rise.
- decay(seconds AS NUMBER) - How long it takes to fall to the sustain level.
- peak(amount AS NUMBER) - How far the filter opens at the top.
- release(seconds AS NUMBER) - How long it takes to fade once the note ends.
- sustain(level AS NUMBER) - The level it holds while the note is held, 0 to 1.
Example
SCREEN 320, 240
INSTRUMENT 200
NAME "Wah"
FILTER "lowpass" !! cutoff(400) resonance(3)
FILTERENVELOPE !! attack(0.1) decay(0.3) sustain(0.2) release(0.2) peak(2000)
LAYER "sawtooth"
END LAYER
END INSTRUMENT
PRINT instrumentname(200), "opens its filter on each note"
Notes
You can write it only inside INSTRUMENT or SET INSTRUMENT.
FIXEDFREQ
Plays every note at this frequency, in Hz.
FIXEDFREQ hz
Parameters
- hz AS NUMBER
Example
SCREEN 320, 240
INSTRUMENT 200
NAME "Click"
FIXEDFREQ 1000
LAYER "square"
END LAYER
END INSTRUMENT
PLAY "t200 o4 i200 l16 c d e" !! background
PRINT instrumentname(200), "plays every note at 1000 Hz"
Notes
You can write it only inside INSTRUMENT or SET INSTRUMENT.
FMENVELOPE
How the layer’s modulation rises and falls over each note.
FMENVELOPE
Also documents: attack, decay, release, sustain
After !!
- attack(seconds AS NUMBER) - How long it takes to rise.
- decay(seconds AS NUMBER) - How long it takes to fall to the sustain level.
- release(seconds AS NUMBER) - How long it takes to fade once the note ends.
- sustain(level AS NUMBER) - The level it holds while the note is held, 0 to 1.
Example
SCREEN 320, 240
INSTRUMENT 201
NAME "E-Piano"
LAYER "sine"
END LAYER
LAYER "sine" !! octave(1) fmtarget(0) fmdepth(4)
FMENVELOPE !! attack(0) decay(0.4) sustain(0.1) release(0.3)
END LAYER
END INSTRUMENT
PRINT instrumentname(201), instrumentlayercount(201)
Notes
You can write it only inside CREATE INSTRUMENT LAYER, LAYER or SET INSTRUMENT LAYER.
INSTRUMENT
Describes an instrument, for a song’s tracks to play: its settings, a line each, then its layers.
INSTRUMENT number
...
END INSTRUMENT
Parameters
- number AS NUMBER - The instrument’s number.
Example
SCREEN 320, 240
INSTRUMENT 200
NAME "Pad"
VOLUME 0.8
ENVELOPE !! attack(0.4) decay(0.2) sustain(0.7) release(1)
FILTER "lowpass" !! cutoff(1800) resonance(0.3)
LAYER "sawtooth"
END LAYER
LAYER "square" !! volume(0.4) detune(7)
END LAYER
END INSTRUMENT
PRINT instrumentname(200), instrumentlayercount(200)
PLAY "t120 o4 i200 l8 c e g" !! background
Notes
Opens a block I run once. Inside it you can write ENVELOPE, FILTER, FILTERENVELOPE, FIXEDFREQ, NAME, PAN, PERCUSSION, PITCHENVELOPE, TREMOLO, VIBRATO, VOLUME and LAYER.
LAYER
One of the instrument’s layers: a wave, with its settings after !! and the ones with parts of their own inside.
LAYER [wave]
...
END LAYER
Also documents: detune, duty, feedback, fmdepth, fmtarget, harmonics, octave, volume
Parameters
- wave AS STRING = NULL - “sine”, “square”, “triangle”, “sawtooth”, “pulse”, “noise” or “custom”.
After !!
- detune(cents AS NUMBER) - How far it is tuned from the note, in cents.
- duty(fraction AS NUMBER) - A pulse wave’s duty cycle.
- feedback(amount AS NUMBER) - How much it modulates itself.
- fmdepth(amount AS NUMBER) - How much it modulates it.
- fmtarget(layer AS NUMBER) - The layer this one modulates.
- harmonics(levels…) - A custom wave’s harmonics, loudest first.
- octave(shift AS NUMBER) - How many octaves up or down it plays.
- volume(level AS NUMBER) - How loud the layer is.
Example
SCREEN 320, 240
INSTRUMENT 201
NAME "Bell"
LAYER "sine"
END LAYER
LAYER "sine" !! octave(2) fmtarget(0) fmdepth(3)
END LAYER
LAYER "pulse" !! duty(0.25) volume(0.3)
END LAYER
END INSTRUMENT
PRINT instrumentlayercount(201)
PRINT layerwave(201, 0), layerwave(201, 2)
Notes
Opens a block I run once. You can write it only inside INSTRUMENT. Inside it you can write FMENVELOPE, PITCHENVELOPE, SAMPLE, UNISON and WAVETABLE.
MUSIC
Describes a song, for PLAYMUSIC to play: its TEMPO and TIMESIG, its patterns, each with the tracks that play together, and the ARRANGEMENT they play in.
MUSIC song
...
END MUSIC
Also documents: loop
Parameters
- song AS STRING - What the song is called.
After !!
- loop(on = TRUE) - Start the song again when it ends.
Example
SCREEN 320, 240
MUSIC "theme" !! loop
TEMPO 120
PATTERN "verse"
TRACK !! channel(1) instrument(0) notes("o4 l8 c d e f g")
END PATTERN
ARRANGEMENT
PLAY "verse" !! repeat(2)
END ARRANGEMENT
END MUSIC
PRINT musicexists("theme"), musicloop("theme"), musictempo("theme")
PLAYMUSIC "theme"
Notes
Opens a block I run once. Inside it you can write ARRANGEMENT, PATTERN, TEMPO and TIMESIG.
NAME
What the instrument is called.
NAME text
Parameters
- text AS STRING
Example
SCREEN 320, 240
INSTRUMENT 200
NAME "Glass Bell"
LAYER "sine"
END LAYER
END INSTRUMENT
PRINT instrumentname(200)
Notes
You can write it only inside INSTRUMENT or SET INSTRUMENT.
PAN
Where it sits, from -1 (left) to 1 (right).
PAN position
Parameters
- position AS NUMBER
Example
SCREEN 320, 240
INSTRUMENT 200
PAN -0.75
LAYER "square"
END LAYER
END INSTRUMENT
PRINT instrumentpan(200)
Notes
You can write it only inside INSTRUMENT or SET INSTRUMENT.
PATTERN
A part of the song: the tracks that play together, for the ARRANGEMENT to play by name.
PATTERN name
...
END PATTERN
Also documents: length
Parameters
- name AS STRING - What the pattern is called.
After !!
- length(beats AS NUMBER) - How many beats the pattern lasts.
Example
SCREEN 320, 240
MUSIC "song"
PATTERN "intro" !! length(8)
TRACK !! channel(1) notes("o4 l2 c g")
END PATTERN
PATTERN "chorus" !! length(16)
TRACK !! channel(1) notes("o5 l4 c c d e")
END PATTERN
END MUSIC
PRINT musicpatterncount("song")
PRINT musicpatternlength("song", "intro"), musicpatternlength("song", "chorus")
Notes
Opens a block I run once. You can write it only inside MUSIC. Inside it you can write AUDIO and TRACK.
PERCUSSION
Plays as a drum: FALSE to play notes again, or how much.
PERCUSSION [amount]
Parameters
- amount = TRUE
Example
SCREEN 320, 240
INSTRUMENT 200
NAME "Snare"
PERCUSSION 1
ENVELOPE !! attack(0) decay(0.1) sustain(0) release(0.05)
LAYER "noise"
END LAYER
END INSTRUMENT
PRINT instrumentpercussion(200)
Notes
You can write it only inside INSTRUMENT or SET INSTRUMENT.
PITCHENVELOPE
Slides each note’s pitch as it starts.
PITCHENVELOPE
Also documents: absolute, from, time, to
After !!
- absolute(on = TRUE) - Read
fromandtoas notes of their own, not distances from the note. - from(semitones AS NUMBER) - Where the pitch starts, in semitones from the note.
- time(seconds AS NUMBER) - How long it takes to get there.
- to(semitones AS NUMBER) - Where it ends.
Example
SCREEN 320, 240
INSTRUMENT 200
NAME "Laser"
PITCHENVELOPE !! from(24) to(0) time(0.15)
LAYER "square"
END LAYER
END INSTRUMENT
PLAY "t160 o4 i200 l8 c c" !! background
PRINT instrumentname(200)
Notes
You can write it only inside INSTRUMENT or SET INSTRUMENT.
PITCHENVELOPE
Slides the layer’s pitch as each note starts.
PITCHENVELOPE
Also documents: absolute, from, time, to
After !!
- absolute(on = TRUE) - Read
fromandtoas notes of their own, not distances from the note. - from(semitones AS NUMBER) - Where the pitch starts, in semitones from the note.
- time(seconds AS NUMBER) - How long it takes to get there.
- to(semitones AS NUMBER) - Where it ends.
Example
SCREEN 320, 240
INSTRUMENT 200
NAME "Kick"
PERCUSSION 1
LAYER "sine"
PITCHENVELOPE !! from(12) to(-12) time(0.08)
END LAYER
LAYER "noise" !! volume(0.2)
END LAYER
END INSTRUMENT
PRINT instrumentlayercount(200)
Notes
You can write it only inside CREATE INSTRUMENT LAYER, LAYER or SET INSTRUMENT LAYER.
PLAY
Plays a pattern, by its name.
PLAY pattern
Also documents: repeat, with
Parameters
- pattern AS STRING - The pattern’s name.
After !!
- repeat(times AS NUMBER) - How many times it plays.
- with(patterns…) - Patterns played alongside it.
Example
SCREEN 320, 240
MUSIC "march"
PATTERN "a"
TRACK !! channel(1) notes("o4 c e g")
END PATTERN
PATTERN "b"
TRACK !! channel(2) notes("o3 c")
END PATTERN
ARRANGEMENT
PLAY "a" !! repeat(2)
PLAY "b" !! with("a")
END ARRANGEMENT
END MUSIC
PRINT arrangementcount("march")
Notes
You can write it only inside ARRANGEMENT.
SAMPLE
Plays a recorded sound for the layer.
SAMPLE path
Also documents: basenote, loop, loopmode, pitchmode
Parameters
- path AS STRING - The sound file.
After !!
- basenote(note AS NUMBER) - The note it was recorded at.
- loop(start AS NUMBER, finish AS NUMBER) - The part that repeats while the note is held, in samples.
- loopmode(mode AS STRING) - How it repeats: “oneshot”, “manual” or “auto”.
- pitchmode(mode AS STRING) - How it follows the note.
Example
SCREEN 320, 240
INSTRUMENT 200
NAME "Boom"
LAYER "sine"
SAMPLE "explosion.wav" !! basenote(60)
END LAYER
END INSTRUMENT
PRINT instrumentname(200), instrumentlayercount(200)
Notes
You can write it only inside CREATE INSTRUMENT LAYER, LAYER or SET INSTRUMENT LAYER.
SET INSTRUMENT
Changes an instrument’s settings: only the ones written inside.
SET INSTRUMENT number
...
END SET INSTRUMENT
Parameters
- number AS NUMBER - The instrument’s number.
Example
SCREEN 320, 240
INSTRUMENT 200
NAME "Lead"
VOLUME 0.8
ENVELOPE !! attack(0.01) decay(0.2) sustain(0.7) release(0.3)
LAYER "square"
END LAYER
END INSTRUMENT
SET INSTRUMENT 200
VOLUME 0.4
ENVELOPE !! attack(0.3)
END SET INSTRUMENT
PRINT instrumentvolume(200), instrumentattack(200), instrumentdecay(200)
Notes
Opens a block I run once. Inside it you can write ENVELOPE, FILTER, FILTERENVELOPE, FIXEDFREQ, NAME, PAN, PERCUSSION, PITCHENVELOPE, TREMOLO, VIBRATO and VOLUME.
SET INSTRUMENT LAYER
Changes one of an instrument’s layers: only what is given.
SET INSTRUMENT LAYER number, index [, wave]
...
END SET INSTRUMENT LAYER
Also documents: detune, duty, feedback, fmdepth, fmtarget, harmonics, octave, volume
Parameters
- number AS NUMBER - The instrument’s number.
- index AS NUMBER - The layer’s place, from 0.
- wave AS STRING = NULL
After !!
- detune(cents AS NUMBER) - How far it is tuned from the note, in cents.
- duty(fraction AS NUMBER) - A pulse wave’s duty cycle.
- feedback(amount AS NUMBER) - How much it modulates itself.
- fmdepth(amount AS NUMBER) - How much it modulates it.
- fmtarget(layer AS NUMBER) - The layer this one modulates.
- harmonics(levels…) - A custom wave’s harmonics, loudest first.
- octave(shift AS NUMBER) - How many octaves up or down it plays.
- volume(level AS NUMBER) - How loud the layer is.
Example
SCREEN 320, 240
INSTRUMENT 200
LAYER "square" !! duty(0.5)
END LAYER
END INSTRUMENT
SET INSTRUMENT LAYER 200, 0, "pulse" !! duty(0.125) detune(-5)
END SET INSTRUMENT LAYER
PRINT layerwave(200, 0)
Notes
Opens a block I run once. Inside it you can write FMENVELOPE, PITCHENVELOPE, SAMPLE, UNISON and WAVETABLE.
TEMPO
How fast the song goes, in beats a minute.
TEMPO bpm
Parameters
- bpm AS NUMBER
Example
SCREEN 320, 240
MUSIC "fast"
TEMPO 180
PATTERN "run"
TRACK !! channel(1) notes("o5 l16 c e g > c")
END PATTERN
END MUSIC
PRINT musictempo("fast")
Notes
You can write it only inside MUSIC.
TIMESIG
How many beats a bar has, and which note is a beat.
TIMESIG beats, unit
Parameters
- beats AS NUMBER
- unit AS NUMBER
Example
SCREEN 320, 240
MUSIC "waltz"
TEMPO 90
TIMESIG 3, 4
PATTERN "step"
TRACK !! channel(1) notes("o4 c4 e4 g4")
END PATTERN
END MUSIC
PRINT musicbeats("waltz"), "/", musicbeatunit("waltz")
Notes
You can write it only inside MUSIC.
TRACK
A track of the pattern: what it plays, after !!.
TRACK
Also documents: channel, generator, instrument, name, notes, pan, repeat, volume
After !!
- channel(number AS NUMBER) - The channel it plays on.
- generator(source AS FUNCTION) - A function that gives the notes, asked again each time the song plays.
- instrument(number AS NUMBER) - The instrument that plays it.
- name(text AS STRING) - What the track is called.
- notes(mml AS STRING) - What it plays, written in MML.
- pan(position AS NUMBER) - Where it sits, from left to right.
- repeat(on = TRUE) - Play the notes again until the pattern ends.
- volume(level AS NUMBER) - How loud, from 0 to 100.
Example
SCREEN 320, 240
MUSIC "band"
PATTERN "groove" !! length(8)
TRACK !! name("bass") channel(1) instrument(33) volume(80) notes("o2 l4 c c g g")
TRACK !! name("drums") channel(10) volume(90) pan(-0.3) repeat notes("c8 r8 c8 r8")
END PATTERN
END MUSIC
PRINT trackcount("band", "groove")
PRINT trackname("band", "groove", 0), tracknotes("band", "groove", 0)
PRINT trackrepeat("band", "groove", 1)
Notes
You can write it only inside PATTERN.
TREMOLO
Makes the volume waver.
TREMOLO
Also documents: delay, depth, rate
After !!
- delay(seconds AS NUMBER) - How long after the note starts it begins.
- depth(amount AS NUMBER) - How far it wavers.
- rate(hz AS NUMBER) - How fast it wavers, in Hz.
Example
SCREEN 320, 240
INSTRUMENT 200
NAME "Organ"
TREMOLO !! rate(6) depth(0.4)
LAYER "sine"
END LAYER
LAYER "sine" !! octave(1) volume(0.5)
END LAYER
END INSTRUMENT
PRINT instrumentname(200), instrumentlayercount(200)
Notes
You can write it only inside INSTRUMENT or SET INSTRUMENT.
UNISON
Plays the layer as several copies at once, a little apart.
UNISON
Also documents: blend, detune, phaserandom, spread, voices
After !!
- blend(amount AS NUMBER) - How loud the copies are against the first.
- detune(cents AS NUMBER) - How far apart they are tuned.
- phaserandom(on = TRUE) - Start each copy at a different point in its wave.
- spread(amount AS NUMBER) - How far apart they sit, left to right.
- voices(count AS NUMBER) - How many copies play at once.
Example
SCREEN 320, 240
INSTRUMENT 200
NAME "Supersaw"
LAYER "sawtooth"
UNISON !! voices(5) detune(15) spread(0.8) blend(0.6) phaserandom
END LAYER
END INSTRUMENT
PRINT instrumentname(200), layerwave(200, 0)
Notes
You can write it only inside CREATE INSTRUMENT LAYER, LAYER or SET INSTRUMENT LAYER.
VIBRATO
Makes the pitch waver.
VIBRATO
Also documents: delay, depth, rate
After !!
- delay(seconds AS NUMBER) - How long after the note starts it begins.
- depth(amount AS NUMBER) - How far it wavers.
- rate(hz AS NUMBER) - How fast it wavers, in Hz.
Example
SCREEN 320, 240
INSTRUMENT 200
NAME "Singer"
VIBRATO !! rate(5) depth(0.2) delay(0.3)
LAYER "triangle"
END LAYER
END INSTRUMENT
PLAY "t90 o5 i200 l2 c" !! background
PRINT instrumentname(200)
Notes
You can write it only inside INSTRUMENT or SET INSTRUMENT.
VOLUME
How loud it is.
VOLUME level
Parameters
- level AS NUMBER
Example
SCREEN 320, 240
INSTRUMENT 200
VOLUME 0.5
LAYER "triangle"
END LAYER
END INSTRUMENT
PRINT instrumentvolume(200)
Notes
You can write it only inside INSTRUMENT or SET INSTRUMENT.
WAVETABLE
Plays waves from a file, moving between them.
WAVETABLE path
Also documents: framesize, morph, position
Parameters
- path AS STRING - The file of waves.
After !!
- framesize(samples AS NUMBER) - How long each wave is.
- morph(mode AS STRING) - How it moves between waves: “crossfade” or “spectral”.
- position(place AS NUMBER) - Which wave plays, from 0 to 1.
Example
SCREEN 320, 240
INSTRUMENT 200
NAME "Morph"
LAYER "sine"
WAVETABLE "ready.mp3" !! framesize(256) position(0.5)
END LAYER
END INSTRUMENT
PRINT instrumentname(200), instrumentlayercount(200)
Notes
You can write it only inside CREATE INSTRUMENT LAYER, LAYER or SET INSTRUMENT LAYER.