foo_midi icon indicating copy to clipboard operation
foo_midi copied to clipboard

XMF doesn't use the embedded DLS

Open spessasus opened this issue 9 months ago • 8 comments

Hi Peter, After implementing XMF support in my own synth, I found an issue with foo_midi when I was comparing my results to yours.

It seems that it doesn't use the embedded sound bank.

Take this for example, it uses piano instead of the embedded dr drums. This is for the Roll on file found in this folder.

https://github.com/user-attachments/assets/bc67de59-de4d-4db6-942c-92575ca87ac3

Tested on 2.17.2.0 under wine, as always.

spessasus avatar Mar 23 '25 01:03 spessasus

I know. None of the XMF with embedded DLS work because FluidSynth is the only player that supports DLS (until my SF2 converter is ready) and I can't get it to use the SoundFont.

I've already asked about it but didn't get a reply that was any help.

Using the same settings as with RMI does not work. You can hear it best with Streetwise.mxmf which plays an annoying telephone ring.

EDIT: It looks like a bug in FluidSynth.

This command:

.\fluidsynth.exe --no-midi-in --quiet -o synth.midi-bank-select=gm -v GM.dls "Roll on.dls" "Roll on.mid"

produces output but with the drum sounding like a piano.

This command:

.\fluidsynth.exe --no-midi-in --quiet -o synth.midi-bank-select=gm -v "Roll on.dls" "Roll on.mid"

produces no output at all. You'd at least expect to hear the drum on channel 15.

The embedded DLS has a very basic structure. Maybe the FluidSynth loader does not like it. There's no debug information when loading a DLS sound font.

Content Version: 0.0.0.0
1 instruments
   1. Regions:   2, Articulators:   1, Bank: CC0 0x00 CC32 0x01 (MMA     1), Program:   0, Is Percussion: false
2 waves
   1. Channels: 1, 24000 samples/s, 48000 avg. bytes/s, Block Align:     2
   2. Channels: 1, 24000 samples/s, 48000 avg. bytes/s, Block Align:     2
Info:
   1. Software: Mobile Sound Builder 1.2.0.14
   2. Creation Date: 2004-09-07
   3. Comments: 1 instruments.

stuerp avatar Mar 23 '25 07:03 stuerp

That's strange. For me, running this: fluidsynth --no-midi-in --quiet -o synth.midi-bank-select=gm -v htdocs/SpessaSynth/soundfonts/gm.dls Desktop/Unnamed\ DLS.dls Desktop/Roll\ on.mid plays the drums fine.

Also about the telephone: Spessasynth plays it too, and I'm sure that this is an indicator for the nokia's audio engine to trigger the vibration motor.

I recommend using this soundfont for testing as it replaces the telephone with a vibration sound and everything checks out.

Nokia_S30.zip

spessasus avatar Mar 23 '25 11:03 spessasus

That's strange. For me, running this: fluidsynth --no-midi-in --quiet -o synth.midi-bank-select=gm -v htdocs/SpessaSynth/soundfonts/gm.dls Desktop/Unnamed\ DLS.dls Desktop/Roll\ on.mid plays the drums fine.

Also about the telephone: Spessasynth plays it too, and I'm sure that this is an indicator for the nokia's audio engine to trigger the vibration motor.

I'm sure it's not. Here's a FLAC render of Streetwise.

Streetwise (2004 Version).zip

stuerp avatar Mar 23 '25 12:03 stuerp

Oh it absolutely is :)

I've compiled some nokia ringtone MIDIs for you. They all have these telephone vibrations.

Archive.zip

In fact, I've dug up an old nokia 100 of mine and I can confirm that for those ringtones that it has (like Destiny), the vibrations match up!

spessasus avatar Mar 23 '25 12:03 spessasus

Then why is the telephone ring not present in the FLAC file?

Making the phone vibrate could be a just a custom Nokia reaction to a particular MIDI event.

stuerp avatar Mar 23 '25 14:03 stuerp

I think you misunderstood me Peter.

What I meant to say is that the program change to the telephone tells the underlying audio engine that this channel is the vibration motor channel. It doesn't play any sounds through the speaker, every note-on on that channel triggers the vibration motor. Other MIDI players obviously don't have that special behavior so they just play the telephone sound. And this SoundFont I've attached just replaced that sound with a sound of a vibration motor to emulate the midi being played on the Nokia phone.

