Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mismatch midi and musicxml scores #8

Open
DavidGarfinkle opened this issue Jun 27, 2019 · 5 comments
Open

Mismatch midi and musicxml scores #8

DavidGarfinkle opened this issue Jun 27, 2019 · 5 comments

Comments

@DavidGarfinkle
Copy link
Collaborator

indexers.notes does not return the same data running on a midi file versus the musicxml output of that midi file as output by music21.converter.parse(midi).write('xml')

@vigliensoni
Copy link
Member

vigliensoni commented Jun 27, 2019 via email

@DavidGarfinkle
Copy link
Collaborator Author

DavidGarfinkle commented Jul 4, 2019

def first_mismatch(midi_path):
     s = music21.converter.parse(midi_path)
     npsmid = indexers.NotePointSet(s)
     o = s.write('xml')
     npsxml = indexers.NotePointSet(music21.converter.parse(o))
     print(next(i for i, (x, y) in enumerate(zip(npsmid, npsxml) if x != y))

with test mass testdata/palestrina_masses/mid/000000000011521_Missa-Ut-re-mi-fa-sol-la_Credo_Palestrina-Giovanni-Pierluigi-da_file2.mid

and found the first mismatch occurs at a tied note

i think this means the bug is on our end, but there remains some thinking..

@DavidGarfinkle
Copy link
Collaborator Author

DavidGarfinkle commented Jul 4, 2019

This bug occurs because music21.converter.parse(midi_file) extended quarter length durations on tied notes, whereas music21.converter.parse(midi_stream.write('xml')) ignored ties in calculating note lengths.

we can arrive at a solution by calling stream.stripTies() on the music21 xml output, but this will prevent occurrences from being found beyond the first note of a tied group

@DavidGarfinkle
Copy link
Collaborator Author

DavidGarfinkle commented Jul 4, 2019

todo: include the expected behaviour of finding occurrences through ties in the documentation

& ask peter

@DavidGarfinkle
Copy link
Collaborator Author

the current solution has been to ensure that the data we search over is the same from which we extract measures

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants