Chapter 10

Playing live

Keyboards into tracks, and takes into piano rolls.

Keyboards

Source
midikeys("KeyStep")(1)a MIDI keyboard on channel 1 (any part of the device's name): notes, velocity, bend, aftertouch, played by the audio engine directly, with no scheduling delay, through Web MIDI (Chrome, Edge, Firefox)
the piano roll's ⌨your typing keyboard: the home row is the white keys, the row above the black; z/x octave, c/v velocity
// double-click pianoroll, press ⌨, play
keys: pianoroll("keys").synth("Wavetable").scale("F minor").postgain(0.4)
beat: s("bd*4, ~ hh ~ hh").postgain(0.3)

_roll("keys", "", { grid: 16, len: 16 })

Live notes start env() envelopes and note-synced LFOs like written ones, and .scale() snaps them into the key. Pitch changes such as .add(12) apply to them; timing changes don't.

Playing over a part

Written after something, .pianoroll() adds a roll under it instead of replacing it, so you can draw while you hear what's already there:

const kb = midikeys("KeyStep")
keys: kb(1).pianoroll().synth("Wavetable")   // play live over a drawn part
riff: n("<0 1 2>").sc(3).pianoroll()       // draw a counter-line under a pattern

Recording a take

● rec in the header records into the piano roll. It counts in to the next phrase, records for the cycles you pick and quantizes to the grid you pick (what's left over is kept as each note's nudge). A roll shorter than the take overdubs; notes played during the count-in land before the start, dimmed, if you want them.

Played something good without recording? The roll's capture grabs the last stretch you played, as if rec had been on.

Drop a .mid file on the window: each lane becomes a pianoroll track, with the key it guessed offered as a setscale line.

DJ mode ({app+d}, or the header button) puts a second deck beside the first, each with its own song, and mixes between them.

A deck plays code or a song file. The songs come from a music folder, chosen in settings → music folder and read where it is.

Controls and displays

Sliders, knobs, step grids, scopes and meters drawn in the code, to play by hand: see Controls & displays.