Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQUEST] Don't forget other features involving bank LSB #9

Open
spessasus opened this issue Feb 12, 2025 · 12 comments
Open

[FEATURE REQUEST] Don't forget other features involving bank LSB #9

spessasus opened this issue Feb 12, 2025 · 12 comments
Assignees
Labels
enhancement New feature or request

Comments

@spessasus
Copy link

For spessasynth to accept the PR, other things need to also be adjusted, not just the synthesizer. That is:

  • the DLS format supports bank LSB. Currently, the parser discards it, but SFe should properly copy it over since it also supports LSB
  • XG hacks can only be removed for SFe banks. Removing them from SF2 will break MIDIs unless they get replaced by proper LSB mapping and behavior. In short: all XG MIDIs have to work the same as they did on existing SF2 and DLS soundfonts. They can be converted to SFe during load time, it just can't break them as it's really important, given that essentially all SF2s are only GS compatible.
  • MIDI editing: Spessasynth has a function to edit the MIDI. It is for example used to save a modified MIDI after you make some changes like switching instruments or controllers via the Synthesizer controller. The part that interests us is the instrument change as it also allows us to turn a channel into a drum channel, which in XG is implemented in a "hacky" way. Same for bank adjustment, it will also have to change LSB now.
  • RMIDI export: it has a feature called "adjust bank select." Since RMIDI with Bank offset does not have a capital tone fallback, this feature changes the bank select to simulate that if a preset doesn't exist in the exported SoundFont. This will have to be adjusted for LSB as well.

I think that's all, so it's mostly related to bank LSB.

@spessasus spessasus added the enhancement New feature or request label Feb 12, 2025
@spessasus spessasus changed the title [FEATURE REQUEST] Don't forget other features. [FEATURE REQUEST] Don't forget other features involving bank LSB Feb 12, 2025
@sylvia-leaf
Copy link

How should SFe implementations be expected to behave when SFe banks are being combined with SF2.0x banks? Should we apply quirks mode on only the SF2.0x banks, or should "flat" (dual bank select) mode be applied?

@sylvia-leaf sylvia-leaf self-assigned this Feb 16, 2025
@spessasus
Copy link
Author

Image

@spessasus
Copy link
Author

I thought SFe spec specified this

@sylvia-leaf
Copy link

In section 11.5.4 of the specification: "It will be standardised in the future depending on the most popular system", so nothing was written there.

However, I think that it would be prudent to use the parameters that correspond to the isng value of each bank.

What do you think? Do you think that this is the best approach, or is it too complicated?

@spessasus
Copy link
Author

The soundfont manager is essentially just adding presets on top of others. Like if you open two soundfonts in polyphone, copy all presets from one to another and if the bank:program is conflicting, overwrite them. Since SF2 does not have bank select, I think this would mean using LSB hacks.

Or we could go for a complex approach like:

  • if bank LSB is zero, then no problem, both formats have MSB so use that
  • if not:
    • look for the exact match with SFe presets
    • if found, use that
    • if not, look for match with SF2 presets using lsb hacks
    • if found, use that
    • if not, capital tone fallback

@spessasus
Copy link
Author

Also, out of topic, but does SFe have a discord server or something like that?

@sylvia-leaf
Copy link

There is the SF server, but I don't really use it much anymore. I think that stgiga may have a link to it.

@sylvia-leaf
Copy link

My idea is to move all the XG hack stuff from the controller_control.js into the soundfont manager and/or preset search algorithm. The CC values sent by controller_control.js will always accurately reflect the status of the MIDI.

In the soundfont manager, or whatever function searches for banks after a bank select instruction is sent, we then attempt to follow the suggested approach:

  • look for presets in SFe non-quirks banks first, which use no translation - these use an isng of SFe 4
  • if nothing, apply the translation/XG hacks to legacy or SFe quirks banks
  • if still nothing, we use base preset fallback (section 8.8)

Remember that the term used by SFe is base preset fallback because we can't guarantee a "capital" preset (with MSB and LSB both zero), and also the term used in legacy SoundFont and SFe is "preset" rather than "tone". Apart from that, what we refer to as base preset fallback is equivalent to "capital tone fallback" used by other MIDI implementations. Despite the algorithm described in section 8.8 being relatively complex, we need to implement as much of it as possible, because after all, this is the reference implementation!

Also remember about quirks mode - this is activated by using SFe 4 (quirks) instead of SFe 4 in isng. It is named after the IE quirks mode that is emulated by modern web browsers to ensure correct display of ancient webpages (before ~2000) that relied on differences in IE's HTML implementation to display correctly. Similarly, the quirks mode needs to emulate the differences in SpessaSynth's legacy SoundFont implementation for banks to function properly.

To help the soundfont manager keep track of whether a bank is SFe or legacy, we added a new property to the soundfontInfo array called soundfontInfo[BankFormat]. This will give the SF type, and there are currently four possible values:

  • SFe for SFe 4 banks
  • SoundFont 2.04 for SF2.04 banks
  • SoundFont 2.01 for SF2.01 banks
  • SoundFont 2.00 for SF2.00 banks

This also makes it easier for us to properly implement the small differences in the various versions of legacy SoundFont 2.0x. We can ignore sm24/sm32 sub-chunks, select the correct default modulators, and disable modulators altogether based on what version is in use. This also ensures correct behaviour for each file version; for example, the isng value is erroneously set to EMU8000 on many SF2.04 banks despite the AWE cards not supporting 24-bit sample playback.

@spessasus
Copy link
Author

I give you full freedom on the implementation, it just can't break the existing GS/XG MIDIs with existing SF2 soundfonts.

@sylvia-leaf
Copy link

So, I've found where I want to move the xg hack code to, that being the getPreset() function in basic_soundfont.js. What I need to do now is to find a way to access the system variable from SpessaSynthProcessor from the basic_soundfont.js. This contains gm, gm2, gs, xg, etc.

Once the system variable is called, then we translate the input bank values (bankNr, programNr). For now, bankNr is implemented as if it were unified (128 * lsb + msb), but this is for now an implementation difference. (In the future, we want to change the system to give MSB and LSB banks their own paths, because this would more closely match the structure of the SFe format as described in the specification.)

I also need to access the soundfontInfo data of each of the files that are loaded in from getPreset(), to determine whether quirks mode/xg hacks are enabled or disabled for each bank. I would find the isng value to determine whether we use quirks or non-quirks (standards), and then prioritise banks that use standards for LSB, and then banks that use quirks.

Then, I will use similar methods to temporarily disable the default modulator implementation quirks (Bassmidi-like chorus and reverb, and the five new default modulators) on only SFe files that use standards instead of quirks.

Also, where can I find information about what hacks need to be implemented for gm2 and xg? And what soundfonts and/or MIDI files can I use to see if the quirks mode is still working properly?

@spessasus
Copy link
Author

spessasus commented Feb 16, 2025

One thing to keep in mind that even though DLS supports LSB, we still use XG hacks for it.

And here's a very quirky XG MIDI + SF2 that works differently on fluid and spessa, but we want to maintain spessa's quirks mode for this. It should serve as a good tester:
Archive.zip

Essentially it boils down to the drums being properly set and bank MSB being interpreted like LSB in this special case.

@spessasus
Copy link
Author

Drag and drop the two into the current spessasynth implementation to see how they should behave.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

2 participants