music21.alpha.analysis.fixer

DeleteFixer

class music21.alpha.analysis.fixer.DeleteFixer(changes, midiStream, omrStream)

CAUTION: this does really weird things still. Deletes measure that have wrong things in them a la OpenScore specs

DeleteFixer bases

DeleteFixer methods

DeleteFixer.fix()

Methods inherited from OMRMidiFixer:

EnharmonicFixer

class music21.alpha.analysis.fixer.EnharmonicFixer(changes, midiStream, omrStream)

Fixes incorrectly spelled enharmonics initialized with self.changes – a list of tuples in this form: (MIDIReference, OMRReference, op) MIDIReference and OMRReference are actual note/rest/chord object in some stream op is a ChangeOp that relates the two references

TEST 1, no changes in omr stream

>>> omrStream1 = stream.Stream()
>>> midiStream1 = stream.Stream()
>>> omrNote1 = note.Note('A#4')
>>> omrNote2 = note.Note('A#4')
>>> midiNote1 = note.Note('B-4')
>>> midiNote2 = note.Note('B-4')
>>> omrStream1.append([omrNote1, omrNote2])
>>> midiStream1.append([midiNote1, midiNote2])
>>> subOp = alpha.analysis.aligner.ChangeOps.Substitution
>>> ct1 = (midiNote1, omrNote1, subOp)
>>> ct2 = (midiNote2, omrNote2, subOp)
>>> changes1 = [ct1, ct2]
>>> fixer1 = alpha.analysis.fixer.EnharmonicFixer(changes1, None, None)
>>> fixer1.fix()
>>> omrStream1[0]
<music21.note.Note A#>
>>> omrStream1[1]
<music21.note.Note A#>

TEST 2, no changes in omr stream

>>> omrStream2 = stream.Stream()
>>> midiStream2 = stream.Stream()
>>> omr2Note1 = note.Note('A#4')
>>> omr2Note2 = note.Note('A#4')
>>> midi2Note1 = note.Note('A#4')
>>> midi2Note2 = note.Note('A#4')
>>> omrStream2.append([omr2Note1, omr2Note2])
>>> midiStream2.append([midi2Note1, midi2Note2])
>>> ncOp = alpha.analysis.aligner.ChangeOps.NoChange
>>> ct2_1 = (midi2Note1, omr2Note1, ncOp)
>>> ct2_2 = (midi2Note2, omr2Note2, ncOp)
>>> changes2 = [ct2_1, ct2_2]
>>> fixer2 = alpha.analysis.fixer.EnharmonicFixer(changes2, None, None)
>>> fixer2.fix()
>>> omrStream2[0]
<music21.note.Note A#>
>>> omrStream1[1]
<music21.note.Note A#>

TEST 3 (case 1)

>>> midiNote3 = note.Note('A4')
>>> omrNote3 = note.Note('An4')
>>> subOp = alpha.analysis.aligner.ChangeOps.Substitution
>>> ct3 = (midiNote3, omrNote3, subOp)
>>> changes3 = [ct3]
>>> omrNote3.pitch.accidental
<accidental natural>
>>> fixer3 = alpha.analysis.fixer.EnharmonicFixer(changes3, None, None)
>>> fixer3.fix()
>>> omrNote3.pitch.accidental

TEST 4 (case 2-1) e.g midi = g#, gt = a-, omr = an

>>> midiNote4 = note.Note('G#4')
>>> omrNote4 = note.Note('An4')
>>> subOp = alpha.analysis.aligner.ChangeOps.Substitution
>>> ct4 = (midiNote4, omrNote4, subOp)
>>> changes4 = [ct4]
>>> omrNote4.pitch.accidental
<accidental natural>
>>> fixer4 = alpha.analysis.fixer.EnharmonicFixer(changes4, None, None)
>>> fixer4.fix()
>>> omrNote4.pitch.accidental
<accidental flat>

TEST 5 (case 2-2) e.g midi = g-, gt = f#, omr = fn

