SOLVED
To get hardware midi going in chocolate-doom; edit i_sdlmusic.c to look like this part:
Code:
// 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;
}
Only problem is a doom.mid remains in the /tmp folder after closing chocolate-doom.
Make sure 128:0 is changed to your proper midi port; also, aplaymidi didn't loop songs on my end but pmidi worked fine.
If you don't have hardware midi; get really good midi playback and replace pmidi -p 128:0 with
Code:
timidity --no-realtime-load --no-trace --realtime-priority=1 --sequencer-ports=1 -A20,100 -EFvlpf=d -EFchorus=n -EFreverb=n -EFns=0 -EFresamp=g -a -N 34+1 -s 44100 --module=4 -q 0.1/0.1
You can change --module=4 (Roland SC-8850) to --module=1 for a roland sc-55 for authenticity sake. This gives really good midi playback and you won't even need a hardware player (rolands or sound blaster audigy not needed!). Pat sets will render correctly and soundfonts too with all effects. I have pat sets over several gigs in size that blow away real hardware modules and huge soundfonts, but sdl_mixer could never use them due to it's built in version of timidity which is really dated and broken. Timidity++ renders them absolutely fantastically and I don't know why sdl_mixer hasn't included it after more than a decade.
Linux users can have proper midi rendition in all sdl_mixer source ports of doom (or any game that uses sdl_mixer for midi) this way. Didn't know sdl_mixer had this function to call an external player and it's very simple! Just make sure Mix_SetMusicCmd is before Mix_LoadMUS.
It would be best to recognizing a variable (something standard like $MIDI; or $CHOCOLATE_DOOM_MIDI) to use whatever external player a user wants (pmidi, timidity++, etc.) instead of hard coding the desired program into i_sdlmusic.c but I'll leave this here for reference. Old timidity built into sdl_mixer should be kept out on all distributions.
All that's left is fixing the sound latency in chocolate-doom (they should add an option to change sound buffers in chocolate-setup).
EDIT:
Changed code to use environment variable $MIDI. This way you can do [code]export MIDI="nameofprogram options" to use whatever program you want, to process midi.
Here's how to do it for Eternity. Make the following section of sourcecode/source/sdl/i_sdlmusic.cpp to look like this:
Code:
// 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);
Someone also made a patch to make this work a slightly different way (used SDL_RWwrite to write a temporary midi file instead of M_WriteFile) but the patch fails on my end. Will post patch if it gets fixed.