From e2c105b4474063515c20a9c1c55501849feb7f91 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Sep 2010 00:35:47 +0000 Subject: [PATCH] - fixed: XMI music files were not converted for playback with FMod or Timidity++. - Was there any reason why the MIDI_GUS device was so well hidden from the user? It sure does not sound broken. Added it to MIDI menu and $mididevice. SVN r2862 (trunk) --- src/s_advsound.cpp | 1 + src/s_sound.h | 1 + src/sound/i_music.cpp | 6 ++- src/sound/music_midi_base.cpp | 75 +++++++++++++++-------------------- 4 files changed, 40 insertions(+), 43 deletions(-) diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index a2fa8ccd01..e6e7ce2a88 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -1295,6 +1295,7 @@ static void S_AddSNDINFO (int lump) else if (sc.Compare("opl")) MidiDevices[nm] = MDEV_OPL; else if (sc.Compare("default")) MidiDevices[nm] = MDEV_DEFAULT; else if (sc.Compare("fluidsynth")) MidiDevices[nm] = MDEV_FLUIDSYNTH; + else if (sc.Compare("gus")) MidiDevices[nm] = MDEV_GUS; else sc.ScriptError("Unknown MIDI device %s\n", sc.String); } break; diff --git a/src/s_sound.h b/src/s_sound.h index 05237ba271..5c2796d5b3 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -379,6 +379,7 @@ enum EMidiDevice MDEV_FMOD = 2, MDEV_TIMIDITY = 3, MDEV_FLUIDSYNTH = 4, + MDEV_GUS = 5, }; typedef TMap MidiDeviceMap; diff --git a/src/sound/i_music.cpp b/src/sound/i_music.cpp index ab8cd8f66c..52a4698e4d 100644 --- a/src/sound/i_music.cpp +++ b/src/sound/i_music.cpp @@ -527,7 +527,7 @@ MusInfo *I_RegisterSong (const char *filename, BYTE *musiccache, int offset, int { devtype = MIDI_OPL; } - else if (snd_mididevice == -4 && device == MDEV_DEFAULT) + else if (device == MDEV_GUS || (snd_mididevice == -4 && device == MDEV_DEFAULT)) { devtype = MIDI_GUS; } @@ -554,6 +554,10 @@ retry_as_fmod: { streamer = new MUSSong2(file, musiccache, len, MIDI_Null); } + else if (miditype == MIDI_XMI) + { + streamer = new XMISong(file, musiccache, len, MIDI_Null); + } else { assert(miditype == MIDI_HMI); diff --git a/src/sound/music_midi_base.cpp b/src/sound/music_midi_base.cpp index 97eb887083..2c8617c4ac 100644 --- a/src/sound/music_midi_base.cpp +++ b/src/sound/music_midi_base.cpp @@ -10,6 +10,34 @@ static DWORD nummididevices; static bool nummididevicesset; +#ifdef HAVE_FLUIDSYNTH +#define NUM_DEF_DEVICES 5 +#else +#define NUM_DEF_DEVICES 4 +#endif + +static void AddDefaultMidiDevices(FOptionValues *opt) +{ + int p; + FOptionValues::Pair *pair = &opt->mValues[opt->mValues.Reserve(NUM_DEF_DEVICES)]; +#ifdef HAVE_FLUIDSYNTH + pair[0].Text = "FluidSynth"; + pair[0].Value = -5.0; + p = 1; +#else + p = 0; +#endif + pair[p].Text = "GUS"; + pair[p].Value = -4.0; + pair[p+1].Text = "OPL Synth Emulation"; + pair[p+1].Value = -3.0; + pair[p+2].Text = "TiMidity++"; + pair[p+2].Value = -2.0; + pair[p+3].Text = "FMOD"; + pair[p+3].Value = -1.0; + +} + #ifdef _WIN32 UINT mididevice; @@ -71,29 +99,9 @@ void I_ShutdownMusicWin32 () } } -#ifdef HAVE_FLUIDSYNTH -#define NUM_DEF_DEVICES 4 -#else -#define NUM_DEF_DEVICES 3 -#endif void I_BuildMIDIMenuList (FOptionValues *opt) { - int p; - FOptionValues::Pair *pair = &opt->mValues[opt->mValues.Reserve(NUM_DEF_DEVICES)]; -#ifdef HAVE_FLUIDSYNTH - pair[0].Text = "FluidSynth"; - pair[0].Value = -5.0; - p = 1; -#else - p = 0; -#endif - pair[p].Text = "OPL Synth Emulation"; - pair[p].Value = -3.0; - pair[p+1].Text = "TiMidity++"; - pair[p+1].Value = -2.0; - pair[p+2].Text = "FMOD"; - pair[p+2].Value = -1.0; - + AddDefaultMidiDevices(opt); for (DWORD id = 0; id < nummididevices; ++id) { @@ -104,7 +112,7 @@ void I_BuildMIDIMenuList (FOptionValues *opt) assert(res == MMSYSERR_NOERROR); if (res == MMSYSERR_NOERROR) { - pair = &opt->mValues[opt->mValues.Reserve(1)]; + FOptionValues::Pair *pair = &opt->mValues[opt->mValues.Reserve(1)]; pair->Text = caps.szPname; pair->Value = (float)id; } @@ -156,6 +164,7 @@ CCMD (snd_listmididevices) #ifdef HAVE_FLUIDSYNTH PrintMidiDevice (-5, "FluidSynth", MOD_SWSYNTH, 0); #endif + PrintMidiDevice (-4, "GUS", 0, MOD_SWSYNTH); PrintMidiDevice (-3, "Emulated OPL FM Synth", MOD_FMSYNTH, 0); PrintMidiDevice (-2, "TiMidity++", 0, MOD_SWSYNTH); PrintMidiDevice (-1, "FMOD", 0, MOD_SWSYNTH); @@ -188,28 +197,9 @@ CUSTOM_CVAR(Int, snd_mididevice, -1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) self = -1; } -#ifdef HAVE_FLUIDSYNTH -#define NUM_DEF_DEVICES 4 -#else -#define NUM_DEF_DEVICES 3 -#endif void I_BuildMIDIMenuList (FOptionValues *opt) { - int p; - FOptionValues::Pair *pair = &opt->mValues[opt->mValues.Reserve(NUM_DEF_DEVICES)]; -#ifdef HAVE_FLUIDSYNTH - pair[0].Text = "FluidSynth"; - pair[0].Value = -5.0; - p = 1; -#else - p = 0; -#endif - pair[p].Text = "OPL Synth Emulation"; - pair[p].Value = -3.0; - pair[p+1].Text = "TiMidity++"; - pair[p+1].Value = -2.0; - pair[p+2].Text = "FMOD"; - pair[p+2].Value = -1.0; + AddDefaultMidiDevices(opt); } CCMD (snd_listmididevices) @@ -217,6 +207,7 @@ CCMD (snd_listmididevices) #ifdef HAVE_FLUIDSYNTH Printf("%s-5. FluidSynth\n", -5 == snd_mididevice ? TEXTCOLOR_BOLD : ""); #endif + Printf("%s-4. GUS\n", -4 == snd_mididevice ? TEXTCOLOR_BOLD : ""); Printf("%s-3. Emulated OPL FM Synth\n", -3 == snd_mididevice ? TEXTCOLOR_BOLD : ""); Printf("%s-2. TiMidity++\n", -2 == snd_mididevice ? TEXTCOLOR_BOLD : ""); Printf("%s-1. FMOD\n", -1 == snd_mididevice ? TEXTCOLOR_BOLD : "");