Skip to main content

refine_variant

Function refine_variant 

Source
pub fn refine_variant(stream: &mut Stream, variant: usize) -> Result<()>
Expand description

Refines the variant at event variant of a stream measure by measure, as music21’s refineVariant does in place: the measures it replaces matched with the measures it holds, and where a run of them match, each stretch of notes that differs a variant inside the stream’s measure. The variant itself is taken out.

music21 adds the runs that do not match to a copy it then lets go, so they are not kept here either. The measures of a matching run are found by their numbers counted from one, as music21 finds them, and the variant’s groups name the first run’s variants only: music21 puts a None before them for each run.

§Errors

No variant at variant; something other than a measure in what it replaces or holds; or as merge_variants_equal_duration.