docs/audio/Soundfont_XML.md
Soundfont XMLs describe the layout of a single soundfont. These package raw samples together into instruments, of which there are three kinds:
In the specification, Note Names can be either a MIDI note name e.g. C4 or it may be a Zelda64 note number, which are related to MIDI note numbers ($n$) by $(n - 21) \mod 128$.
<Soundfont
Name="<C Identifier>"
Index="<uint>"
Medium="<Medium>"
CachePolicy="<CachePolicy>"
SampleBank="<Path>"
Indirect="[uint]"
SampleBankDD="[Path]"
IndirectDD="[uint]"
LoopsHaveFrames="[bool]"
PadToSize="[uint]"
NumInstruments="[uint]"
>
Begins a new soundfont.
Attributes
SampleMedium.AudioCacheLoadType.max(program_number) + 1 but some vanilla banks don't match this way.Tags
<Envelopes>
Lists envelopes defined in this soundfont.
Attributes
N/A
Tags
<Envelope
Name="<C Identifier>"
Release="<u8>"
>
Starts a new envelope.
Attributes
gAudioCtx.adsrDecayTable) for this envelopeTags
<Point
Delay="<s16>"
Arg="<s16>"
/>
Add a point to the envelope at (delay, arg)
Attributes
<Disable/>
Insert a ADSR_DISABLE command
<Hang/>
Insert a ADSR_HANG command
<Goto
Index="<uint>"
/>
Insert a ADSR_GOTO command
Attributes
</Envelope>
</Envelopes>
<Samples
IsDD="[Bool]"
Cached="[Bool]"
>
Begins a list of samples used in this Soundfont.
Attributes
SampleBankDD. Default is false. NOTE this is not fully implemented, it should always be false.usedSamples cache. Default is false.Tags
<Sample
Name="<C Identifier>"
SampleRate="[Sample Rate]"
BaseNote="[Note Name]"
FineTune="[Fine Tune]"
IsDD="[Bool]"
Cached="[Bool]"
/>
Declares a sample used in this soundfont.
Attributes
SampleBankDD. Default is false. NOTE this is not fully implemented, it should always be false.usedSamples cache. Default is false.</Samples>
<Effects>
Begins a list of sound effects to define for this soundfont. Sound effects correspond to simple sounds that cannot be played at different keys.
Attributes
N/A
Tags
<Effect
Name="<C Identifier>"
Sample="<Sample Name>"
SampleRate="[Sample Rate]"
BaseNote="[Note Name]"
FineTune="[Fine Tune]"
/>
Defines a single sound effect.
Attributes
SF{n}_{name} where n is the index of this soundfont and name is this name. For example, if n=0 and name=ExampleEffect the name to use in sequence files is SF0_ExampleEffect.</Effects>
<Drums>
Begins the percussion definitions for this soundfont. Percussion corresponds to the MIDI notion of percussion, where single samples are mapped across a range of keys.
Attributes
N/A
Tags
<Drum
Name="<C Identifier>"
Note="[Note Name]"
NoteStart="[Note Name]"
NoteEnd="[Note Name]"
Pan="<u8>"
Envelope="<Envelope Name>"
Release="[u8]"
Sample="<Sample Name>"
SampleRate="[Sample Rate]"
BaseNote="[Note Name]"
FineTune="[Fine Tune]"
/>
Defines a single percussion range.
Attributes
SF{n}_{name}_{note} for every note covered by this sound.NoteStart and NoteEnd become required.Note becomes required. If this field is specified, NoteEnd must also be specified.Note becomes required. If this field is specified, NoteStart must also be specified.64.Envelopes list.</Drums>
<Instruments>
Begins the instrument definitions for this soundfont. Instruments correspond to the MIDI notion of instruments, with up to 3 samples (voices) per instrument that must map to contiguous ranges of notes.
Attributes
N/A
Tags
<Instrument
ProgramNumber="<>"
Name="<C Identifier>"
Envelope="<Envelope Name>"
Release="[u8]"
Sample="<Sample Name>"
SampleRate="[Sample Rate]"
BaseNote="[Note Name]"
FineTune="[Fine Tune]"
RangeLo="[Note Name]"
SampleLo="[Sample Name]"
SampleRateLo="[Sample Rate]"
BaseNoteLo="[Note Name]"
FineTuneLo="[Fine Tune]"
RangeHi="[Note Name]"
SampleHi="[Sample Name]"
SampleRateHi="[Sample Rate]"
BaseNoteHi="[Note Name]"
FineTuneHi="[Fine Tune]"
/>
Defines an instrument.
Attributes
0 <= n <= 125</Instruments>
</Soundfont>