Skip to main content

Module correctors

Module correctors 

Source
Expand description

Correcting the rhythm of a score read by optical music recognition: music21’s omr.correctors.

A measure whose notes do not fill its bar was most likely misread. The correctors look for the measure that most likely stands where it should – another measure of the same part a likely distance away whose rhythm differs from it in likely ways (the horizontal model), or the measure at the same place in another part that tends to move with it (the vertical model) – and put that measure’s rhythm in its place, keeping its pitches.

Rhythms are compared as text: each note, chord or rest of a measure is one character for its length, notes on even codes and rests on odd ones (measure_hash).

Structs§

MeasureRelationship
A flagged measure and the measure found to correct it, with how likely the correction is: music21’s MeasureRelationship.
Opcode
One step of turning one sequence into another: Python’s opcode (tag, i1, i2, j1, j2), the first sequence’s items i1..i2 and the second’s j1..j2.
PriorsIntegrationScore
How many flagged measures were corrected, and by which model: music21’s PriorsIntegrationScore.
ScoreCorrector
A score being corrected, part by part: music21’s ScoreCorrector.
SinglePart
One part of a score being corrected, its measures’ rhythms and those flagged: music21’s SinglePart.

Enums§

OpcodeTag
What one stretch of an Opcode does to turn the first sequence into the second: Python’s opcode tags.

Constants§

PROBABILITY_ON_ADDITION
How likely a note is read that is not there: music21’s getProbabilityOnAddition.
PROBABILITY_ON_EQUALITY
How likely a note is read right: music21’s getProbabilityOnEquality.
PROBABILITY_ON_OMISSION
How likely a note is missed: music21’s getProbabilityOnOmission.

Functions§

hash_grace
The character anything of no length is written as: music21’s hashGrace, which writes a grace note as a 128th.
hash_note
The character a note or chord of a length is written as: music21’s hashNote, which is hash_quarter_length made even.
hash_quarter_length
music21’s hashQuarterLength: ten times the base-2 logarithm of a length in 256ths of a quarter, from 1 to 127, and 1 for no length.
hash_rest
The character a rest of a length is written as: music21’s hashRest, which is hash_quarter_length made odd.
incorrect_measures
Which of a part’s measures do not fill their bar, and so would be flagged by an optical reader: music21’s SinglePart.getIncorrectMeasureIndices.
measure_difference
How unlike two rhythms are, as music21’s getMeasureDifference has it: one less their difflib likeness, except that the same rhythm is as unlike as can be, one.
measure_hash
The rhythm of a measure as text, a character for each note, chord or rest, as music21’s MeasureHash.getHashString writes it. A measure holding voices is chordified first.
opcodes
The steps that turn one rhythm into another: Python’s difflib opcodes, music21’s getOpCodes.
part_hashes
The rhythm of every measure of a part: music21’s SinglePart.getSequenceHashesFromMeasureStream.
probability_based_on_changes
How likely other was misread as own, from the steps that turn the one into the other: music21’s getProbabilityBasedOnChanges. Each equal note is PROBABILITY_ON_EQUALITY, each one missed PROBABILITY_ON_OMISSION, each one added PROBABILITY_ON_ADDITION, and a stretch replaced is probability_on_substitute.
probability_based_on_changes_between
How likely the measure source was misread as destination, with the steps read between matching and source: music21’s getProbabilityBasedOnChanges with its two strings told apart.
probability_for_one_opcode
How likely one of the steps that turn a rhythm into another is: music21’s differenceProbabilityForOneOpCode.
probability_from_one_char_sub
How likely one length was misread as another: music21’s getProbabilityFromOneCharSub. A length doubled or halved any number of times is 0.0165 for each; a rest read for a note of the same length an addition, the other way an omission; a note read as a rest 0.003; and anything else an omission and an addition at once.
probability_on_substitute
How likely the rhythm source was misread as destination: music21’s getProbabilityOnSubstitute. The longer is cut to the shorter, each character cut an addition or an omission, and the rest compared character by character (probability_from_one_char_sub).
slice_search
Which measure of one place across the parts most likely corrects the flagged one there: music21’s MeasureSlice.runSliceSearch.