pub struct ScoreCorrector { /* private fields */ }Expand description
A score being corrected, part by part: music21’s ScoreCorrector.
use music21_rs::omr::correctors::ScoreCorrector;
use music21_rs::tinynotation::from_tiny_notation;
use music21_rs::{Stream, StreamKind};
// The third bar is a quarter short.
let part = from_tiny_notation("4/4 c4 d e f g a b c' d'4 e' f'")?;
let mut score = Stream::with_kind(StreamKind::Score);
score.insert(0.0, part);
let mut corrector = ScoreCorrector::new(score)?;
assert_eq!(corrector.single_parts()[0].incorrect_measures(), [2]);
corrector.run()?;
assert_eq!(corrector.single_parts()[0].hashed_notes()[2], "PPPP");Implementations§
Source§impl ScoreCorrector
impl ScoreCorrector
Sourcepub fn new(score: Stream) -> Result<Self>
pub fn new(score: Stream) -> Result<Self>
A corrector for a score: each part’s measures hashed and those not filling the bar of the score’s first time signature flagged.
§Errors
A measure of voices that cannot be chordified.
Sourcepub fn into_score(self) -> Stream
pub fn into_score(self) -> Stream
The score, as corrected so far, given back.
Sourcepub fn single_parts(&self) -> &[SinglePart]
pub fn single_parts(&self) -> &[SinglePart]
The parts being corrected: music21’s singleParts.
Sourcepub fn single_part_mut(&mut self, part: usize) -> &mut SinglePart
pub fn single_part_mut(&mut self, part: usize) -> &mut SinglePart
One part, to run its horizontal model on its own.
Sourcepub fn all_hashes(&self) -> Vec<&[String]>
pub fn all_hashes(&self) -> Vec<&[String]>
Every part’s measure rhythms: music21’s getAllHashes.
Sourcepub fn all_incorrect_measures(&self) -> Vec<&[usize]>
pub fn all_incorrect_measures(&self) -> Vec<&[usize]>
Every part’s flagged measures: music21’s getAllIncorrectMeasures.
Sourcepub fn find_incorrect_measures(
&mut self,
part: usize,
run_fast: bool,
) -> Result<&[usize]>
pub fn find_incorrect_measures( &mut self, part: usize, run_fast: bool, ) -> Result<&[usize]>
Flags a part’s measures whose notes do not fill their bar, and
gives them back: music21’s getIncorrectMeasureIndices. With
run_fast, every bar is that of the first measure’s time signature,
or of 4/4 where none is in force; without, each measure’s own.
§Errors
Without run_fast, a measure with no time signature in force,
which music21 fails on.
Sourcepub fn run_horizontal_correction_model(
&mut self,
) -> Vec<Vec<MeasureRelationship>>
pub fn run_horizontal_correction_model( &mut self, ) -> Vec<Vec<MeasureRelationship>>
Every part’s horizontal model: music21’s
runHorizontalCorrectionModel.
Sourcepub fn vertical_probability_dist(&mut self) -> Result<&[Vec<FloatType>]>
pub fn vertical_probability_dist(&mut self) -> Result<&[Vec<FloatType>]>
For each part, the share of its measures whose rhythm is like that
of the measure at the same place in each part, as music21 counts
likeness: music21’s verticalProbabilityDist. Worked out once and
kept.
§Errors
Parts of different lengths, or one with no measures, which music21 fails on.
Sourcepub fn run_vertical_search(
&mut self,
measure: usize,
part: usize,
) -> Result<MeasureRelationship>
pub fn run_vertical_search( &mut self, measure: usize, part: usize, ) -> Result<MeasureRelationship>
The measure at the same place in another part most likely to
correct a flagged one: of the parts whose measure there is not
flagged, the one most likely misread as it by its changes, times how
often the two parts’ rhythms are alike, the first of those as
likely: music21’s runVerticalSearch.
§Errors
As Self::vertical_probability_dist, or a measure of voices that
cannot be chordified.
Sourcepub fn run_vertical_correction_model(
&mut self,
) -> Result<Vec<Vec<MeasureRelationship>>>
pub fn run_vertical_correction_model( &mut self, ) -> Result<Vec<Vec<MeasureRelationship>>>
Self::run_vertical_search for every flagged measure of every
part: music21’s runVerticalCorrectionModel.
§Errors
Sourcepub fn substitute_measure(
&mut self,
source_measure: usize,
source_part: usize,
destination_measure: usize,
destination_part: usize,
) -> Result<()>
pub fn substitute_measure( &mut self, source_measure: usize, source_part: usize, destination_measure: usize, destination_part: usize, ) -> Result<()>
Puts the contents of one measure in another’s place, the notes
keeping the pitches the replaced measure’s notes had, in order, as
far as they go: music21’s substituteOneMeasureContentsForAnother.
As music21 does, everything is appended one after another, a measure’s right barline and its voices included: a barline ends up inside the measure, and voices one after another rather than together. Spanners naming the replaced measure’s notes name nothing afterwards. A measure put in its own place is emptied, as music21 empties it before copying from it.
§Errors
A pitch whose accidental cannot be written again from its modifier.
§Panics
A part or measure past the last.
Sourcepub fn generate_corrected_score(
&mut self,
horizontal: &[Vec<MeasureRelationship>],
vertical: &[Vec<MeasureRelationship>],
) -> Result<PriorsIntegrationScore>
pub fn generate_corrected_score( &mut self, horizontal: &[Vec<MeasureRelationship>], vertical: &[Vec<MeasureRelationship>], ) -> Result<PriorsIntegrationScore>
Corrects each flagged measure both models found a correction for,
from the horizontal model’s measure where it is more likely, and
from the vertical model’s otherwise, then hashes each part’s
measures again: music21’s generateCorrectedScore. Corrections are
made in turn, so a measure corrected may correct another after it.
§Errors
A measure of voices that cannot be chordified.
Sourcepub fn run(&mut self) -> Result<PriorsIntegrationScore>
pub fn run(&mut self) -> Result<PriorsIntegrationScore>
Corrects the score by both models: music21’s run and
runPriorModel. The score corrected is Self::score.
§Errors
Trait Implementations§
Source§impl Clone for ScoreCorrector
impl Clone for ScoreCorrector
Auto Trait Implementations§
impl Freeze for ScoreCorrector
impl RefUnwindSafe for ScoreCorrector
impl Send for ScoreCorrector
impl Sync for ScoreCorrector
impl Unpin for ScoreCorrector
impl UnsafeUnpin for ScoreCorrector
impl UnwindSafe for ScoreCorrector
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