Skip to content

Commit 59cbe3a

Browse files
committed
fix for import of Octave Shift.
1 parent d71fbfa commit 59cbe3a

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

partitura/io/importmusicxml.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -436,23 +436,24 @@ def _parse_parts(document, part_dict):
436436
# when constructed from MusicXML
437437
score.set_end_times(part)
438438

439+
# Octave Shifts are only visual doesn't to change the octave of notes.
439440
# Apply octave shifts directly to notes
440-
for shift in part.iter_all(score.OctaveShiftDirection):
441-
# Shifts normal notes
442-
for note in part.iter_all(score.Note, start=shift.start.t, end=shift.end.t):
443-
if note.staff == shift.staff:
444-
if shift.shift_type == "up":
445-
note.octave -= OCTAVE_SHIFTS[shift.shift_size] if shift.shift_size in OCTAVE_SHIFTS.keys() else 0
446-
elif shift.shift_type == "down":
447-
note.octave += OCTAVE_SHIFTS[shift.shift_size] if shift.shift_size in OCTAVE_SHIFTS.keys() else 0
448-
# Shifts grace notes
449-
for note in part.iter_all(score.GraceNote, start=shift.start.t, end=shift.end.t):
450-
if note.staff == shift.staff:
451-
if shift.shift_type == "up":
452-
note.octave -= OCTAVE_SHIFTS[shift.shift_size] if shift.shift_size in OCTAVE_SHIFTS.keys() else 0
453-
elif shift.shift_type == "down":
454-
note.octave += OCTAVE_SHIFTS[shift.shift_size] if shift.shift_size in OCTAVE_SHIFTS.keys() else 0
455-
shift.applied = True
441+
# for shift in part.iter_all(score.OctaveShiftDirection):
442+
# # Shifts normal notes
443+
# for note in part.iter_all(score.Note, start=shift.start.t, end=shift.end.t):
444+
# if note.staff == shift.staff:
445+
# if shift.shift_type == "up":
446+
# note.octave -= OCTAVE_SHIFTS[shift.shift_size] if shift.shift_size in OCTAVE_SHIFTS.keys() else 0
447+
# elif shift.shift_type == "down":
448+
# note.octave += OCTAVE_SHIFTS[shift.shift_size] if shift.shift_size in OCTAVE_SHIFTS.keys() else 0
449+
# # Shifts grace notes
450+
# for note in part.iter_all(score.GraceNote, start=shift.start.t, end=shift.end.t):
451+
# if note.staff == shift.staff:
452+
# if shift.shift_type == "up":
453+
# note.octave -= OCTAVE_SHIFTS[shift.shift_size] if shift.shift_size in OCTAVE_SHIFTS.keys() else 0
454+
# elif shift.shift_type == "down":
455+
# note.octave += OCTAVE_SHIFTS[shift.shift_size] if shift.shift_size in OCTAVE_SHIFTS.keys() else 0
456+
# shift.applied = True
456457

457458

458459
def _handle_measure(measure_el, position, part, ongoing, doc_order):

tests/test_octave_shift.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class OctaveShift(unittest.TestCase):
1010
def test_octave_shift(self):
1111
part = load_score(EXAMPLE_MUSICXML)[0]
1212
na = part.note_array(include_pitch_spelling=True, include_staff=True)
13-
na["octave"][na["staff"] == 1] += 1
13+
# na["octave"][na["staff"] == 1] += 1
1414
# Octave shift is applied to the 1st staff
1515
shift_part = load_score(OCTAVE_SHIFT_TESTFILES[0])[0]
1616
octave_post_shift = shift_part.note_array(include_pitch_spelling=True)["octave"]

0 commit comments

Comments
 (0)