If you download the DLS file that Nokia phones use, you'll see that it lacks the telephone patch, as it represents vibration in the Nokia world.

spessasus avatar Mar 23 '25 14:03 spessasus

I think you misunderstood me Peter.

What I meant to say is that the program change to the telephone tells the underlying audio engine that this channel is the vibration motor channel. It doesn't play any sounds through the speaker, every note-on on that channel triggers the vibration motor. Other MIDI players obviously don't have that special behavior so they just play the telephone sound. And this SoundFont I've attached just replaced that sound with a sound of a vibration motor to emulate the midi being played on the Nokia phone.

If you download the DLS file that Nokia phones use, you'll see that it lacks the telephone patch, as it represents vibration in the Nokia world.

Got it.

stuerp avatar Mar 23 '25 14:03 stuerp

But still, roll on under the fluidsynth command you used works fine for me and the drums play.

spessasus avatar Mar 23 '25 21:03 spessasus

Please reopen this issue, there are no drums.

Tested on a fresh foobar install on windows 11, on v3.1.0.0-alpha1 which claims to fix this. Fluidsynth 2.4.7.

spessasus avatar Jul 21 '25 13:07 spessasus

I tried with another soundfont and you're right. The first soundfont drowned everything in synths. I get a drum if I change the offset to -1. But then all the other files with embedded DLS don't work. So this is unfixable.

stuerp avatar Jul 21 '25 15:07 stuerp

So maybe set offset to -1 only for XMF files?

spessasus avatar Jul 21 '25 18:07 spessasus

Possible but ugly. It's a good suggestion. It'll require some re-engineering because at that point I only have a stream of MIDI events, decoupled from the serialized format.

Through experimentation I found a couple of rules that work for BASS MIDI and FluidSynth but not yet for all files.

stuerp avatar Jul 21 '25 18:07 stuerp

I hacked it in the MIDI processor and now the FluidSynth player appears to play the drums.

Can you please check the next alpha when it becomes available?

stuerp avatar Jul 22 '25 19:07 stuerp

Alright, let me know when it's ready.

spessasus avatar Jul 22 '25 23:07 spessasus

https://github.com/stuerp/foo_midi/releases/tag/v3.1.0.0-alpha3 is available. But HTONIGHT.rmi also contains bank 2 selects which will still fallback to bank 0.

stuerp avatar Jul 23 '25 16:07 stuerp

I'm now getting

Decoding failure at 0:00.000 (Unknown exception): "Z:\home\spessasus\Desktop\GENERAL_MIDI\rmidi_midi_sf\DLS\HTONIGHT.rmi"

but this is probably because i can't get fluidsynth to work:

foo_midi failed to initialize FluidSynth: Failed to load FluidSynth library "%s": Module not found (0x0000007E)
foo_midi is enumerating VSTi plug-ins...
foo_midi found 1 compatible VSTi plug-ins.
foo_midi is enumerating CLAP plug-ins...
foo_midi is built with CLAP 1.2.6.
foo_midi
foo_midi found no compatible CLAP plug-ins.
foo_midi failed to initialize FluidSynth: Failed to load FluidSynth library "%s": Module not found (0x0000007E)
foo_midi is enumerating VSTi plug-ins...
foo_midi found 1 compatible VSTi plug-ins.
foo_midi is enumerating CLAP plug-ins...
foo_midi is built with CLAP 1.2.6.
foo_midi
foo_midi found no compatible CLAP plug-ins.

Even though I've set path to fluidsynth 2.4.7 x64: Z:\home\spessasus\Music\fluid\x64\bin And the foobar is x64 as well. What can I do?

spessasus avatar Jul 24 '25 13:07 spessasus

The library loading code has not been changed for quite some time. There's obviously an error in the error message. Can you try with an older FluidSynth release 2.4.5 perhaps? Is the SDL3.dll in your search path?

stuerp avatar Jul 24 '25 14:07 stuerp

2.4.5 does not work either. (same error) What's interesting is that syxg50 and secret sauce both work, so foobar can load executables just fine.

spessasus avatar Jul 24 '25 17:07 spessasus

Any progress? Did you manage to get FluidSynth loading?

stuerp avatar Aug 02 '25 17:08 stuerp

No, I'm still getting 0x0000007E. Latest alpha6. Secret Sayce and Yamaha VST still work without a problem.

