diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 0e692f311..4844aaae1 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,16 @@ +September 11, 2007 (Changes by Graf Zahl) +- fixed: The Timidity player didn't close its temporary files and left them + behind because it couldn't delete them. +- added a $MidiDevice option to SNDINFO which can either set the preferred + MIDI device for a song to Timidity or Windows' standard MIDI device. + The reason for this: About 80% of my MIDI music collection sounds better + with Timidity and the other 20% with Windows' standard synth and I'd like + to be able to use each with the one that sounds better. For MUS files you + can also force the use of OPL playback. + +September 8, 2007 (Changes by Graf Zahl) +- added telefrag option to A_SpawnItemEx. + September 5, 2007 (Changes by Graf Zahl) - Fixed: Several options while changing maps only worked for the regular exit but caused problems when used with the secret exit. Rewrote the code to diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index 6789a9a79..d9164d94b 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -141,6 +141,7 @@ enum SICommands SI_Registered, SI_ArchivePath, SI_MusicVolume, + SI_MidiDevice, SI_IfDoom, SI_IfHeretic, SI_IfHexen, @@ -178,6 +179,9 @@ struct FSavedPlayerSoundInfo bool alias; }; +// This specifies whether Timidity or Windows playback is preferred for a certain song (only useful for Windows.) +MidiDeviceMap MidiDevices; + // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- void S_StartNamedSound (AActor *ent, fixed_t *pt, int channel, @@ -231,6 +235,7 @@ static const char *SICommandStrings[] = "$registered", "$archivepath", "$musicvolume", + "$mididevice", "$ifdoom", "$ifheretic", "$ifhexen", @@ -1159,6 +1164,20 @@ static void S_AddSNDINFO (int lump) } break; + case SI_MidiDevice: { + SC_MustGetString(); + FName nm = sc_String; + int tim; + SC_MustGetString(); + if (SC_Compare("timidity")) tim = 1; + else if (SC_Compare("standard")) tim = 0; + else if (SC_Compare("opl")) tim = 2; + else if (SC_Compare("default")) tim = -1; + else SC_ScriptError("Unknown MIDI device %s\n", sc_String); + MidiDevices[nm]=tim; + } + break; + case SI_IfDoom: if (gameinfo.gametype != GAME_Doom) { diff --git a/src/s_sound.cpp b/src/s_sound.cpp index dc56434cd..c41556ca5 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -1539,6 +1539,11 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force) { int lumpnum = -1; int offset, length; + int device = -1; + + + int * devp = MidiDevices.CheckKey(FName(musicname)); + if (devp != NULL) device = *devp; if (!FileExists (musicname)) { @@ -1588,13 +1593,11 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force) { mus_playing.handle = I_RegisterSong (lumpnum != -1 ? Wads.GetWadFullName (Wads.GetLumpFile (lumpnum)) : - musicname, NULL, offset, length); + musicname, NULL, offset, length, device); } else { - // musiccache is used globally because otherwise I'd have to pass - // it as a parameter through several layers of code. - mus_playing.handle = I_RegisterSong (NULL, &musiccache[0], -1, length); + mus_playing.handle = I_RegisterSong (NULL, &musiccache[0], -1, length, device); } } diff --git a/src/s_sound.h b/src/s_sound.h index 919aa37cf..8ea9f0bf9 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -274,4 +274,8 @@ ReverbContainer *S_FindEnvironment (const char *name); ReverbContainer *S_FindEnvironment (int id); void S_AddEnvironment (ReverbContainer *settings); +typedef TMap MidiDeviceMap; + +extern MidiDeviceMap MidiDevices; + #endif diff --git a/src/sound/i_music.cpp b/src/sound/i_music.cpp index 9289b2e50..aed44e993 100644 --- a/src/sound/i_music.cpp +++ b/src/sound/i_music.cpp @@ -208,7 +208,7 @@ void I_UnRegisterSong (void *handle) } } -void *I_RegisterSong (const char *filename, char * musiccache, int offset, int len) +void *I_RegisterSong (const char *filename, char * musiccache, int offset, int len, int device) { FILE *file; MusInfo *info = NULL; @@ -254,18 +254,27 @@ void *I_RegisterSong (const char *filename, char * musiccache, int offset, int l // Check for MUS format if (id == MAKE_ID('M','U','S',0x1a)) { - if (GSnd != NULL && opl_enable) + if (GSnd != NULL && device != 0 && device != 1 && (opl_enable || device == 2) ) { info = new OPLMUSSong (file, musiccache, len); } if (info == NULL) { #ifdef _WIN32 - if (snd_mididevice != -2) + if (device == 1 && GSnd != NULL) + { + info = new TimiditySong (file, musiccache, len); + if (!info->IsValid()) + { + delete info; + info = NULL; + } + } + if (info == NULL && (snd_mididevice != -2 || device == 0)) { info = new MUSSong2 (file, musiccache, len); } - else if (GSnd != NULL) + else if (info == NULL && GSnd != NULL) #endif // _WIN32 { info = new TimiditySong (file, musiccache, len); @@ -277,11 +286,20 @@ void *I_RegisterSong (const char *filename, char * musiccache, int offset, int l { // This is a midi file #ifdef _WIN32 - if (snd_mididevice != -2) + if (device == 1 && GSnd != NULL) + { + info = new TimiditySong (file, musiccache, len); + if (!info->IsValid()) + { + delete info; + info = NULL; + } + } + if (info == NULL && (snd_mididevice != -2 || device == 0)) { info = new MIDISong2 (file, musiccache, len); } - else if (GSnd != NULL) + else if (info == NULL && GSnd != NULL) #endif // _WIN32 { info = new TimiditySong (file, musiccache, len); diff --git a/src/sound/i_music.h b/src/sound/i_music.h index 0a5587aaf..575910110 100644 --- a/src/sound/i_music.h +++ b/src/sound/i_music.h @@ -53,7 +53,7 @@ void I_PauseSong (void *handle); void I_ResumeSong (void *handle); // Registers a song handle to song data. -void *I_RegisterSong (const char *file, char * musiccache, int offset, int length); +void *I_RegisterSong (const char *file, char * musiccache, int offset, int length, int device); void *I_RegisterCDSong (int track, int cdid = 0); // Called by anything that wishes to start music. diff --git a/src/sound/music_midi_midiout.cpp b/src/sound/music_midi_midiout.cpp index 9bd9197c5..16767b3d4 100644 --- a/src/sound/music_midi_midiout.cpp +++ b/src/sound/music_midi_midiout.cpp @@ -176,7 +176,7 @@ void MIDISong2::Play (bool looping) // Find out if this an FM synth or not for EMIDI DesignationMask = 0xFF0F; - if (MMSYSERR_NOERROR == midiOutGetDevCaps (mididevice, &caps, sizeof(caps))) + if (MMSYSERR_NOERROR == midiOutGetDevCaps (mididevice<0? MIDI_MAPPER:mididevice, &caps, sizeof(caps))) { if (caps.wTechnology == MOD_FMSYNTH) { @@ -188,7 +188,7 @@ void MIDISong2::Play (bool looping) } } - if (MMSYSERR_NOERROR != midiOutOpen (&MidiOut, mididevice, 0, 0, CALLBACK_NULL)) + if (MMSYSERR_NOERROR != midiOutOpen (&MidiOut, mididevice<0? MIDI_MAPPER:mididevice, 0, 0, CALLBACK_NULL)) { Printf (PRINT_BOLD, "Could not open MIDI out device\n"); return; diff --git a/src/sound/music_midi_timidity.cpp b/src/sound/music_midi_timidity.cpp index a849ad84b..64e771407 100644 --- a/src/sound/music_midi_timidity.cpp +++ b/src/sound/music_midi_timidity.cpp @@ -213,9 +213,9 @@ TimiditySong::TimiditySong (FILE *file, char * musiccache, int len) { success = ProduceMIDI (buf, f); } + fclose (f); if (file!=NULL) { - fclose (f); delete[] buf; } diff --git a/src/sound/music_mus_midiout.cpp b/src/sound/music_mus_midiout.cpp index b1a3bf0c4..6cee79533 100644 --- a/src/sound/music_mus_midiout.cpp +++ b/src/sound/music_mus_midiout.cpp @@ -114,7 +114,7 @@ void MUSSong2::Play (bool looping) m_Status = STATE_Stopped; m_Looping = looping; - if (MMSYSERR_NOERROR != midiOutOpen (&MidiOut, mididevice, 0, 0, CALLBACK_NULL)) + if (MMSYSERR_NOERROR != midiOutOpen (&MidiOut, mididevice<0? MIDI_MAPPER:mididevice, 0, 0, CALLBACK_NULL)) { Printf (PRINT_BOLD, "Could not open MIDI out device\n"); return; diff --git a/src/thingdef_codeptr.cpp b/src/thingdef_codeptr.cpp index e375d0f20..65b7d426c 100644 --- a/src/thingdef_codeptr.cpp +++ b/src/thingdef_codeptr.cpp @@ -1451,7 +1451,8 @@ enum SIX_Flags SIXF_ABSOLUTEANGLE=4, SIXF_ABSOLUTEMOMENTUM=8, SIXF_SETMASTER=16, - SIXF_NOCHECKPOSITION=32 + SIXF_NOCHECKPOSITION=32, + SIXF_TELEFRAG=64 }; void A_SpawnItemEx(AActor * self) @@ -1520,6 +1521,7 @@ void A_SpawnItemEx(AActor * self) mo->momy=ymom; mo->momz=zmom; mo->angle=Angle; + if (flags & SIXF_TELEFRAG) P_TeleportMove(mo, mo->x, mo->y, mo->z, true); } } diff --git a/wadsrc/decorate/constants.txt b/wadsrc/decorate/constants.txt index c776c8c8f..779530240 100644 --- a/wadsrc/decorate/constants.txt +++ b/wadsrc/decorate/constants.txt @@ -12,6 +12,7 @@ const int SXF_ABSOLUTEANGLE=4; const int SXF_ABSOLUTEMOMENTUM=8; const int SXF_SETMASTER=16; const int SXF_NOCHECKPOSITION = 32; +const int SXF_TELEFRAG=64; // Flags for A_Chase const int CHF_FASTCHASE = 1;