BASS_MIDI_FONTGETPRESET - in XG mode bank 126 wrong preset names

Started by Falcosoft, 2 Jun '24 - 06:55

Falcosoft

Hi Ian,
New Bassmidi versions (last release version as well as new beta versions) report bank 127 preset names for bank 126 in XG mode. The problem is present regardless of BASS_MIDI_FONT_XGDRUMS flag is used or not.
This problem is NOT present in Bassmidi version 2.4.12.1 from 2018.

Edit:
It seems the problem is that new Bassmidi versions reports MIDI_EVENT_DRUMS in XG mode for Bank 126 when BASS_MIDI_StreamGetEvent() is called.
This is a breaking change so some kind of fallback should be provided.

Ian @ un4seen

XG bank 126 is indeed treated like a drum channel, eg. with support for the MIDI_EVENT_DRUM_XXX events. But that shouldn't prevent BASS_MIDI_StreamGetEvent returning the correct names. Is the issue you're having that BASS_MIDI_StreamGetEvent is reporting MIDI_EVENT_DRUMS=1, and that's making you request bank 128 (or 127) instead of 126 from BASS_MIDI_FontGetPreset?

If you happen to want to get the active preset in a MIDI channel then you shouldn't need to do any special bank mapping but instead use BASS_MIDI_StreamGetPreset, like this:

BASS_MIDI_FONT font;
BASS_MIDI_StreamGetPreset(midi, midichan, &font);
const char *name = BASS_MIDI_FontGetPreset(font.font, font.preset, font.bank);

Falcosoft

Quote from: Ian @ un4seen on  3 Jun '24 - 17:17XG bank 126 is indeed treated like a drum channel, eg. with support for the MIDI_EVENT_DRUM_XXX events. But that shouldn't prevent BASS_MIDI_StreamGetEvent returning the correct names. Is the issue you're having that BASS_MIDI_StreamGetEvent is reporting MIDI_EVENT_DRUMS=1, and that's making you request bank 128 (or 127) instead of 126 from BASS_MIDI_FontGetPreset?

If you happen to want to get the active preset in a MIDI channel then you shouldn't need to do any special bank mapping but instead use BASS_MIDI_StreamGetPreset, like this:

BASS_MIDI_FONT font;
BASS_MIDI_StreamGetPreset(midi, midichan, &font);
const char *name = BASS_MIDI_FontGetPreset(font.font, font.preset, font.bank);

Hi,
No, I do not want the active preset on a channel so I cannot use BASS_MIDI_StreamGetPreset().
In my BassMidi related Midi software products I usually offer a list of potential presets that are available at different Program/Bank combinations (it works even in case of multiple stacked soundfonts).
So far the logic has been clear: For the list of presets you ask for the programs of a bank when MIDI_EVENT_DRUMS=0 and of bank 128 when MIDI_EVENT_DRUMS=1 (or bank 127 when BASS_MIDI_FONT_XGDRUMS flag is used in XG mode).
But with this change this logic is broken.
Strictly on theoretical grounds this flag should not be set on bank 126 in XG mode since it is an SFX bank not a Drum bank (maybe a new flag will be better?).
With this change the clear distinction between drum vs. non-drum channel is lost. 
BTW, the majority of SF2 files do not contain an SFX bank in bank 126 so the validity of this flag (without any option to disable it) is questionable.

Ian @ un4seen

Here's an update that won't report MIDI_EVENT_DRUMS=1 for XG bank 126, but will still treat it like a drum channel, eg. enable MIDI_EVENT_DRUM_XXX.

   www.un4seen.com/stuff/bassmidi.zip

Let me know if you still see any problem with it.

Falcosoft

Quote from: Ian @ un4seen on  4 Jun '24 - 13:39Here's an update that won't report MIDI_EVENT_DRUMS=1 for XG bank 126, but will still treat it like a drum channel, eg. enable MIDI_EVENT_DRUM_XXX.

   www.un4seen.com/stuff/bassmidi.zip

Let me know if you still see any problem with it.

