TypeScript library for programmatically generating MIDI files. Builds to CJS, ESM, and browser IIFE via Rollup.
npm run build— build with Rollupnpm test— build + run Mocha tests with NYC coveragenpm run lint:js— ESLintnpm run watch— watch mode
Only run tests when explicitly asked.
- Entry point:
src/main.ts - Source organized into
src/chunks/,src/midi-events/,src/meta-events/ - Interface-based design:
AbstractEvent,Chunk,MetaEvent,MidiEvent - Tests in
test/use Mocha + Node assert, import from compiled build (build/index.js) - Tests validate output by comparing base64-encoded MIDI strings
- VexFlow integration (
src/vexflow.ts) is experimental — treat with caution
- Tabs for indentation (4-space width), LF line endings
- PascalCase classes, camelCase methods/properties, UPPER_SNAKE_CASE constants
- kebab-case filenames
- Named exports from modules, default export object from
main.ts - JSDoc comments on public APIs
- No Prettier — ESLint only
- New event types should mirror existing ones in their category
Track.addEvent()supports method chaining (returnsthis)- Single production dependency:
@tonaljs/midifor note name → MIDI number conversion
- TypeScript 5, Rollup 2, Mocha 9, NYC 15