>>> midiNote5 = note.Note('G-4')
>>> omrNote5 = note.Note('Fn4')
>>> subOp = alpha.analysis.aligner.ChangeOps.Substitution
>>> ct5 = (midiNote5, omrNote5, subOp)
>>> changes5 = [ct5]
>>> omrNote5.pitch.accidental
<accidental natural>
>>> fixer5 = alpha.analysis.fixer.EnharmonicFixer(changes5, None, None)
>>> fixer5.fix()
>>> omrNote5.pitch.accidental
<accidental sharp>

TEST 6.1 (case 3) e.g. midi = g#, gt = g#, omr = gn or omr = g-

>>> midiNote6_1 = note.Note('G#4')
>>> midiNote6_2 = note.Note('G#4')
>>> omrNote6_1 = note.Note('Gn4')
>>> omrNote6_2 = note.Note('G-4')
>>> subOp6_1 = alpha.analysis.aligner.ChangeOps.Substitution
>>> subOp6_2 = alpha.analysis.aligner.ChangeOps.Substitution
>>> ct6_1 = (midiNote6_1, omrNote6_1, subOp6_1)
>>> ct6_2 = (midiNote6_2, omrNote6_2, subOp6_2)
>>> changes6 = [ct6_1, ct6_2]
>>> omrNote6_1.pitch.accidental
<accidental natural>
>>> omrNote6_2.pitch.accidental
<accidental flat>
>>> fixer6 = alpha.analysis.fixer.EnharmonicFixer(changes6, None, None)
>>> fixer6.fix()
>>> omrNote6_1.pitch.accidental
<accidental sharp>
>>> omrNote6_2.pitch.accidental
<accidental sharp>

TEST 7 (case 4-1, 4-2) notes are on different step, off by an interval of 2, * 4-1: e.g. midi = g#, gt = a-, omr = a# * 4-2: e.g. midi = a-, gt = g#, omr = g-

>>> midiNote7_1 = note.Note('G#4')
>>> omrNote7_1 = note.Note('A#4')
>>> midiNote7_2 = note.Note('A-4')
>>> omrNote7_2 = note.Note('G-4')
>>> subOp7_1 = alpha.analysis.aligner.ChangeOps.Substitution
>>> subOp7_2 = alpha.analysis.aligner.ChangeOps.Substitution
>>> ct7_1 = (midiNote7_1, omrNote7_1, subOp7_1)
>>> ct7_2 = (midiNote7_2, omrNote7_2, subOp7_2)
>>> changes7 = [ct7_1, ct7_2]
>>> omrNote7_1.pitch.accidental
<accidental sharp>
>>> omrNote7_2.pitch.accidental
<accidental flat>
>>> fixer7 = alpha.analysis.fixer.EnharmonicFixer(changes7, None, None)
>>> fixer7.fix()
>>> omrNote7_1.pitch.step
'A'
>>> omrNote7_1.pitch.accidental
<accidental flat>
>>> omrNote7_2.pitch.step
'G'
>>> omrNote7_2.pitch.accidental
<accidental sharp>

EnharmonicFixer bases

EnharmonicFixer methods

EnharmonicFixer.fix()
EnharmonicFixer.hasAcc(omrRef)
EnharmonicFixer.hasNatAcc(omrRef)
EnharmonicFixer.hasSharpFlatAcc(omrRef)
EnharmonicFixer.intervalTooBig(midiRef, omrRef, setint=5)
EnharmonicFixer.isEnharmonic(midiRef, omrRef)
EnharmonicFixer.stepEq(midiRef, omrRef)
EnharmonicFixer.stepNotEq(midiRef, omrRef)

Methods inherited from OMRMidiFixer:

OMRMidiFixer

class music21.alpha.analysis.fixer.OMRMidiFixer(changes, midiStream, omrStream)

Base class for future fixers changes is a list of changes associated with the midiStream and omrStream, not a list of lists

OMRMidiFixer methods

OMRMidiFixer.checkIfNoteInstance(midiRef, omrRef)