Skip to main content

translate_monophonic_part_to_segments

Function translate_monophonic_part_to_segments 

Source
pub fn translate_monophonic_part_to_segments(
    part: &Stream,
    segment_length: usize,
    overlap: usize,
    translate: fn(&[Searched<'_>]) -> Translation,
) -> Result<Segments>
Expand description

A part’s notes, written by translate, cut into stretches segment_length characters long, each starting segment_length - overlap after the one before, the last as long as what is left: music21’s translateMonophonicPartToSegments. Each stretch’s measures are read off the translation’s measures at its first and last character, as music21 reads them, which is a note’s measure only where the translation writes one character a note, as translate_stream_to_string_no_rhythm, music21’s default, does.

music21’s jitter, which moves each start by a random amount, is not offered.

§Errors

An overlap as long as the stretches, or a translation with fewer measures than characters, which music21 cannot index either.