spessasus avatar Aug 02 '25 18:08 spessasus

FluidSynth does not find the necessary presets. That's why you hear a piano:

foo_midi FluidSynth warning: Instrument not found on channel 3 [bank=2 prog=0], substituted [bank=0 prog=0]
foo_midi FluidSynth warning: Instrument not found on channel 3 [bank=2 prog=0], substituted [bank=0 prog=0]
foo_midi FluidSynth warning: Instrument not found on channel 4 [bank=2 prog=1], substituted [bank=0 prog=1]
foo_midi FluidSynth warning: Instrument not found on channel 4 [bank=2 prog=1], substituted [bank=0 prog=1]

stuerp avatar Aug 04 '25 16:08 stuerp

I have managed to get it working and roll on works fine now, however HTONIGHT still does not work.

I've looked at swami project which is an sf2/dls editor based on the same library that fluidsynth is using for dls (libinstpatch) and even has the same authors (I think) and it seems to read the bank numbers correctly? Hm, can you check as well?

spessasus avatar Aug 09 '25 13:08 spessasus

I wrote my own parser:

Content Version: 0.0.0.0
10 instruments
   1. Regions:   1, Articulators:   0, Bank: CC0 0x01 CC32 0x00 (MMA   128), Program:   1, Is Percussion: false, Name: "sinte"
    Regions:
      MIDI Key:   0 - 127, Velocity:   0 - 127, Options: 0x0000, Key Group: 0, Zone: 1
    Articulators:
   2. Regions:   1, Articulators:   0, Bank: CC0 0x01 CC32 0x00 (MMA   128), Program:   0, Is Percussion: false, Name: "house tonight 22kHz"
    Regions:
      MIDI Key:   0 - 127, Velocity:   0 - 127, Options: 0x0000, Key Group: 0, Zone: 1
    Articulators:
   3. Regions:   1, Articulators:   0, Bank: CC0 0x00 CC32 0x00 (MMA     0), Program:  10, Is Percussion: false, Name: "SYNTH4"
    Regions:
      MIDI Key:  12 - 107, Velocity:   0 - 127, Options: 0x0000, Key Group: 0, Zone: 1
    Articulators:
   4. Regions:   1, Articulators:   0, Bank: CC0 0x00 CC32 0x00 (MMA     0), Program:   6, Is Percussion: false, Name: "BASE4"
    Regions:
      MIDI Key:  12 - 107, Velocity:   0 - 127, Options: 0x0000, Key Group: 0, Zone: 1
    Articulators:
   5. Regions:   1, Articulators:   0, Bank: CC0 0x00 CC32 0x00 (MMA     0), Program:   5, Is Percussion: false, Name: "BASE3"
    Regions:
      MIDI Key:  12 - 107, Velocity:   0 - 127, Options: 0x0000, Key Group: 0, Zone: 1
    Articulators:
   6. Regions:   1, Articulators:   0, Bank: CC0 0x00 CC32 0x00 (MMA     0), Program:   4, Is Percussion: false, Name: "SNARE"
    Regions:
      MIDI Key:  12 - 107, Velocity:   0 - 127, Options: 0x0000, Key Group: 0, Zone: 1
    Articulators:
   7. Regions:   1, Articulators:   0, Bank: CC0 0x00 CC32 0x00 (MMA     0), Program:   3, Is Percussion: false, Name: "HIHAT-O"
    Regions:
      MIDI Key:  12 - 107, Velocity:   0 - 127, Options: 0x0000, Key Group: 0, Zone: 1
    Articulators:
   8. Regions:   1, Articulators:   0, Bank: CC0 0x00 CC32 0x00 (MMA     0), Program:   2, Is Percussion: false, Name: "SYNTH"
    Regions:
      MIDI Key:  12 - 107, Velocity:   0 - 127, Options: 0x0000, Key Group: 0, Zone: 1
    Articulators:
   9. Regions:   1, Articulators:   0, Bank: CC0 0x00 CC32 0x00 (MMA     0), Program:   1, Is Percussion: false, Name: "BASE2"
    Regions:
      MIDI Key:  12 - 107, Velocity:   0 - 127, Options: 0x0000, Key Group: 0, Zone: 1
    Articulators:
  10. Regions:   1, Articulators:   0, Bank: CC0 0x00 CC32 0x00 (MMA     0), Program:   0, Is Percussion: false, Name: "BASE"
    Regions:
      MIDI Key:  12 - 107, Velocity:   0 - 127, Options: 0x0000, Key Group: 0, Zone: 1
    Articulators:

