Skip to main content

Module reduction

Module reduction 

Source
Expand description

Reductions written into a score by its lyrics: music21’s analysis.reduction.

A lyric starting :: marks its note for a reduction, saying how it is written there: ::/p:e/o:5/nf:no/ta:3/g:Ursatz takes the E of a chord, puts it in the fifth octave with a hollow notehead and the text 3 above, in the part for the group Ursatz. A ScoreReduction gathers every note so marked into parts of their own, above the score with the marks taken out of its lyrics. A PartReduction answers when, and how loudly, each part or group of parts plays.

use music21_rs::analysis::reduction::ScoreReduction;
use music21_rs::stream::{Stream, StreamElement, StreamKind};
use music21_rs::tinynotation::from_tiny_notation;

let mut part = from_tiny_notation("4/4 c4 d e f g1")?;
part.set_kind(StreamKind::Part);
part.for_each_mut(&mut |_, element| {
    if let StreamElement::Note(note) = element
        && note.pitch().name() == "E"
    {
        note.add_lyric("::/o:5/tb:3", None, false)
            .expect("a note takes a lyric");
    }
});
let mut score = Stream::with_kind(StreamKind::Score);
score.insert(0.0, part);
let mut reduction = ScoreReduction::new();
reduction.set_score(score);
let reduced = reduction.reduce()?;
let notes = reduced.parts()[0].notes();
assert_eq!(notes.len(), 1);

Structs§

PartActivity
A part, or a group of parts, and the stretches it plays.
PartGroup
A group of a score’s parts drawn as one: music21’s partGroups entry.
PartReduction
When and how loudly each part, or group of parts, of a score plays: music21’s PartReduction, whose getGraphHorizontalBarWeightedData PartReduction::weighted_spans answers.
ReductiveNote
A note marked by a lyric for a reduction, with where it stands: music21’s ReductiveNote.
ReductiveParameters
How a lyric marks its note for a reduction: music21’s ReductiveNote parameters, each as the lyric writes it. The keys are p for the pitch taken from a chord, o the octave, nf the notehead fill, sd the stem direction, g the group, v the voice, ta text above and tb text below.
ScoreReduction
A score with its marked notes drawn out into parts of their own: music21’s ScoreReduction.
WeightedSpan
A stretch of a part’s playing, and how loud: one bar of music21’s weighted horizontal bar graph.