2006-02-24 04:48:15 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2006-09-14 00:02:31 +00:00
|
|
|
#define USE_WINDOWS_DWORD
|
2006-02-24 04:48:15 +00:00
|
|
|
#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0400
|
|
|
|
#undef _WIN32_WINNT
|
|
|
|
#endif
|
|
|
|
#ifndef _WIN32_WINNT
|
|
|
|
#define _WIN32_WINNT 0x0400
|
|
|
|
#endif
|
2009-06-04 00:58:42 +00:00
|
|
|
#ifndef USE_WINDOWS_DWORD
|
|
|
|
#define USE_WINDOWS_DWORD
|
|
|
|
#endif
|
2006-02-24 04:48:15 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include <mmsystem.h>
|
|
|
|
#else
|
|
|
|
#include <SDL.h>
|
|
|
|
#define FALSE 0
|
|
|
|
#define TRUE 1
|
|
|
|
#endif
|
|
|
|
#include "tempfiles.h"
|
|
|
|
#include "oplsynth/opl_mus_player.h"
|
|
|
|
#include "c_cvars.h"
|
|
|
|
#include "mus2midi.h"
|
|
|
|
#include "i_sound.h"
|
2008-08-03 03:54:48 +00:00
|
|
|
#include "i_music.h"
|
2010-10-02 04:12:21 +00:00
|
|
|
#include "s_sound.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
void I_InitMusicWin32 ();
|
|
|
|
void I_ShutdownMusicWin32 ();
|
|
|
|
|
|
|
|
extern float relative_volume;
|
|
|
|
|
2008-04-12 21:36:10 +00:00
|
|
|
EXTERN_CVAR (Float, timidity_mastervolume)
|
|
|
|
|
|
|
|
|
2008-03-07 00:43:05 +00:00
|
|
|
// A device that provides a WinMM-like MIDI streaming interface -------------
|
|
|
|
|
2008-03-28 03:19:18 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
struct MIDIHDR
|
|
|
|
{
|
|
|
|
BYTE *lpData;
|
|
|
|
DWORD dwBufferLength;
|
|
|
|
DWORD dwBytesRecorded;
|
2008-03-29 05:01:38 +00:00
|
|
|
MIDIHDR *lpNext;
|
2008-03-28 03:19:18 +00:00
|
|
|
};
|
2008-03-29 05:01:38 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
MOD_MIDIPORT = 1,
|
|
|
|
MOD_SYNTH,
|
|
|
|
MOD_SQSYNTH,
|
|
|
|
MOD_FMSYNTH,
|
|
|
|
MOD_MAPPER,
|
|
|
|
MOD_WAVETABLE,
|
|
|
|
MOD_SWSYNTH
|
|
|
|
};
|
|
|
|
|
2008-03-30 00:04:09 +00:00
|
|
|
typedef BYTE *LPSTR;
|
|
|
|
|
2008-03-29 05:01:38 +00:00
|
|
|
#define MEVT_TEMPO ((BYTE)1)
|
|
|
|
#define MEVT_NOP ((BYTE)2)
|
|
|
|
#define MEVT_LONGMSG ((BYTE)128)
|
|
|
|
|
|
|
|
#define MEVT_EVENTTYPE(x) ((BYTE)((x) >> 24))
|
|
|
|
#define MEVT_EVENTPARM(x) ((x) & 0xffffff)
|
|
|
|
|
|
|
|
#define MOM_DONE 969
|
2008-04-12 05:33:20 +00:00
|
|
|
#else
|
|
|
|
// w32api does not define these
|
|
|
|
#ifndef MOD_WAVETABLE
|
|
|
|
#define MOD_WAVETABLE 6
|
|
|
|
#define MOD_SWSYNTH 7
|
|
|
|
#endif
|
2008-03-28 03:19:18 +00:00
|
|
|
#endif
|
|
|
|
|
2010-10-02 02:19:50 +00:00
|
|
|
class MIDIStreamer;
|
|
|
|
|
2008-03-07 00:43:05 +00:00
|
|
|
class MIDIDevice
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MIDIDevice();
|
|
|
|
virtual ~MIDIDevice();
|
|
|
|
|
|
|
|
virtual int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata) = 0;
|
|
|
|
virtual void Close() = 0;
|
|
|
|
virtual bool IsOpen() const = 0;
|
|
|
|
virtual int GetTechnology() const = 0;
|
|
|
|
virtual int SetTempo(int tempo) = 0;
|
|
|
|
virtual int SetTimeDiv(int timediv) = 0;
|
|
|
|
virtual int StreamOut(MIDIHDR *data) = 0;
|
2008-03-30 00:04:09 +00:00
|
|
|
virtual int StreamOutSync(MIDIHDR *data) = 0;
|
2008-03-07 00:43:05 +00:00
|
|
|
virtual int Resume() = 0;
|
|
|
|
virtual void Stop() = 0;
|
2010-10-02 02:19:50 +00:00
|
|
|
virtual int PrepareHeader(MIDIHDR *data);
|
|
|
|
virtual int UnprepareHeader(MIDIHDR *data);
|
|
|
|
virtual bool FakeVolume();
|
2008-03-29 05:01:38 +00:00
|
|
|
virtual bool Pause(bool paused) = 0;
|
2010-10-02 02:19:50 +00:00
|
|
|
virtual bool NeedThreadedCallback();
|
2008-04-12 05:04:37 +00:00
|
|
|
virtual void PrecacheInstruments(const WORD *instruments, int count);
|
2008-04-19 05:57:09 +00:00
|
|
|
virtual void TimidityVolumeChanged();
|
2010-08-15 19:54:59 +00:00
|
|
|
virtual void FluidSettingInt(const char *setting, int value);
|
|
|
|
virtual void FluidSettingNum(const char *setting, double value);
|
|
|
|
virtual void FluidSettingStr(const char *setting, const char *value);
|
2010-10-02 03:36:19 +00:00
|
|
|
virtual bool Preprocess(MIDIStreamer *song, bool looping);
|
2008-04-19 05:57:09 +00:00
|
|
|
virtual FString GetStats();
|
2008-03-07 00:43:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// WinMM implementation of a MIDI output device -----------------------------
|
|
|
|
|
2008-03-30 00:04:09 +00:00
|
|
|
#ifdef _WIN32
|
2008-03-07 00:43:05 +00:00
|
|
|
class WinMIDIDevice : public MIDIDevice
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
WinMIDIDevice(int dev_id);
|
|
|
|
~WinMIDIDevice();
|
|
|
|
int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
|
|
|
|
void Close();
|
|
|
|
bool IsOpen() const;
|
|
|
|
int GetTechnology() const;
|
|
|
|
int SetTempo(int tempo);
|
|
|
|
int SetTimeDiv(int timediv);
|
|
|
|
int StreamOut(MIDIHDR *data);
|
2008-03-30 00:04:09 +00:00
|
|
|
int StreamOutSync(MIDIHDR *data);
|
2008-03-07 00:43:05 +00:00
|
|
|
int Resume();
|
|
|
|
void Stop();
|
|
|
|
int PrepareHeader(MIDIHDR *data);
|
|
|
|
int UnprepareHeader(MIDIHDR *data);
|
2008-03-29 05:01:38 +00:00
|
|
|
bool FakeVolume();
|
2008-03-30 00:04:09 +00:00
|
|
|
bool NeedThreadedCallback();
|
2008-03-29 05:01:38 +00:00
|
|
|
bool Pause(bool paused);
|
2008-04-12 05:04:37 +00:00
|
|
|
void PrecacheInstruments(const WORD *instruments, int count);
|
2008-03-07 00:43:05 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void CALLBACK CallbackFunc(HMIDIOUT, UINT, DWORD_PTR, DWORD, DWORD);
|
|
|
|
|
|
|
|
HMIDISTRM MidiOut;
|
|
|
|
UINT DeviceID;
|
|
|
|
DWORD SavedVolume;
|
|
|
|
bool VolumeWorks;
|
|
|
|
|
|
|
|
void (*Callback)(unsigned int, void *, DWORD, DWORD);
|
|
|
|
void *CallbackData;
|
|
|
|
};
|
2008-03-30 00:04:09 +00:00
|
|
|
#endif
|
2008-03-07 00:43:05 +00:00
|
|
|
|
2010-10-02 13:49:33 +00:00
|
|
|
// Base class for pseudo-MIDI devices ---------------------------------------
|
2010-10-02 02:19:50 +00:00
|
|
|
|
2010-10-02 13:49:33 +00:00
|
|
|
class PseudoMIDIDevice : public MIDIDevice
|
2010-10-02 02:19:50 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-10-02 13:49:33 +00:00
|
|
|
PseudoMIDIDevice();
|
|
|
|
~PseudoMIDIDevice();
|
2010-10-02 02:19:50 +00:00
|
|
|
|
|
|
|
void Close();
|
|
|
|
bool IsOpen() const;
|
|
|
|
int GetTechnology() const;
|
|
|
|
bool Pause(bool paused);
|
|
|
|
int Resume();
|
|
|
|
void Stop();
|
|
|
|
int StreamOut(MIDIHDR *data);
|
|
|
|
int StreamOutSync(MIDIHDR *data);
|
|
|
|
int SetTempo(int tempo);
|
|
|
|
int SetTimeDiv(int timediv);
|
|
|
|
FString GetStats();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
SoundStream *Stream;
|
|
|
|
bool Started;
|
2010-10-02 03:36:19 +00:00
|
|
|
bool bLooping;
|
2010-10-02 02:19:50 +00:00
|
|
|
};
|
|
|
|
|
2010-10-02 13:49:33 +00:00
|
|
|
// FMOD pseudo-MIDI device --------------------------------------------------
|
2010-10-02 02:19:50 +00:00
|
|
|
|
2010-10-02 13:49:33 +00:00
|
|
|
class FMODMIDIDevice : public PseudoMIDIDevice
|
2010-10-02 02:19:50 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
|
2010-10-02 03:36:19 +00:00
|
|
|
bool Preprocess(MIDIStreamer *song, bool looping);
|
|
|
|
};
|
|
|
|
|
|
|
|
// MIDI file played with TiMidity++ and possibly streamed through FMOD ------
|
|
|
|
|
2010-10-02 13:49:33 +00:00
|
|
|
class TimidityPPMIDIDevice : public PseudoMIDIDevice
|
2010-10-02 03:36:19 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
TimidityPPMIDIDevice();
|
|
|
|
~TimidityPPMIDIDevice();
|
|
|
|
|
|
|
|
int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
|
|
|
|
bool Preprocess(MIDIStreamer *song, bool looping);
|
|
|
|
bool IsOpen() const;
|
|
|
|
int Resume();
|
|
|
|
|
|
|
|
void Stop();
|
|
|
|
bool IsOpen();
|
|
|
|
void TimidityVolumeChanged();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool LaunchTimidity();
|
|
|
|
|
|
|
|
FTempFileName DiskName;
|
|
|
|
#ifdef _WIN32
|
|
|
|
HANDLE ReadWavePipe;
|
|
|
|
HANDLE WriteWavePipe;
|
|
|
|
HANDLE ChildProcess;
|
|
|
|
bool Validated;
|
|
|
|
bool ValidateTimidity();
|
|
|
|
#else // _WIN32
|
|
|
|
int WavePipe[2];
|
|
|
|
pid_t ChildProcess;
|
|
|
|
#endif
|
|
|
|
FString CommandLine;
|
|
|
|
size_t LoopPos;
|
|
|
|
|
|
|
|
static bool FillStream(SoundStream *stream, void *buff, int len, void *userdata);
|
|
|
|
#ifdef _WIN32
|
|
|
|
static const char EventName[];
|
|
|
|
#endif
|
2010-10-02 02:19:50 +00:00
|
|
|
};
|
|
|
|
|
2010-10-02 03:36:19 +00:00
|
|
|
|
2010-08-20 04:21:53 +00:00
|
|
|
// Base class for software synthesizer MIDI output devices ------------------
|
2008-03-04 06:36:23 +00:00
|
|
|
|
2010-08-20 04:21:53 +00:00
|
|
|
class SoftSynthMIDIDevice : public MIDIDevice
|
2008-03-28 03:19:18 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-08-20 04:21:53 +00:00
|
|
|
SoftSynthMIDIDevice();
|
|
|
|
~SoftSynthMIDIDevice();
|
|
|
|
|
2008-03-28 03:19:18 +00:00
|
|
|
void Close();
|
|
|
|
bool IsOpen() const;
|
|
|
|
int GetTechnology() const;
|
|
|
|
int SetTempo(int tempo);
|
|
|
|
int SetTimeDiv(int timediv);
|
|
|
|
int StreamOut(MIDIHDR *data);
|
2008-03-30 00:04:09 +00:00
|
|
|
int StreamOutSync(MIDIHDR *data);
|
2008-03-28 03:19:18 +00:00
|
|
|
int Resume();
|
|
|
|
void Stop();
|
2008-03-29 05:01:38 +00:00
|
|
|
bool Pause(bool paused);
|
2008-03-28 03:19:18 +00:00
|
|
|
|
|
|
|
protected:
|
2010-08-20 04:21:53 +00:00
|
|
|
FCriticalSection CritSec;
|
2008-03-29 05:01:38 +00:00
|
|
|
SoundStream *Stream;
|
|
|
|
double Tempo;
|
|
|
|
double Division;
|
2010-08-20 04:21:53 +00:00
|
|
|
double SamplesPerTick;
|
|
|
|
double NextTickIn;
|
2008-03-29 05:01:38 +00:00
|
|
|
MIDIHDR *Events;
|
|
|
|
bool Started;
|
|
|
|
DWORD Position;
|
2010-08-20 04:21:53 +00:00
|
|
|
int SampleRate;
|
|
|
|
|
|
|
|
void (*Callback)(unsigned int, void *, DWORD, DWORD);
|
|
|
|
void *CallbackData;
|
|
|
|
|
|
|
|
virtual void CalcTickRate();
|
|
|
|
int PlayTick();
|
|
|
|
int OpenStream(int chunks, int flags, void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
|
|
|
|
static bool FillStream(SoundStream *stream, void *buff, int len, void *userdata);
|
|
|
|
virtual bool ServiceStream (void *buff, int numbytes);
|
|
|
|
|
|
|
|
virtual void HandleEvent(int status, int parm1, int parm2) = 0;
|
|
|
|
virtual void HandleLongEvent(const BYTE *data, int len) = 0;
|
|
|
|
virtual void ComputeOutput(float *buffer, int len) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
// OPL implementation of a MIDI output device -------------------------------
|
|
|
|
|
|
|
|
class OPLMIDIDevice : public SoftSynthMIDIDevice, protected OPLmusicBlock
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
OPLMIDIDevice();
|
|
|
|
int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
|
|
|
|
void Close();
|
|
|
|
int GetTechnology() const;
|
|
|
|
FString GetStats();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void CalcTickRate();
|
|
|
|
int PlayTick();
|
|
|
|
void HandleEvent(int status, int parm1, int parm2);
|
|
|
|
void HandleLongEvent(const BYTE *data, int len);
|
|
|
|
void ComputeOutput(float *buffer, int len);
|
|
|
|
bool ServiceStream(void *buff, int numbytes);
|
2008-03-28 03:19:18 +00:00
|
|
|
};
|
|
|
|
|
2008-04-03 02:31:39 +00:00
|
|
|
// OPL dumper implementation of a MIDI output device ------------------------
|
|
|
|
|
|
|
|
class OPLDumperMIDIDevice : public OPLMIDIDevice
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
OPLDumperMIDIDevice(const char *filename);
|
|
|
|
~OPLDumperMIDIDevice();
|
|
|
|
int Resume();
|
|
|
|
void Stop();
|
|
|
|
};
|
|
|
|
|
2008-04-11 04:59:23 +00:00
|
|
|
// Internal TiMidity MIDI device --------------------------------------------
|
|
|
|
|
|
|
|
namespace Timidity { struct Renderer; }
|
|
|
|
|
2010-08-20 04:21:53 +00:00
|
|
|
class TimidityMIDIDevice : public SoftSynthMIDIDevice
|
2008-04-11 04:59:23 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
TimidityMIDIDevice();
|
|
|
|
~TimidityMIDIDevice();
|
|
|
|
|
|
|
|
int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
|
2008-04-12 05:04:37 +00:00
|
|
|
void PrecacheInstruments(const WORD *instruments, int count);
|
2008-04-19 05:57:09 +00:00
|
|
|
FString GetStats();
|
2008-04-11 04:59:23 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Timidity::Renderer *Renderer;
|
2010-08-20 04:21:53 +00:00
|
|
|
|
|
|
|
void HandleEvent(int status, int parm1, int parm2);
|
|
|
|
void HandleLongEvent(const BYTE *data, int len);
|
|
|
|
void ComputeOutput(float *buffer, int len);
|
2008-04-11 04:59:23 +00:00
|
|
|
};
|
|
|
|
|
2008-04-19 21:36:53 +00:00
|
|
|
// Internal TiMidity disk writing version of a MIDI device ------------------
|
|
|
|
|
|
|
|
class TimidityWaveWriterMIDIDevice : public TimidityMIDIDevice
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TimidityWaveWriterMIDIDevice(const char *filename, int rate);
|
|
|
|
~TimidityWaveWriterMIDIDevice();
|
|
|
|
int Resume();
|
|
|
|
void Stop();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
FILE *File;
|
|
|
|
};
|
|
|
|
|
2010-08-15 19:54:59 +00:00
|
|
|
// FluidSynth implementation of a MIDI device -------------------------------
|
|
|
|
|
|
|
|
#ifdef HAVE_FLUIDSYNTH
|
2010-08-19 16:49:43 +00:00
|
|
|
#ifndef DYN_FLUIDSYNTH
|
2010-08-15 19:54:59 +00:00
|
|
|
#include <fluidsynth.h>
|
2010-08-19 16:49:43 +00:00
|
|
|
#else
|
|
|
|
struct fluid_settings_t;
|
|
|
|
struct fluid_synth_t;
|
|
|
|
#endif
|
2010-08-15 19:54:59 +00:00
|
|
|
|
2010-08-20 04:21:53 +00:00
|
|
|
class FluidSynthMIDIDevice : public SoftSynthMIDIDevice
|
2010-08-15 19:54:59 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
FluidSynthMIDIDevice();
|
|
|
|
~FluidSynthMIDIDevice();
|
|
|
|
|
|
|
|
int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
|
|
|
|
FString GetStats();
|
|
|
|
void FluidSettingInt(const char *setting, int value);
|
|
|
|
void FluidSettingNum(const char *setting, double value);
|
|
|
|
void FluidSettingStr(const char *setting, const char *value);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void HandleEvent(int status, int parm1, int parm2);
|
2010-08-20 04:21:53 +00:00
|
|
|
void HandleLongEvent(const BYTE *data, int len);
|
|
|
|
void ComputeOutput(float *buffer, int len);
|
2010-08-15 19:54:59 +00:00
|
|
|
int LoadPatchSets(const char *patches);
|
|
|
|
|
|
|
|
fluid_settings_t *FluidSettings;
|
|
|
|
fluid_synth_t *FluidSynth;
|
2010-08-19 16:49:43 +00:00
|
|
|
|
|
|
|
#ifdef DYN_FLUIDSYNTH
|
2010-09-18 02:12:49 +00:00
|
|
|
enum { FLUID_FAILED = -1, FLUID_OK = 0 };
|
2010-08-19 16:49:43 +00:00
|
|
|
fluid_settings_t *(STACK_ARGS *new_fluid_settings)();
|
|
|
|
fluid_synth_t *(STACK_ARGS *new_fluid_synth)(fluid_settings_t *);
|
|
|
|
int (STACK_ARGS *delete_fluid_synth)(fluid_synth_t *);
|
|
|
|
void (STACK_ARGS *delete_fluid_settings)(fluid_settings_t *);
|
|
|
|
int (STACK_ARGS *fluid_settings_setnum)(fluid_settings_t *, const char *, double);
|
|
|
|
int (STACK_ARGS *fluid_settings_setstr)(fluid_settings_t *, const char *, const char *);
|
|
|
|
int (STACK_ARGS *fluid_settings_setint)(fluid_settings_t *, const char *, int);
|
|
|
|
int (STACK_ARGS *fluid_settings_getstr)(fluid_settings_t *, const char *, char **);
|
|
|
|
int (STACK_ARGS *fluid_settings_getint)(fluid_settings_t *, const char *, int *);
|
|
|
|
int (STACK_ARGS *fluid_synth_set_interp_method)(fluid_synth_t *, int, int);
|
|
|
|
int (STACK_ARGS *fluid_synth_set_polyphony)(fluid_synth_t *, int);
|
|
|
|
int (STACK_ARGS *fluid_synth_get_polyphony)(fluid_synth_t *);
|
|
|
|
int (STACK_ARGS *fluid_synth_get_active_voice_count)(fluid_synth_t *);
|
|
|
|
double (STACK_ARGS *fluid_synth_get_cpu_load)(fluid_synth_t *);
|
|
|
|
int (STACK_ARGS *fluid_synth_system_reset)(fluid_synth_t *);
|
|
|
|
int (STACK_ARGS *fluid_synth_noteon)(fluid_synth_t *, int, int, int);
|
|
|
|
int (STACK_ARGS *fluid_synth_noteoff)(fluid_synth_t *, int, int);
|
|
|
|
int (STACK_ARGS *fluid_synth_cc)(fluid_synth_t *, int, int, int);
|
|
|
|
int (STACK_ARGS *fluid_synth_program_change)(fluid_synth_t *, int, int);
|
|
|
|
int (STACK_ARGS *fluid_synth_channel_pressure)(fluid_synth_t *, int, int);
|
|
|
|
int (STACK_ARGS *fluid_synth_pitch_bend)(fluid_synth_t *, int, int);
|
|
|
|
int (STACK_ARGS *fluid_synth_write_float)(fluid_synth_t *, int, void *, int, int, void *, int, int);
|
|
|
|
int (STACK_ARGS *fluid_synth_sfload)(fluid_synth_t *, const char *, int);
|
2010-08-19 23:11:16 +00:00
|
|
|
void (STACK_ARGS *fluid_synth_set_reverb)(fluid_synth_t *, double, double, double, double);
|
|
|
|
void (STACK_ARGS *fluid_synth_set_chorus)(fluid_synth_t *, int, double, double, double, int);
|
2010-08-20 04:21:53 +00:00
|
|
|
int (STACK_ARGS *fluid_synth_sysex)(fluid_synth_t *, const char *, int, char *, int *, int *, int);
|
2010-08-19 16:49:43 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
HMODULE FluidSynthDLL;
|
2010-08-19 20:46:19 +00:00
|
|
|
#else
|
|
|
|
void *FluidSynthSO;
|
2010-08-19 16:49:43 +00:00
|
|
|
#endif
|
|
|
|
bool LoadFluidSynth();
|
|
|
|
void UnloadFluidSynth();
|
|
|
|
#endif
|
2010-08-15 19:54:59 +00:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2008-03-28 03:19:18 +00:00
|
|
|
// Base class for streaming MUS and MIDI files ------------------------------
|
2008-03-07 00:43:05 +00:00
|
|
|
|
2008-03-05 03:10:31 +00:00
|
|
|
class MIDIStreamer : public MusInfo
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-10-02 04:12:21 +00:00
|
|
|
MIDIStreamer(EMidiDevice type);
|
2008-03-05 03:10:31 +00:00
|
|
|
~MIDIStreamer();
|
|
|
|
|
VERY IMPORTANT NOTE FOR ANYBODY BUILDING FROM THE TRUNK: This commit adds support
for FMOD Ex while at the same time removing support for FMOD 3. Be sure to update
your SDKs. GCC users, be sure to do a "make cleandep && make clean" before
building, or you will likely get inexplicable errors.
- Fixed: If you wanted to make cleandep with MinGW, you had to specifically
specify Makefile.mingw as the makefile to use.
- Added a normalizer to the OPL synth. It helped bring up the volume a little,
but not nearly as much as I would have liked.
- Removed MIDI Mapper references. It doesn't work with the stream API, and
it doesn't really exist on NT kernels, either.
- Reworked music volume: Except for MIDI, all music volume is controlled
through GSnd and not at the individual song level.
- Removed the mididevice global variable.
- Removed snd_midivolume. Now that all music uses a linear volume scale,
there's no need for two separate music volume controls.
- Increased snd_samplerate default up to 48000.
- Added snd_format, defaulting to "PCM-16".
- Added snd_speakermode, defaulting to "Auto".
- Replaced snd_fpu with snd_resampler, defaulting to "Linear".
- Bumped the snd_channels default up from a pitiful 12 to 32.
- Changed snd_3d default to true. The new cvar snd_hw3d determines if
hardware 3D support is used and default to false.
- Removed the libFLAC source, since FMOD Ex has native FLAC support.
- Removed the altsound code, since it was terribly gimped in comparison to
the FMOD code. It's original purpose was to have been as a springboard for
writing a non-FMOD sound system for Unix-y systems, but that never
happened.
- Finished preliminary FMOD Ex support.
SVN r789 (trunk)
2008-03-09 03:13:49 +00:00
|
|
|
void MusicVolumeChanged();
|
2008-04-12 21:36:10 +00:00
|
|
|
void TimidityVolumeChanged();
|
2008-08-03 03:54:48 +00:00
|
|
|
void Play(bool looping, int subsong);
|
2008-03-05 03:10:31 +00:00
|
|
|
void Pause();
|
|
|
|
void Resume();
|
|
|
|
void Stop();
|
|
|
|
bool IsPlaying();
|
|
|
|
bool IsMIDI() const;
|
|
|
|
bool IsValid() const;
|
2010-09-28 03:58:41 +00:00
|
|
|
bool SetSubsong(int subsong);
|
2008-03-05 03:10:31 +00:00
|
|
|
void Update();
|
2008-04-19 05:57:09 +00:00
|
|
|
FString GetStats();
|
2010-08-15 19:54:59 +00:00
|
|
|
void FluidSettingInt(const char *setting, int value);
|
|
|
|
void FluidSettingNum(const char *setting, double value);
|
|
|
|
void FluidSettingStr(const char *setting, const char *value);
|
2012-02-22 03:28:33 +00:00
|
|
|
void CreateSMF(TArray<BYTE> &file, int looplimit=0);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
protected:
|
2010-10-02 04:12:21 +00:00
|
|
|
MIDIStreamer(const char *dumpname, EMidiDevice type);
|
2008-03-30 00:04:09 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
void OutputVolume (DWORD volume);
|
2008-03-04 06:36:23 +00:00
|
|
|
int FillBuffer(int buffer_num, int max_events, DWORD max_time);
|
2010-06-20 04:41:23 +00:00
|
|
|
int ServiceEvent();
|
2008-03-05 03:10:31 +00:00
|
|
|
int VolumeControllerChange(int channel, int volume);
|
2010-09-29 03:35:53 +00:00
|
|
|
int ClampLoopCount(int loopcount);
|
|
|
|
void SetTempo(int new_tempo);
|
2010-10-02 04:12:21 +00:00
|
|
|
static EMidiDevice SelectMIDIDevice(EMidiDevice devtype);
|
|
|
|
MIDIDevice *CreateMIDIDevice(EMidiDevice devtype) const;
|
|
|
|
|
2008-04-03 02:31:39 +00:00
|
|
|
static void Callback(unsigned int uMsg, void *userdata, DWORD dwParam1, DWORD dwParam2);
|
|
|
|
|
2008-03-05 03:10:31 +00:00
|
|
|
// Virtuals for subclasses to override
|
2010-10-02 02:19:50 +00:00
|
|
|
virtual void StartPlayback();
|
2010-09-03 05:08:05 +00:00
|
|
|
virtual void CheckCaps(int tech);
|
2008-03-05 03:10:31 +00:00
|
|
|
virtual void DoInitialSetup() = 0;
|
|
|
|
virtual void DoRestart() = 0;
|
|
|
|
virtual bool CheckDone() = 0;
|
2010-09-02 23:17:58 +00:00
|
|
|
virtual void Precache();
|
2010-09-28 03:58:41 +00:00
|
|
|
virtual bool SetMIDISubsong(int subsong);
|
2008-03-05 03:10:31 +00:00
|
|
|
virtual DWORD *MakeEvents(DWORD *events, DWORD *max_event_p, DWORD max_time) = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
enum
|
|
|
|
{
|
2008-03-04 06:36:23 +00:00
|
|
|
MAX_EVENTS = 128
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
2008-03-04 06:36:23 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SONG_MORE,
|
|
|
|
SONG_DONE,
|
|
|
|
SONG_ERROR
|
|
|
|
};
|
|
|
|
|
2008-03-30 00:04:09 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
static DWORD WINAPI PlayerProc (LPVOID lpParameter);
|
|
|
|
DWORD PlayerLoop();
|
|
|
|
|
2008-03-05 03:10:31 +00:00
|
|
|
HANDLE PlayerThread;
|
|
|
|
HANDLE ExitEvent;
|
|
|
|
HANDLE BufferDoneEvent;
|
2008-03-30 00:04:09 +00:00
|
|
|
#endif
|
2008-03-07 00:43:05 +00:00
|
|
|
|
2008-03-30 00:04:09 +00:00
|
|
|
MIDIDevice *MIDI;
|
2008-03-05 03:10:31 +00:00
|
|
|
DWORD Events[2][MAX_EVENTS*3];
|
2008-03-04 06:36:23 +00:00
|
|
|
MIDIHDR Buffer[2];
|
|
|
|
int BufferNum;
|
|
|
|
int EndQueued;
|
|
|
|
bool VolumeChanged;
|
|
|
|
bool Restarting;
|
2008-03-05 03:10:31 +00:00
|
|
|
bool InitialPlayback;
|
2008-03-04 06:36:23 +00:00
|
|
|
DWORD NewVolume;
|
2008-03-05 03:10:31 +00:00
|
|
|
int Division;
|
|
|
|
int Tempo;
|
|
|
|
int InitialTempo;
|
|
|
|
BYTE ChannelVolumes[16];
|
VERY IMPORTANT NOTE FOR ANYBODY BUILDING FROM THE TRUNK: This commit adds support
for FMOD Ex while at the same time removing support for FMOD 3. Be sure to update
your SDKs. GCC users, be sure to do a "make cleandep && make clean" before
building, or you will likely get inexplicable errors.
- Fixed: If you wanted to make cleandep with MinGW, you had to specifically
specify Makefile.mingw as the makefile to use.
- Added a normalizer to the OPL synth. It helped bring up the volume a little,
but not nearly as much as I would have liked.
- Removed MIDI Mapper references. It doesn't work with the stream API, and
it doesn't really exist on NT kernels, either.
- Reworked music volume: Except for MIDI, all music volume is controlled
through GSnd and not at the individual song level.
- Removed the mididevice global variable.
- Removed snd_midivolume. Now that all music uses a linear volume scale,
there's no need for two separate music volume controls.
- Increased snd_samplerate default up to 48000.
- Added snd_format, defaulting to "PCM-16".
- Added snd_speakermode, defaulting to "Auto".
- Replaced snd_fpu with snd_resampler, defaulting to "Linear".
- Bumped the snd_channels default up from a pitiful 12 to 32.
- Changed snd_3d default to true. The new cvar snd_hw3d determines if
hardware 3D support is used and default to false.
- Removed the libFLAC source, since FMOD Ex has native FLAC support.
- Removed the altsound code, since it was terribly gimped in comparison to
the FMOD code. It's original purpose was to have been as a springboard for
writing a non-FMOD sound system for Unix-y systems, but that never
happened.
- Finished preliminary FMOD Ex support.
SVN r789 (trunk)
2008-03-09 03:13:49 +00:00
|
|
|
DWORD Volume;
|
2010-10-02 04:12:21 +00:00
|
|
|
EMidiDevice DeviceType;
|
2008-03-30 00:04:09 +00:00
|
|
|
bool CallbackIsThreaded;
|
2010-09-29 03:35:53 +00:00
|
|
|
int LoopLimit;
|
2008-04-03 02:31:39 +00:00
|
|
|
FString DumpFilename;
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
2008-03-05 03:10:31 +00:00
|
|
|
// MUS file played with a MIDI stream ---------------------------------------
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-03-05 03:10:31 +00:00
|
|
|
class MUSSong2 : public MIDIStreamer
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-10-02 04:12:21 +00:00
|
|
|
MUSSong2(FILE *file, BYTE *musiccache, int length, EMidiDevice type);
|
2008-04-03 02:31:39 +00:00
|
|
|
~MUSSong2();
|
|
|
|
|
|
|
|
MusInfo *GetOPLDumper(const char *filename);
|
2008-04-19 21:36:53 +00:00
|
|
|
MusInfo *GetWaveDumper(const char *filename, int rate);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-03-05 03:10:31 +00:00
|
|
|
protected:
|
2010-10-02 04:12:21 +00:00
|
|
|
MUSSong2(const MUSSong2 *original, const char *filename, EMidiDevice type); // file dump constructor
|
2008-04-03 02:31:39 +00:00
|
|
|
|
2008-03-05 03:10:31 +00:00
|
|
|
void DoInitialSetup();
|
|
|
|
void DoRestart();
|
|
|
|
bool CheckDone();
|
2008-04-09 03:55:04 +00:00
|
|
|
void Precache();
|
2008-03-05 03:10:31 +00:00
|
|
|
DWORD *MakeEvents(DWORD *events, DWORD *max_events_p, DWORD max_time);
|
|
|
|
|
|
|
|
MUSHeader *MusHeader;
|
|
|
|
BYTE *MusBuffer;
|
|
|
|
BYTE LastVelocity[16];
|
|
|
|
size_t MusP, MaxMusP;
|
|
|
|
};
|
|
|
|
|
|
|
|
// MIDI file played with a MIDI stream --------------------------------------
|
|
|
|
|
|
|
|
class MIDISong2 : public MIDIStreamer
|
|
|
|
{
|
|
|
|
public:
|
2010-10-02 04:12:21 +00:00
|
|
|
MIDISong2(FILE *file, BYTE *musiccache, int length, EMidiDevice type);
|
2008-04-03 02:31:39 +00:00
|
|
|
~MIDISong2();
|
|
|
|
|
|
|
|
MusInfo *GetOPLDumper(const char *filename);
|
2008-04-19 21:36:53 +00:00
|
|
|
MusInfo *GetWaveDumper(const char *filename, int rate);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
protected:
|
2010-10-02 04:12:21 +00:00
|
|
|
MIDISong2(const MIDISong2 *original, const char *filename, EMidiDevice type); // file dump constructor
|
2008-04-03 02:31:39 +00:00
|
|
|
|
2010-09-03 05:08:05 +00:00
|
|
|
void CheckCaps(int tech);
|
2008-03-05 03:10:31 +00:00
|
|
|
void DoInitialSetup();
|
|
|
|
void DoRestart();
|
|
|
|
bool CheckDone();
|
|
|
|
DWORD *MakeEvents(DWORD *events, DWORD *max_events_p, DWORD max_time);
|
2008-03-30 02:51:34 +00:00
|
|
|
void AdvanceTracks(DWORD time);
|
2008-03-05 03:10:31 +00:00
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
struct TrackInfo;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
void ProcessInitialMetaEvents ();
|
2008-03-05 03:10:31 +00:00
|
|
|
DWORD *SendCommand (DWORD *event, TrackInfo *track, DWORD delay);
|
2006-02-24 04:48:15 +00:00
|
|
|
TrackInfo *FindNextDue ();
|
2006-09-14 00:02:31 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
BYTE *MusHeader;
|
2008-04-03 02:31:39 +00:00
|
|
|
int SongLen;
|
2006-02-24 04:48:15 +00:00
|
|
|
TrackInfo *Tracks;
|
|
|
|
TrackInfo *TrackDue;
|
|
|
|
int NumTracks;
|
|
|
|
int Format;
|
|
|
|
WORD DesignationMask;
|
|
|
|
};
|
2008-03-05 03:10:31 +00:00
|
|
|
|
2010-09-02 23:17:58 +00:00
|
|
|
// HMI file played with a MIDI stream ---------------------------------------
|
|
|
|
|
2010-09-28 03:58:41 +00:00
|
|
|
struct AutoNoteOff
|
|
|
|
{
|
|
|
|
DWORD Delay;
|
|
|
|
BYTE Channel, Key;
|
|
|
|
};
|
|
|
|
// Sorry, std::priority_queue, but I want to be able to modify the contents of the heap.
|
|
|
|
class NoteOffQueue : public TArray<AutoNoteOff>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void AddNoteOff(DWORD delay, BYTE channel, BYTE key);
|
|
|
|
void AdvanceTime(DWORD time);
|
|
|
|
bool Pop(AutoNoteOff &item);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void Heapify();
|
|
|
|
|
|
|
|
unsigned int Parent(unsigned int i) { return (i + 1u) / 2u - 1u; }
|
|
|
|
unsigned int Left(unsigned int i) { return (i + 1u) * 2u - 1u; }
|
|
|
|
unsigned int Right(unsigned int i) { return (i + 1u) * 2u; }
|
|
|
|
};
|
|
|
|
|
2010-09-02 23:17:58 +00:00
|
|
|
class HMISong : public MIDIStreamer
|
|
|
|
{
|
|
|
|
public:
|
2010-10-02 04:12:21 +00:00
|
|
|
HMISong(FILE *file, BYTE *musiccache, int length, EMidiDevice type);
|
2010-09-02 23:17:58 +00:00
|
|
|
~HMISong();
|
|
|
|
|
|
|
|
MusInfo *GetOPLDumper(const char *filename);
|
|
|
|
MusInfo *GetWaveDumper(const char *filename, int rate);
|
|
|
|
|
|
|
|
protected:
|
2010-10-02 04:12:21 +00:00
|
|
|
HMISong(const HMISong *original, const char *filename, EMidiDevice type); // file dump constructor
|
2010-09-02 23:17:58 +00:00
|
|
|
|
2010-09-24 02:46:48 +00:00
|
|
|
void SetupForHMI(int len);
|
|
|
|
void SetupForHMP(int len);
|
2010-09-03 05:08:05 +00:00
|
|
|
void CheckCaps(int tech);
|
2010-10-05 22:35:59 +00:00
|
|
|
|
2010-09-02 23:17:58 +00:00
|
|
|
void DoInitialSetup();
|
|
|
|
void DoRestart();
|
|
|
|
bool CheckDone();
|
|
|
|
DWORD *MakeEvents(DWORD *events, DWORD *max_events_p, DWORD max_time);
|
|
|
|
void AdvanceTracks(DWORD time);
|
|
|
|
|
|
|
|
struct TrackInfo;
|
|
|
|
|
|
|
|
void ProcessInitialMetaEvents ();
|
|
|
|
DWORD *SendCommand (DWORD *event, TrackInfo *track, DWORD delay);
|
|
|
|
TrackInfo *FindNextDue ();
|
|
|
|
|
2010-09-24 02:46:48 +00:00
|
|
|
static DWORD ReadVarLenHMI(TrackInfo *);
|
|
|
|
static DWORD ReadVarLenHMP(TrackInfo *);
|
|
|
|
|
2010-09-02 23:17:58 +00:00
|
|
|
BYTE *MusHeader;
|
|
|
|
int SongLen;
|
|
|
|
int NumTracks;
|
|
|
|
TrackInfo *Tracks;
|
|
|
|
TrackInfo *TrackDue;
|
|
|
|
TrackInfo *FakeTrack;
|
2010-09-24 02:46:48 +00:00
|
|
|
DWORD (*ReadVarLen)(TrackInfo *);
|
2010-09-02 23:17:58 +00:00
|
|
|
NoteOffQueue NoteOffs;
|
|
|
|
};
|
|
|
|
|
2010-09-28 03:58:41 +00:00
|
|
|
// XMI file played with a MIDI stream ---------------------------------------
|
|
|
|
|
|
|
|
class XMISong : public MIDIStreamer
|
|
|
|
{
|
|
|
|
public:
|
2010-10-02 04:12:21 +00:00
|
|
|
XMISong(FILE *file, BYTE *musiccache, int length, EMidiDevice type);
|
2010-09-28 03:58:41 +00:00
|
|
|
~XMISong();
|
|
|
|
|
|
|
|
MusInfo *GetOPLDumper(const char *filename);
|
|
|
|
MusInfo *GetWaveDumper(const char *filename, int rate);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
struct TrackInfo;
|
|
|
|
enum EventSource { EVENT_None, EVENT_Real, EVENT_Fake };
|
|
|
|
|
2010-10-02 04:12:21 +00:00
|
|
|
XMISong(const XMISong *original, const char *filename, EMidiDevice type); // file dump constructor
|
2010-09-28 03:58:41 +00:00
|
|
|
|
|
|
|
int FindXMIDforms(const BYTE *chunk, int len, TrackInfo *songs) const;
|
|
|
|
void FoundXMID(const BYTE *chunk, int len, TrackInfo *song) const;
|
|
|
|
bool SetMIDISubsong(int subsong);
|
|
|
|
void DoInitialSetup();
|
|
|
|
void DoRestart();
|
|
|
|
bool CheckDone();
|
|
|
|
DWORD *MakeEvents(DWORD *events, DWORD *max_events_p, DWORD max_time);
|
|
|
|
void AdvanceSong(DWORD time);
|
|
|
|
|
|
|
|
void ProcessInitialMetaEvents();
|
|
|
|
DWORD *SendCommand (DWORD *event, EventSource track, DWORD delay);
|
|
|
|
EventSource FindNextDue();
|
|
|
|
|
|
|
|
BYTE *MusHeader;
|
|
|
|
int SongLen; // length of the entire file
|
|
|
|
int NumSongs;
|
|
|
|
TrackInfo *Songs;
|
|
|
|
TrackInfo *CurrSong;
|
|
|
|
NoteOffQueue NoteOffs;
|
|
|
|
EventSource EventDue;
|
|
|
|
};
|
|
|
|
|
VERY IMPORTANT NOTE FOR ANYBODY BUILDING FROM THE TRUNK: This commit adds support
for FMOD Ex while at the same time removing support for FMOD 3. Be sure to update
your SDKs. GCC users, be sure to do a "make cleandep && make clean" before
building, or you will likely get inexplicable errors.
- Fixed: If you wanted to make cleandep with MinGW, you had to specifically
specify Makefile.mingw as the makefile to use.
- Added a normalizer to the OPL synth. It helped bring up the volume a little,
but not nearly as much as I would have liked.
- Removed MIDI Mapper references. It doesn't work with the stream API, and
it doesn't really exist on NT kernels, either.
- Reworked music volume: Except for MIDI, all music volume is controlled
through GSnd and not at the individual song level.
- Removed the mididevice global variable.
- Removed snd_midivolume. Now that all music uses a linear volume scale,
there's no need for two separate music volume controls.
- Increased snd_samplerate default up to 48000.
- Added snd_format, defaulting to "PCM-16".
- Added snd_speakermode, defaulting to "Auto".
- Replaced snd_fpu with snd_resampler, defaulting to "Linear".
- Bumped the snd_channels default up from a pitiful 12 to 32.
- Changed snd_3d default to true. The new cvar snd_hw3d determines if
hardware 3D support is used and default to false.
- Removed the libFLAC source, since FMOD Ex has native FLAC support.
- Removed the altsound code, since it was terribly gimped in comparison to
the FMOD code. It's original purpose was to have been as a springboard for
writing a non-FMOD sound system for Unix-y systems, but that never
happened.
- Finished preliminary FMOD Ex support.
SVN r789 (trunk)
2008-03-09 03:13:49 +00:00
|
|
|
// Anything supported by FMOD out of the box --------------------------------
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
class StreamSong : public MusInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
StreamSong (const char *file, int offset, int length);
|
|
|
|
~StreamSong ();
|
2008-08-03 03:54:48 +00:00
|
|
|
void Play (bool looping, int subsong);
|
2006-02-24 04:48:15 +00:00
|
|
|
void Pause ();
|
|
|
|
void Resume ();
|
|
|
|
void Stop ();
|
|
|
|
bool IsPlaying ();
|
|
|
|
bool IsValid () const { return m_Stream != NULL; }
|
2008-08-03 03:54:48 +00:00
|
|
|
bool SetPosition (unsigned int pos);
|
|
|
|
bool SetSubsong (int subsong);
|
- The garbage collector is now run one last time just before exiting the game.
- Removed movie volume from the sound menu and renamed some of the other
options to give the MIDI device name more room to display itself.
- Moved the midi device selection into the main sound menu.
- Added FMOD as MIDI device -1, to replace the MIDI mapper. This is still the
default device. By default, it uses exactly the same DLS instruments as the
Microsoft GS Wavetable Synth. If you have another set DLS level 1 patch set
you want to use, set the snd_midipatchfile cvar to specify where it should
load the instruments from.
- Changed the ProduceMIDI function to store its output into a TArray<BYTE>.
An overloaded version wraps around it to continue to supply file-writing
support for external Timidity++ usage.
- Added an FMOD credits banner to comply with their non-commercial license.
- Reimplemented the snd_buffersize cvar for the FMOD Ex sound system. Rather
than a time in ms, this is now the length in samples of the DSP buffer.
Also added the snd_buffercount cvar to offer complete control over the
call to FMOD::System::setDSPBufferSize(). Note that with any snd_samplerate
below about 44kHz, you will need to set snd_buffersize to avoid long
latencies.
- Reimplemented the snd_output cvar for the FMOD Ex sound system.
- Changed snd_samplerate default to 0. This now means to use the default
sample rate.
- Made snd_output, snd_output_format, snd_speakermode, snd_resampler, and
snd_hrtf available through the menu.
- Split the HRTF effect selection into its own cvar: snd_hrtf.
- Removed 96000 Hz option from the menu. It's still available through the
cvar, if desired.
- Fixed: If Windows sound init failed, retry with DirectSound. (Apparently,
WASAPI doesn't work with more than two speakers and PCM-Float output at the
same time.)
- Fixed: Area sounds only played from the front speakers once you got within
the 2D panning area.
SVN r854 (trunk)
2008-03-26 04:27:07 +00:00
|
|
|
FString GetStats();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
protected:
|
2008-04-30 05:36:24 +00:00
|
|
|
StreamSong () : m_Stream(NULL) {}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
SoundStream *m_Stream;
|
|
|
|
};
|
|
|
|
|
|
|
|
// MUS file played by a software OPL2 synth and streamed through FMOD -------
|
|
|
|
|
|
|
|
class OPLMUSSong : public StreamSong
|
|
|
|
{
|
|
|
|
public:
|
2009-06-03 03:05:02 +00:00
|
|
|
OPLMUSSong (FILE *file, BYTE *musiccache, int length);
|
2006-02-24 04:48:15 +00:00
|
|
|
~OPLMUSSong ();
|
2008-08-03 03:54:48 +00:00
|
|
|
void Play (bool looping, int subsong);
|
2006-02-24 04:48:15 +00:00
|
|
|
bool IsPlaying ();
|
|
|
|
bool IsValid () const;
|
|
|
|
void ResetChips ();
|
2008-04-03 02:31:39 +00:00
|
|
|
MusInfo *GetOPLDumper(const char *filename);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
protected:
|
2008-04-03 02:31:39 +00:00
|
|
|
OPLMUSSong(const OPLMUSSong *original, const char *filename); // OPL dump constructor
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
static bool FillStream (SoundStream *stream, void *buff, int len, void *userdata);
|
|
|
|
|
2008-03-28 03:19:18 +00:00
|
|
|
OPLmusicFile *Music;
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
2008-04-03 02:31:39 +00:00
|
|
|
class OPLMUSDumper : public OPLMUSSong
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
OPLMUSDumper(const OPLMUSSong *original, const char *filename);
|
|
|
|
void Play(bool looping);
|
|
|
|
};
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// CD track/disk played through the multimedia system -----------------------
|
|
|
|
|
|
|
|
class CDSong : public MusInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CDSong (int track, int id);
|
|
|
|
~CDSong ();
|
2008-08-03 03:54:48 +00:00
|
|
|
void Play (bool looping, int subsong);
|
2006-02-24 04:48:15 +00:00
|
|
|
void Pause ();
|
|
|
|
void Resume ();
|
|
|
|
void Stop ();
|
|
|
|
bool IsPlaying ();
|
|
|
|
bool IsValid () const { return m_Inited; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
CDSong () : m_Inited(false) {}
|
|
|
|
|
|
|
|
int m_Track;
|
|
|
|
bool m_Inited;
|
|
|
|
};
|
|
|
|
|
|
|
|
// CD track on a specific disk played through the multimedia system ---------
|
|
|
|
|
|
|
|
class CDDAFile : public CDSong
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CDDAFile (FILE *file, int length);
|
|
|
|
};
|
|
|
|
|
2008-05-29 23:33:07 +00:00
|
|
|
// Module played via foo_dumb -----------------------------------------------
|
|
|
|
|
2009-06-03 03:05:02 +00:00
|
|
|
MusInfo *MOD_OpenSong(FILE *file, BYTE *musiccache, int len);
|
|
|
|
|
|
|
|
// Music played via Game Music Emu ------------------------------------------
|
|
|
|
|
|
|
|
const char *GME_CheckFormat(uint32 header);
|
|
|
|
MusInfo *GME_OpenSong(FILE *file, BYTE *musiccache, int len, const char *fmt);
|
2008-05-29 23:33:07 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
extern MusInfo *currSong;
|
|
|
|
|
|
|
|
EXTERN_CVAR (Float, snd_musicvolume)
|