Notation

@xromdev/notation v0.1.1 · MITnpm i @xromdev/notationnpm ↗GitHub ↗Piano roll →

Ticks in, a score a person can read out — note values, ties, triplets, key spelling, the grand staff, drums and dynamics. It draws nothing; VexFlow engraves what it returns.

0 dependencies · ~6 KB gzipped · ~1 ms a score · 20 Battletoads tracks checked by ear

Values
Tuplets
Bars

Off the beat. Notes that start between the beats and run over the bar line: each written with the fewest heads — a syncopation is one note, not a sixteenth tied into scraps.

C major · 3 bars · opening bar 4/4

loading the music font…

Use it

import { buildScore, keyOf, staffKey } from '@xromdev/notation';

// Ticks: 16 to a quarter — a sound driver's grid, a sixty-fourth each.
const score = buildScore(
  [{ id: 'lead', notes: [
    { start: 0, ticks: 16, midi: 66, volume: 6 },   // F#4, a quarter
    { start: 16, ticks: 24, midi: 69, volume: 12 }, // A4, a dotted quarter
    { start: 40, ticks: 40, midi: 74 },             // D5, over the bar line
  ] }],
  [],            // drums: { start, ticks, period } — NES noise rates
  80,            // ticks in the piece
  { measureTicks: 64 }
);

for (const bar of score.staves[0].bars) {
  for (const item of bar) {
    const head = item.midi === null ? 'rest' : staffKey(item.midi, keyOf('D'));
    console.log(head, item.duration + '.'.repeat(item.dots), item.tieStart ? '⌒' : '');
  }
}
// bar 1: f#/4 q · a/4 q. · d/5 q. ⌒
// bar 2: d/5 q · rest h.
console.log(score.dynamics.lead); // [{ tick: 0, dynamic: 'mp' }, { tick: 16, dynamic: 'f' }]