Skip to main content

Module music

Module music 

Source
Expand description

The music dictionary for notes: scales, keys, chords, progressions, rhythm and technique words, each with a checkable note rule, and the parsers and functions that read them.

The data lives in dictionary/music/, one JSON file per topic. The binary embeds those files and parses them once (dictionary); it reads nothing else from the dictionary. cargo xtask reference writes the reference files under reference/core/ from the same data.

  • entry: the entry, its rule and its example fragments.
  • check: the rules every entry must meet, the coverage of the tiers and the recomputed shares.
  • pitch: pitch classes, spelling and the three middle-C labels.
  • key: the key parser, Camelot and Open Key.
  • roman: Roman numerals as semitones.
  • chord: the chord-symbol parser.
  • scale: scale lookup and the snap rule.
  • rhythm: Euclidean patterns, swing and tick arithmetic.
use sound_to_patch::music::{dictionary, key::parse_key};

let phrygian = dictionary()?.entry("scale.phrygian").unwrap();
assert_eq!(phrygian.word, "Phrygian");
let reading = parse_key("8A")?;
assert_eq!(reading.key.to_string(), "A minor");

Modules§

check
The rules every entry of the music dictionary meets, the coverage of the tiers and the recomputed shares. dictionary refuses data that breaks one.
chord
The chord-symbol parser.
entry
One entry of the music dictionary, its checkable note rule and its example fragments. schemas/music.schema.json describes the same shape for editors.
key
Keys: the key parser, relative and parallel keys, Camelot and Open Key.
pitch
Pitch classes, spelling for display and the three middle-C labels.
rhythm
Rhythm arithmetic: Euclidean patterns, swing and ticks.
roman
Roman numerals, stored as semitones above the tonic.
scale
Scale lookup and the snap rule.

Structs§

Dictionary
The parsed dictionary.
Stat
A share the dictionary states.
Topic
One topic file of the dictionary and the groups it may hold.

Enums§

MusicError
A failure of the music dictionary or of one of its parsers.

Constants§

TOPICS
Every topic, in reference order.

Functions§

dictionary
The dictionary, parsed once.