Skip to main content

pitch_ticks

Function pitch_ticks 

Source
pub fn pitch_ticks(
    labels: PitchLabels,
    min: i64,
    max: i64,
    counts: &[(String, usize)],
    value_of: impl Fn(&str) -> Result<FloatType>,
    unused_label: impl Fn(i64) -> Result<String>,
) -> Result<Vec<(i64, String)>>
Expand description

A pitch axis’s ticks from min to max, one a whole number: music21’s PitchAxis._pitchTickHelper.

counts is how often each name was found, in the order found; value_of says where a name stands on the axis, and unused_label names a tick no name stands at, where one is wanted.

use music21::graph::axis::{Octaves, PitchLabels, pitch_ticks};

let labels = PitchLabels {
    octaves: Octaves::Hidden,
    show_enharmonic: true,
    blank_label_unused: true,
    hide_unused: false,
};
let counts = [("G#".to_string(), 1), ("A-".to_string(), 2)];
let ticks = pitch_ticks(labels, 7, 8, &counts, |_| Ok(8.0), |_| Ok(String::new()))?;
assert_eq!(ticks, vec![(7, String::new()), (8, "G\u{266f}/A\u{266d}".to_string())]);

§Errors

What value_of or unused_label returns.