- 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)
This commit is contained in:
Randy Heit 2008-03-26 04:27:07 +00:00
commit 8d0c48bf81
21 changed files with 615 additions and 186 deletions

View file

@ -100,9 +100,6 @@ extern int skullAnimCounter;
EXTERN_CVAR (Bool, cl_run)
EXTERN_CVAR (Int, crosshair)
EXTERN_CVAR (Bool, freelook)
EXTERN_CVAR (Int, snd_buffersize)
EXTERN_CVAR (Int, snd_samplerate)
EXTERN_CVAR (Bool, snd_waterreverb)
EXTERN_CVAR (Int, sv_smartaim)
static void CalcIndent (menu_t *menu);
@ -1128,62 +1125,131 @@ EXTERN_CVAR (Float, snd_movievolume)
#endif
EXTERN_CVAR (Bool, snd_flipstereo)
EXTERN_CVAR (Bool, snd_pitched)
EXTERN_CVAR (String, snd_output_format)
EXTERN_CVAR (String, snd_speakermode)
EXTERN_CVAR (String, snd_resampler)
EXTERN_CVAR (String, snd_output)
EXTERN_CVAR (Int, snd_buffersize)
EXTERN_CVAR (Int, snd_buffercount)
EXTERN_CVAR (Int, snd_samplerate)
EXTERN_CVAR (Bool, snd_hrtf)
EXTERN_CVAR (Bool, snd_waterreverb)
EXTERN_CVAR (Int, snd_mididevice)
static void MakeSoundChanges ();
static void AdvSoundOptions ();
static void ChooseMIDI ();
static value_t SampleRates[] =
{
{ 4000.f, "4000 Hz" },
{ 8000.f, "8000 Hz" },
{ 11025.f, "11025 Hz" },
{ 22050.f, "22050 Hz" },
{ 32000.f, "32000 Hz" },
{ 44100.f, "44100 Hz" },
{ 48000.f, "48000 Hz" },
{ 96000.f, "96000 Hz" }
{ 0.f, "Default" },
{ 4000.f, "4000 Hz" },
{ 8000.f, "8000 Hz" },
{ 11025.f, "11025 Hz" },
{ 22050.f, "22050 Hz" },
{ 32000.f, "32000 Hz" },
{ 44100.f, "44100 Hz" },
{ 48000.f, "48000 Hz" }
};
static value_t BufferSizes[] =
{
{ 0.f, "Default" },
{ 20.f, "20 ms" },
{ 40.f, "40 ms" },
{ 60.f, "60 ms" },
{ 80.f, "80 ms" },
{ 100.f, "100 ms" },
{ 120.f, "120 ms" },
{ 140.f, "140 ms" },
{ 160.f, "160 ms" },
{ 180.f, "180 ms" },
{ 200.f, "200 ms" },
{ 0.f, "Default" },
{ 64.f, "64 samples" },
{ 128.f, "128 samples" },
{ 256.f, "256 samples" },
{ 512.f, "512 samples" },
{ 1024.f, "1024 samples" },
{ 2048.f, "2048 samples" },
{ 4096.f, "4096 samples" }
};
static value_t BufferCounts[] =
{
{ 0.f, "Default" },
{ 2.f, "2" },
{ 3.f, "3" },
{ 4.f, "4" },
{ 5.f, "5" },
{ 6.f, "6" },
{ 7.f, "7" },
{ 8.f, "8" },
{ 9.f, "9" },
{ 10.f, "10" },
{ 11.f, "11" },
{ 12.f, "12" }
};
static valueenum_t Outputs[] =
{
{ "Default", "Default" },
#if defined(_WIN32)
{ "DirectSound", "DirectSound" },
{ "WASAPI", "Vista WASAPI" },
{ "ASIO", "ASIO" },
{ "WaveOut", "WaveOut" },
{ "OpenAL", "OpenAL (very beta)" },
#elif defined(unix)
{ "OSS", "OSS" },
{ "ALSA", "ALSA" },
{ "ESD", "ESD" },
#elif defined(__APPLE__)
{ "Sound Manager", "Sound Manager" },
{ "Core Audio", "Core Audio" },
#endif
{ "No sound", "No sound" }
};
static valueenum_t OutputFormats[] =
{
{ "PCM-8", "8-bit" },
{ "PCM-16", "16-bit" },
{ "PCM-24", "24-bit" },
{ "PCM-32", "32-bit" },
{ "PCM-Float", "32-bit float" }
};
static valueenum_t SpeakerModes[] =
{
{ "Auto", "Auto" },
{ "Mono", "Mono" },
{ "Stereo", "Stereo" },
{ "Prologic", "Dolby Prologic Decoder" },
{ "Quad", "Quad" },
{ "Surround", "5 speakers" },
{ "5.1", "5.1 speakers" },
{ "7.1", "7.1 speakers" }
};
static valueenum_t Resamplers[] =
{
{ "NoInterp", "No interpolation" },
{ "Linear", "Linear" },
{ "Cubic", "Cubic" },
{ "Spline", "Spline" }
};
static menuitem_t SoundItems[] =
{
{ slider, "Sound effects volume", {&snd_sfxvolume}, {0.0}, {1.0}, {0.05}, {NULL} },
#ifdef _WIN32
{ slider, "Sounds volume", {&snd_sfxvolume}, {0.0}, {1.0}, {0.05}, {NULL} },
{ slider, "Music volume", {&snd_musicvolume}, {0.0}, {1.0}, {0.05}, {NULL} },
{ slider, "Movie volume", {&snd_movievolume}, {0.0}, {1.0}, {0.05}, {NULL} },
#else
{ slider, "Music volume", {&snd_musicvolume}, {0.0}, {1.0}, {0.05}, {NULL} },
#endif
{ discrete, "MIDI device", {&snd_mididevice}, {0.0}, {0.0}, {0.0}, {NULL} },
{ redtext, " ", {NULL}, {0.0}, {0.0}, {0.0}, {NULL} },
{ discrete, "Underwater Reverb", {&snd_waterreverb}, {2.0}, {0.0}, {0.0}, {OnOff} },
{ discrete, "Flip Stereo Channels", {&snd_flipstereo}, {2.0}, {0.0}, {0.0}, {OnOff} },
{ discrete, "Random Pitch Variations", {&snd_pitched}, {2.0}, {0.0}, {0.0}, {OnOff} },
{ discrete, "Underwater reverb", {&snd_waterreverb}, {2.0}, {0.0}, {0.0}, {OnOff} },
{ discrete, "Randomize pitches", {&snd_pitched}, {2.0}, {0.0}, {0.0}, {OnOff} },
{ redtext, " ", {NULL}, {0.0}, {0.0}, {0.0}, {NULL} },
{ more, "Activate below settings", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)MakeSoundChanges} },
{ more, "Restart sound", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)MakeSoundChanges} },
{ redtext, " ", {NULL}, {0.0}, {0.0}, {0.0}, {NULL} },
{ discrete, "Sample Rate", {&snd_samplerate}, {8.0}, {0.0}, {0.0}, {SampleRates} },
{ discrete, "Buffer Size", {&snd_buffersize}, {11.0}, {0.0}, {0.0}, {BufferSizes} },
{ ediscrete,"Output system", {&snd_output}, {countof(Outputs)}, {0.0}, {0.0}, {(value_t *)Outputs} },
{ ediscrete,"Output format", {&snd_output_format}, {5.0}, {0.0}, {0.0}, {(value_t *)OutputFormats} },
{ ediscrete,"Speaker mode", {&snd_speakermode}, {8.0}, {0.0}, {0.0}, {(value_t *)SpeakerModes} },
{ ediscrete,"Resampler", {&snd_resampler}, {4.0}, {0.0}, {0.0}, {(value_t *)Resamplers} },
{ discrete, "HRTF filter", {&snd_hrtf}, {2.0}, {0.0}, {0.0}, {(value_t *)OnOff} },
{ discrete, "Sample rate", {&snd_samplerate}, {8.0}, {0.0}, {0.0}, {SampleRates} },
{ discrete, "Buffer size", {&snd_buffersize}, {8.0}, {0.0}, {0.0}, {BufferSizes} },
{ discrete, "Buffer count", {&snd_buffercount}, {12.0}, {0.0}, {0.0}, {BufferCounts} },
{ redtext, " ", {NULL}, {0.0}, {0.0}, {0.0}, {NULL} },
{ more, "Advanced Options", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)AdvSoundOptions} },
#ifdef _WIN32
{ more, "Select MIDI Device", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)ChooseMIDI} },
#endif
{ more, "Advanced options", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)AdvSoundOptions} },
};
static menu_t SoundMenu =
@ -1195,29 +1261,7 @@ static menu_t SoundMenu =
SoundItems,
};
#ifdef _WIN32
/*=======================================
*
* MIDI Device Menu
*
*=======================================*/
EXTERN_CVAR (Int, snd_mididevice)
static menuitem_t MidiDeviceItems[] =
{
{ discrete, "Device", {&snd_mididevice}, {0.0}, {0.0}, {0.0}, {NULL} },
};
static menu_t MidiDeviceMenu =
{
"SELECT MIDI DEVICE",
0,
1,
0,
MidiDeviceItems,
};
#endif
#define MIDI_DEVICE_ITEM 2
/*=======================================
*
@ -1498,6 +1542,42 @@ int M_FindCurGUID (const GUID &guid, GUIDName *values, int numvals)
return v;
}
const char *M_FindCurVal(const char *cur, valueenum_t *values, int numvals)
{
for (int v = 0; v < numvals; ++v)
{
if (stricmp(values[v].value, cur) == 0)
{
return values[v].name;
}
}
return cur;
}
const char *M_FindPrevVal(const char *cur, valueenum_t *values, int numvals)
{
for (int v = 0; v < numvals; ++v)
{
if (stricmp(values[v].value, cur) == 0)
{
return values[v == 0 ? numvals - 1 : v - 1].value;
}
}
return values[0].value;
}
const char *M_FindNextVal(const char *cur, valueenum_t *values, int numvals)
{
for (int v = 0; v < numvals; ++v)
{
if (stricmp(values[v].value, cur) == 0)
{
return values[v == numvals - 1 ? 0 : v + 1].value;
}
}
return values[0].value;
}
void M_OptDrawer ()
{
EColorRange color;
@ -1684,6 +1764,16 @@ void M_OptDrawer ()
}
break;
case ediscrete:
{
const char *v;
value = item->a.cvar->GetGenericRep (CVAR_String);
v = M_FindCurVal(value.String, item->e.enumvalues, (int)item->b.numvalues);
screen->DrawText(ValueColor, CurrentMenu->indent + 14, y, v, DTA_Clean, true, TAG_DONE);
}
break;
case discrete_guid:
{
int v, vals;
@ -2163,6 +2253,13 @@ void M_OptResponder (event_t *ev)
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
break;
case ediscrete:
value = item->a.cvar->GetGenericRep(CVAR_String);
value.String = const_cast<char *>(M_FindPrevVal(value.String, item->e.enumvalues, (int)item->b.numvalues));
item->a.cvar->SetGenericRep(value, CVAR_String);
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
break;
case bitmask:
{
int cur;
@ -2305,6 +2402,13 @@ void M_OptResponder (event_t *ev)
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
break;
case ediscrete:
value = item->a.cvar->GetGenericRep(CVAR_String);
value.String = const_cast<char *>(M_FindNextVal(value.String, item->e.enumvalues, (int)item->b.numvalues));
item->a.cvar->SetGenericRep(value, CVAR_String);
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
break;
case bitmask:
{
int cur;
@ -2870,9 +2974,19 @@ CCMD (menu_joystick)
JoystickOptions ();
}
static void FreeMIDIMenuList()
{
if (SoundItems[MIDI_DEVICE_ITEM].e.values != NULL)
{
delete[] SoundItems[MIDI_DEVICE_ITEM].e.values;
}
}
static void SoundOptions ()
{
M_SwitchMenu (&SoundMenu);
I_BuildMIDIMenuList(&SoundItems[MIDI_DEVICE_ITEM].e.values, &SoundItems[MIDI_DEVICE_ITEM].b.min);
atterm(FreeMIDIMenuList);
M_SwitchMenu(&SoundMenu);
}
CCMD (menu_sound)
@ -2894,22 +3008,6 @@ CCMD (menu_advsound)
AdvSoundOptions ();
}
#ifdef _WIN32
static void ChooseMIDI ()
{
I_BuildMIDIMenuList (&MidiDeviceItems[0].e.values,
&MidiDeviceItems[0].b.min);
M_SwitchMenu (&MidiDeviceMenu);
}
CCMD (menu_mididevice)
{
M_StartControlPanel (true);
OptionsActive = true;
ChooseMIDI ();
}
#endif
static void MakeSoundChanges (void)
{
static char snd_reset[] = "snd_reset";