Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Doomkid

Tutorial: Using Soundfonts for DOOM Midi Music

Recommended Posts

Created an account to thank you :) I was just looking for something like this yesterday.

 

Is there also a way to extract the MIDI signals (not sure what the correct name is) from wads so I can listen to them without launching doom?

Share this post


Link to post
14 minutes ago, auxo said:

Is there also a way to extract the MIDI signals (not sure what the correct name is) from wads so I can listen to them without launching doom?

MIDI music in Doom mods is typically either in MUS format or directly as standard MIDI files. Advanced music players can usually handle MUS files when they have their MIDI plugins, but you can also convert them to standard MIDI format with SLADE. Standard MIDI files obviously do not need conversion. In both cases, export them from the WAD with SLADE and there you go.

 

XMPlay can actually just open WADs directly if you get its WAD plugin. So with that and the MIDI plugin you don't even need to extract anything, you can just load the wad in XMPlay and listen to its soundtrack.

Share this post


Link to post
8 hours ago, Gez said:

MIDI music in Doom mods is typically either in MUS format or directly as standard MIDI files. Advanced music players can usually handle MUS files when they have their MIDI plugins, but you can also convert them to standard MIDI format with SLADE. Standard MIDI files obviously do not need conversion. In both cases, export them from the WAD with SLADE and there you go.

 

XMPlay can actually just open WADs directly if you get its WAD plugin. So with that and the MIDI plugin you don't even need to extract anything, you can just load the wad in XMPlay and listen to its soundtrack.

Thanks for the suggestions. I couldn't get the XMPlay WAD plugin to work, but I managed to extract the MIDI files using Slade. The MIDI plugin for XMPlay works like a charm so thanks for that. Now I can listen to the Eviternity soundtrack with some kickass drums :)

Share this post


Link to post

USING SOUNDFONTS IN LINUX

 

I figure here is a good place to post this. No video, sorry.

 

(This might also work for Mac users too, but I'm not sure. Most of this can be applied to Windows as well, with some changes, but you're really better off just using Virtual MIDI Synth.)

 

 

