2006-02-24 04:48:15 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include "i_musicinterns.h"
|
2006-09-14 00:02:31 +00:00
|
|
|
#include "c_dispatch.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "i_music.h"
|
|
|
|
|
|
|
|
#include "templates.h"
|
|
|
|
#include "v_text.h"
|
|
|
|
#include "m_menu.h"
|
|
|
|
|
|
|
|
static DWORD nummididevices;
|
|
|
|
static bool nummididevicesset;
|
|
|
|
UINT mididevice;
|
|
|
|
|
|
|
|
CVAR (Bool, snd_midiprecache, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
|
|
|
|
|
|
|
|
CUSTOM_CVAR (Int, snd_mididevice, -1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|
|
|
{
|
|
|
|
UINT oldmididev = mididevice;
|
|
|
|
|
|
|
|
if (!nummididevicesset)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((self >= (signed)nummididevices) || (self < -2))
|
|
|
|
{
|
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
|
|
|
Printf ("ID out of range. Using default device.\n");
|
|
|
|
self = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (self < 0)
|
|
|
|
{
|
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
|
|
|
mididevice = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mididevice = self;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If a song is playing, move it to the new device.
|
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
|
|
|
if (oldmididev != mididevice && currSong != NULL && currSong->IsMIDI())
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
MusInfo *song = currSong;
|
|
|
|
if (song->m_Status == MusInfo::STATE_Playing)
|
|
|
|
{
|
|
|
|
I_StopSong (song);
|
|
|
|
I_PlaySong (song, song->m_Looping);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void I_InitMusicWin32 ()
|
|
|
|
{
|
|
|
|
nummididevices = midiOutGetNumDevs ();
|
|
|
|
nummididevicesset = true;
|
|
|
|
snd_mididevice.Callback ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void I_ShutdownMusicWin32 ()
|
|
|
|
{
|
|
|
|
// I don't know if this is an NT 4.0 bug or an FMOD bug, but if waveout
|
|
|
|
// is used for sound, and a MIDI is also played, then when I quit, the OS
|
|
|
|
// tells me a free block was modified after being freed. This is
|
|
|
|
// apparently a synchronization issue between two threads, because if I
|
|
|
|
// put this Sleep here after stopping the music but before shutting down
|
|
|
|
// the entire sound system, the error does not happen. I don't think it's
|
|
|
|
// a driver problem, because it happens with both a Vortex 2 and an Audigy.
|
|
|
|
// Though if their drivers are both based off some common Microsoft sample
|
|
|
|
// code, I suppose it could be a driver issue.
|
|
|
|
Sleep (50);
|
|
|
|
}
|
|
|
|
|
|
|
|
void I_BuildMIDIMenuList (struct value_s **outValues, float *numValues)
|
|
|
|
{
|
|
|
|
if (*outValues == NULL)
|
|
|
|
{
|
|
|
|
int count = 1 + nummididevices + (nummididevices > 0);
|
|
|
|
value_t *values;
|
|
|
|
|
|
|
|
*outValues = values = new value_t[count];
|
|
|
|
|
|
|
|
values[0].name = "TiMidity++";
|
|
|
|
values[0].value = -2.0;
|
|
|
|
if (nummididevices > 0)
|
|
|
|
{
|
|
|
|
UINT id;
|
|
|
|
int p;
|
|
|
|
|
|
|
|
values[1].name = "MIDI Mapper";
|
|
|
|
values[1].value = -1.0;
|
|
|
|
for (id = 0, p = 2; id < nummididevices; ++id)
|
|
|
|
{
|
|
|
|
MIDIOUTCAPS caps;
|
|
|
|
MMRESULT res;
|
|
|
|
|
|
|
|
res = midiOutGetDevCaps (id, &caps, sizeof(caps));
|
|
|
|
if (res == MMSYSERR_NOERROR)
|
|
|
|
{
|
|
|
|
size_t len = strlen (caps.szPname) + 1;
|
2006-12-29 03:48:00 +00:00
|
|
|
char *name = new char[len];
|
|
|
|
|
|
|
|
memcpy (name, caps.szPname, len);
|
|
|
|
values[p].name = name;
|
2006-02-24 04:48:15 +00:00
|
|
|
values[p].value = (float)id;
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*numValues = (float)p;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*numValues = 1.f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PrintMidiDevice (int id, const char *name, WORD tech, DWORD support)
|
|
|
|
{
|
|
|
|
if (id == snd_mididevice)
|
|
|
|
{
|
|
|
|
Printf (TEXTCOLOR_BOLD);
|
|
|
|
}
|
|
|
|
Printf ("% 2d. %s : ", id, name);
|
|
|
|
switch (tech)
|
|
|
|
{
|
|
|
|
case MOD_MIDIPORT: Printf ("MIDIPORT"); break;
|
|
|
|
case MOD_SYNTH: Printf ("SYNTH"); break;
|
|
|
|
case MOD_SQSYNTH: Printf ("SQSYNTH"); break;
|
|
|
|
case MOD_FMSYNTH: Printf ("FMSYNTH"); break;
|
|
|
|
case MOD_MAPPER: Printf ("MAPPER"); break;
|
|
|
|
#ifdef MOD_WAVETABLE
|
|
|
|
case MOD_WAVETABLE: Printf ("WAVETABLE"); break;
|
|
|
|
case MOD_SWSYNTH: Printf ("SWSYNTH"); break;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
if (support & MIDICAPS_CACHE)
|
|
|
|
{
|
|
|
|
Printf (" CACHE");
|
|
|
|
}
|
|
|
|
if (support & MIDICAPS_LRVOLUME)
|
|
|
|
{
|
|
|
|
Printf (" LRVOLUME");
|
|
|
|
}
|
|
|
|
if (support & MIDICAPS_STREAM)
|
|
|
|
{
|
|
|
|
Printf (" STREAM");
|
|
|
|
}
|
|
|
|
if (support & MIDICAPS_VOLUME)
|
|
|
|
{
|
|
|
|
Printf (" VOLUME");
|
|
|
|
}
|
|
|
|
Printf (TEXTCOLOR_NORMAL "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
CCMD (snd_listmididevices)
|
|
|
|
{
|
|
|
|
UINT id;
|
|
|
|
MIDIOUTCAPS caps;
|
|
|
|
MMRESULT res;
|
|
|
|
|
|
|
|
PrintMidiDevice (-2, "TiMidity++", 0, 0);
|
|
|
|
if (nummididevices != 0)
|
|
|
|
{
|
|
|
|
PrintMidiDevice (-1, "MIDI Mapper", MOD_MAPPER, 0);
|
|
|
|
for (id = 0; id < nummididevices; ++id)
|
|
|
|
{
|
|
|
|
res = midiOutGetDevCaps (id, &caps, sizeof(caps));
|
|
|
|
if (res == MMSYSERR_NODRIVER)
|
|
|
|
strcpy (caps.szPname, "<Driver not installed>");
|
|
|
|
else if (res == MMSYSERR_NOMEM)
|
|
|
|
strcpy (caps.szPname, "<No memory for description>");
|
|
|
|
else if (res != MMSYSERR_NOERROR)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
PrintMidiDevice (id, caps.szPname, caps.wTechnology, caps.dwSupport);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|