Skip to main content

beat_float_or_frac

Function beat_float_or_frac 

Source
pub fn beat_float_or_frac(src: &str) -> Result<OffsetQL>
Expand description

A beat atom’s beat, independent of any meter: music21’s RTBeat.getBeatFloatOrFrac. b1.66 is beat one and two thirds, and a third part is that much of the second’s denominator: b1.66.5 is half a third further on.

use music21::common::numbertools::OffsetQL;
use music21::romantext::tokens::beat_float_or_frac;

assert_eq!(beat_float_or_frac("b1.5")?, OffsetQL::Float(1.5));
assert_eq!(
    beat_float_or_frac("b1.66.5")?,
    OffsetQL::Fraction { numerator: 11, denominator: 6 }
);

§Errors

More than three parts, or a part that is not a number.