w3c / musicxml

MusicXML specification
518 stars 57 forks source link

How to know the actual percussive instrument #431

Closed GeorgeTailor closed 3 years ago

GeorgeTailor commented 3 years ago

Hello, I am following the example here https://w3c.github.io/musicxml/musicxml-reference/examples/tutorial-percussion/ and wondering how to persist the info about a Snare Drum, since in the example we have the following data:

<score-instrument id="P1-X4">
    <instrument-name>Snare Drum</instrument-name>
</score-instrument>
<midi-instrument id="P1-X4">
  <midi-channel>10</midi-channel>
  <midi-program>1</midi-program>
  <midi-unpitched>39</midi-unpitched>
  <volume>80</volume>
  <pan>0</pan>
</midi-instrument>

but when we look at the MIDI standard the midi-unpitched 39 maps to hand clap - https://en.wikipedia.org/wiki/General_MIDI

Since the instrument-name can be an arbitrary string it is impossible to retain the mapping across different software.

jsawruk commented 3 years ago

This appears to be an "off by one" issue. The MIDI 1.0 spec defines program numbers to be in the range 0-127 (7 bits). See MIDI 1.0 Detailed Specification, Table II, Channel Voice Messages. However, the General MIDI Sound Set ranges from 1-128. The General MIDI percussion map could similarly be off by one.

Given that the two MIDI specifications differ, this might cause inconsistencies across different implementations.

@mdgood Any suggestions on how to address this?

GeorgeTailor commented 3 years ago

I think this is explained here https://w3c.github.io/musicxml/musicxml-reference/elements/midi-unpitched/ and here https://w3c.github.io/musicxml/musicxml-reference/data-types/midi-128/

I'll close this issue, even though I cannot understand why the decision about the note numbers came to be this way.

mdgood commented 3 years ago

@GeorgeTailor The 1-128 vs 0-127 mismatch was a mistake. It came about because some MIDI ranges, like https://w3c.github.io/musicxml/musicxml-reference/data-types/midi-16/, are indeed 1-based. MIDI 1.0 channels range from 1 to 16 at the user level, not 0 to 15. That concept got over-generalized into this range. We now have to live with it for compatibility with earlier MusicXML versions. Fortunately it is easy enough to work around, but as you demonstrate it is confusing when you first encounter it.

Perhaps a better way to specify the exact sound would be to use the <instrument-sound> element within the <score-instrument> element. Most software however does not yet handle individual instrument sounds when a percussion virtual instrument combines several sounds together into a single patch. I am not sure yet if this is something we can improve just through better software, or if there are MusicXML changes that could help in the future.