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

How to add improved midi support to chocolate-doom and eternity (and other ports)!

Recommended Posts

         // Load the MIDI

        Mix_SetMusicCMD(getenv("MIDI"));
        music = Mix_LoadMUS(filename);
        if (music == NULL)
        {
            // Failed to load

            fprintf(stderr, "Error loading midi: %s\n", Mix_GetError());
        }

        // remove file now

    //    remove(filename);

    //    Z_Free(filename);

        return music;
    } 

Thanks Fraggle! Now Eternity needs something like this...

EDIT:
Thanks to Quasar I figured out how to get Eternity to do the same. Here's eternity/source/sdl/i_sdlmusic.cpp where it should like this this:
   // Try SDL_mixer locally
//   rw    = SDL_RWFromMem(data, size);
   M_WriteFile("/tmp/doom.mid", data, size);
   char *filename = NULL;
   Mix_SetMusicCMD(getenv("MIDI"));
   filename = "/tmp/doom.mid";
   music = Mix_LoadMUS(filename);
//   music = Mix_LoadMUS_RW(rw);
MP2E submitted a great patch that should make it easier to do the abov e (haven't tried it and don't know if it'll work building for Windows). http://www.mediafire.com/download/k8f1b2tw2do46ey/eternity_sound.tar.xz

Basically what this does, is allow users to forward the midi tracks to an external command line midi player. This does wonders for Linux users because sdl_mixer always defaults to it's built-in version of timidity which is really dated and broken (doesn't render pat sets properly or midi for that matter, and users can't choose anything else to render the midi which totally isn't right; especially when you can't use hardware midi which you can using this code); there's also the newer version of sdl_mixer, 1.2.12, which can have the fluidsynth soundfont backend built-in but for some reason that also doesn't work right (panning, envelopes, reverb, chorus, mapping, and other stuff is borked!). For Windows, users should be able to call an external program such as timidity.exe so users get the full benefit of timidity++ or any other command line midi synthesizer. Sdl_mixer on Windows defaults to Windows General Midi so using timidity++ via midi yoke doesn't work; that's where this code can avoid those problems. A Windows front-end for Chocolate-doom, Eternity, or any source port with sdl_mixer that can use this code, can make the command line easier to handle for users; Linux and Mac OS users too. Haven't tried building Windows executable's with this code however, and the filename should be adjusted for Windows; built Linux binaries fine however.


Here's what sdl_mixer sounds like when using it's built-in method of handling midi (it uses an ancient and broken version of timidity):
http://speedy.sh/gYrVd/e1m1-portmidi.ogg
http://speedy.sh/ja3dE/e1m1-sdlmixer.ogg
http://speedy.sh/bTDEM/map02-portmidi.ogg
http://speedy.sh/GsvMH/map02-sdlmixer.ogg

Here's some ogg samples I recorded using eternity revision 2570 using the above code with MIDI="timidity -A20,100"; I'm also using the exact same pat set here but forgot to record the same tracks (you can still probably tell how much better and FIXED it sounds):
e5m1 http://speedy.sh/euJca/e5m1-external-timidity.ogg
e5m2 http://speedy.sh/XQ28T/e5m2-external-timidity.ogg
e5m3 http://speedy.sh/cyeqs/e5m3-external-timidity.ogg
e5m8 http://speedy.sh/8BXFJ/e5m8-external-timidity.ogg

Only downside is there's a temporary file left over after closing chocolate-doom and/or eternity. And there's a small pause when a song changes. These issues can probably get fixed but they're not a big deal anyway.

I can swap around pat sets and use a Sega Genesis/32x or Super Nintendo pat set now, to make Doom music sound more interesting :P

Share this post


Link to post

Was able to get help from Fraggle and Quasar to do what's mentioned in my first post. Want to share this so people can use whatever the heck they want for midi when playing their Doom games; and to avoid sdl_mixer's broken and awful midi backends and default choices. This code should work on every source port that uses sdl_mixer which is practically all of them.

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
×