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

Another two problems when running my .musicxml-test-files in the converter (For later use) #4

Closed
mogenslundholm opened this issue Sep 8, 2020 · 1 comment

Comments

@mogenslundholm
Copy link

Another two problems come when running my test files and both are unimplemented functionality, but I list it here to have it when time comes.

  1. Unpitched as in example R.musicxml gives an error. I looked at the Python code and make a hack - just handling unpithed as pitched to assure that the only problem is just not handling unpitched. This could also be a solution just to process unpitched the same way as pitched notes.

  2. Another problem occurs with music with no time-specification and no measures. This occurs in old ballads.

The rhythm-problem (R.musicxml):

C:\Users\Mogens Lundholm\Desktop\MNX-test\MusicXml>python convert.py R.musicxml
Traceback (most recent call last):
  File "convert.py", line 7, in <module>
    s = get_score_from_musicxml(filedata)
  File "C:\Users\Mogens Lundholm\Desktop\MNX-test\MusicXml\mnxconverter\musicxml.py", line 83, in get_score
    return read_musicxml(xml)
  File "C:\Users\Mogens Lundholm\Desktop\MNX-test\MusicXml\mnxconverter\musicxml.py", line 194, in read_musicxml
    return reader.read()
  File "C:\Users\Mogens Lundholm\Desktop\MNX-test\MusicXml\mnxconverter\musicxml.py", line 219, in read
    self.parse_measures()
  File "C:\Users\Mogens Lundholm\Desktop\MNX-test\MusicXml\mnxconverter\musicxml.py", line 250, in parse_measures
    self.parse_measure_part(measure_part_el, bar, parts[part_idx])
  File "C:\Users\Mogens Lundholm\Desktop\MNX-test\MusicXml\mnxconverter\musicxml.py", line 269, in parse_measure_part
    self.parse_note(el, part, bar_part)
  File "C:\Users\Mogens Lundholm\Desktop\MNX-test\MusicXml\mnxconverter\musicxml.py", line 555, in parse_note
    raise NotationDataError('Got a <note> without <pitch>.')
mnxconverter.musicxml.NotationDataError: Got a <note> without <pitch>.

To investigate this problem I made a Python hack in musicxml.py:

______________________

        elif tag == 'pitch':
            note.pitch = self.parse_pitch(el)
        elif tag == 'unpitched':
            note.pitch = self.parse_pitch(el)
______________________

        elif tag == 'octave':
            try:
                octave = int(el.text)
            except ValueError:
                raise NotationDataError('Invalid <octave> for <pitch>.')
        elif tag == 'display-octave':
            try:
                octave = int(el.text)
            except ValueError:
                raise NotationDataError('Invalid <octave> for <pitch>.')
_______________________

        elif tag == 'step':
            step = el.text
        elif tag == 'display-step':
            step = el.text
_______________________

I do not know if unpitched is really needed in every single note. Isn't rhythm just an instrument where two notes sound more different than for other instruments?
Could we just specify unpitched once and for all notes in a rhythm part:

 <part>
    <part-name>Drums</part-name>
    <part-type>rhythm</part-type>
    <measure>
  ....

Python output for the second problem, where there is no time signature and there are no measures:

C:\Users\Mogens Lundholm\Desktop\MNX-test\MusicXml-Makam>PYTHON convert.py "C:\Users\Mogens Lundholm\Desktop\MNX-test\MusicXml-Makam\muhayyer--bozlak--serbest--havayi_da--asaf_guven.musicxml"
Traceback (most recent call last):
  File "convert.py", line 7, in <module>
    s = get_score_from_musicxml(filedata)
  File "C:\Users\Mogens Lundholm\Desktop\MNX-test\MusicXml-Makam\mnxconverter\musicxml.py", line 88, in get_score
    return read_musicxml(xml)
  File "C:\Users\Mogens Lundholm\Desktop\MNX-test\MusicXml-Makam\mnxconverter\musicxml.py", line 199, in read_musicxml
    return reader.read()
  File "C:\Users\Mogens Lundholm\Desktop\MNX-test\MusicXml-Makam\mnxconverter\musicxml.py", line 224, in read
    self.parse_measures()
  File "C:\Users\Mogens Lundholm\Desktop\MNX-test\MusicXml-Makam\mnxconverter\musicxml.py", line 255, in parse_measures
    self.parse_measure_part(measure_part_el, bar, parts[part_idx])
  File "C:\Users\Mogens Lundholm\Desktop\MNX-test\MusicXml-Makam\mnxconverter\musicxml.py", line 264, in parse_measure_part
    clef = self.parse_measure_attributes(el, bar, part, bar_part)
  File "C:\Users\Mogens Lundholm\Desktop\MNX-test\MusicXml-Makam\mnxconverter\musicxml.py", line 351, in parse_measure_attributes
    bar.timesig = self.parse_time(el)
  File "C:\Users\Mogens Lundholm\Desktop\MNX-test\MusicXml-Makam\mnxconverter\musicxml.py", line 479, in parse_time
    raise NotationDataError('Invalid <time> element.')
mnxconverter.musicxml.NotationDataError: Invalid <time> element.

Most errors when running my test files come from "ValueError: Invalid duration fraction 3/8" (See issue #3). Together with the two errors described here, I don't get other errors.

R.zip

@adrianholovaty
Copy link
Collaborator

I've just pushed a commit ffe07d9, which adds line numbers to MusicXML import errors. Thanks for the suggestion!

For the other thing you brought up (unpitched notes), these are still unspecified in MNX. I've just opened an issue in the MNX repository to log this as a to-do: w3c/mnx#316

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