Music theory analysis, composition utilities, and MIDI tooling for MoonBit.
test "Readme examples" {
// 1. Parsing and transposing notes
let c4 = @theory.Note::parse("C4").unwrap()
let m3 = @theory.Interval::parse("M3").unwrap()
let e4 = c4.transpose(m3)
inspect(e4.to_string(), content="E4")
// 2. Generating chords
let (root, chord_type) = @theory.parse_chord_symbol("Cmaj7").unwrap()
let notes = @theory.generate_chord(root, chord_type)
let notes_strs = notes.map(fn(n) { n.to_string() })
inspect(notes_strs, content="[\"C4\", \"E4\", \"G4\", \"B4\"]")
// 3. Roman Numeral analysis
let c_major = @theory.Key::new(NoteLetter::C, Accidental::Natural, ScaleType::Major)
let result = c_major.analyze_chord("G7").unwrap()
inspect(result, content="V7")
}# Query chord notes
moon run src/cli -- chord Cmaj7
# Generate scale notes
moon run src/cli -- scale C major
# Transpose a note by an interval
moon run src/cli -- transpose C4 M3
# Roman numeral degree analysis
moon run src/cli -- roman C major G7
# Generate a deterministic score report
moon run src/cli -- report C major I,IV,V,I
# Encode/decode a MIDI fixture
moon run src/cli -- midi-roundtrip I,IV,V,Imoon check --deny-warn
moon test --deny-warn
moon fmtMusic theory analysis, composition utilities, and MIDI tooling for MoonBit.