Feat: WIP terse code documentation

This commit is contained in:
2026-02-26 01:08:16 +01:00
parent 71bd09d5ea
commit e1cf57918e
47 changed files with 499 additions and 24 deletions

View File

@@ -1,8 +1,12 @@
//! Chord definitions as semitone interval arrays.
/// Named chord with its interval pattern.
pub struct Chord {
pub name: &'static str,
pub intervals: &'static [i64],
}
/// All built-in chord types.
pub static CHORDS: &[Chord] = &[
// Triads
Chord {
@@ -169,6 +173,7 @@ pub static CHORDS: &[Chord] = &[
},
];
/// Find a chord's intervals by name.
pub fn lookup(name: &str) -> Option<&'static [i64]> {
CHORDS.iter().find(|c| c.name == name).map(|c| c.intervals)
}

View File

@@ -1,3 +1,5 @@
//! Music theory data — chord and scale lookup tables.
pub mod chords;
mod scales;

View File

@@ -1,8 +1,12 @@
//! Scale definitions as semitone offset arrays.
/// Named scale with its semitone pattern.
pub struct Scale {
pub name: &'static str,
pub pattern: &'static [i64],
}
/// All built-in scale types.
pub static SCALES: &[Scale] = &[
Scale {
name: "major",
@@ -125,6 +129,7 @@ pub static SCALES: &[Scale] = &[
},
];
/// Find a scale's pattern by name.
pub fn lookup(name: &str) -> Option<&'static [i64]> {
SCALES.iter().find(|s| s.name == name).map(|s| s.pattern)
}