Skip to main content

slice_weight

Function slice_weight 

Source
pub fn slice_weight(
    quarter_length: FloatType,
    accent: FloatType,
    is_last: bool,
    is_consonant: bool,
) -> FloatType
Expand description

What a slice weighs by default: music21’s sliceWeight. Its quarter length times its accent, or its quarter length alone if it is the last sounding slice, times a tenth unless it is consonant.

use music21::analysis::reduce_chords::slice_weight;

assert_eq!(slice_weight(2.0, 0.5, false, true), 1.0);
assert!((slice_weight(2.0, 0.5, true, false) - 0.2).abs() < 1e-12);