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§

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.
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_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).