pub fn best_spelling(
pitches: &[Pitch],
rules: EnharmonicRules,
) -> Result<Vec<Pitch>>Expand description
The best spelling of pitches under rules: music21’s
EnharmonicSimplifier.bestPitches. Octaves move with a respelling, so
B#3 may come back as C4.
use music21_rs::{Pitch, analysis::enharmonics::{EnharmonicRules, best_spelling}};
let pitches: Vec<Pitch> = ["D--", "E", "F##"].iter().map(|n| n.parse()).collect::<Result<_, _>>()?;
let best = best_spelling(&pitches, EnharmonicRules::MELODIC)?;
let names: Vec<String> = best.iter().map(Pitch::name).collect();
assert_eq!(names, ["C", "E", "G"]);§Errors
No pitches, which music21 refuses too, or a spelling base 40 has no place for.