- 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.
- added telefrag option to A_SpawnItemEx.


SVN r545 (trunk)
This commit is contained in:
Christoph Oelckers 2007-09-12 00:20:11 +00:00
parent d0c3ebb5c2
commit e8875041ca
11 changed files with 76 additions and 16 deletions

View file

@ -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

View file

@ -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)
{

View file

@ -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);
}
}

View file

@ -274,4 +274,8 @@ ReverbContainer *S_FindEnvironment (const char *name);
ReverbContainer *S_FindEnvironment (int id);
void S_AddEnvironment (ReverbContainer *settings);
typedef TMap<FName, int> MidiDeviceMap;
extern MidiDeviceMap MidiDevices;
#endif

View file

@ -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);

View file

@ -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.

View file

@ -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;

View file

@ -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;
}

View file

@ -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;

View file

@ -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);
}
}

View file

@ -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;