pub struct FiguredBassLine { /* private fields */ }Expand description
A bass line and its figures, in a key and a meter.
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")?, 1.0, None);
line.add_element(Pitch::from_name("D3")?, 1.0, Some("4,3"));
line.add_element(Pitch::from_name("C3")?, 2.0, None);
let realization = line.realize(&Rules::default(), 4, &Pitch::from_name("B5")?)?;
assert_eq!(realization.num_solutions(), 30);Implementations§
Source§impl FiguredBassLine
impl FiguredBassLine
Sourcepub fn new(scale: FiguredBassScale) -> Self
pub fn new(scale: FiguredBassScale) -> Self
An empty line in common time whose figures are read in scale.
Sourcepub fn in_key(key: &Key) -> Result<Self>
pub fn in_key(key: &Key) -> Result<Self>
An empty line in key and common time. The key must be in one of
the five modes a figured bass is read in.
§Errors
A key in another mode.
Sourcepub fn in_key_and_time(key: &Key, time: TimeSignature) -> Result<Self>
pub fn in_key_and_time(key: &Key, time: TimeSignature) -> Result<Self>
An empty line in key and time: music21’s
FiguredBassLine(inKey, inTime).
§Errors
A key in a mode no figured bass is read in.
Sourcepub fn scale(&self) -> &FiguredBassScale
pub fn scale(&self) -> &FiguredBassScale
The scale its figures are read in.
Sourcepub fn time_signature(&self) -> &TimeSignature
pub fn time_signature(&self) -> &TimeSignature
The meter it is written in: music21’s inTime.
Sourcepub fn add_element(
&mut self,
bass: Pitch,
quarter_length: FloatType,
notation: Option<&str>,
)
pub fn add_element( &mut self, bass: Pitch, quarter_length: FloatType, notation: Option<&str>, )
Adds a bass note lasting quarter_length, with the figures written
under it, if any: music21’s addElement of a note.
Sourcepub fn add_chord(
&mut self,
bass: Pitch,
quarter_length: FloatType,
pitch_names: Vec<String>,
)
pub fn add_chord( &mut self, bass: Pitch, quarter_length: FloatType, pitch_names: Vec<String>, )
Adds a bass note with the names of the notes above it rather than figures, as music21 reads a chord symbol or a roman numeral into a line. A chord lasting nothing is realized as lasting a quarter, as music21’s is.
Sourcepub fn overlay_part(&mut self, part: &Stream)
pub fn overlay_part(&mut self, part: &Stream)
Lays a written part over the line, to be kept as it is by every
realization: music21’s overlayPart.
Each note of the part holds one part of the voicing to its pitch while it sounds, the first part laid over being the highest. Where it moves and the bass does not, the line gains a segment of no length, into which only the parts laid over may move. As in music21, the first segment of the line is not held to the parts laid over it.
Only the part’s notes and rests are read, at their offsets from its start.
Sourcepub fn generate_bass_line(&self) -> Result<Stream>
pub fn generate_bass_line(&self) -> Result<Stream>
The bass line written out as a part: a bass clef, the key signature,
the meter and the bass notes one after another, each with its
figures under it as lyrics, cut into measures with the notes that
run past a barline tied, tuplets completed and bracketed and the
notes beamed. music21’s generateBassLine.
use music21_rs::figuredbass::realizer::FiguredBassLine;
use music21_rs::{Key, Pitch, TimeSignature};
let key = Key::from_tonic("B")?;
let mut line = FiguredBassLine::in_key_and_time(&key, TimeSignature::new(3, 4)?)?;
line.add_element(Pitch::from_name("B2")?, 1.0, None);
line.add_element(Pitch::from_name("C#3")?, 1.0, Some("6"));
line.add_element(Pitch::from_name("D#3")?, 2.5, Some("6"));
let written = line.generate_bass_line()?;
assert_eq!(written.measures().len(), 2);
assert_eq!(written.notes().len(), 4);§Errors
A line holding chords rather than bass notes and figures, figures that cannot be read, or a length no duration has.
Sourcepub fn segments(
&self,
rules: &Rules,
num_parts: usize,
max_pitch: &Pitch,
) -> Result<Vec<Segment>>
pub fn segments( &self, rules: &Rules, num_parts: usize, max_pitch: &Pitch, ) -> Result<Vec<Segment>>
A segment for each bass note as the line is written, voiced in
num_parts parts under rules, no part above max_pitch: music21’s
retrieveSegments.
A bass note cut by a barline is a segment for each piece, and a part laid over the line holds its part of each segment to its pitch. A line of chords is a segment for each chord.
§Errors
Figures the line’s scale cannot read, or a part laid over the line that sounds something other than a note where a segment needs its pitch.
Sourcepub fn realize(
&self,
rules: &Rules,
num_parts: usize,
max_pitch: &Pitch,
) -> Result<Realization>
pub fn realize( &self, rules: &Rules, num_parts: usize, max_pitch: &Pitch, ) -> Result<Realization>
Every way of voicing the line in num_parts parts that keeps
rules, no part above max_pitch: music21’s realize.
§Errors
A line with nothing in it, figures its scale cannot read, or a resolution that fails.
Trait Implementations§
Source§impl Clone for FiguredBassLine
impl Clone for FiguredBassLine
Source§impl Debug for FiguredBassLine
impl Debug for FiguredBassLine
Source§impl Default for FiguredBassLine
impl Default for FiguredBassLine
Source§impl PartialEq for FiguredBassLine
impl PartialEq for FiguredBassLine
impl StructuralPartialEq for FiguredBassLine
Auto Trait Implementations§
impl Freeze for FiguredBassLine
impl RefUnwindSafe for FiguredBassLine
impl Send for FiguredBassLine
impl Sync for FiguredBassLine
impl Unpin for FiguredBassLine
impl UnsafeUnpin for FiguredBassLine
impl UnwindSafe for FiguredBassLine
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