Skip to main content

measure_hash

Function measure_hash 

Source
pub fn measure_hash(measure: &Stream) -> Result<String>
Expand description

The rhythm of a measure as text, a character for each note, chord or rest, as music21’s MeasureHash.getHashString writes it. A measure holding voices is chordified first.

The character is ten times the base-2 logarithm of the length in 256ths of a quarter, from 1 to 127 – made even for a note or chord and odd for a rest – and that of a 64th for anything of no length. A stroke with no pitch is left out.

use music21_rs::omr::correctors::measure_hash;
use music21_rs::tinynotation::from_tiny_notation;

let line = from_tiny_notation("4/4 c4 d8 r8 e2")?;
let measure = line.measures()[0];
assert_eq!(measure_hash(measure)?, "PFGZ");

§Errors

A measure of voices that cannot be chordified.