Skip to main content

Module variant

Module variant 

Source
Expand description

Other readings of a passage, kept beside it: music21’s variant module.

A Variant stands in a stream at the offset of the passage it is another reading of, holding that reading as a stream of its own. It takes no time in the stream holding it. Its replacement length says how much of the stream it stands in for, which may be more than it holds (a deletion), less (an elongation) or the same (a replacement).

The functions here merge another version of a stream into it as variants (merge_variants and those it chooses between), add one (add_variant), find what one stands in for (replaced_elements), and make the variants of a group the stream’s reading (Stream::activate_variants). They do as music21’s do, the slips included: measures are found by their numbers where music21 finds them by number, and a function music21 fails in fails here too, as each one’s documentation says.

Structs§

Variant
Another reading of a passage: music21’s Variant.

Enums§

LengthType
How a Variant’s reading compares in length with the passage it stands in for: music21’s lengthType.

Functions§

add_variant
Adds a variant to a stream at start_offset, holding contents: a measure, the measures of a stream, or, for a stream with none, its elements – each put as far after the variant’s start as start_offset, as music21 puts them. The variant is in variant_groups and variant_name, and stands in for replacement_quarter_length, or for as long as it lasts: music21’s addVariant.
highest_time
When the last thing a stream holds ends, as music21’s highestTime has it: each end snapped to the fraction it stands for, as music21 keeps its offsets and lengths as fractions.
make_all_variants_replacements
Makes each variant of a copy of a stream that only inserts or only deletes into one that replaces: an insertion at the start, or a deletion anywhere but the end, takes in the element after it, and the others the element before it, moving back to start there: music21’s makeAllVariantsReplacements. With recurse, the variants of the streams the stream holds are made so, and not the stream’s own, as music21 does; music21’s variantNames leaves every variant as it is, so it is not taken.
make_variant_blocks
Moves each variant starting inside another’s span to start where that one does, a hidden rest put before what it holds, as music21’s makeVariantBlocks does.
measure_hashes
Each measure of a stream as the text of its notes and rests: music21’s getMeasureHashes.
merge_part_as_ossia
Merges the measures of an ossia part that hold notes into a copy of a part, each as a variant named ossia_name where the ossia’s measure stands – the measure of the same number, with compare_by_measure_number, or else at the same offset – or, with recurse_in_measures, each stretch of its notes that differs as a variant inside the part’s measure: music21’s mergePartAsOssia.
merge_variant_measure_streams
Merges another version of a stream of measures into a copy of it: the measures of the two compared by their notes and rests as difflib compares lists, and a variant added where they differ – replacing measures, taking them out or putting new ones in: music21’s mergeVariantMeasureStreams.
merge_variant_scores
Merges another version of a score into a copy of it, each part into the part at its place, as merge_variant_measure_streams merges them: music21’s mergeVariantScores.
merge_variants
Merges another version of a stream into a copy of it as variants named variant_name: a score part by part (merge_variant_scores), a stream of measures measure by measure (merge_variant_measure_streams), or notes and rests of the same length note by note (merge_variants_equal_duration): music21’s mergeVariants.
merge_variants_equal_duration
Merges other versions of a stream, each as long as it, into a copy of it: part by part and measure by measure where it has them, each stretch of notes and rests that differs a variant, named by variant_names in turn: music21’s mergeVariantsEqualDuration.
refine_variant
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.
remove_replaced_elements_from_stream
Takes out of a stream what the variant at event variant stands in for: music21’s removeReplacedElementsFromStream.
replaced_elements
What the variant at event variant of a stream stands in for: the elements of the stream of the classes of what the variant holds (and of class_list) starting where it does and within its replacement length, at their offsets from the variant’s unless keep_original_offsets: music21’s replacedElements. With include_spacers, the span goes on by as long as the first hidden rest the variant holds.