What You Can Show

showNotes takes music in several shapes and writes each out the same way. The programs on this page are parts of a scene: in JavaScript the names are ready with nothing to import, and in Python a scene begins with from pynotation import *.

A tune as text

showNotes("C4 E4 G4 - C5:2", "quarter")
You writeIt is
C4, F#3, Bb5A note: a letter and a number. C4 is middle C
-A rest
:2The note lasts two steps
:q, :h, :e, :s, :wA length by name: a quarter, a half, an eighth, a sixteenth, a whole note
C4+E4+G4, Cm7A chord, by its notes or by its name

The second thing is how long a step is: "eighth" if you leave it out.

A list

showNotes(["C4", null, ["C4", "E4"]], "quarter")

The same as a list: null (None) is a rest, and a list inside is a chord.

A sheet, written a note at a time

A sheet is for writing music as code, with loops and all:

const sheet = makeSheet({ key: "G", time: "3/4", tempo: 132, title: "Waltz" })
sheet.add("D4", "quarter")
sheet.add(["B4", "D5"], "half")          // a chord
sheet.rest("quarter")
for (const name of ["G4", "A4", "B4"]) sheet.add(name, "eighth")
showNotes(sheet)

A length is "whole", "half", "quarter", "eighth", "sixteenth" or "thirtysecond", with a dot for half as long again ("quarter."), or a number of beats. A sheet that is added to later is drawn again by itself.

A song

const written = await loadJSON("songs/night_drive.json")
showNotes(written, { channels: [3, 1] })

A tracker song: our own JSON kind, as an object, as text or as the name of a song file. In a JavaScript scene loadJSON reads the file from beside the scene; in Python the name is enough. A MOD or XM file is shown once the sound library has packed it. See A song as sheet music.

Plain data

showNotes([
  { note: "C4", start: 0, length: 1 },
  { notes: ["E4", "G4"], start: 1, length: 2 },
])

Each note says when it starts and how long it lasts, in beats. Anything can make this: a game, a recording of what was played, a sum.

Options

In JavaScript the options are the last thing, in braces. In Python they are given by name.

showNotes("C4 E4 G4 - C5:2", "quarter", {
  key: "G", time: "3/4", clef: "treble",     // each is worked out when it is left out
  at: "bottom", zoom: 1.5, paper: "dark",
})
OptionWhat it does
key"C", "G", "Bb", "Am", or sharps as a number (2) and flats as a negative one (-3). Left out: the key with the fewest sharps, flats and naturals to write
time"4/4" unless you say: "3/4", "6/8", "2/2"
clef"treble", "bass", "grand" (both, joined by a brace: notes from middle C up on the top staff) or "percussion". Left out: whichever the notes sit best in
tempoBeats a minute, for the mark over the first line and for page.play()
titleWritten over the music
at"top" (where it goes unless you say), "bottom", "middle" or "fill" (the whole picture). x, y, width and height place it exactly
zoom1 unless you say: 1.5 is half as big again
paper"light" (cream paper, dark ink), "dark", or "clear" (no paper: white ink straight on your scene)
coloursAny of paper, ink, line, now, right, wrong and cursor: now is the colour of a note that is sounding
scroll"down": lines of music one under another, and the page turns. "across": one long line that slides past
linesfalse hides the staff lines
barNumbers (bar_numbers)false hides the small number over each line
followA song (or a function that gives beats) to follow from the start
hearfalse: a tapped note is not played
seekfalse: a tapped bar does not move the music there
linefalse hides the moving line
voiceThe ready-made synth the page plays on: "bell"
synthA synth of yours for the page to play on

A song has five more, in A song as sheet music.

A mistake is said in plain words

"H4" is not a note. Write a note as a name like "C4", "F#3" or "Bb5", or as a number, where 60 is middle C
"alto" is not a clef. The clefs are "treble", "bass", "grand" (both, joined) and "percussion"