Sync to tempo and key
Lock to the song's beat, and to its key and scale.Your device can read where the song is, and what key it's in, from inside process.
The beat
const bpm = ctx.tempo(); // BPM
const playing = ctx.isPlaying();
const bar = ctx.bar();
const beat = ctx.beat();
const phase = ctx.beatPhase(); // 0..1 through the current beatDrive anything rhythmic with these: flash a light on each beat, step a sequencer. The building blocks also have tempo-sync helpers so an LFO or delay can lock to note values.
The key
For scale-aware tools (a smart arp, a quantizer):
const root = ctx.meshKey(); // 0..11, C = 0
const mask = ctx.meshScaleMask(); // which notes are in scale
const inScale = ctx.noteInScale(note, mask);Snap a note onto the scale with foldToMask(note, mask) (or foldToScale(note, root, scaleId) for a fixed scale). Full list in Harmony and
sequencing.