The short version

  1. Get this file, save it somewhere.
     
  2. Make sure you have Fluidsynth installed. The package is probably called 'fluidsynth'
     
  3. Edit ~/.bashrc with a text editor and add this line, then log out.
    export SDL_SOUNDFONTS=/full/path/to/soundfont/SC-55-fluidsynth.sf2

     

  4. For Chocolate and Crispy, run the setup program, and under Sound Configuration choose Native MIDI or MIDI/MP3/OGG/FLAC, depending on your version. Leave the 'Timidity configuration file' field blank.

    For PrBoom+, go to Options -> General, and set Preferred MIDI file player (at the bottom of the first page) to SDL.

    For other ports, probably set it like in PrBoom+.

    For GZDoom, copy the soundfont to ~/.config/gzdoom/soundfonts/ (make this directory first if it doesn't exist). Start GZDoom, set Options -> Sound Options -> MIDI device to Fluidsynth, then go to Advanced options -> Midi player options -> Fluidsynth and pick SC-55-fluidsynth
     
  5. If you want more soundfonts, try Doomkid's mega soundfont pack, but be aware that Fluidsynth could make some sound bad.

 

The long version:  A lot of words here, but only because I'm trying to be thorough.

 

Any port that uses SDL2 can use soundfonts via Fluidsynth. Unfortunately, Fluidsynth has some potentially major problems:

  • The defaults for its reverb and chorus effects are very strong. Chorus in particular makes any sounds that use it extremely loud.
  • You can't change these effects settings or even disable them unless the program calling fluidsynth (sdl2-mixer in this case) gives you an interface to do so.
  • The strength of these effects are applied based on the defaults set in the soundfont, instead of any settings set in MIDI files.
  • Fluidsynth is also pretty loud, which isn't a big deal but does get annoying with some loud MIDIs.

Despite this, it's still your best option for ports like Chocolate and Crispy Doom. So to work around those problems, you have some options:

 

  1. Use a soundfont that has the effects defaults low, or off. This is the easiest option.

    Here is a hacked version of one of the SC-55 soundfonts (Emperor Grieferus's I think) that has low reverb and no chorus, as well as lower volumes all around. Here is that soundfont with no reverb at all, if you prefer. Doomkid's soundfont list probably has a few others that will work OK, but I haven't tested them thoroughly.
     
  2. Edit a soundfont yourself to lower/eliminate the effects.

    Polyphone is a free and open-source soundfont editor that's quite easy to use. Most distributions should have it. I'm not going to include how to do this in this tutorial (yet?), but I didn't find it too hard to figure out. How easy it is to remove all the chorus/reverb values depends on the soundfont -- there are a lot of places to specify these values, and changing some of them is easier than others.

    If you do this, you might want to lower the volumes (increase the attenuation) of everything as well.
     
  3. Patch sdl2-mixer to have better default effect values.

    If you're comfortable doing this, here is the patch I use:
    Spoiler
    
    --- SDL2_mixer-2.0.4_orig/music_fluidsynth.c	2020-03-11 22:55:20.225265298 -0400
    +++ SDL2_mixer-2.0.4_hax/music_fluidsynth.c	2020-05-22 07:37:41.313632811 -0400
    @@ -165,6 +165,12 @@
                 if ((music->buffer = SDL_malloc(music->buffer_size))) {
                     if ((settings = fluidsynth.new_fluid_settings())) {
                         fluidsynth.fluid_settings_setnum(settings, "synth.sample-rate", (double) music_spec.freq);
    +                    fluidsynth.fluid_settings_setnum(settings, "synth.chorus.depth", (double) 5);
    +                    fluidsynth.fluid_settings_setnum(settings, "synth.chorus.level", (double) 0.35);
    +                    fluidsynth.fluid_settings_setnum(settings, "synth.reverb.damp", (double) 0.4);
    +                    fluidsynth.fluid_settings_setnum(settings, "synth.reverb.level", (double) 0.08);
    +                    fluidsynth.fluid_settings_setnum(settings, "synth.reverb.width", (double) 5);
    +                    fluidsynth.fluid_settings_setnum(settings, "synth.reverb.room-size", (double) 0.5);
     
                         if ((music->synth = fluidsynth.new_fluid_synth(settings))) {
                             if (Mix_EachSoundFont(fluidsynth_load_soundfont, (void*) music->synth)) {
    @@ -223,7 +229,7 @@
     {
         FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context;
         /* FluidSynth's default is 0.2. Make 1.2 the maximum. */
    -    fluidsynth.fluid_synth_set_gain(music->synth, (float) (volume * 1.2 / MIX_MAX_VOLUME));
    +    fluidsynth.fluid_synth_set_gain(music->synth, (float) (volume * 0.6 / MIX_MAX_VOLUME)); // new max 0.6
     }
     
     static int FLUIDSYNTH_Play(void *context, int play_count)

     


    I could also upload an Arch Linux package if someone wants, but I'm not really interested in making sure it stays up to date (sorry) so you might have a problem the next time it gets updated.

 

So, with all that out of the way, here's how you actually use a soundfont:

 

 

SDL2-based ports - Chocolate, Crispy, PrBoom+, Eternity, and pretty much anything else that's not based on ZDoom.

 

  1. Make sure you have Fluidsynth. 'fluidsynth' is probably the package name.
     
  2. Download a soundfont and set the SDL_SOUNDFONTS environment variable to point to it. There are a few ways to do this:

    * To set it permanently, edit your ~/.bashrc (or maybe ~/.bash_profile, depending on your system) and add this line. Logout and back in for it to take effect:
    export SDL_SOUNDFONTS=/full/path/to/soundfont.sf2


    * To set it temporarily (good for testing soundfonts), open up a console window and type the above line into a command-prompt, then run your Doom source port from the same prompt (once you've done step 3 below).
     

  3. Set your source port to use SDL for music playback.

    * For Chocolate and Crispy Doom, run the setup program, and under Sound Configuration choose Native MIDI or MIDI/MP3/OGG/FLAC, depending on your version. Leave the 'Timidity configuration file' field blank.

    * For PrBoom+, go to Options -> General, and set Preferred MIDI file player (at the bottom of the first page) to SDL.

    * For Eternity, go to Options -> Sound Options, and make sure Music Driver is SDL Mixer, and MIDI Device is default.

    * Other ports will probably have a similar choice of options. You might need to restart after setting the music device.
     
  4. If all has gone well, you'll now be using a soundfont for MIDI playback.

 

Use Fluidsynth directly - PrBoom+ and maybe others.

 

For PrBoom+, if you edit ~/.prboom-plus/prboom-plus.cfg, you can set the option 'snd_soundfont' to a soundfont directly and set 'snd_midiplayer' to "fluidsynth". Compared to using SDL2, this has the advantage of being able to shut off chorus and reverb with the mus_fluidsynth_chorus/mus_fluidsynth_reverb options, as well as adjusting mus_fluidsynth_gain. Recent devbuilds of PrBoom+ 2.5.1.7um will have reverb and chorus defaults that sound OK.

 

 

GZDoom and other ZDoom-based ports

 

GZDoom has a bunch of music player options that you can point directly to a soundfont. There are a lot of choices for music players and I'm honestly not sure if most users will need to do anything special to be able to use them. Here are some things that should work, though.

 

For recent versions of GZDoom, you can place soundfonts in one of GZDoom's default soundfont search paths, or edit gzdoom.ini to add another one.

Spoiler

 

[SoundfontSearch.Directories]

Path=$HOME/.config/gzdoom/soundfonts

Path=$HOME/.config/gzdoom/fm_banks

Path=/usr/share/gzdoom/soundfonts

Path=/usr/share/gzdoom/fm_banks

Path=/usr/local/share/doom/soundfonts

Path=/usr/local/share/doom/fm_banks

Path=/usr/local/share/games/doom/soundfonts

Path=/usr/local/share/games/doom/fm_banks

Path=/usr/share/doom/soundfonts

Path=/usr/share/doom/fm_banks

Path=/usr/share/games/doom/soundfonts

Path=/usr/share/games/doom/fm_banks

Path=/usr/share/soundfonts

 

 

Choose a MIDI device, usually either Timidity++ or Fluidsynth, under Options -> Sound Options, then go to Advanced options -> Midi player options -> [the MIDI device you chose] and pick a soundfont.

 

For older ports, you can get timidity++. Edit timidity's cfg file (probably either /etc/timidity++.cfg or /etc/timidity++/timidity.cfg or similar) and add this line:

soundfont /full/path/to/soundfont.sf2

and then you should be able to use that soundfont if you choose Timidity++ as your MIDI playback device.

 

Please let me know if you have any questions. MIDI playback on Linux can be fiddly and generally poorly documented; hopefully this covers everything relevant for Doom.

Share this post


Link to post

Great stuff, plums :D

 

What if I run FluidSynth daemonized? Is there a way to use ALSA instead, in Crispy Doom?

Share this post


Link to post

Can't setup soundfonts in FL Studio. What program shall I use?

 

Edit: wrongly understood the topic, move on.

Share this post


Link to post

Thanks for this, was very helpful. I had tried a couple weeks back to do this when I was going through TNT with that midi pack that released recently. I was comparing music with the old ones, specifically Lets Kill at Will and I noticed all the videos on youtube used a different much better sounding soundfont than I used and I thought "damn I've been robbed of this". Tried to use virtualmidisynth but didn't use it correctly and it didn't quite work so I abandoned that.


Even really good midis get a bit stale when I'm stuck on a map for a while, so it'll be really nice to switch those out to keep it fresh.

Share this post


Link to post

Yep!

 

Over time I've switched from Arachno to eawpats.sf2 (SHA1 18b70011ba5858764793f8d3a98307ac90341a9d) to briefly Musyng Kite and now am on SGM. It's good to be able to switch soundfonts :)

 

Anyway, my original question still stands. Does Crispy Doom even have alsa-seq support?

I know I wrote PRBoom UM-fork's :P </self-plug state="embarassment">

Share this post


Link to post

Oh wait, it uses SDL_mixer. That does have Timidity playback, which is blergh, and also redundant since I have a daemonized Fluidsynth anyways.

 

In my searches I found this brief mailing lists thread. My hopes are low for being able to use "native MIDI" – or honestly, more like just being able to plug it to another running program via ALSA, like Fluidsynth at all lol – but they're not null! Do let me know if you guys find anything of use.

 

Crispy Doom could also implement ALSA separately, but I do wonder how much would cross the line and be considered tampering and un-Doom-like...

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×