10 waves
   1. Channels: 1, 22050 samples/s, 44100 avg. bytes/s, Block Align:     1, Name: "sample 1"
   2. Channels: 1, 44100 samples/s, 88200 avg. bytes/s, Block Align:     1, Name: "Rave Organ:0"
   3. Channels: 1, 44100 samples/s, 88200 avg. bytes/s, Block Align:     1, Name: "BASE"
   4. Channels: 1, 44100 samples/s, 88200 avg. bytes/s, Block Align:     1, Name: "BASE2"
   5. Channels: 1, 44100 samples/s, 88200 avg. bytes/s, Block Align:     1, Name: "SYNTH"
   6. Channels: 1, 44100 samples/s, 88200 avg. bytes/s, Block Align:     1, Name: "HIHAT-O"
   7. Channels: 1, 44100 samples/s, 88200 avg. bytes/s, Block Align:     1, Name: "SNARE"
   8. Channels: 1, 44100 samples/s, 88200 avg. bytes/s, Block Align:     1, Name: "BASE3"
   9. Channels: 1, 44100 samples/s, 88200 avg. bytes/s, Block Align:     1, Name: "BASE4"
  10. Channels: 1, 44100 samples/s, 88200 avg. bytes/s, Block Align:     1, Name: "SYNTH4"

Properties:
   1. Name: HTONIGHT
   2. Software: Awave Studio v8.8

stuerp avatar Aug 09 '25 19:08 stuerp

I meant that taking a look at swami could possibly reveal why fluidsynth refuses to acknowledge some of the presets, as they share the DLS parser.

f you want to explore and edit DLS files or RMIDIs, you can do that with SpessaFont, a sound bank editor I made :-)

Image

spessasus avatar Aug 09 '25 22:08 spessasus

I was working with Tom from FluidSynth on another issue with probably the same cause:

16:06:27:070	[118391ms] foo_midi FluidSynth warning: Instrument '1081 Saw Wave': Some invalid generators were discarded
16:06:27:070	[118391ms] foo_midi FluidSynth warning: Instrument 'D056 SFX kit': Some invalid generators were discarded
16:06:27:070	[118407ms] foo_midi FluidSynth warning: Instrument '8081 Saw Wave': Some invalid generators were discarded

These are 3 presets that are ignored by FluidSynth because the generator list does not follow the specs. Tom likes to keep FluidSynth very strict. It's probably a common error in the generator list: the spec says that keyRange should be the first generator if it is present. A lot of sound fonts don't follow that rule.

I have a better grasp of the in-memory SoundFont layout now so I can proceed with the DLS to SF2 conversion.

stuerp avatar Aug 20 '25 14:08 stuerp

I'm not sure what you mean by the key range generator. DLS does not have generators, the closest things to it are the articulators, where the key and velocity ranges are defined in the region header I believe.

spessasus avatar Aug 20 '25 15:08 spessasus

They must have been generated during the DLS to SF2 conversion. I don't know for sure because there's no way to save the converted soundfont.

stuerp avatar Aug 20 '25 18:08 stuerp

The first smoke test has been passed: BASSMIDI uses the converted embedded and external DLS sound fonts. 18 months in the making!

stuerp avatar Aug 27 '25 17:08 stuerp

https://github.com/stuerp/foo_midi/releases/tag/v3.2.0.0-alpha1 with custom DLS support for BASSMIDI and FluidSynth plays all test cases correctly AFAICT.

stuerp avatar Aug 30 '25 13:08 stuerp

3 things I've tested:

  • HTONIGHT works fine now, including the voice!
  • Blue Ice and Roll on XMF files still do not work. They still use piano instead of drums (like in the recording). I've selected BASSMIDI with Use DLS set to on as fluidsynth still isn't available. I've confirmed that it's BASSMIDI that's playing the files as it responds to a few sysEx messages that fluidsynth ignores.
  • I can't put a dls file into the "Soundfont" in the "paths" section. Which is a shame because I'd like to test your converter :-)

spessasus avatar Sep 01 '25 14:09 spessasus