Files
skills/plugins/document-navigator/docs/media/audio/midi/README.md
admin 9bf56a806b Move docs/ package mirror into document-navigator plugin
Relocate the ~6k-file docs tree from the repo root into
plugins/document-navigator/docs/ so the plugin is self-contained and
portable. docs/superpowers/ (specs and plans) stays at the repo root.

Moved via cp+rm rather than git mv because directory rename() fails with
EPERM on this WSL /mnt DrvFs mount; git rename-detection pairs the
identical-content files at commit time.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-30 01:10:00 +01:00

6.6 KiB

@suaveplan/midi - Universal MIDI primitives: 18-variant MidiMessage discriminated union, encode/decode with running-status, NRPN/RPN/CC14 reducers, SysEx framing with manufacturer registry, MidiPortLike contract, MIDI Clock helpers, General MIDI tables (Level 1, Level 2, GS, XG), and MIDI 2.0 UMP framing with lossless MIDI1<->UMP bridge. Zero browser/Node coupling.

Universal MIDI primitives for the Suaveplan platform. Owns the canonical types, byte parsers, message constructors, control-surface dispatchers (NRPN, RPN, 14-bit CC), SysEx framing with a manufacturer-id registry, MIDI Clock helpers, the General MIDI Level 1 / Level 2 / GS / XG patch tables, MIDI 2.0 UMP framing with a lossless MIDI1 ↔ UMP bridge, and an OpenTelemetry-shaped (structural) instrumentation surface. Zero browser/Node coupling — Web MIDI access lives in @suaveplan/react-midi, node-midi access in a future @suaveplan/midi-node.

Documentation tree

  • clock — Helpers for converting between MIDI Clock ticks, beats, and tempo. MIDI 1.0 defines 24 pulses per quarter note (`PPQN =…
    • clock — Helpers for converting between MIDI Clock ticks, beats, and tempo. MIDI 1.0 defines 24 pulses per quarter note (`PPQN =…
  • cc14 — CC14Reducer accumulates paired MIDI 1.0 control-change messages into 14-bit values. The wire convention is: CCs 0..31…
  • nrpn — NRPNReducer accumulates the four-CC "dance" that MIDI 1.0 uses to express Non-Registered Parameter Number changes int…
  • rpn — RPNReducer is the sister of NRPNReducer for Registered Parameter Numbers — the parameter MSB and LSB CC numbers mov…
  • running-status — RunningStatusDecoder is the streaming MIDI 1.0 decoder that honours running status — the wire convention where succes…
  • error-codes — Defines the MidiError class and the MIDI_CODES namespaced registry used by every @suaveplan/midi module that rais…
    • error-codes — Defines the MidiError class and the MIDI_CODES namespaced registry used by every @suaveplan/midi module that rais…
  • gs — Roland's GS dialect predates GM2 and uses Bank-Select LSB (CC 32) to select instrument variations on top of the GM1 bas…
  • level1 — The General MIDI Level 1 patch and percussion tables — the canonical instrument-name lookups every GM-compliant playbac…
  • level2 — General MIDI Level 2 added a bank-select-driven variation layer on top of GM1. Each GM1 program (0..127) gains optional…
  • xg — Yamaha's XG dialect uses Bank-Select MSB (CC 0) to select instrument variations on top of the GM1 base programs — the i…
  • decode — decodeMessage parses one MIDI 1.0 message starting at a given offset in a Uint8Array and returns both the typed mes…
  • encode — encodeMessage converts a strongly-typed MidiMessage value into the byte sequence a MIDI 1.0 wire format expects. It…
  • sysex — parseSysEx and buildSysEx are the canonical helpers for working with MIDI System Exclusive payloads — the manufactu…
    • manufacturers — The manufacturer-id registry maps the bytes that follow F0 in a SysEx frame to a human-readable name. The MIDI Manufa…
    • sysex — parseSysEx and buildSysEx are the canonical helpers for working with MIDI System Exclusive payloads — the manufactu…
  • telemetry — OpenTelemetry-shaped instrumentation for @suaveplan/midi without taking a runtime dependency on @opentelemetry/api.…
    • telemetry — OpenTelemetry-shaped instrumentation for @suaveplan/midi without taking a runtime dependency on @opentelemetry/api.…
  • ump — MIDI 2.0 introduces the Universal MIDI Packet (UMP) format — fixed-width 32, 64, 96, or 128 bit packets that carry MIDI…
    • ump — MIDI 2.0 introduces the Universal MIDI Packet (UMP) format — fixed-width 32, 64, 96, or 128 bit packets that carry MIDI…

Install

bun add @suaveplan/midi

Quick start

import {
  decodeMessage,
  encodeMessage,
  RunningStatusDecoder,
} from "@suaveplan/midi";

// Encode a NoteOn.
const bytes = encodeMessage({
  type: "noteOn",
  channel: 0,
  note: 60,
  velocity: 100,
});

// Decode a buffer with running-status enabled.
const decoder = new RunningStatusDecoder();
decoder.push(bytes);
const messages = decoder.drain();
// messages = [{ type: "noteOn", channel: 0, note: 60, velocity: 100 }]

Modules

Tier and dependencies

  • Tier: universal — no window, no navigator, no node:*.
  • Runtime deps: @suaveplan/error, @suaveplan/types, tslib, zod.
  • Test deps: @suaveplan/testing, fast-check.
  • No @opentelemetry/api runtime dep — OTel is consumed structurally per MidiTelemetry.

Coverage gate

bunx turbo test:coverage --filter=@suaveplan/midi enforces 100/100/100/100 (statements / branches / functions / lines).