-
Notifications
You must be signed in to change notification settings - Fork 1
Description
I'm pretty certain that I have now finalized the bank LSB system in spessasynth.
This issue is here to explain and potentially transfer the bank selection algorithm to SFe.
The code is here:
Now for the description
MIDI Patch
Each preset is a MIDI Patch. This means that it has 4 properties:
- program - the MIDI program number.
- bankMSB - the CC#0 value.
- bankLSB - the CC#32 value.
- isGMGSDrum - a flag indicating if this is a drum patch.
This allows to select presets accurately with extensive fallback options for all 4 bank selection systems.
Below is how each of the three formats loads the patch:
SF2 presets
- program - copied directly from wPreset.
- bankMSB - copied directly from wBank.
- bankLSB - set to zero/copied from the top wBank byte (if it's not zero). But it will mostly be zero.
- isGMGSDrums - copied directly from wBank drum bit (bit 8).
DLS instrument
- program - copied directly from ulInstrument.
- bankMSB - copied directly from ulBank.
- bankLSB - copied directly from ulBank.
- isGMGSDrums - copied directly from ulBank drum bit
SFe preset
- program - copied directly from wPreset.
- bankMSB - copied directly from wBank.
- bankLSB - copied directly from wBank.
- isGMGSDrums - copied directly from wBank drum bit (bit 8).
System behaviors
default
By default, the synthesizer is initialized in GS mode.
Note that all modes use the same bank selection system.
gs
Triggered by: GS/SC-88 reset, boot up of the synthesizer.
All banks and all programs are set to 0. Channel 10's isGMGSDrum is set to true, everywhere else set to false.
A GS Use for Drums Part SysEx can be used to toggle the isGMGSDrum on any channel
gm
Triggered by: GM1 mode on.
All banks and all programs are set to 0. Channel 10's isGMGSDrum is set to true, everywhere else set to false.
Bank select messages are ignored.
gm2
Triggered by: GM2 mode on, GS mode off.
All programs are set to 0. All channels' bank MSB is set to 121, with the exception of channe 10 where it is set to 120. (per GM2 spec) isGMGSDrum is set to false on all channels.
xg
Triggered by: XG reset.
All programs are set to 0. All channels' bank MSB is set to 0, with the exception of channe 10 where it is set to 127. isGMGSDrum` is set to false on all channels.
Definitions
Below are the few definitions when selecting a preset.
Valid XG bank
Each sound bank in the list has to be validated for XG compatibility. This is done because some sound bank set the bank MSB of 127 for Roland MT presets.
Each bank's presets are tied to that bank, i.e. even with an SFList consisting of multiple sound banks, each of the presets must know if it's a part of a valid XG bank or not.
Checking algorithm
- Assume that bank is not a valid XG bank.
- Iterate through all the presets.
- If bank MSB = 120, 126 or 127, check the program:
- If the program is one of these values:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 17, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 40, 41, 48, 56, 57, 58, 64, 65, 66, 126, 127- Set the bank to a valid XG bank and continue iteration.
- If not:
- Set bank as not XG valid and end the iteration immediately.
Is XG drums
A preset is considered xg drums if the following conditions are met:
- bankMSB of this preset is 120 or 126.
- AND
- the parent sound bank of this preset is a valid XG bank.
Is any drums
A preset is considered any drums if the following conditions are met:
- isGMGSDrum flag is set.
- OR
- the preset is
xg drums.
Bank selection algorithm
The bank selection takes two arguments:
- MIDI Patch: the 4 properties described.
- System: the bank selection system currently active.
BEGIN:
Look for an exactly matching preset:
- Program matches.
- Bank MSB matches.
- Bank LSB matches.
- isGMGSDrum flag matches.
If a match is found, select it.
if isGMGSDrums is true:
- Look for a preset with a matching program number and
isGMGSDrumsflag set. If a match is found, select it. - Look for
any drumspreset with a matching program. If a match is found, select it. - Look for any preset with the
isGMGSDrumsflag. If a match is found, select it. - Look for
any drumspreset. If a match is found, select it. - Select the first available preset.
if bank MSB is 120, 126 or 127 AND the bank selection system is xg or gm2
- Look for a preset with a matching program number that is
xg drums. If a match is found, select it. - Look for
any drumspreset with a matching program. If a match is found, select it. - Look for any preset that is
xg drums. If a match is found, select it. - Look for
any drumspreset. If a match is found, select it. - Select the first available preset.
If the conditions above don't apply, this is a melodic preset.
- Find all presets with a matching program number that are not
any drums. - Store them in
matchingPrograms
if matchingPrograms is empty
Select the first available preset.
if the bank selection system is xg or gm2
- Look for a preset in
matchingProgramsthat has a bank LSB match. If a match is found, select it.
else
-
Look for a preset in
matchingProgramsthat has a bank MSB match. If a match is found, select it. -
Find the larger bank number of the two and call it
bank. -
Look for a preset in
matchingProgramsthat has a bank LSB OR bank MSB match withbank. If a match is found, select it. -
Select the first
matchingPrograms.
@sylvia-leaf
@stgiga
@nehochupechatat
What do you think about this preset selection system? I've tested it extensively and it works with both GM2 files (nokia DLS sound banks), XG files (DLSByXG.dls as well as the SF2 conversion) and regular GS sound banks.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status