pub struct IntervalNetwork {
pub octaves: Octaves,
pub pathways: Pathways,
pub simplification: Simplification,
/* private fields */
}Expand description
A scale or chord as a graph of intervals: music21’s IntervalNetwork.
Fields§
§octaves: OctavesWhether the pitches repeat at the octave.
pathways: PathwaysWhether any node branches.
simplification: SimplificationHow pitches are respelled as the network is walked.
Implementations§
Source§impl IntervalNetwork
impl IntervalNetwork
Sourcepub fn bidirected(steps: &[&str]) -> Result<Self>
pub fn bidirected(steps: &[&str]) -> Result<Self>
A network of these steps walked both ways, from interval names.
§Errors
A name that is not an interval.
Sourcepub fn edge_id_count(&self) -> usize
pub fn edge_id_count(&self) -> usize
The next key a filling method gives an edge: music21’s edgeIdCount.
Sourcepub fn node_id_count(&self) -> usize
pub fn node_id_count(&self) -> usize
The next number a filling method gives a node: music21’s
nodeIdCount.
Sourcepub fn fill_bidirected(&mut self, steps: &[Interval])
pub fn fill_bidirected(&mut self, steps: &[Interval])
Replaces the network with a chain of steps walked both ways:
music21’s fillBiDirectedEdges.
Sourcepub fn fill_directed(
&mut self,
ascending: &[Interval],
descending: &[Interval],
) -> Result<()>
pub fn fill_directed( &mut self, ascending: &[Interval], descending: &[Interval], ) -> Result<()>
Replaces the network with one chain of steps walked up and another,
given as rising steps, walked down between the same termini:
music21’s fillDirectedEdges.
§Errors
Chains of different lengths, whose degrees cannot be matched up.
Sourcepub fn fill_arbitrary(
&mut self,
nodes: Vec<Node>,
edges: Vec<EdgeSpec>,
) -> Result<()>
pub fn fill_arbitrary( &mut self, nodes: Vec<Node>, edges: Vec<EdgeSpec>, ) -> Result<()>
Replaces the network with these nodes and edges: music21’s
fillArbitrary. Edges are keyed by their place in the list; the
id counters are left at nought, as music21 leaves them.
§Errors
A connection to a node not in nodes.
Sourcepub fn fill_melodic_minor(&mut self) -> Result<()>
pub fn fill_melodic_minor(&mut self) -> Result<()>
Replaces the network with a melodic minor, which raises its sixth
and seventh going up and not coming down: music21’s
fillMelodicMinor.
§Errors
None in practice; the intervals are fixed.
Source§impl IntervalNetwork
impl IntervalNetwork
Sourcepub fn degree_min(&self) -> Option<IntegerType>
pub fn degree_min(&self) -> Option<IntegerType>
The lowest degree: music21’s degreeMin.
Sourcepub fn degree_max(&self) -> Option<IntegerType>
pub fn degree_max(&self) -> Option<IntegerType>
The highest degree: music21’s degreeMax.
Sourcepub fn degree_max_unique(&self) -> Option<IntegerType>
pub fn degree_max_unique(&self) -> Option<IntegerType>
The highest degree but the high terminus’s, which repeats the low
one: music21’s degreeMaxUnique.
Sourcepub fn node_degrees(&self, termini: Termini) -> Vec<(NodeId, IntegerType)>
pub fn node_degrees(&self, termini: Termini) -> Vec<(NodeId, IntegerType)>
Each node’s id and degree, in order: music21’s
getNodeDegreeDictionary.
Sourcepub fn degree_of(&self, id: NodeId) -> Result<IntegerType>
pub fn degree_of(&self, id: NodeId) -> Result<IntegerType>
The degree of a node, the high terminus taking the low one’s:
music21’s nodeIdToDegree.
§Errors
A node not in the network.
Sourcepub fn edge_directions(&self, id: NodeId) -> Result<Vec<Direction>>
pub fn edge_directions(&self, id: NodeId) -> Result<Vec<Direction>>
The direction of every edge meeting a node: music21’s
nodeIdToEdgeDirections.
§Errors
A node no edge meets.
Sourcepub fn degree_modulus(&self, degree: IntegerType) -> Result<IntegerType>
pub fn degree_modulus(&self, degree: IntegerType) -> Result<IntegerType>
The degree folded into the network’s span, so that degree 8 of a
seven-note scale is 1: music21’s degreeModulus.
§Errors
An empty network, or one whose nodes all share a degree.
Sourcepub fn nodes_named(
&self,
name: NodeName,
termini: Termini,
moduli: Moduli,
) -> Result<Vec<NodeId>>
pub fn nodes_named( &self, name: NodeName, termini: Termini, moduli: Moduli, ) -> Result<Vec<NodeId>>
The nodes a name stands for: music21’s nodeNameToNodes.
§Errors
A node id the network does not hold.
Sourcepub fn next_steps(
&self,
from: NodeId,
direction: Direction,
) -> Result<Vec<(usize, NodeId)>>
pub fn next_steps( &self, from: NodeId, direction: Direction, ) -> Result<Vec<(usize, NodeId)>>
Every edge leaving a node walked direction, each as its index and
the node it reaches: music21’s getNext. Leaving the high terminus
upward is leaving the low one, and the other way round.
§Errors
No edge leaving the node that way.
Source§impl IntervalNetwork
impl IntervalNetwork
Sourcepub fn transpose_step(
&self,
interval: &Interval,
pitch: &Pitch,
) -> Result<Pitch>
pub fn transpose_step( &self, interval: &Interval, pitch: &Pitch, ) -> Result<Pitch>
The pitch moved by one step and respelled as the network’s
simplification says: music21’s
transposePitchAndApplySimplification. A network told to spell
exactly takes the most common spelling of a step given only in
semitones, which has no spelling of its own.
§Errors
A pitch moved past the octaves an integer counts.
Sourcepub fn search_span(&self) -> IntegerType
pub fn search_span(&self) -> IntegerType
How many semitones either side of a pitch a search realizes: an
octave, or the widest edge where that is wider. music21’s
_searchSpan.
Sourcepub fn spell_terminus(
&self,
pitch: Pitch,
node: NodeId,
name: Option<&str>,
) -> Result<Pitch>
pub fn spell_terminus( &self, pitch: Pitch, node: NodeId, name: Option<&str>, ) -> Result<Pitch>
The pitch spelled as name where it lands on a terminus and the two
are the same note an octave or more apart: music21’s
_spellTerminus. Respelling accidentals along a walk can change its
letters, so a walk can reach the octave as C## where it set out from
D.
§Errors
A name that is not a pitch.
Source§impl IntervalNetwork
impl IntervalNetwork
Sourcepub fn realize_ascending(
&self,
reference: &Pitch,
start: Option<NodeName>,
range: &PitchRange,
fill: Fill,
draw: &mut Draw<'_>,
) -> Result<Realized>
pub fn realize_ascending( &self, reference: &Pitch, start: Option<NodeName>, range: &PitchRange, fill: Fill, draw: &mut Draw<'_>, ) -> Result<Realized>
The pitches from reference on start upward: music21’s
realizeAscending. With no range the walk stops at the high
terminus; with Fill::IfUnbounded it first works one out.
§Errors
A start the network does not hold, or a walk that never reaches the top of its range.
Sourcepub fn realize_descending(
&self,
reference: &Pitch,
start: Option<NodeName>,
range: &PitchRange,
walk: DescendingWalk,
draw: &mut Draw<'_>,
) -> Result<Realized>
pub fn realize_descending( &self, reference: &Pitch, start: Option<NodeName>, range: &PitchRange, walk: DescendingWalk, draw: &mut Draw<'_>, ) -> Result<Realized>
The pitches from reference on start downward: music21’s
realizeDescending. With no lower bound the walk stops at the low
terminus.
§Errors
A start the network does not hold, or a walk that never descends.
Sourcepub fn realize(
&self,
reference: &Pitch,
start: Option<NodeName>,
range: &PitchRange,
direction: Direction,
order: Order,
draw: &mut Draw<'_>,
) -> Result<Realized>
pub fn realize( &self, reference: &Pitch, start: Option<NodeName>, range: &PitchRange, direction: Direction, order: Order, draw: &mut Draw<'_>, ) -> Result<Realized>
The network realized from reference standing on start: music21’s
realize.
A network that repeats at the octave is walked direction over the
range, the whole span between the termini where there is none; one
that does not is walked up and down from the reference whatever the
direction.
§Errors
A start the network does not hold, or a walk that fails.
Sourcepub fn realize_pitches(
&self,
reference: &Pitch,
start: Option<NodeName>,
range: &PitchRange,
) -> Result<Vec<Pitch>>
pub fn realize_pitches( &self, reference: &Pitch, start: Option<NodeName>, range: &PitchRange, ) -> Result<Vec<Pitch>>
The pitches of Self::realize walked upward, lowest first:
music21’s realizePitch with its defaults. A weighted network
branches on a fixed draw.
§Errors
As Self::realize.
Sourcepub fn realize_intervals(
&self,
start: Option<NodeName>,
range: &PitchRange,
direction: Direction,
order: Order,
draw: &mut Draw<'_>,
) -> Result<Vec<Interval>>
pub fn realize_intervals( &self, start: Option<NodeName>, range: &PitchRange, direction: Direction, order: Order, draw: &mut Draw<'_>, ) -> Result<Vec<Interval>>
The steps between successive pitches of a realization from C4:
music21’s realizeIntervals.
§Errors
As Self::realize.
Sourcepub fn realize_termini(
&self,
reference: &Pitch,
start: Option<NodeName>,
draw: &mut Draw<'_>,
) -> Result<(Pitch, Pitch)>
pub fn realize_termini( &self, reference: &Pitch, start: Option<NodeName>, draw: &mut Draw<'_>, ) -> Result<(Pitch, Pitch)>
The pitches on the termini of a realization from reference:
music21’s realizeTermini.
§Errors
As Self::realize, or a realization with no pitches.
Sourcepub fn realize_min_max(
&self,
reference: &Pitch,
start: Option<NodeName>,
draw: &mut Draw<'_>,
) -> Result<(Pitch, Pitch)>
pub fn realize_min_max( &self, reference: &Pitch, start: Option<NodeName>, draw: &mut Draw<'_>, ) -> Result<(Pitch, Pitch)>
The lowest and highest pitches of one span from terminus to terminus
either side of reference: music21’s realizeMinMax.
§Errors
As Self::realize.
Sourcepub fn pitches_by_degree(
&self,
reference: &Pitch,
start: Option<NodeName>,
degrees: &[IntegerType],
range: &PitchRange,
direction: Direction,
draw: &mut Draw<'_>,
) -> Result<Vec<Pitch>>
pub fn pitches_by_degree( &self, reference: &Pitch, start: Option<NodeName>, degrees: &[IntegerType], range: &PitchRange, direction: Direction, draw: &mut Draw<'_>, ) -> Result<Vec<Pitch>>
The realized pitches on any of degrees, each folded into the
network: music21’s realizePitchByDegree.
§Errors
As Self::realize.
Source§impl IntervalNetwork
impl IntervalNetwork
Sourcepub fn relative_node_ids(
&self,
reference: &Pitch,
start: Option<NodeName>,
target: &Pitch,
comparison: DegreeComparison,
direction: Direction,
draw: &mut Draw<'_>,
) -> Result<Vec<NodeId>>
pub fn relative_node_ids( &self, reference: &Pitch, start: Option<NodeName>, target: &Pitch, comparison: DegreeComparison, direction: Direction, draw: &mut Draw<'_>, ) -> Result<Vec<NodeId>>
Every node that sounds target on a realization from reference
standing on start, in any octave, by degree: music21’s
getRelativeNodeIds.
§Errors
As Self::realize.
Sourcepub fn relative_node_id(
&self,
reference: &Pitch,
start: Option<NodeName>,
target: &Pitch,
comparison: DegreeComparison,
direction: Direction,
draw: &mut Draw<'_>,
) -> Result<Option<NodeId>>
pub fn relative_node_id( &self, reference: &Pitch, start: Option<NodeName>, target: &Pitch, comparison: DegreeComparison, direction: Direction, draw: &mut Draw<'_>, ) -> Result<Option<NodeId>>
One node of Self::relative_node_ids, chosen by weight where
several sound the target: music21’s getRelativeNodeId.
§Errors
As Self::realize.
Sourcepub fn relative_degree(
&self,
reference: &Pitch,
start: Option<NodeName>,
target: &Pitch,
comparison: DegreeComparison,
direction: Direction,
draw: &mut Draw<'_>,
) -> Result<Option<IntegerType>>
pub fn relative_degree( &self, reference: &Pitch, start: Option<NodeName>, target: &Pitch, comparison: DegreeComparison, direction: Direction, draw: &mut Draw<'_>, ) -> Result<Option<IntegerType>>
Sourcepub fn neighbor_node_ids(
&self,
reference: &Pitch,
start: Option<NodeName>,
target: &Pitch,
direction: Direction,
draw: &mut Draw<'_>,
) -> Result<Option<(Option<NodeId>, NodeId)>>
pub fn neighbor_node_ids( &self, reference: &Pitch, start: Option<NodeName>, target: &Pitch, direction: Direction, draw: &mut Draw<'_>, ) -> Result<Option<(Option<NodeId>, NodeId)>>
The nodes either side of target on a realization, where it lies
below some realized pitch: music21’s getNeighborNodeIds. The lower
one is none where nothing realized lies below.
§Errors
As Self::realize.
Sourcepub fn pitch_of_degree(
&self,
reference: &Pitch,
name: NodeName,
target: NodeName,
direction: Direction,
range: &PitchRange,
termini: Termini,
draw: &mut Draw<'_>,
) -> Result<Option<Pitch>>
pub fn pitch_of_degree( &self, reference: &Pitch, name: NodeName, target: NodeName, direction: Direction, range: &PitchRange, termini: Termini, draw: &mut Draw<'_>, ) -> Result<Option<Pitch>>
The pitch of the node of degree target on a realization from
reference standing on name: music21’s getPitchFromNodeDegree.
Where two nodes have the degree, the one walked direction is
taken; a weighted network that may skip it is realized up to forty
times.
§Errors
No node named name or target, or a realization that fails.
Sourcepub fn match_pitches(
&self,
reference: &Pitch,
start: Option<NodeName>,
targets: &[Pitch],
comparison: DegreeComparison,
) -> Result<Matched>
pub fn match_pitches( &self, reference: &Pitch, start: Option<NodeName>, targets: &[Pitch], comparison: DegreeComparison, ) -> Result<Matched>
Which of targets a realization from reference standing on start
over their range holds: music21’s match.
§Errors
No targets, or a realization that fails.
Sourcepub fn find_missing(
&self,
reference: &Pitch,
start: Option<NodeName>,
targets: &[Pitch],
comparison: DegreeComparison,
range: &PitchRange,
) -> Result<Vec<Pitch>>
pub fn find_missing( &self, reference: &Pitch, start: Option<NodeName>, targets: &[Pitch], comparison: DegreeComparison, range: &PitchRange, ) -> Result<Vec<Pitch>>
The realized pitches none of targets matches: music21’s
findMissing.
§Errors
No targets, or a realization that fails.
Sourcepub fn find(
&self,
targets: &[Pitch],
comparison: DegreeComparison,
) -> Result<Vec<Found>>
pub fn find( &self, targets: &[Pitch], comparison: DegreeComparison, ) -> Result<Vec<Found>>
How many of targets the network holds standing on each of fifteen
tonics, most first: music21’s find. Ties keep the higher tonic
first, and the later-tried of two enharmonic ones.
§Errors
No targets, or a realization that fails.
Sourcepub fn next_pitch(
&self,
reference: &Pitch,
name: NodeName,
origin: &Pitch,
direction: Direction,
step_size: usize,
neighbor: Neighbor,
draw: &mut Draw<'_>,
) -> Result<Option<Pitch>>
pub fn next_pitch( &self, reference: &Pitch, name: NodeName, origin: &Pitch, direction: Direction, step_size: usize, neighbor: Neighbor, draw: &mut Draw<'_>, ) -> Result<Option<Pitch>>
The pitch step_size steps on from origin walking direction on a
realization from reference standing on name: music21’s
nextPitch. An origin on no node steps from its neighbor.
§Errors
No node named name, or an origin with no node to step from.
Trait Implementations§
Source§impl Clone for IntervalNetwork
impl Clone for IntervalNetwork
Source§impl Debug for IntervalNetwork
impl Debug for IntervalNetwork
Source§impl Default for IntervalNetwork
impl Default for IntervalNetwork
Source§impl PartialEq for IntervalNetwork
impl PartialEq for IntervalNetwork
impl StructuralPartialEq for IntervalNetwork
Auto Trait Implementations§
impl Forget for IntervalNetwork
impl Freeze for IntervalNetwork
impl Move for IntervalNetwork
impl RefUnwindSafe for IntervalNetwork
impl Send for IntervalNetwork
impl Sync for IntervalNetwork
impl Unpin for IntervalNetwork
impl UnsafeUnpin for IntervalNetwork
impl UnwindSafe for IntervalNetwork
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more