0

I am using music21 to parse and play musicxml files on Windows 10 Jupyter Notebook.

When I do:

sa = converter.parse('d:/musicxml_folder/BeetAnGeSample.xml')
sa.show('midi')

the midi player opens and the output is a midi file that has sound of just the

<score-part id="P1">

And instrument is parsed wrong too. I hear grand piano sound but score-part P1 has the "Voice" instrument.

This sample xml has 3 attribute like this:

<part-list>
    <score-part id="P1">
      <part-name>Voice</part-name>
      <score-instrument id="xxx">
        <instrument-name>Voice</instrument-name>
      </score-instrument>
      <midi-instrument id="xxx">
        <midi-channel>1</midi-channel>
        <midi-program>53</midi-program>
      </midi-instrument>
    </score-part>
    <score-part id="P2">
      <part-name>Piano</part-name>
      <score-instrument id="xxx2">
        <instrument-name>Acoustic Grand Piano</instrument-name>
      </score-instrument>
      <midi-instrument id="xxx">
        <midi-channel>2</midi-channel>
        <midi-program>1</midi-program>
      </midi-instrument>
    </score-part>
    <score-part id="P652d2f88e786a36c81c494f7869835df">
      <part-name>Piano</part-name>
      <score-instrument id="xxx3">
        <instrument-name>Acoustic Grand Piano</instrument-name>
      </score-instrument>
      <midi-instrument id="xxx">
        <midi-channel>3</midi-channel>
        <midi-program>1</midi-program>
      </midi-instrument>
    </score-part>
  </part-list>

(i changed score-instrument id and midi-instrument id values for readability)

I want to hear all the instruments' parts in a midi player.
How to handle it ?

Ege
  • 138
  • 1
  • 14
  • Maybe the problem is in your input file? Can you provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example)? – Tupteq Mar 02 '20 at 11:08
  • @Tupteq The musicxml files that i collect from this download link https://www.musicxml.com/music-in-musicxml/example-set/ not correctly rendered by music21 convert method. I can hear just one instrument's sound. But some files from MuseScore web site like this https://musescore.com/classicman/scores/49143 sounds correctly, i can hear both instruments. I think the problem is about context of musicxml files(xml, musicxml, mxl). There must be a converter method that can export musicxml files music21 understand. – Ege Mar 05 '20 at 09:00
  • @Tupteq i added socre-part information of the sample xml. There is no problem with the xml files(musicxml, xml, mxl). All of three types of musicxml has the problem: i just hear only one score-part's sound. – Ege Mar 06 '20 at 10:19
  • Your example is not complete. I'm not familiar with `music21`, so I don't know exactly how to reproduce your problem. XML you provided is not complete and doesn't work a input for `converter.parse()`. – Tupteq Mar 06 '20 at 11:29
  • I just showed you the to understand how many score-parts this sample musicxml has. The whole sample musicxml file is here(its name is BeetAnGeSample.xml) [link](https://www.musicxml.com/music-in-musicxml/example-set/) @Tupteq – Ege Mar 06 '20 at 11:42
  • I couldn't use `sa.show('midi')` on my computed (it didn't work). Instead I wrote file `sa.write('midi', 'a.mid')` and this midi file seems to be fine (3 parts - voice + piano + piano playing together). – Tupteq Mar 06 '20 at 12:16
  • I can produce correct MIDI file too, i can hear all the 3 instruments when i played BeetAnGeSample.mid on my media player. But I want to hear this in jupyter notebook when i do show('midi'). Thanks for your fast responses. @Tupteq – Ege Mar 06 '20 at 12:34
  • There must be something wrong with Jupyter. I was able to restore polyphony by: `sa.partsToVoices(1, True).show('midi')` but unfortunately instrument data is lost (all parts are now piano). – Tupteq Mar 06 '20 at 13:23
  • I agree, Jupyter cannot play midi correctly. Producing MIDI files is usefull for me at the moment. @Tupteq – Ege Mar 07 '20 at 08:10

0 Answers0