🎼 Compact Music Token (CMT) Documentation

A comprehensive guide to encoding musical events using Compact Music Token formatβ€” your custom format for pitch and duration encoding in a compact, audit-friendly way.

πŸ“… Version 1.0 🏷️ ETA v13M πŸ“ Software Documentation

🎯CMT Format Overview

CMT encodes each musical event as a single token using this standardized format:

<Note><Accidental><Octave>:<DurationCode>

πŸ’‘ Key Concept: Each token represents a complete musical event with both pitch information (using Scientific Pitch Notation) and timing information (using ABC notation-style duration codes).

πŸ”ΉPitch Encoding (SPN-style)

Token Part Meaning Examples
Note Letter names A–G C, F, G
Accidental # for sharp, b for flat F#, Bb
Octave Integer (0–8) C4, A3

πŸ”ΈDuration Encoding (ABC-style)

Code Meaning Beats (4/4) Example
w Whole 4 C4:w
h Half 2 D4:h
q Quarter 1 E4:q
e Eighth Β½ F#4:e
s Sixteenth ΒΌ G4:s
. Dot modifier +Β½ of base A4:h. (dotted half = 3 beats)
t Triplet prefix β…“ of base tq = triplet quarter

πŸ›‘Representing Rests

Use "rest" as the pitch component to represent silence:

"rest:q" // quarter rest "rest:h." // dotted half rest "rest:w" // whole rest "rest:e" // eighth rest

πŸ“ Note: Rest tokens follow the same duration encoding rules as pitched notes, but use the literal string "rest" instead of a pitch specification.

πŸ§ͺBasic Examples

Here are some practical examples of CMT tokens in action:

[ "C4:q", // Quarter note C4 "F#3:e", // Eighth note F#3 "Bb5:h.", // Dotted half note Bb5 "rest:q", // Quarter rest "G4:tq" // Triplet quarter note G4 ]

βœ… Valid Examples

  • A4:q - Quarter note A4
  • C#5:h. - Dotted half C#5
  • rest:e - Eighth rest

❌ Invalid Examples

  • H4:q - Invalid note name
  • C4 - Missing duration
  • C:q - Missing octave

🧰Optional Extensions

You can extend CMT tokens with suffixes or tags for additional musical information:

Articulation

C4:q.staccato D4:e.legato

Lyrics

D4:e:"hello" E4:q:"world"

Velocity/Dynamics

E4:q@80 F4:h@forte

Measure Markers

M1:C4:q M2:D4:h

🧠Why Use CMT?

βœ…

Compact and Readable

Human-readable format that's also machine-parseable

βœ…

Easy to Parse and Validate

Simple regex patterns can validate and extract components

βœ…

Ideal for Music Applications

Perfect for audit overlays, tutor apps, and export workflows

βœ…

SPN-Aligned and MIDI-Compatible

Integrates seamlessly with existing music software standards

🧱JSON Measure Structure

CMT tokens are typically organized within JSON structures representing musical measures:

[ { "measure": 1, "notes": ["rest:q", "A4:e", "E4:e", "E4:e", "C#4:q", "B3:e"] }, { "measure": 2, "notes": ["B3:q", "C#4:e", "D4:e", "D4:q", "rest:q"] } ]

πŸ“Š Structure Benefits

  • β€’ Clear measure boundaries for musical organization
  • β€’ Easy to iterate through for playback or analysis
  • β€’ Compatible with existing JSON-based music formats
  • β€’ Supports additional measure-level metadata