pub fn add_variant(
stream: &mut Stream,
start_offset: FloatType,
contents: Option<&Stream>,
variant_name: Option<&str>,
variant_groups: Option<&[String]>,
replacement_quarter_length: Option<FloatType>,
)Expand description
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.
use music21_rs::tinynotation::from_tiny_notation;
use music21_rs::variant::add_variant;
let mut line = from_tiny_notation("4/4 c4 d e f g1")?;
let other = from_tiny_notation("4/4 c4 d e g")?;
add_variant(&mut line, 0.0, Some(other.measures()[0]), Some("draft"), None, None);
assert_eq!(line.events().iter().filter(|event| matches!(
event.element(),
music21_rs::StreamElement::Variant(_)
)).count(), 1);