Skip to main content

chord_symbol_durations

Function chord_symbol_durations 

Source
pub fn chord_symbol_durations(stream: &Stream) -> Vec<(usize, FloatType)>
Expand description

How long each chord symbol of a stream is held: its position in Stream::leaves and the quarter length from it to the next symbol, the last to the end of the stream. This is the reading realize_chord_symbol_durations writes, for a caller that keeps something of its own beside each element.

use music21_rs::{chordsymbol::chord_symbol_durations, ChordSymbol, Note, Stream};

let mut stream = Stream::new();
stream.insert(0.0, ChordSymbol::parse("C")?);
stream.insert(0.0, Note::from_name("C4")?);
stream.insert(3.0, ChordSymbol::parse("G7")?);
stream.insert(3.0, Note::from_name("B3")?);
assert_eq!(chord_symbol_durations(&stream), [(0, 3.0), (2, 1.0)]);