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§
- Length
Type - How a
Variant’s reading compares in length with the passage it stands in for: music21’slengthType.
Functions§
- add_
variant - Adds a variant to a stream at
start_offset, holdingcontents: a measure, the measures of a stream, or, for a stream with none, its elements – each put as far after the variant’s start asstart_offset, as music21 puts them. The variant is invariant_groupsandvariant_name, and stands in forreplacement_quarter_length, or for as long as it lasts: music21’saddVariant. - highest_
time - When the last thing a stream holds ends, as music21’s
highestTimehas 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. Withrecurse, the variants of the streams the stream holds are made so, and not the stream’s own, as music21 does; music21’svariantNamesleaves 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
makeVariantBlocksdoes. - 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_namewhere the ossia’s measure stands – the measure of the same number, withcompare_by_measure_number, or else at the same offset – or, withrecurse_in_measures, each stretch of its notes that differs as a variant inside the part’s measure: music21’smergePartAsOssia. - 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
difflibcompares lists, and a variant added where they differ – replacing measures, taking them out or putting new ones in: music21’smergeVariantMeasureStreams. - 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_streamsmerges them: music21’smergeVariantScores. - 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’smergeVariants. - 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_namesin turn: music21’smergeVariantsEqualDuration. - refine_
variant - Refines the variant at event
variantof a stream measure by measure, as music21’srefineVariantdoes 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
variantstands in for: music21’sremoveReplacedElementsFromStream. - replaced_
elements - What the variant at event
variantof a stream stands in for: the elements of the stream of the classes of what the variant holds (and ofclass_list) starting where it does and within its replacement length, at their offsets from the variant’s unlesskeep_original_offsets: music21’sreplacedElements. Withinclude_spacers, the span goes on by as long as the first hidden rest the variant holds.