Skip to main content

melodic_interval_variability

Function melodic_interval_variability 

Source
pub fn melodic_interval_variability(
    stream: &Stream,
    options: &ConsecutiveOptions,
) -> Result<FloatType>
Expand description

The melodic interval variability of a stream (Patel, Music, Language, and the Brain, p. 223): music21’s melodicIntervalVariability.

It is a hundred times the coefficient of variation – the sample standard deviation over the mean – of the sizes in semitones of the intervals Stream::melodic_intervals finds with options, worked out exactly and rounded once, as Python’s statistics module does.

use music21_rs::analysis::patel::melodic_interval_variability;
use music21_rs::stream::ConsecutiveOptions;
use music21_rs::tinynotation::from_tiny_notation;

let line = from_tiny_notation("4/4 C4 D E F G C")?;
let miv = melodic_interval_variability(&line, &ConsecutiveOptions::default())?;
assert!((miv - 85.266_688).abs() < 1e-6);

§Errors

Fewer than two intervals, intervals averaging nothing, or as Stream::melodic_intervals.