Skip to main content

IntervalNetwork

Struct IntervalNetwork 

Source
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: Octaves

Whether the pitches repeat at the octave.

§pathways: Pathways

Whether any node branches.

§simplification: Simplification

How pitches are respelled as the network is walked.

Implementations§

Source§

impl IntervalNetwork

Source

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.

Source

pub fn nodes(&self) -> &[Node]

The nodes, in the order they were added.

Source

pub fn edges(&self) -> &[Edge]

The edges, each at the index that is its key.

Source

pub fn edge_id_count(&self) -> usize

The next key a filling method gives an edge: music21’s edgeIdCount.

Source

pub fn node_id_count(&self) -> usize

The next number a filling method gives a node: music21’s nodeIdCount.

Source

pub fn node(&self, id: NodeId) -> Option<&Node>

The node with this id.

Source

pub fn clear(&mut self)

Removes every node and edge: music21’s clear.

Source

pub fn fill_bidirected(&mut self, steps: &[Interval])

Replaces the network with a chain of steps walked both ways: music21’s fillBiDirectedEdges.

Source

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.

Source

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.

Source

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

Source

pub fn degree_min(&self) -> Option<IntegerType>

The lowest degree: music21’s degreeMin.

Source

pub fn degree_max(&self) -> Option<IntegerType>

The highest degree: music21’s degreeMax.

Source

pub fn degree_max_unique(&self) -> Option<IntegerType>

The highest degree but the high terminus’s, which repeats the low one: music21’s degreeMaxUnique.

Source

pub fn node_degrees(&self, termini: Termini) -> Vec<(NodeId, IntegerType)>

Each node’s id and degree, in order: music21’s getNodeDegreeDictionary.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source

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.

Source

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.

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source

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.

Source

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.

Source

pub fn relative_degree( &self, reference: &Pitch, start: Option<NodeName>, target: &Pitch, comparison: DegreeComparison, direction: Direction, draw: &mut Draw<'_>, ) -> Result<Option<IntegerType>>

The degree of the node sounding target: music21’s getRelativeNodeDegree.

§Errors

As Self::realize.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IntervalNetwork

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for IntervalNetwork

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for IntervalNetwork

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for IntervalNetwork

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.