Skip to main content

interpolate_elements

Function interpolate_elements 

Source
pub fn interpolate_elements(
    source: &Stream,
    destination: &mut Stream,
    start: (FloatType, FloatType),
    end: (FloatType, FloatType),
) -> Result<()>
Expand description

Carries what lies between two points of one stream into another, keeping each thing’s place between them: music21’s interpolateElements.

start and end each say where one point stands in the source and where it stands in the destination – a downbeat at offset 10 of a score and 20.5 of a recording, the next at 14 and at 25. Everything strictly between them in the source is inserted into the destination at the same proportion of the way across, so a note at 11 lands at 21.625.

music21 finds the two points by asking one object for its offset in each stream. A stream here owns what it holds, so there is no such object to ask and the offsets are given instead; and for the same reason this is always music21’s autoAdd, since nothing can already be in both.