Tonal Functions
These functions use tonaljs to provide helpers for musical operations.
scale(name)
Turns numbers into notes in the scale (zero indexed). Also sets scale for other scale operations, like scaleTranspose.
"0 2 4 6 4 2" .scale("C2:major C2:minor").slow(2)) .note().s("piano")
Note that the scale root is octaved here. You can also omit the octave, then index zero will default to octave 3.
All the available scale names can be found here.
transpose(semitones)
Transposes all notes to the given number of semitones:
This method gets really exciting when we use it with a pattern as above.
Instead of numbers, scientific interval notation can be used as well:
scaleTranspose(steps)
Transposes notes inside the scale by the number of steps:
"-8 [2,4,6]" .scale('C4 bebop major') .scaleTranspose("<0 -1 -2 -3 -4 -5 -6 -4>") .note()
voicings(range?)
Turns chord symbols into voicings, using the smoothest voice leading possible:
rootNotes(octave = 2)
Turns chord symbols into root notes of chords in given octave.
Together with layer, struct and voicings, this can be used to create a basic backing track:
"<C^7 A7b13 Dm7 G7>".layer( x => x.voicings('lefthand').struct("~ x").note(), x => x.rootNotes(2).note().s('sawtooth').cutoff(800) )
So far, we’ve stayed within the browser. MIDI and OSC are ways to break out of it.