mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-18 15:42:34 +00:00
- extended $mididevice to add an optional parameter, which has the following meaning for the different MIDI devices:
* OPL: specify the core to use for playing this song * FluidSynth: specify a soundfont that should be used for playing the song. * WildMidi: specify a config file that should be used for playing the song. * Timidity++: specify an executable that should be used for playing the song. At least under Windows this allows using Timidity++ with different configs if the executable and each single config are placed in different directories. * GUS: currently not operational, but should later also specify the config. This will need some work, because right now this is initialized only when the sound system is initialized. * all other: no function. These options should mainly be for end users who want to fine-tune how to play the music.
This commit is contained in:
parent
1316120fe4
commit
5e975ac9f6
21 changed files with 135 additions and 79 deletions
|
@ -48,6 +48,7 @@
|
||||||
#define HALF_PI (PI*0.5)
|
#define HALF_PI (PI*0.5)
|
||||||
|
|
||||||
EXTERN_CVAR(Int, opl_core)
|
EXTERN_CVAR(Int, opl_core)
|
||||||
|
extern int current_opl_core;
|
||||||
|
|
||||||
OPLio::~OPLio()
|
OPLio::~OPLio()
|
||||||
{
|
{
|
||||||
|
@ -323,7 +324,7 @@ int OPLio::OPLinit(uint numchips, bool stereo, bool initopl3)
|
||||||
{
|
{
|
||||||
assert(numchips >= 1 && numchips <= countof(chips));
|
assert(numchips >= 1 && numchips <= countof(chips));
|
||||||
uint i;
|
uint i;
|
||||||
IsOPL3 = (opl_core == 1 || opl_core == 2 || opl_core == 3);
|
IsOPL3 = (current_opl_core == 1 || current_opl_core == 2 || current_opl_core == 3);
|
||||||
|
|
||||||
memset(chips, 0, sizeof(chips));
|
memset(chips, 0, sizeof(chips));
|
||||||
if (IsOPL3)
|
if (IsOPL3)
|
||||||
|
@ -332,7 +333,7 @@ int OPLio::OPLinit(uint numchips, bool stereo, bool initopl3)
|
||||||
}
|
}
|
||||||
for (i = 0; i < numchips; ++i)
|
for (i = 0; i < numchips; ++i)
|
||||||
{
|
{
|
||||||
OPLEmul *chip = IsOPL3 ? (opl_core == 1 ? DBOPLCreate(stereo) : (opl_core == 2 ? JavaOPLCreate(stereo) : NukedOPL3Create(stereo))) : YM3812Create(stereo);
|
OPLEmul *chip = IsOPL3 ? (current_opl_core == 1 ? DBOPLCreate(stereo) : (current_opl_core == 2 ? JavaOPLCreate(stereo) : NukedOPL3Create(stereo))) : YM3812Create(stereo);
|
||||||
if (chip == NULL)
|
if (chip == NULL)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
|
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
|
||||||
|
void OPL_SetCore(const char *args);
|
||||||
|
|
||||||
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
|
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
|
||||||
|
|
||||||
|
@ -76,8 +77,9 @@ CVAR(Bool, opl_fullpan, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
OPLMIDIDevice::OPLMIDIDevice()
|
OPLMIDIDevice::OPLMIDIDevice(const char *args)
|
||||||
{
|
{
|
||||||
|
OPL_SetCore(args);
|
||||||
FullPan = opl_fullpan;
|
FullPan = opl_fullpan;
|
||||||
FWadLump data = Wads.OpenLumpName("GENMIDI");
|
FWadLump data = Wads.OpenLumpName("GENMIDI");
|
||||||
OPLloadBank(data);
|
OPLloadBank(data);
|
||||||
|
|
|
@ -262,6 +262,7 @@ protected:
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
OPLDumperMIDIDevice::OPLDumperMIDIDevice(const char *filename)
|
OPLDumperMIDIDevice::OPLDumperMIDIDevice(const char *filename)
|
||||||
|
: OPLMIDIDevice(NULL)
|
||||||
{
|
{
|
||||||
// Replace the standard OPL device with a disk writer.
|
// Replace the standard OPL device with a disk writer.
|
||||||
delete io;
|
delete io;
|
||||||
|
|
|
@ -1364,16 +1364,36 @@ static void S_AddSNDINFO (int lump)
|
||||||
case SI_MidiDevice: {
|
case SI_MidiDevice: {
|
||||||
sc.MustGetString();
|
sc.MustGetString();
|
||||||
FName nm = sc.String;
|
FName nm = sc.String;
|
||||||
|
FScanner::SavedPos save = sc.SavePos();
|
||||||
|
|
||||||
|
sc.SetCMode(true);
|
||||||
sc.MustGetString();
|
sc.MustGetString();
|
||||||
if (sc.Compare("timidity")) MidiDevices[nm] = MDEV_TIMIDITY;
|
MidiDeviceSetting devset;
|
||||||
else if (sc.Compare("fmod") || sc.Compare("sndsys")) MidiDevices[nm] = MDEV_SNDSYS;
|
if (sc.Compare("timidity")) devset.device = MDEV_TIMIDITY;
|
||||||
else if (sc.Compare("standard")) MidiDevices[nm] = MDEV_MMAPI;
|
else if (sc.Compare("fmod") || sc.Compare("sndsys")) devset.device = MDEV_SNDSYS;
|
||||||
else if (sc.Compare("opl")) MidiDevices[nm] = MDEV_OPL;
|
else if (sc.Compare("standard")) devset.device = MDEV_MMAPI;
|
||||||
else if (sc.Compare("default")) MidiDevices[nm] = MDEV_DEFAULT;
|
else if (sc.Compare("opl")) devset.device = MDEV_OPL;
|
||||||
else if (sc.Compare("fluidsynth")) MidiDevices[nm] = MDEV_FLUIDSYNTH;
|
else if (sc.Compare("default")) devset.device = MDEV_DEFAULT;
|
||||||
else if (sc.Compare("gus")) MidiDevices[nm] = MDEV_GUS;
|
else if (sc.Compare("fluidsynth")) devset.device = MDEV_FLUIDSYNTH;
|
||||||
else if (sc.Compare("wildmidi")) MidiDevices[nm] = MDEV_WILDMIDI;
|
else if (sc.Compare("gus")) devset.device = MDEV_GUS;
|
||||||
|
else if (sc.Compare("wildmidi")) devset.device = MDEV_WILDMIDI;
|
||||||
else sc.ScriptError("Unknown MIDI device %s\n", sc.String);
|
else sc.ScriptError("Unknown MIDI device %s\n", sc.String);
|
||||||
|
|
||||||
|
if (sc.CheckString(","))
|
||||||
|
{
|
||||||
|
sc.SetCMode(false);
|
||||||
|
sc.MustGetString();
|
||||||
|
devset.args = sc.String;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// This does not really do what one might expect, because the next token has already been parsed and can be a '$'.
|
||||||
|
// So in order to continue parsing without C-Mode, we need to reset and parse the last token again.
|
||||||
|
sc.SetCMode(false);
|
||||||
|
sc.RestorePos(save);
|
||||||
|
sc.MustGetString();
|
||||||
|
}
|
||||||
|
MidiDevices[nm] = devset;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -2421,11 +2421,8 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
|
||||||
{
|
{
|
||||||
int lumpnum = -1;
|
int lumpnum = -1;
|
||||||
int length = 0;
|
int length = 0;
|
||||||
int device = MDEV_DEFAULT;
|
|
||||||
MusInfo *handle = NULL;
|
MusInfo *handle = NULL;
|
||||||
|
MidiDeviceSetting *devp = MidiDevices.CheckKey(musicname);
|
||||||
int *devp = MidiDevices.CheckKey(musicname);
|
|
||||||
if (devp != NULL) device = *devp;
|
|
||||||
|
|
||||||
// Strip off any leading file:// component.
|
// Strip off any leading file:// component.
|
||||||
if (strncmp(musicname, "file://", 7) == 0)
|
if (strncmp(musicname, "file://", 7) == 0)
|
||||||
|
@ -2495,7 +2492,7 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mus_playing.handle = I_RegisterSong (reader, device);
|
mus_playing.handle = I_RegisterSong (reader, devp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -397,8 +397,19 @@ enum EMidiDevice
|
||||||
MDEV_WILDMIDI = 6,
|
MDEV_WILDMIDI = 6,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct MidiDeviceSetting
|
||||||
|
{
|
||||||
|
int device;
|
||||||
|
FString args;
|
||||||
|
|
||||||
|
MidiDeviceSetting()
|
||||||
|
{
|
||||||
|
device = MDEV_DEFAULT;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
typedef TMap<FName, FName> MusicAliasMap;
|
typedef TMap<FName, FName> MusicAliasMap;
|
||||||
typedef TMap<FName, int> MidiDeviceMap;
|
typedef TMap<FName, MidiDeviceSetting> MidiDeviceMap;
|
||||||
|
|
||||||
extern MusicAliasMap MusicAliases;
|
extern MusicAliasMap MusicAliases;
|
||||||
extern MidiDeviceMap MidiDevices;
|
extern MidiDeviceMap MidiDevices;
|
||||||
|
|
|
@ -311,21 +311,21 @@ MusInfo *MusInfo::GetWaveDumper(const char *filename, int rate)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
static MIDIStreamer *CreateMIDIStreamer(FileReader &reader, EMidiDevice devtype, EMIDIType miditype)
|
static MIDIStreamer *CreateMIDIStreamer(FileReader &reader, EMidiDevice devtype, EMIDIType miditype, const char *args)
|
||||||
{
|
{
|
||||||
switch (miditype)
|
switch (miditype)
|
||||||
{
|
{
|
||||||
case MIDI_MUS:
|
case MIDI_MUS:
|
||||||
return new MUSSong2(reader, devtype);
|
return new MUSSong2(reader, devtype, args);
|
||||||
|
|
||||||
case MIDI_MIDI:
|
case MIDI_MIDI:
|
||||||
return new MIDISong2(reader, devtype);
|
return new MIDISong2(reader, devtype, args);
|
||||||
|
|
||||||
case MIDI_HMI:
|
case MIDI_HMI:
|
||||||
return new HMISong(reader, devtype);
|
return new HMISong(reader, devtype, args);
|
||||||
|
|
||||||
case MIDI_XMI:
|
case MIDI_XMI:
|
||||||
return new XMISong(reader, devtype);
|
return new XMISong(reader, devtype, args);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -387,7 +387,7 @@ static EMIDIType IdentifyMIDIType(DWORD *id, int size)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
MusInfo *I_RegisterSong (FileReader *reader, int device)
|
MusInfo *I_RegisterSong (FileReader *reader, MidiDeviceSetting *device)
|
||||||
{
|
{
|
||||||
MusInfo *info = NULL;
|
MusInfo *info = NULL;
|
||||||
const char *fmt;
|
const char *fmt;
|
||||||
|
@ -405,12 +405,6 @@ MusInfo *I_RegisterSong (FileReader *reader, int device)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
// non-Windows platforms don't support MDEV_MMAPI so map to MDEV_SNDSYS
|
|
||||||
if (device == MDEV_MMAPI)
|
|
||||||
device = MDEV_SNDSYS;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Check for gzip compression. Some formats are expected to have players
|
// Check for gzip compression. Some formats are expected to have players
|
||||||
// that can handle it, so it simplifies things if we make all songs
|
// that can handle it, so it simplifies things if we make all songs
|
||||||
// gzippable.
|
// gzippable.
|
||||||
|
@ -447,10 +441,15 @@ MusInfo *I_RegisterSong (FileReader *reader, int device)
|
||||||
EMIDIType miditype = IdentifyMIDIType(id, sizeof(id));
|
EMIDIType miditype = IdentifyMIDIType(id, sizeof(id));
|
||||||
if (miditype != MIDI_NOTMIDI)
|
if (miditype != MIDI_NOTMIDI)
|
||||||
{
|
{
|
||||||
EMidiDevice devtype = (EMidiDevice)device;
|
EMidiDevice devtype = device == NULL? MDEV_DEFAULT : (EMidiDevice)device->device;
|
||||||
|
#ifndef _WIN32
|
||||||
|
// non-Windows platforms don't support MDEV_MMAPI so map to MDEV_SNDSYS
|
||||||
|
if (devtype == MDEV_MMAPI)
|
||||||
|
devtype = MDEV_SNDSYS;
|
||||||
|
#endif
|
||||||
|
|
||||||
retry_as_sndsys:
|
retry_as_sndsys:
|
||||||
info = CreateMIDIStreamer(*reader, devtype, miditype);
|
info = CreateMIDIStreamer(*reader, devtype, miditype, device != NULL? device->args.GetChars() : "");
|
||||||
if (info != NULL && !info->IsValid())
|
if (info != NULL && !info->IsValid())
|
||||||
{
|
{
|
||||||
delete info;
|
delete info;
|
||||||
|
@ -464,7 +463,7 @@ retry_as_sndsys:
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (info == NULL && devtype != MDEV_MMAPI && snd_mididevice >= 0)
|
if (info == NULL && devtype != MDEV_MMAPI && snd_mididevice >= 0)
|
||||||
{
|
{
|
||||||
info = CreateMIDIStreamer(*reader, MDEV_MMAPI, miditype);
|
info = CreateMIDIStreamer(*reader, MDEV_MMAPI, miditype, "");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -475,7 +474,7 @@ retry_as_sndsys:
|
||||||
(id[0] == MAKE_ID('D','B','R','A') && id[1] == MAKE_ID('W','O','P','L')) || // DosBox Raw OPL
|
(id[0] == MAKE_ID('D','B','R','A') && id[1] == MAKE_ID('W','O','P','L')) || // DosBox Raw OPL
|
||||||
(id[0] == MAKE_ID('A','D','L','I') && *((BYTE *)id + 4) == 'B')) // Martin Fernandez's modified IMF
|
(id[0] == MAKE_ID('A','D','L','I') && *((BYTE *)id + 4) == 'B')) // Martin Fernandez's modified IMF
|
||||||
{
|
{
|
||||||
info = new OPLMUSSong (*reader);
|
info = new OPLMUSSong (*reader, device != NULL? device->args.GetChars() : "");
|
||||||
}
|
}
|
||||||
// Check for game music
|
// Check for game music
|
||||||
else if ((fmt = GME_CheckFormat(id[0])) != NULL && fmt[0] != '\0')
|
else if ((fmt = GME_CheckFormat(id[0])) != NULL && fmt[0] != '\0')
|
||||||
|
|
|
@ -53,7 +53,8 @@ void I_SetMusicVolume (float volume);
|
||||||
|
|
||||||
// Registers a song handle to song data.
|
// Registers a song handle to song data.
|
||||||
class MusInfo;
|
class MusInfo;
|
||||||
MusInfo *I_RegisterSong (FileReader *reader, int device);
|
struct MidiDeviceSetting;
|
||||||
|
MusInfo *I_RegisterSong (FileReader *reader, MidiDeviceSetting *device);
|
||||||
MusInfo *I_RegisterCDSong (int track, int cdid = 0);
|
MusInfo *I_RegisterCDSong (int track, int cdid = 0);
|
||||||
MusInfo *I_RegisterURLSong (const char *url);
|
MusInfo *I_RegisterURLSong (const char *url);
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,7 @@ public:
|
||||||
class TimidityPPMIDIDevice : public PseudoMIDIDevice
|
class TimidityPPMIDIDevice : public PseudoMIDIDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TimidityPPMIDIDevice();
|
TimidityPPMIDIDevice(const char *args);
|
||||||
~TimidityPPMIDIDevice();
|
~TimidityPPMIDIDevice();
|
||||||
|
|
||||||
int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
|
int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
|
||||||
|
@ -270,7 +270,7 @@ protected:
|
||||||
class OPLMIDIDevice : public SoftSynthMIDIDevice, protected OPLmusicBlock
|
class OPLMIDIDevice : public SoftSynthMIDIDevice, protected OPLmusicBlock
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OPLMIDIDevice();
|
OPLMIDIDevice(const char *args);
|
||||||
int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
|
int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
|
||||||
void Close();
|
void Close();
|
||||||
int GetTechnology() const;
|
int GetTechnology() const;
|
||||||
|
@ -303,7 +303,7 @@ namespace Timidity { struct Renderer; }
|
||||||
class TimidityMIDIDevice : public SoftSynthMIDIDevice
|
class TimidityMIDIDevice : public SoftSynthMIDIDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TimidityMIDIDevice();
|
TimidityMIDIDevice(const char *args);
|
||||||
~TimidityMIDIDevice();
|
~TimidityMIDIDevice();
|
||||||
|
|
||||||
int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
|
int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
|
||||||
|
@ -337,7 +337,7 @@ protected:
|
||||||
class WildMIDIDevice : public SoftSynthMIDIDevice
|
class WildMIDIDevice : public SoftSynthMIDIDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WildMIDIDevice();
|
WildMIDIDevice(const char *args);
|
||||||
~WildMIDIDevice();
|
~WildMIDIDevice();
|
||||||
|
|
||||||
int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
|
int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
|
||||||
|
@ -366,7 +366,7 @@ struct fluid_synth_t;
|
||||||
class FluidSynthMIDIDevice : public SoftSynthMIDIDevice
|
class FluidSynthMIDIDevice : public SoftSynthMIDIDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FluidSynthMIDIDevice();
|
FluidSynthMIDIDevice(const char *args);
|
||||||
~FluidSynthMIDIDevice();
|
~FluidSynthMIDIDevice();
|
||||||
|
|
||||||
int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
|
int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
|
||||||
|
@ -431,7 +431,7 @@ protected:
|
||||||
class MIDIStreamer : public MusInfo
|
class MIDIStreamer : public MusInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MIDIStreamer(EMidiDevice type);
|
MIDIStreamer(EMidiDevice type, const char *args);
|
||||||
~MIDIStreamer();
|
~MIDIStreamer();
|
||||||
|
|
||||||
void MusicVolumeChanged();
|
void MusicVolumeChanged();
|
||||||
|
@ -517,6 +517,7 @@ protected:
|
||||||
bool CallbackIsThreaded;
|
bool CallbackIsThreaded;
|
||||||
int LoopLimit;
|
int LoopLimit;
|
||||||
FString DumpFilename;
|
FString DumpFilename;
|
||||||
|
FString Args;
|
||||||
};
|
};
|
||||||
|
|
||||||
// MUS file played with a MIDI stream ---------------------------------------
|
// MUS file played with a MIDI stream ---------------------------------------
|
||||||
|
@ -524,7 +525,7 @@ protected:
|
||||||
class MUSSong2 : public MIDIStreamer
|
class MUSSong2 : public MIDIStreamer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MUSSong2(FileReader &reader, EMidiDevice type);
|
MUSSong2(FileReader &reader, EMidiDevice type, const char *args);
|
||||||
~MUSSong2();
|
~MUSSong2();
|
||||||
|
|
||||||
MusInfo *GetOPLDumper(const char *filename);
|
MusInfo *GetOPLDumper(const char *filename);
|
||||||
|
@ -550,7 +551,7 @@ protected:
|
||||||
class MIDISong2 : public MIDIStreamer
|
class MIDISong2 : public MIDIStreamer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MIDISong2(FileReader &reader, EMidiDevice type);
|
MIDISong2(FileReader &reader, EMidiDevice type, const char *args);
|
||||||
~MIDISong2();
|
~MIDISong2();
|
||||||
|
|
||||||
MusInfo *GetOPLDumper(const char *filename);
|
MusInfo *GetOPLDumper(const char *filename);
|
||||||
|
@ -607,7 +608,7 @@ protected:
|
||||||
class HMISong : public MIDIStreamer
|
class HMISong : public MIDIStreamer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HMISong(FileReader &reader, EMidiDevice type);
|
HMISong(FileReader &reader, EMidiDevice type, const char *args);
|
||||||
~HMISong();
|
~HMISong();
|
||||||
|
|
||||||
MusInfo *GetOPLDumper(const char *filename);
|
MusInfo *GetOPLDumper(const char *filename);
|
||||||
|
@ -650,7 +651,7 @@ protected:
|
||||||
class XMISong : public MIDIStreamer
|
class XMISong : public MIDIStreamer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XMISong(FileReader &reader, EMidiDevice type);
|
XMISong(FileReader &reader, EMidiDevice type, const char *args);
|
||||||
~XMISong();
|
~XMISong();
|
||||||
|
|
||||||
MusInfo *GetOPLDumper(const char *filename);
|
MusInfo *GetOPLDumper(const char *filename);
|
||||||
|
@ -713,7 +714,7 @@ protected:
|
||||||
class OPLMUSSong : public StreamSong
|
class OPLMUSSong : public StreamSong
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OPLMUSSong (FileReader &reader);
|
OPLMUSSong (FileReader &reader, const char *args);
|
||||||
~OPLMUSSong ();
|
~OPLMUSSong ();
|
||||||
void Play (bool looping, int subsong);
|
void Play (bool looping, int subsong);
|
||||||
bool IsPlaying ();
|
bool IsPlaying ();
|
||||||
|
|
|
@ -255,7 +255,7 @@ CUSTOM_CVAR(Int, fluid_chorus_type, FLUID_CHORUS_DEFAULT_TYPE, CVAR_ARCHIVE|CVAR
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FluidSynthMIDIDevice::FluidSynthMIDIDevice()
|
FluidSynthMIDIDevice::FluidSynthMIDIDevice(const char *args)
|
||||||
{
|
{
|
||||||
FluidSynth = NULL;
|
FluidSynth = NULL;
|
||||||
FluidSettings = NULL;
|
FluidSettings = NULL;
|
||||||
|
@ -293,7 +293,15 @@ FluidSynthMIDIDevice::FluidSynthMIDIDevice()
|
||||||
fluid_reverb_width, fluid_reverb_level);
|
fluid_reverb_width, fluid_reverb_level);
|
||||||
fluid_synth_set_chorus(FluidSynth, fluid_chorus_voices, fluid_chorus_level,
|
fluid_synth_set_chorus(FluidSynth, fluid_chorus_voices, fluid_chorus_level,
|
||||||
fluid_chorus_speed, fluid_chorus_depth, fluid_chorus_type);
|
fluid_chorus_speed, fluid_chorus_depth, fluid_chorus_type);
|
||||||
if (0 == LoadPatchSets(fluid_patchset))
|
|
||||||
|
// try loading a patch set that got specified with $mididevice.
|
||||||
|
int res = 0;
|
||||||
|
if (args != NULL && *args != 0)
|
||||||
|
{
|
||||||
|
res = LoadPatchSets(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res == 0 && 0 == LoadPatchSets(fluid_patchset))
|
||||||
{
|
{
|
||||||
#ifdef __unix__
|
#ifdef __unix__
|
||||||
// This is the standard location on Ubuntu.
|
// This is the standard location on Ubuntu.
|
||||||
|
|
|
@ -128,8 +128,8 @@ extern char MIDI_CommonLengths[15];
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
HMISong::HMISong (FileReader &reader, EMidiDevice type)
|
HMISong::HMISong (FileReader &reader, EMidiDevice type, const char *args)
|
||||||
: MIDIStreamer(type), MusHeader(0), Tracks(0)
|
: MIDIStreamer(type, args), MusHeader(0), Tracks(0)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (ExitEvent == NULL)
|
if (ExitEvent == NULL)
|
||||||
|
|
|
@ -72,7 +72,7 @@ CUSTOM_CVAR (Int, timidity_frequency, 22050, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
TimidityPPMIDIDevice::TimidityPPMIDIDevice()
|
TimidityPPMIDIDevice::TimidityPPMIDIDevice(const char *args)
|
||||||
: DiskName("zmid"),
|
: DiskName("zmid"),
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
ReadWavePipe(INVALID_HANDLE_VALUE), WriteWavePipe(INVALID_HANDLE_VALUE),
|
ReadWavePipe(INVALID_HANDLE_VALUE), WriteWavePipe(INVALID_HANDLE_VALUE),
|
||||||
|
@ -86,6 +86,12 @@ TimidityPPMIDIDevice::TimidityPPMIDIDevice()
|
||||||
WavePipe[0] = WavePipe[1] = -1;
|
WavePipe[0] = WavePipe[1] = -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (args == NULL || *args == 0) args = timidity_exe;
|
||||||
|
|
||||||
|
CommandLine.Format("%s %s -EFchorus=%s -EFreverb=%s -s%d ",
|
||||||
|
args, *timidity_extargs,
|
||||||
|
*timidity_chorus, *timidity_reverb, *timidity_frequency);
|
||||||
|
|
||||||
if (DiskName == NULL)
|
if (DiskName == NULL)
|
||||||
{
|
{
|
||||||
Printf(PRINT_BOLD, "Could not create temp music file\n");
|
Printf(PRINT_BOLD, "Could not create temp music file\n");
|
||||||
|
@ -187,10 +193,6 @@ int TimidityPPMIDIDevice::Open(void (*callback)(unsigned int, void *, DWORD, DWO
|
||||||
Validated = true;
|
Validated = true;
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
||||||
CommandLine.Format("%s %s -EFchorus=%s -EFreverb=%s -s%d ",
|
|
||||||
*timidity_exe, *timidity_extargs,
|
|
||||||
*timidity_chorus, *timidity_reverb, *timidity_frequency);
|
|
||||||
|
|
||||||
pipeSize = (timidity_pipe * timidity_frequency / 1000)
|
pipeSize = (timidity_pipe * timidity_frequency / 1000)
|
||||||
<< (timidity_stereo + !timidity_8bit);
|
<< (timidity_stereo + !timidity_8bit);
|
||||||
|
|
||||||
|
|
|
@ -89,12 +89,12 @@ static const BYTE StaticMIDIhead[] =
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
MIDIStreamer::MIDIStreamer(EMidiDevice type)
|
MIDIStreamer::MIDIStreamer(EMidiDevice type, const char *args)
|
||||||
:
|
:
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
PlayerThread(0), ExitEvent(0), BufferDoneEvent(0),
|
PlayerThread(0), ExitEvent(0), BufferDoneEvent(0),
|
||||||
#endif
|
#endif
|
||||||
MIDI(0), Division(0), InitialTempo(500000), DeviceType(type)
|
MIDI(0), Division(0), InitialTempo(500000), DeviceType(type), Args(args)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
BufferDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
BufferDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
|
@ -269,19 +269,19 @@ MIDIDevice *MIDIStreamer::CreateMIDIDevice(EMidiDevice devtype) const
|
||||||
|
|
||||||
#ifdef HAVE_FLUIDSYNTH
|
#ifdef HAVE_FLUIDSYNTH
|
||||||
case MDEV_FLUIDSYNTH:
|
case MDEV_FLUIDSYNTH:
|
||||||
return new FluidSynthMIDIDevice;
|
return new FluidSynthMIDIDevice(Args);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case MDEV_SNDSYS:
|
case MDEV_SNDSYS:
|
||||||
return new SndSysMIDIDevice;
|
return new SndSysMIDIDevice;
|
||||||
|
|
||||||
case MDEV_GUS:
|
case MDEV_GUS:
|
||||||
return new TimidityMIDIDevice;
|
return new TimidityMIDIDevice(Args);
|
||||||
|
|
||||||
case MDEV_OPL:
|
case MDEV_OPL:
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return new OPLMIDIDevice;
|
return new OPLMIDIDevice(Args);
|
||||||
}
|
}
|
||||||
catch (CRecoverableError &err)
|
catch (CRecoverableError &err)
|
||||||
{
|
{
|
||||||
|
@ -291,10 +291,10 @@ MIDIDevice *MIDIStreamer::CreateMIDIDevice(EMidiDevice devtype) const
|
||||||
}
|
}
|
||||||
|
|
||||||
case MDEV_TIMIDITY:
|
case MDEV_TIMIDITY:
|
||||||
return new TimidityPPMIDIDevice;
|
return new TimidityPPMIDIDevice(Args);
|
||||||
|
|
||||||
case MDEV_WILDMIDI:
|
case MDEV_WILDMIDI:
|
||||||
return new WildMIDIDevice;
|
return new WildMIDIDevice(Args);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -93,8 +93,8 @@ static const BYTE CtrlTranslate[15] =
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
MUSSong2::MUSSong2 (FileReader &reader, EMidiDevice type)
|
MUSSong2::MUSSong2 (FileReader &reader, EMidiDevice type, const char *args)
|
||||||
: MIDIStreamer(type), MusHeader(0), MusBuffer(0)
|
: MIDIStreamer(type, args), MusHeader(0), MusBuffer(0)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (ExitEvent == NULL)
|
if (ExitEvent == NULL)
|
||||||
|
|
|
@ -20,16 +20,25 @@ CUSTOM_CVAR (Int, opl_numchips, 2, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CVAR(Int, opl_core, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
CVAR(Int, opl_core, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||||
|
int current_opl_core;
|
||||||
|
|
||||||
OPLMUSSong::OPLMUSSong (FileReader &reader)
|
// Get OPL core override from $mididevice
|
||||||
|
void OPL_SetCore(const char *args)
|
||||||
|
{
|
||||||
|
current_opl_core = opl_core;
|
||||||
|
if (args != NULL && *args >= '0' && *args < '4') current_opl_core = *args - '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
OPLMUSSong::OPLMUSSong (FileReader &reader, const char *args)
|
||||||
{
|
{
|
||||||
int samples = int(OPL_SAMPLE_RATE / 14);
|
int samples = int(OPL_SAMPLE_RATE / 14);
|
||||||
|
|
||||||
|
OPL_SetCore(args);
|
||||||
Music = new OPLmusicFile (&reader);
|
Music = new OPLmusicFile (&reader);
|
||||||
|
|
||||||
m_Stream = GSnd->CreateStream (FillStream, samples*4,
|
m_Stream = GSnd->CreateStream (FillStream, samples*4,
|
||||||
(opl_core == 0 ? SoundStream::Mono : 0) | SoundStream::Float, int(OPL_SAMPLE_RATE), this);
|
(current_opl_core == 0 ? SoundStream::Mono : 0) | SoundStream::Float, int(OPL_SAMPLE_RATE), this);
|
||||||
if (m_Stream == NULL)
|
if (m_Stream == NULL)
|
||||||
{
|
{
|
||||||
Printf (PRINT_BOLD, "Could not create music stream.\n");
|
Printf (PRINT_BOLD, "Could not create music stream.\n");
|
||||||
|
|
|
@ -102,8 +102,8 @@ char MIDI_CommonLengths[15] = { 0, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
MIDISong2::MIDISong2 (FileReader &reader, EMidiDevice type)
|
MIDISong2::MIDISong2 (FileReader &reader, EMidiDevice type, const char *args)
|
||||||
: MIDIStreamer(type), MusHeader(0), Tracks(0)
|
: MIDIStreamer(type, args), MusHeader(0), Tracks(0)
|
||||||
{
|
{
|
||||||
int p;
|
int p;
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -86,10 +86,10 @@ struct FmtChunk
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
TimidityMIDIDevice::TimidityMIDIDevice()
|
TimidityMIDIDevice::TimidityMIDIDevice(const char *args)
|
||||||
{
|
{
|
||||||
Renderer = NULL;
|
Renderer = NULL;
|
||||||
Renderer = new Timidity::Renderer((float)SampleRate);
|
Renderer = new Timidity::Renderer((float)SampleRate, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -245,6 +245,7 @@ FString TimidityMIDIDevice::GetStats()
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
TimidityWaveWriterMIDIDevice::TimidityWaveWriterMIDIDevice(const char *filename, int rate)
|
TimidityWaveWriterMIDIDevice::TimidityWaveWriterMIDIDevice(const char *filename, int rate)
|
||||||
|
:TimidityMIDIDevice(NULL)
|
||||||
{
|
{
|
||||||
File = fopen(filename, "wb");
|
File = fopen(filename, "wb");
|
||||||
if (File != NULL)
|
if (File != NULL)
|
||||||
|
|
|
@ -81,7 +81,7 @@ CUSTOM_CVAR(Bool, wildmidi_enhanced_resampling, true, CVAR_ARCHIVE | CVAR_GLOBAL
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
WildMIDIDevice::WildMIDIDevice()
|
WildMIDIDevice::WildMIDIDevice(const char *args)
|
||||||
{
|
{
|
||||||
Renderer = NULL;
|
Renderer = NULL;
|
||||||
|
|
||||||
|
@ -94,16 +94,18 @@ WildMIDIDevice::WildMIDIDevice()
|
||||||
SampleRate = clamp(SampleRate, 11025, 65535);
|
SampleRate = clamp(SampleRate, 11025, 65535);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CurrentConfig.CompareNoCase(wildmidi_config) != 0 || SampleRate != WildMidi_GetSampleRate())
|
if (args == NULL || *args == 0) args = wildmidi_config;
|
||||||
|
|
||||||
|
if (CurrentConfig.CompareNoCase(args) != 0 || SampleRate != WildMidi_GetSampleRate())
|
||||||
{
|
{
|
||||||
if (CurrentConfig.IsNotEmpty())
|
if (CurrentConfig.IsNotEmpty())
|
||||||
{
|
{
|
||||||
WildMidi_Shutdown();
|
WildMidi_Shutdown();
|
||||||
CurrentConfig = "";
|
CurrentConfig = "";
|
||||||
}
|
}
|
||||||
if (!WildMidi_Init(wildmidi_config, SampleRate, 0))
|
if (!WildMidi_Init(args, SampleRate, 0))
|
||||||
{
|
{
|
||||||
CurrentConfig = wildmidi_config;
|
CurrentConfig = args;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (CurrentConfig.IsNotEmpty())
|
if (CurrentConfig.IsNotEmpty())
|
||||||
|
|
|
@ -108,8 +108,8 @@ extern char MIDI_CommonLengths[15];
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
XMISong::XMISong (FileReader &reader, EMidiDevice type)
|
XMISong::XMISong (FileReader &reader, EMidiDevice type, const char *args)
|
||||||
: MIDIStreamer(type), MusHeader(0), Songs(0)
|
: MIDIStreamer(type, args), MusHeader(0), Songs(0)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (ExitEvent == NULL)
|
if (ExitEvent == NULL)
|
||||||
|
|
|
@ -678,8 +678,9 @@ int LoadDMXGUS()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer::Renderer(float sample_rate)
|
Renderer::Renderer(float sample_rate, const char *args)
|
||||||
{
|
{
|
||||||
|
// 'args' should be used to load a custom config or DMXGUS, but since setup currently requires a snd_reset call, this will need some refactoring first
|
||||||
rate = sample_rate;
|
rate = sample_rate;
|
||||||
patches = NULL;
|
patches = NULL;
|
||||||
resample_buffer_size = 0;
|
resample_buffer_size = 0;
|
||||||
|
|
|
@ -630,7 +630,7 @@ struct Renderer
|
||||||
int voices;
|
int voices;
|
||||||
int lost_notes, cut_notes;
|
int lost_notes, cut_notes;
|
||||||
|
|
||||||
Renderer(float sample_rate);
|
Renderer(float sample_rate, const char *args);
|
||||||
~Renderer();
|
~Renderer();
|
||||||
|
|
||||||
void HandleEvent(int status, int parm1, int parm2);
|
void HandleEvent(int status, int parm1, int parm2);
|
||||||
|
|
Loading…
Reference in a new issue