Thanks Ian, it works perfectly!
BTW, I have talked to S. Christian Collins (I have added the option to remove SB HW limits to BassMidiVSTi as he asked) and he said you worked a lot on the new BassMidi version so I should wait a while before a new release.
Can you tell me some info about the changes (so I could test them) and the release date of the new version?
Thanks in advance.
 

Ian @ un4seen

Good to hear the update's working better for you.

Regarding the recent changes, the main one is that when BASS_MIDI_FONT_NOLIMITS is set (automatic with SFZ files), a different filter is used, with a greater range and support for SFZ's highpass option. There's also support for some more SF2 modulators and SFZ opcodes relating to the mod envelope, and the envelope's attack phase is tweaked a bit. The vibrato moving from SF2's LFO1 to LFO2 (for MIDI_EVENT_VIBRATO_RATE/DEPTH/DELAY support) is also tweaked to only apply when the speed is at least 3hz (or identical in LFO1 and LFO2).

Here's what the BASSMIDI 2.4.15 changelog currently looks like (some of these were added a while ago in earlier updates):

Quote* Support for Key On Velocity to attackModEnv/decayModEnv/releaseModEnv and Key Number to startAddrsOffset SF2 modulators
   BASS_MIDI_FontInit/User
* Support for fileg_vel2attack/fileg_vel2decay/fileg_vel2release/pitcheg_vel2attack/pitcheg_vel2decay/pitcheg_vel2release SFZ opcodes
   BASS_MIDI_FontInit/User
* Improved SFZ variable parsing compatibility (uses the shortest match)
   BASS_MIDI_FontInit/User
* Extended filter cutoff range and highpass support when SB limits are disabled
   BASS_MIDI_FONT_NOLIMITS (BASS_MIDI_FontInit/User flag)
* Improved single note releasing when there are overlapping instances of the same note
   BASS_MIDI_NOTEOFF1 (BASS_MIDI_StreamCreateFile/User/URL flag)
* Ports above 7 are mapped to lower ports (modulo 8)
   BASS_MIDI_StreamCreateFile
* Higher ports are shifted to lower channels when lower ports are unused
   BASS_MIDI_StreamCreateFile
* Default per-drum USERFX levels to 127 instead of 0 in all modes
   BASS_MIDI_NODRUMPARAMUSER (BASS_MIDI_StreamCreate/Events/File/User/URL flag)
* Per-drum key settings may be applied to all keys at once
   MIDI_EVENT_DRUM_xxx (BASS_MIDI_StreamEvent/s)
* System mode/reset events are ignored from additional ports
   BASS_MIDI_StreamCreateFile/User/URL
   BASS_MIDI_StreamEvents
* Sequencer specific meta-event retrieval
   BASS_MIDI_MARK_SEQSPEC (BASS_MIDI_StreamGetMark type)
* Custom event buffer preallocation
   BASS_ATTRIB_MIDI_EVENTBUF_TICK/BYTE/ASYNC (BASS_ChannelSetAttribute options)
* Faster SFZ info retrieval
   BASS_MIDI_FontGetInfo
* MIDI filename retrieval
   BASS_CHANNELINFO (filename member)
* Approximate support for AWE32 filter NRPN (7f15/7f16)
   MIDI_EVENT_CUTOFF/RESONANCE

It isn't yet, but the BASS_MIDI_FONT_NOLIMITS option may be enabled by default, in which case there will be a new flag added to disable that. Of course, that isn't back-compatible, but most soundfonts these days probably aren't designed for SB hardware limits.

Ian @ un4seen

Here's an update that doesn't enable SB hardware limits by default:

   www.un4seen.com/stuff/bassmidi.zip

There's a new BASS_MIDI_FONT_SBLIMITS flag to enable the SB hardware limits on SF2 files (ignored on SFZ). It's applied automatically to the default SB soundfonts (28MBGM/CT8MGM/CT4MGM/CT2MGM.SF2), but only when they're used by default, ie. not with BASS_MIDI_FontInit. For some back-compatibility, BASS_MIDI_FontFlags will return BASS_MIDI_FONT_NOLIMITS when BASS_MIDI_FONT_SBLIMITS isn't set, so at least existing apps can know SB limits are disabled even if they didn't request it. Please let me know if you see any problems.