Skip to main content

Realization

Struct Realization 

Source
pub struct Realization { /* private fields */ }
Expand description

Every way of voicing a figured bass line: music21’s Realization.

Implementations§

Source§

impl Realization

Source

pub fn of(segments: Vec<Segment>) -> Result<Self>

The realization of segments, a line’s segments in order. Written out, it is in C major and common time, each segment’s bass lasting as long as the segment; a realization made by FiguredBassLine::realize is written as its line is.

§Errors

No segments, or a resolution that fails.

Source

pub fn segments(&self) -> &[Segment]

The segments realized, one for each bass note.

Source

pub fn fallbacks(&self) -> &[String]

What each chord that found no resolution of its own warned, in order.

Source

pub fn num_solutions(&self) -> usize

How many ways there are of voicing the whole line: music21’s getNumSolutions.

Source

pub fn all_possibility_progressions(&self) -> Vec<Vec<Possibility>>

Every way of voicing the whole line, a voicing for each bass note: music21’s getAllPossibilityProgressions, in its order.

Source

pub fn possibility_progression_by( &self, choose: impl FnMut(usize) -> usize, ) -> Result<Vec<Possibility>>

One way of voicing the whole line, each voicing chosen by choose, which is given how many there are to choose from and answers the index of one: music21’s getRandomPossibilityProgression, with the choosing left to the caller.

§Errors

A line with no way of voicing it, or a choice out of range.

Source

pub fn keyboard_style_output(&self) -> bool

Whether realizations are written in keyboard style, the upper parts as chords on one staff over the bass, as they are to begin with, or in chorale style with a staff for each part: music21’s keyboardStyleOutput.

Source

pub fn set_keyboard_style_output(&mut self, keyboard_style: bool)

Says whether realizations are written in keyboard style or in chorale style.

Source

pub fn generate_realization_from_possibility_progression( &self, progression: &[Possibility], ) -> Result<Stream>

One way of voicing the line written out as a score, a voicing for each segment: music21’s generateRealizationFromPossibilityProgression.

In keyboard style the score is two parts, the upper parts of each voicing as a chord under a treble clef and the bass under a bass clef; in chorale style each part has a staff of its own, under the clef that fits it best. Every part opens with the key signature and the meter of the line, is cut into measures, and has the notes that run past a barline tied, its tuplets bracketed and its notes beamed.

use music21_rs::Pitch;
use music21_rs::figuredbass::realizer::FiguredBassLine;
use music21_rs::figuredbass::rules::Rules;

let mut line = FiguredBassLine::default();
line.add_element(Pitch::from_name("C3")?, 2.0, None);
line.add_element(Pitch::from_name("G2")?, 2.0, Some("7"));
line.add_element(Pitch::from_name("C3")?, 4.0, None);
let realization = line.realize(&Rules::default(), 4, &Pitch::from_name("B5")?)?;
let voicings = realization.all_possibility_progressions();
let score = realization.generate_realization_from_possibility_progression(&voicings[0])?;
assert_eq!(score.parts().len(), 2);
assert_eq!(score.parts()[0].measures().len(), 2);
§Errors

A progression with fewer voicings than the line has segments, or a voicing that is no chord.

Source

pub fn generate_all_realizations(&self) -> Result<Stream>

Every way of voicing the line written out one after another in one score: music21’s generateAllRealizations. Each realization keeps its own measure numbers and its closing barline.

§Errors

A line with no way of voicing it, or a realization that cannot be written.

Source

pub fn generate_random_realization( &self, choose: impl FnMut(usize) -> usize, ) -> Result<Stream>

One way of voicing the line written out as a score, each voicing chosen by choose, which is given how many there are to choose from and answers the index of one: music21’s generateRandomRealization, with the choosing left to the caller.

§Errors

A line with no way of voicing it, or a choice out of range.

Source

pub fn generate_random_realizations( &self, amount: usize, choose: impl FnMut(usize) -> usize, ) -> Result<Stream>

So many ways of voicing the line, each chosen by choose, written out one after another in one score: music21’s generateRandomRealizations. Asked for more than there are, it answers every one of them in order, as generate_all_realizations does. One way may be chosen more than once.

§Errors

A line with no way of voicing it, or a choice out of range.

Trait Implementations§

Source§

impl Clone for Realization

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 Realization

Source§

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

Formats the value using the given formatter. Read more

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.