Soundfont, MIDI velocity and instruments.xml

frissítés ideje: 2 hónap

    Changes in MuseScore 4

    See and maintain the post at MuseScore 3 features not (yet) implemented in MuseScore 4. The following is a short summary (ms4.2) that may be outdated:

    The following describes Musescore 3

    This page offers Musescore 3 playback related info, instructions on how to use your own sound files inside Musescore, and instruments.xml syntax and definitions. Requires basic understanding of soundfonts

    To setup a new soundfont in Musescore, visit SoundFonts and SFZ files
    To setup instruments in a score, eg add a new violin staff, visit Change Instrument Setup

    Online Resources

    A collection of ready to use new soundfonts for download
    SoundFonts forum on musescore.org

    SF2 specification document

    Use your own sound samples / Create custom soundfont

    Also try the tutorials by Freepats project on its github wiki

    Benefit of SF2/SF3 over SFZ : one SF2/SF3 can contain multiple sounds, which makes setting up in MuseScore synthesizer and sharing with other musicians way easier. Convert between SFZ and SF2/SF3 in Polyphone.

    Default dynamics MIDI velocity conversion, MIDI velocity output dB conversion

    Dynamics symbol => MIDI velocity conversion is hardcoded in Musescore. You can also edit any Dynamics Velocity property inside Musescore. Note that this kind of conversion is a matter of program coders' preference ref1 ref2

    MIDI velocity => sound level converion is defined in soundfont file: the default soundfont is edited with the following dB level aim in mind approximately based on this doc calculated as L(dB) = 40 log (MIDIVelocity/127).

    For soundfont creators wishing to match with default sound level, it'd be wise to export samples instead of monitoring musescore audio output. Musescore 3.6.2 by default adds a 10% headroom to instrument, so that it's 90% volume of sound sample at the default 100/127 in the Mixer. Full volume sound sample would be ~111/127 in Mixer.

    MIDI velocity is a parameter on the synthesizer, relating to soundfont. musescore Mixer value is final post process output volume. The max 127 in Mixer is an arbitrary number, it is not related to MIDI velocity.
    this table may not be displayed properly in mobile browsers

    Velocity full volume sample dB Musescore 3 Dynamics
    127 0.0dB ffff, fffff, ffffff
    126 fff
    112 -2,2dB ff
    96 - 4.8dB f
    80 - 8.0dB mf
    64 -11.9dB mp
    48 -16,9dB p
    32 -23.9dB pp
    16 -36.0dB ppp
    10 pppp
    8 -48,0dB
    5 ppppp
    4 -60,0dB
    2 -72,1dB
    1 -84.15dB pppppp
    0 -Infinity

    Instrument abstraction in Musescore

    What users can do in a score with soundfont and instrument definition in instruments.xml:

    What users can do with soundfont alone:

    Changing settings inside Musescore will not update instruments.xml automatically.

    Instrument concept in Musescore

    An instrument (jump to xml) in Musescore is a concept including the following:

    • name
    • notation (brackets, barlines, staves, clefs, and noteheads, depending on the type of instrument)
    • behaviors (transposition, playable range)
    • sound (audio samples in the soundfont) thru a layer of Channel concept
    • articulations (playback duration; articulation as in notation)

    it provides a easy way to mix and reuse sound and notation setup. Instruments are defined in instruments.xml

    Channel concept in Musescore

    Not to be confused with MIDI Output Port and Channel.
    Channel (jump to xml) is a concept that represent one specific type of sound produced by a single instrument, alike the articulation/sound sample concept in commercial libraries.
    To simulate different articulation or playing technique of same instrument, you must use a multi-channel instrument. You can only add and remove channel under an instrument by creating a custom instruments.xml, you cannot add or remove channel inside Musescore. Multiple channels of the same instrument can be seen in a folder like manner in the Mixer. eg expand a default violin to see 3 channels: arco, tremolo and pizzicato.
    Total number of channel is unlimited, it is unrelated to number of voices. Each staff (that can contain a clef symbol) has four voices, like a four tracks group concept in DAW. You can assign channel to each voice separately.

    Change sound/articulation sample of an instrument in the middle of your music

    Not to be confused with 'Change Instrument' Text, or other actions, jump to understanding instrument concept for more info

    If your instrument has multiple channels, you can simulate change of performance articulation or playing technique, such as switching between detache and legato for different note:

    If you xml has the instrument with Channel name="pizzicato", you'll see inside Musescore:

    Staff text: staff does not means one staff on a score paper in real world sense, it represents the whole instrument. ie. piano have two staffs, Staff text affect the whole piano.

    Musescore's usage of MIDI Bank and Preset number / Two types of sound any instrument channel can point to

    Musescore use MIDI Bank number in a way that seems different from other app and mainstream MIDI keyboards. TIPS: Use an editor that show Bank number directly.

    Two types of sound any instrument channel can point to:

    • Pitched

      • Most comomon
      • Cannot use Drumset palette
      • Musescore3's default soundfont
        • use different Preset to represent different instruments , it may be from GM
        • use Bank 0 as default normal sound for each instrument; and
        • Bank 17 for instruments' Expressive version = Single note dynamic sversion = CC 2 responsive version, see meanings of SND
      • Free to use any Bank and Preset number in your custom soundfont , just make sure instruments.xml's <channel> points to the correct sound.

      Default soundfont's Bank 0 Preset 0 = Piano normal
      Default soundfont's Bank 0 Preset 12 = Marimba normal
      Default soundfont's Bank 0 Preset 24 = Guitar open
      Default soundfont's Bank 0 Preset 41 = Violin arco non expressive (no response to CC)
      Default soundfont's Bank 17 Preset 41 = Violin arco expressive (response to CC 2)

    • Unpitched

      • To use the Drumset palette in Input mode, you must use this sound.
      • <drumset>1</drumset> is equal to Ticking the Drumset checkbox in Mixer
      • each note represent a different sound sample. It may be from Percussion layout in GM
      • <Drum pitch=n> defines the sound sample to be represented by that pitch/note, its staff appearance eg position on staff, notehead etc, and its input keyboard shortcut.
      • Musescore3's default soundfont
        • Bank 128 includes almost all unpitched percussion instruments
        • use different Preset for different taste/style.
      • You must use BANK 128 to be listed in Mixer, free to use any Preset number in your custom soundfont, just make sure instruments.xml's <channel> points to the correct sound and <drumset>1</drumset>.

      Default soundfont's Bank128 Preset 0 = Standard Kit
      Default soundfont's Bank128 Preset 16 = Power Kit
      Default soundfont's Bank128 Preset 48 = Orchestra Kit
      Pitch 36=Bass Drum 1
      Pitch 38=Acoustic Snare

    What SND

    Single Note Dynamics (SND) has several different meanings

    Musescore's 'Single Note Dynamics' audio creation mechanism provides:

    • Attack envelope simulation effect (wikipedia) on note playback, eg sfz on violins , for more info see Dynamics
    • simulation of 'variation of loudness' effect eg crescendo on one violin long note, for more info see Hairpins

    It depends on:

    Make a soundfont repond to MIDI CC

    Understand SND first.

    Attenuation response to MIDI velocity and MIDI CC in sounds is a matter of preference of soundfont creators.
    Musescore default soundfont has sounds that response to CC 2, devs call them expressive sounds.
    Musescore synthesizer is set to communicate in CC 2 by default, it is a global setting.
    To allow users to use SND features to compose scores that contains sounds from both default soundfont and custom soundfont, you should make your SF2/SF3 response to CC 2:

    Edit Instrument modulator and/or Preset modulator:

    • Disable default attenuation mod (Note-On velocity),
    • add a MIDI CC 2 attenuation mod,

    study the polyphone screenshot example below, more info visit Polyphone manual, also open and study the modulator in default MuseScore_General.sf3 soundfont.
    In Polyphone's param table, the attenuation use dB values, the meaningful range for 24bit sample is 0 to 144; 16bit: 0to 96; 8bit: 0 to 48 etc, see thread on polyphone forum. The attenuation modulators however use centibel, a 1200 cents based unit, see spec
    cc2.PNG

    SND and soundfont without MIDI CC reponse

    Setup Musescore synthesizer to allow SND feature with soundfont that has no MIDI CC response How to setup Musescore 3.x for correct playback for all dynamics and hairpins (not tested yet, please add info)

    Make soundfont support articulation sample switches (default StaffTexts eg pizz.)

    musescoreTextPalette_2.png
    Change sound sample by using Staff Text, Musescore is shipped with 5 default: pizz., arco, tremolo, mute, open
    They affect playback by sending instructions, which can be viewed by opening any saved .mscx file or exported palette item in plaintext, the name properties refers to an instrument's channel name (jump to xml):

    <StaffText>
      <channelSwitch voice="0" name="pizzicato"/>
      <channelSwitch voice="1" name="pizzicato"/>
      <channelSwitch voice="2" name="pizzicato"/>
      <channelSwitch voice="3" name="pizzicato"/>
      <text>pizz.</text>
    </StaffText>
    <StaffText>
      <channelSwitch voice="0" name="arco"/>
      <channelSwitch voice="1" name="arco"/>
      <channelSwitch voice="2" name="arco"/>
      <channelSwitch voice="3" name="arco"/>
      <text>arco</text>
    </StaffText>
    <StaffText>
      <channelSwitch voice="0" name="tremolo"/>
      <channelSwitch voice="1" name="tremolo"/>
      <channelSwitch voice="2" name="tremolo"/>
      <channelSwitch voice="3" name="tremolo"/>
      <style>Expression</style>
      <text>tremolo</text>
    </StaffText>
    <StaffText>
      <channelSwitch voice="0" name="mute"/>
      <channelSwitch voice="1" name="mute"/>
      <channelSwitch voice="2" name="mute"/>
      <channelSwitch voice="3" name="mute"/>
      <text>mute</text>
    </StaffText>
    <StaffText>
      <channelSwitch voice="0" name="open"/>
      <channelSwitch voice="1" name="open"/>
      <channelSwitch voice="2" name="open"/>
      <channelSwitch voice="3" name="open"/>
      <text>open</text>
    </StaffText>

    For example, to switch to Bank 6 Preset 41 sound upon default pizz. text:

    • Arrange your soundfont in Synthesizer to be at 2nd ordered,if your soundfont is 1st ordered, default instruments will not play correct sound.
    • In instruments.xml, setting up a custom instrument with channels
    <Channel name="customchannel">
        ...
    </Channel>
    <Channel name="pizzicato">
      <controller ctrl="0" value="1"/><!-- soundfont order - 1 -->
      <controller ctrl="32" value="7"/><!-- soundfont order - 1 +  bank number -->
      <program value="41"/><!-- preset number-->
    </Channel>
    <Channel name="customchannel2">
        ...
    </Channel>

    If you want alternative soundfont ordering in Synthesizer, you need to modify the value properties accordingly, jump to polyphone demo to learn more.
    You can also create custom staff text save as custom palette item, palette items can be exported and imported.

    instruments.xml

    • defines Instruments (jump to concept, jump to xml)
      • number of channels each instrument has, and
      • the sound each channel points to, and
    • supply GUI layout used in Change instrument set-up menu using Genres (jump to xml) and InstrumentGroup (jump to xml)

    There are two types of sound an instrument channel can point to, see Musescore's usage of MIDI Bank and Preset number

    Create a new instruments.xml, Setup musescore

    Modifying instruments.xml will not update score automatically, you must restart musescore, then add the updated version of instrument as new staff, or update a existing staff.

    File directory

    Windows: C:\Program Files\MuseScore 3\instruments

    You may not need to learn the instruments.xml syntax

    Copy and paste method:

    Instrument's notation setting edited and sound assigned in Mixer inside Musescore are not automatically save back to instruments.xml, but they are saved in the score file. Open it as plaintext to copy and paste to create your custom instruments.xml.

    How-to:

    • Edit and finalize your custom soundfonts
    • Load them in synthesizer. If you wish to continue to use musescore default sounds, keep default soundfont as 1st, add your custom soundfonts after it, order as desired, if you wish to use this setup for all score click Set as default.
    • Create a new score, choose an instrument that has notation similar to your custom sound, add it. Open Mixer, select the instrument in Mixer, select your custom sound in Sound dropdown list, set Drumset checkbox in Mixer and config Drumset palette according to your sound layout, save as mscx.
    • Opened mscx as plaintext to copy and paste to create your custom instruments.xml.
    • Add your instruments.xml in Preferences

    Important:
    Do not

    • rearrange Banks and Presets number in your old soundfonts afterwards, or
    • change the order of existing soundfonts in the synthesizer,

    as these may affect what sound your instruments.xml point to. Instead, add new soundfonts by putting them after existing ones.

    instruments.xml syntax definitions

    Element names are case sensitive.

    The museScore element is the container for all of the definitions for all of the instruments.

    museScore element - Genre (optional, multiple)
    museScore element - Articulation (optional, multiple)
    museScore element - InstrumentGroup (optional, multiple)

    Genre

    Genre attribute - id (required)
    The id should be unique. Each instrument element defines the Genre or Genres in which the instrument is used.

    Genre element - name (required)
    Text of item inside dropdown selection menu in instrument setup eg Common.

    Articulation

    As in notation, not referring to sound samples.
    An articulation modifies the velocity (loudness) and or gateTime (length) of a note.

          <Articulation name="marcatoStaccato">
                    <velocity>120</velocity>
                    <gateTime>50</gateTime>
          </Articulation>

    Articulation attribute - name (required)
    The name of the Articulation (e.g. staccato). Articulations defined for an Instrument take precedence over Articulations defined in the museScore element for all Instruments*.
    The name should correspond to an entry in the articulations palette:

    staccato, staccatissimo, portato, tenuto, marcato, sforzato (the accent symbol, not the "sfz" dynamics symbol), sforzatoStaccato, marcatoStaccato, marcatoTenuto

    Articulation element - velocity (optional)
    The content is the velocity (loudness) multiplier in percent: 100% leaves the velocity unchanged. The % is optional.

    Articulation element - gateTime (optional)
    The content is the gate time (note length) multiplier in percent: 100% leaves the note length unchanged. The % is optional.

    Articulation element - descr (inactive)
    Currently not used. The description may be helpful for people editing the instruments.xml file in the future.

    InstrumentGroup

    Defines a type of instrument, e.g, Woodwinds, Brass, etc. An Instrument can only be defined in one InstrumentGroup, but it can be included in several InstrumentGroups by cross referencing using the ref element.

        <InstrumentGroup id="woodwinds">
            <name>Woodwinds</name>
            <Instrument id="flute">
                ....
            </Instrument>
            ....
       </InstrumentGroup>

    InstrumentGroup attribute - id (required)
    The InstrumentGroup id need not be unique within the instruments.xml files. If the id has already been used, then a new InstrumentGroup is not created but the Instruments defined in this element will be added to the previously defined InstrumentGroup.

    InstrumentGroup element - name (required)
    Text of collapsable in instrument setup eg Percussion - Pitched.

    InstrumentGroup element - ref (optional, multiple)
    As of MuseScore 3.6.2, referencing and re-using / re-positioning of instrument is not working.
    The content is the id of an Instrument previously defined. The Instrument will be added to this InstrumentGroup and will appear in both groups. ref can be used in an InstrumentGroup in the instruments.xml file 2 to refer to an instrument in file 1.

    InstrumentGroup element - Instrument (optional, multiple)

    Instrument

    Understanding the instrument concept in Musescore
    MuseScore offers three types of notation (with many variants): standard vocal and instrumental staves, tablatures and unpitched percussion staves. MuseScore interprets two types of sound in soundfont file.

    definitions common to all

    Instrument attribute - id (required)
    The Instrument id must be unique. It is not only used internally but also for identifying the Instrument for the init element in another Instrument and for the ref element in another InstrumentGroup.
    As of MuseScore 3.6.2, referencing and re-using / re-positioning of instrument is not working.

    Instrument element - init (optional)
    The content is the id of an Instrument previously defined. init copies most elements from the referenced Instrument into this Instrument.

    New elements can be added to the instrument and most existing elements can be redefined.

    init does not copy the genres: these should be redefined.

    Redefining staves, bracket, bracketSpans and barlineSpans can have unfortunate effects.

    Instrument element - longName (1 or more)
    Instrument element - shortName (1 or more)
    Used to define staff labels.

    longName / shortName attribute - pos (optional)
    Where where an Instrument has multiple staves pos is used to position the label. The value is 1 for the first staff, 2 between staff 1 and staff 2 etc. Even numbers are always between staves.

    The content is the label identifying the staves on the score. Usually there is only one longName and one shortName. The longName is used on the first system in the score and the shortName for all other systems. The longName is also used to display the Instrument in the instrument list if the trackName is not defined.

    Instrument element - trackName (optional)
    The content is the trackName used to display the Instrument in the instrument list and as the part name. If trackName is not defined, the first longName is used.

    Instrument element - description (inactive)
    Currently not used. The description may be helpful for people editing the instruments.xml file in the future. It should describe the instruments and give helpful information that cannot be found in the other elements.

    Instrument element - genre (optional, multiple)
    The content is a Genre id defined in the main museScore element. One or more genre (small letter g) elements are used to assign the Instrument to Genres. If an Instrument doesn’t have any genre elements, it will only appear in the Instrument list if the “All instruments” category is selected.

    Instrument element - musicXMLid (optional)
    The content is the MusicXML sound id for this Instrument. Not yet implemented, but MuseScore will use this id to import and export MusicXML files with the MusicXML id.

    Instrument element - staves (optional)
    The content is the number of staves for this Instrument, defaults to one.

    Instrument element - bracket (optional - only for multiple staves)
    The content is the type of bracket to use for joining staves. The value should be 0 for a normal bracket, 1 for a grand staff brace, 2 for a thin square bracket and 3 for a simple line.

    Instrument element - bracketSpan (optional - only for multiple staves)

    bracketSpan attribute - staff (optional)
    The first staff to bracket, numbered from 1, defaulting to 1.

    The content is the number of staves that are spanned by the bracket.

    The staff number plus the span should be no more that the number of staves + 1, otherwise the bracket will span to the next instrument.

    Instrument element - barlineSpan (optional - only for multiple staves)

    barlineSpan attribute - staff (optional)
    The first staff to for the spanning barline, numbered from 1, defaulting to 1.

    The content is the number of staves that are spanned by the barline.

    The staff number plus the span should be no more that the number of staves + 1, otherwise the barline will span to the next instrument.

    Instrument element - clef (optional)
    Instrument element - concertClef (optional)
    Instrument element - transposingClef (optional)
    Sets the clef to be used for a given staff for the Instrument. The clef element sets the clef for both concert pitch and transposed scores and parts; the concertClef element sets the clef for concert pitch only and the transposingClef element sets the clef for transposed scores and parts only.

    ...Clef attribute - staff
    The target staff for the Clef, numbered from 1, defaulting to 1.

    The content must be one of the following clef IDs.

    Clefs.png

    The definition for a piano, grand staff, would be

        <staves>2</staves>
        <bracket>1</bracket> <!-- Grand staff brace -->
        <bracketSpan>2</bracketSpan>
        <barlineSpan >2</barlineSpan>
        <clef>G</clef>
        <clef staff="2">F</clef>

    Instrument element - stafftype (optional)
    stafftype presets the number of lines in the staff, the type of notation and the clef. If the clef is also defined by a clef element, then the clef element takes precedence.

    stafftype attribute - staffTypePreset (required)
    This should be one of

    stdNormal,
    -- if the stafftype element content is standard;

    perc1Line, perc3Line, perc5Line,
    -- if the stafftype element content is percussion;

    tabBalajka,
    tab4StrSimple, tab4StrCommon, tab4StrFull, tabUkulele,
    tab5StrSimple, tab5StrCommon, tab5StrFull
    tab6StrSimple, tab6StrCommon, tab6StrFull, tab6StrItalian, tab6StrFrench,
    tab7StrCommon,
    tab8StrCommon
    -- if the stafftype element content is tablature.

    See Tablature for an explanation of Simple, Common, etc.

    For example, for a guitar

        <stafftype staffTypePreset="tab6StrCommon">tablature</stafftype>    

    Instrument element - singleNoteDynamics (optional) .
    Enables and disables SND notation interpretation, see meanings of SND
    When correcly setup mod in soundfont, Synthesizer, instrument (.xml here provides default setting, users can adjust inside Musescore with 'Use single note dynamics' property in Staff / Part properties), provides a loudness variation effect for use by special Dynamics symbols and Hairpins.

    Default enabled (>0). To disable eg for plucked and percussion instruments set it to 0

    Instrument element - aPitchRange (optional)
    Instrument element - pPitchRange (optional)
    The amateur and professional ranges of the instrument, eg 50-89 for a clarinet. Important for woodwinds and voices. Notes outside the amateur range are highlighted in yellow; notes outside professional range are highlighted in red.

    Instrument element - transposeChromatic (optional)
    Instrument element - transposeDiatonic (required if transposeChromatic is defined)
    If negative, the part sounds lower than written.
    transposeChromatic is used for transposing instruments to define the transposition interval between a transposed part and concert pitch.
    transposeDiatonic should be set to the diatonic equivalent of transposeChromatic. For instruments (Bb and Eb) where there is no direct equivalent, a near equivalent should be used, -15, -8, -1, 6 ... for Bb and -12, -5, 2, 9 ... for Eb.

    Instrument element - Articulation (optional, multiple)
    An articulation defined for an Instrument takes precedence over the same articulation in the museScore element, see above.

    Instrument element - Channel (required, multiple) .
    A Channel defines a set of playback parameters including sound.

    Channel attribute - name (optional) .
    required if more than one Channel is defined. Musescore's sound changing Staff Texts use this to refer to the channel. Any string will work if you setup a custom Staff Text properly. Use one of the following 5 to support the 5 default Staff Texts: "pizzicato", "arco", "tremolo", "mute", "open".

    Channel element - Controller (optional, multiple)
    controller attribute - ctrl : the MIDI continuous controller number
    controller attribute - value : the the value to be set.

    select MIDI Bank .

    Use values of ctrl="0" and ctrl="32" (refered below as ctrl_0, ctrl_32) to select MIDI Bank
    Understanding Bank and Preset in Musescore 3
    See screenshot: jump to polyphone example
    To switch sound sample in score: jump to Change sound/articulation sample

    • When using one soundfont only:
      To use Bank 17 of the 1st soundfont
            <controller ctrl="0" value="0" /> 
            <controller ctrl="32" value="17" /> 
    • When using multiple soundfonts:
      The sound selection logic becomes horribly messy, try the copy and paste method , you may not need to bother with the following details.

      Details of MuseScore 3.6.2's messy sound selection logic:
      Soundfont definition allows 129 Banks (#0-#128), but ctrl_32 has 128 distinct values only (0-127). As of MuseScore 3.6.2, what ctrl_0 and ctrl_32 refer to varies with

      • the number of soundfonts used in synthesizer
      • the ordering in synthesizer
      • the number of occupied banks in each soundfont (except the last)

      A workaround to handle the problem is to make sure ordering in synthesizer stay the same, hint: Set as default, and edit your soundfonts so they all have the number 128 bank occupied, then
      1st soundfont Bank 0-127 => ctrl_0_value=0, ctrl_32_value=0,1,2...127
      1st soundfont Bank 128 => ctrl_0_value=1, ctrl_32_value=0
      2nd soundfont Bank 0-126 => ctrl_0_value=1, ctrl_32_value=1,2,3...127
      2nd soundfont Bank 127 => ctrl_0_value=2, ctrl_32_value=0
      2nd soundfont Bank 128 => ctrl_0_value=2, ctrl_32_value=1
      3rd soundfont Bank 0... => ctrl_0_value=2, ctrl_32_value=2,3,4....
      the n-th soundfont's (smaller number banks only) Bank m will be ctrl_0_value= n-1 , ctrl_32_value= n-1+m
      eg
      To use Bank 0 of the 1st soundfont

      <controller ctrl="0" value="0" />
      <controller ctrl="32" value="0" />
       

      To use Bank 0 of the 2nd soundfont

      <controller ctrl="0" value="1" />
      <controller ctrl="32" value="1" />
       
    MIDI CC

    For audio output, Musescore use Fluid Synthesizer's MIDI Continuous Controller / Control Change (MIDI CC) Messages, see a list of MIDI CC. To select sound(Bank) thru Staff Text, CC 0 MSB and CC 32 LSB are used. For Hairpins and SNDs such as sfz , CC 2 is used by default (can be disabled or switched to use CC 11 instead in the synthesizer ). To use other MIDI CC, you must declare MIDI Actions for each channel first, study this github project.
    For MIDI out, the reverb and chorus are available in Mixer

    <controller ctrl="0" value="0" /> <!--  0x128 (MSB) -->
    <controller ctrl="32" value="17" /> <!-- 17 (LSB) -->
    select MIDI Preset .

    Channel element - program (optional)
    program attribute - value
    Selects MIDI preset/program, counts from zero. It is the Preset number as shown in Polyphone. Note the counting difference in the official General MIDI documentation table, GM's preset/program counts from one.
    Understanding Bank and Preset in Musescore 3
    See screenshot: jump to polyphone example
    To switch sound sample in score: jump to Change sound/articulation sample

    MIDI Bank and Preset selection demo

    Example soundfont created using Polyphone

    bankeg.PNG
    This soundfond MuseScore_GumGum.sf3 is created using Polyphone
    Consider this Bank 6 Preset 41 sound, to refer to this sound:


    If you want to use musescore's default sounds, load the custom soundfont as the 2nd soundfont in synthesizer

    <Channel name="cres1">  
      <controller ctrl="0" value="1"/><!-- soundfont order - 1 -->
      <controller ctrl="32" value="7"/><!-- soundfont order - 1 +  bank number -->
      <program value="41"/><!-- preset number-->
    </Channel>

    the n-th soundfont's (smaller number banks only) Bank m will be ctrl_0_value= n-1 , ctrl_32_value= n-1+m because preceding soundfont's Bank 128 is occupied, see the messy logic in controller definition

    If your sound requires drumset layout, Bank must be 128, the above formula will not work. For example, to refer to Bank 128 Preset 20 sound, use:

    <Channel name="cres1">  
      <controller ctrl="0" value="2"/><!-- higher bank like 128 is tricky, see logic -->
      <controller ctrl="32" value="1"/><!-- higher bank like 128 is tricky, see logic -->
      <program value="20"/><!-- preset number-->
    </Channel>

    These ctrl_0_value, ctrl_32_value are correct only if custom soundfont is 2nd ordered in the synthesizer, and the preceding soundfont's Bank 128 is occupied, for more info about logic see controller definition

    Alternatively,

    You can load soundfont as the 1st soundfont in synthesizer, but musescore's default instruments will not create correct sound ,
    refer to Bank 6 Preset 41 sound:

    <Channel name="cres1">  
      <controller ctrl="0" value="0"/>
      <controller ctrl="32" value="6"/>
      <program value="41"/>
    </Channel>

    Bank 128 Preset 20 sound:

    <Channel name="cres1">  
      <controller ctrl="0" value="1"/>
      <controller ctrl="32" value="0"/>
      <program value="20"/>
    </Channel>

    Channel element - synti (optional, Channel only)
    Selects the synthesizer. The default MuseScore synthesizer is Fluid which uses SF2/SF3 soundfonts. MuseScore also includes the Zerberus synthesizer which uses SFZ<synti>Zerberus</synti>. The Aeolus synthesizer is not currently supported.

    Channel element - MidiAction (optional, multiple)
    An optional action (set midi controller and/or set program) that can be selected for the channel when the channel is activated in the stave text properties dialog box.
    To use other custom MIDI CC, you must declare MIDI Actions for each channel first, study this github project.

    Channel element - descr (inactive)
    Currently not used. The description may be helpful for people editing the instruments.xml file in the future.

    Channel element - mute (deprecated)
    Channel element - solo (deprecated)

    definitions specific to tablatures

    Instrument element - StringData (required for tablatures) .
    Defines the number of frets and the tuning for each string.
    Althrough the string data is required for a tabulature, it can also be defined for a standard notation Instrument. This Instrument can then be displayed on a standard staff or displayed as a tablature by setting the appropriate tablature style in the edit instruments menu.

    StringData element - frets (required)
    Number of frets for the instrument.

    StringData element - string (required, multiple)
    Tuning of a string as a MIDI pitch number. Uppermost string first.

    For a 5 string banjo:

          <StringData>
            <frets>19</frets>
            <string>67</string>
            <string>50</string>
            <string>55</string>
            <string>59</string>
            <string>62</string>
          </StringData>
    definitions specific to unpitched percussion

    Try the .mscx copy and paste method
    Also try .drm copy and paste method: Use Edit Drumset GUI to set up sounds, save it as .drm file, open as plaintext, copy from them to create your custom instruments.xml.

    Instrument element - drumset (required) .
    The value should be true (>0) for an unpitched percussion instrument. Note that a "drumset" may include non-percussive, unpitched instruments such a whistle.

    Instrument element - Drum (multiple)
    Defines the sound, the staff line and the noteheads for each sound in the drumset such as snare, snare crossstick, snare rimshot ...

    Drum attribute - pitch (required)
    The content is the MIDI note number (pitch) for the sound.

    Drum element - head (recommended unless noteheads is specified)
    The content is the notehead group to use for this sound. Specifying the notehead group number is deprecated: the notehead group name is required. The default and the fallback if the name is not recognized is normal.

    Each notehead group defines a set of four noteheads for "black" notes (quarter notes / crotchets and shorter), half notes (minims), whole notes (semibreves) and double whole notes (breves).

    The notehead group may be one of the standard groups for percussion
    normal, cross, plus, xcircle | withx, triangle-up, triangle-down, slash perc 0-7s.png
    slashed1, slashed2, diamond, diamond-old | circled, circled-large perc 8-13s.png

    or one of the oddities
    large-arrow, do, re, mi | fa, (no so), la, ti perc 14-20s.png

    Drum element - noteheads (optional)
    Sets the the noteheads for "black" notes (quarter notes / crotchets and shorter), half notes (minims), whole notes (semibreves) and double whole notes (breves) individually using internationally recognized names. noteheads takes precedence over head.

    noteheads has four, optional, elements defining the noteheads for each length note: quarter for "black" notes, half for half notes /minims, whole for whole notes / semibreves and breve for double whole notes / breves.

    The noteheads equivalent of the notehead group slashed2 is

        <noteheads>
            <quarter>noteheadSlashedBlack2</quarter>
            <half>noteheadSlashedHalf2</half>
            <whole>noteheadSlashedWhole2</whole>
            <breve>noteheadSlashedDoubleWhole2</breve>
        </noteheads>

    Any noteheads from the SMuFL ranges Noteheads, Slash noteheads, Round and square noteheads and Shape note noteheads can be used.

    For unpitched percussion instruments, you may only ever need black noteheads. If the notehead definition for any note length is omitted, the notehead defaults to normal.

    Drum element - line (recommended)
    The content is the staff line to use for this sound. 0 is the top line, 1 the top interline and so on. The default is -1. This is not guaranteed.

    Drum element - voice (recommended)
    The content is the preset voice to use for this sound: a number between 0 and 3, corresponding to staff voices 1 to 4. The default is 0 (staff voice 1). This is not guaranteed.

    Drum element - name (required)
    The content is the name of the sound. This is the tip text for the sound in the drum palette and name of the sound in the Edit drumset dialog box.

    Drum element - stem (recommended)
    The content is the preset stem direction: 0 for automatic. 1 for up and 2 for down. Defaults to up for voice 0 or 3 (staff voice 1 or 4) and defaults to down for voice 1 or 2 (staff voice 2 or 3).

    Drum element - shortcut (optional)
    The content is the shortcut for this sound which should be a letter between A and G.