Skip to main content

thomassen_melodic_accent

Function thomassen_melodic_accent 

Source
pub fn thomassen_melodic_accent(line: &Stream) -> Result<Vec<FloatType>>
Expand description

The melodic accent of each note of a line, after Thomassen (1982) as Huron and Royal (1996) apply it: music21’s thomassenMelodicAccent.

The first note takes an accent of one. Each note after it is accented by the contour around it – a peak or a valley, a turn, a run on or a note repeated – times what the contour before it left over for it, and the last note takes what is left over. Only pitch heights are compared, so enharmonic notes are one. The line is the notes the stream holds itself, in order.

use music21_rs::Stream;
use music21_rs::analysis::metrical::thomassen_melodic_accent;
use music21_rs::stream::StreamElement;
use music21_rs::tinynotation::from_tiny_notation;

let line = from_tiny_notation("7/4 c4 c c d e d d")?.flatten();
let notes = Stream::from_events(
    line.events()
        .iter()
        .filter(|event| matches!(event.element(), StreamElement::Note(_)))
        .cloned(),
);
let accents = thomassen_melodic_accent(&notes)?;
assert_eq!(accents, [1.0, 0.0, 0.0, 0.33, 0.67 * 0.83, 0.17, 0.0]);

§Errors

Anything in the stream but a note, once there are three elements to compare.