Skip to main content

Module intervalnetwork

Module intervalnetwork 

Source
Expand description

music21’s IntervalNetwork: a scale or a chord as a graph whose nodes are pitches not yet realized and whose edges are intervals.

A network has two ends, its low and high termini, which are the same pitch class an octave or more apart; walking off one end comes back in at the other, so a scale can be realized over any range. Edges are walked ascending, descending or both ways, which is how a melodic minor goes up by one set of steps and down by another. Where two edges leave a node the same way, the node weights choose between them, from a draw the caller supplies: nothing here reaches for a random number generator of its own.

use music21::Pitch;
use music21::scale::intervalnetwork::{IntervalNetwork, PitchRange};

let major = IntervalNetwork::bidirected(&["M2", "M2", "m2", "M2", "M2", "M2", "m2"])?;
let realized = major.realize_pitches(&Pitch::from_name("G4")?, None, &PitchRange::default())?;
let names: Vec<String> = realized.iter().map(Pitch::name_with_octave).collect();
assert_eq!(names, ["G4", "A4", "B4", "C5", "D5", "E5", "F#5", "G5"]);

Structs§

DescendingWalk
How a descending realization is walked.
Edge
An interval between two nodes, and the way it is walked: music21’s Edge.
EdgeSpec
An edge of IntervalNetwork::fill_arbitrary: its step and the nodes it connects, each pair with the way it is walked.
Found
A tonic IntervalNetwork::find tried, and how many pitches it found.
IntervalNetwork
A scale or chord as a graph of intervals: music21’s IntervalNetwork.
Matched
Which of a list of pitches a realization holds and which it does not, each as an index into the list.
Node
A pitch the network does not hold yet: music21’s Node.
PitchRange
The range a realization keeps; either bound may be open.
Realized
A realization: its pitches, and the node each stands on.

Enums§

Direction
The way an edge is walked: music21’s Direction.
Fill
Whether a realization starting at the low terminus first works out a range when none is given.
First
Whether a descending walk keeps the pitch it starts from.
Moduli
Whether a degree past either end is folded back into the network.
Neighbor
Which node next_pitch starts from when the pitch it is given is on none: music21’s getNeighbor.
NodeId
Which node an edge connects: a terminus, or a node between them, numbered as it was added.
NodeName
How a node is named when asking for it: by scale degree, or as itself.
Octaves
Whether a network’s pitches repeat at the octave, which lets a walk start an octave from where it was asked to.
Order
The order a realization comes back in.
Pathways
Whether every walk through a network takes the same way.
Termini
Whether the two termini count as one degree.
Terminus
Either end of a network: music21’s Terminus.

Functions§

close_on_tonic
The steps with the last one respelled so that they climb from C4 to exactly C5: music21’s _closeOnTonic. Steps that already do are returned as they are, and so are steps spanning anything but an octave.
cyclical
music21’s AbstractCyclicalScale network: the steps walked both ways. Whole semitones adding up to a divisor of the octave repeat to fill it, closed on the tonic, and the network then repeats at the octave.
octave_repeating
music21’s AbstractOctaveRepeatingScale steps and network: the steps completed to an octave by the interval left over, or respelled to close on the tonic where they already span twelve semitones. Steps past the octave make a network that does not repeat at it.
pitch_bounds
The indices of the lowest and highest of pitches, the earlier of two equal lows and the later of two equal highs: music21’s filterPitchList, which sorts on pitch space and then on index.
weighted_hexatonic_blues
music21’s AbstractWeightedHexatonicBlues: the minor pentatonic with the blue note between its fourth and fifth degrees as a second way from F to G, which a weighted walk takes or passes by.

Type Aliases§

Draw
A source of draws from 0.0 (inclusive) to 1.0 (exclusive), used to choose between branches by weight.