Browse Source

fix(Playback): Fix "steel drums" played as "drums" and not "steel drum", fix other matching priorities like alto, soprano to be last

https://github.com/opensheetmusicdisplay/opensheetmusicdisplay/issues/1231
sschmidTU 1 year ago
parent
commit
6a3fe958d8
1 changed files with 10 additions and 9 deletions
  1. 10 9
      src/MusicalScore/InstrumentNames.ts

+ 10 - 9
src/MusicalScore/InstrumentNames.ts

@@ -3,18 +3,14 @@ import {MidiInstrument} from "./VoiceData/Instructions/ClefInstruction";
 /** Collections of instrument names, mapped to MidiInstruments. */
 export class InstrumentNames {
     public static MidiInstrument: { [key: string]: MidiInstrument } = {
-        "alt": MidiInstrument.Synth_Voice,
-        "alto": MidiInstrument.Synth_Voice,
         "banjo": MidiInstrument.Banjo,
-        "bariton": MidiInstrument.Synth_Voice,
-        "baritone": MidiInstrument.Synth_Voice,
-        "bass": MidiInstrument.Synth_Voice,
         "blockfloete": MidiInstrument.Recorder,
         "brass": MidiInstrument.Trombone,
         "bratsche": MidiInstrument.Viola,
         "cello": MidiInstrument.Cello,
         "clarinet": MidiInstrument.Clarinet,
         "contrabass": MidiInstrument.Contrabass,
+        "steel drum": MidiInstrument.Steel_Drums, // this needs to be before "drums" (and "sopran"), otherwise "steel drums" matches "drums"
         "drums": MidiInstrument.Percussion,
         "flute": MidiInstrument.Flute,
         "floete": MidiInstrument.Flute,
@@ -38,11 +34,9 @@ export class InstrumentNames {
         "sax": MidiInstrument.Tenor_Sax,
         "schlagwerk": MidiInstrument.Percussion,
         "schlagzeug": MidiInstrument.Percussion,
-        "sopran": MidiInstrument.Synth_Voice,
         "steeldrum": MidiInstrument.Steel_Drums,
         "streicher": MidiInstrument.String_Ensemble_1,
         "strings": MidiInstrument.String_Ensemble_1,
-        "tenor": MidiInstrument.Synth_Voice,
         "tpt": MidiInstrument.Trumpet,
         "trombone": MidiInstrument.Trombone,
         "trompete": MidiInstrument.Trumpet,
@@ -54,7 +48,15 @@ export class InstrumentNames {
         "violon-c": MidiInstrument.Cello,
         "violon.": MidiInstrument.Violin,
         "voice": MidiInstrument.Synth_Voice,
-        "woodblock": MidiInstrument.Woodblock
+        "woodblock": MidiInstrument.Woodblock,
+        // the following should be matched last, so that e.g. "alto sax" doesn't get matched to "alto".
+        "alt": MidiInstrument.Synth_Voice,
+        "alto": MidiInstrument.Synth_Voice,
+        "bariton": MidiInstrument.Synth_Voice,
+        "baritone": MidiInstrument.Synth_Voice,
+        "bass": MidiInstrument.Synth_Voice,
+        "sopran": MidiInstrument.Synth_Voice,
+        "tenor": MidiInstrument.Synth_Voice,
     };
 
     /** A map of MusicXML `instrument-sound` values to MidiInstrument.
@@ -615,6 +617,5 @@ export class InstrumentNames {
         "wood.tic-toc-block": MidiInstrument.Woodblock,
         "wood.tonetang": MidiInstrument.Woodblock,
         "wood.wood-block": MidiInstrument.Woodblock
-
     };
 }