mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-08-03 12:47:01 -04:00
Restore resampler menu option (#1671)
This commit is contained in:
parent
7d6784db60
commit
6b849f9d22
@ -31,6 +31,7 @@
|
||||
#include "i_sound.h"
|
||||
#include "m_array.h"
|
||||
#include "m_fixed.h"
|
||||
#include "m_misc.h"
|
||||
#include "sounds.h"
|
||||
#include "w_wad.h"
|
||||
#include "z_zone.h"
|
||||
@ -57,7 +58,7 @@
|
||||
# define FUNCTION_CAST(T, ptr) (T)(ptr)
|
||||
#endif
|
||||
|
||||
char *snd_resampler;
|
||||
int snd_resampler;
|
||||
boolean snd_limiter;
|
||||
boolean snd_hrtf;
|
||||
int snd_absorption;
|
||||
@ -195,7 +196,7 @@ void I_OAL_ShutdownSound(void)
|
||||
oal = NULL;
|
||||
}
|
||||
|
||||
static void SetResampler(ALuint *sources)
|
||||
void I_OAL_SetResampler(void)
|
||||
{
|
||||
LPALGETSTRINGISOFT alGetStringiSOFT = NULL;
|
||||
ALint i, num_resamplers, def_resampler;
|
||||
@ -216,7 +217,6 @@ static void SetResampler(ALuint *sources)
|
||||
}
|
||||
|
||||
num_resamplers = alGetInteger(AL_NUM_RESAMPLERS_SOFT);
|
||||
def_resampler = alGetInteger(AL_DEFAULT_RESAMPLER_SOFT);
|
||||
|
||||
if (!num_resamplers)
|
||||
{
|
||||
@ -224,34 +224,29 @@ static void SetResampler(ALuint *sources)
|
||||
return;
|
||||
}
|
||||
|
||||
def_resampler = alGetInteger(AL_DEFAULT_RESAMPLER_SOFT);
|
||||
|
||||
for (i = 0; i < num_resamplers; i++)
|
||||
{
|
||||
if (!strcasecmp(snd_resampler,
|
||||
alGetStringiSOFT(AL_RESAMPLER_NAME_SOFT, i)))
|
||||
if (!strcasecmp("Linear", alGetStringiSOFT(AL_RESAMPLER_NAME_SOFT, i)))
|
||||
{
|
||||
def_resampler = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == num_resamplers)
|
||||
|
||||
if (snd_resampler >= num_resamplers)
|
||||
{
|
||||
I_Printf(VB_WARNING, " Failed to find resampler: '%s'. Valid choices:",
|
||||
snd_resampler);
|
||||
for (i = 0; i < num_resamplers; i++)
|
||||
{
|
||||
I_Printf(VB_WARNING, " %s",
|
||||
alGetStringiSOFT(AL_RESAMPLER_NAME_SOFT, i));
|
||||
}
|
||||
return;
|
||||
snd_resampler = def_resampler;
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_CHANNELS; i++)
|
||||
{
|
||||
alSourcei(sources[i], AL_SOURCE_RESAMPLER_SOFT, def_resampler);
|
||||
alSourcei(oal->sources[i], AL_SOURCE_RESAMPLER_SOFT, snd_resampler);
|
||||
}
|
||||
|
||||
I_Printf(VB_DEBUG, " Using '%s' resampler.",
|
||||
alGetStringiSOFT(AL_RESAMPLER_NAME_SOFT, def_resampler));
|
||||
alGetStringiSOFT(AL_RESAMPLER_NAME_SOFT, snd_resampler));
|
||||
}
|
||||
|
||||
void I_OAL_ResetSource2D(int channel)
|
||||
@ -327,9 +322,38 @@ void I_OAL_UpdateListenerParams(const ALfloat *position,
|
||||
alListenerfv(AL_ORIENTATION, orientation);
|
||||
}
|
||||
|
||||
const char **I_OAL_GetResamplerStrings(void)
|
||||
{
|
||||
LPALGETSTRINGISOFT alGetStringiSOFT = NULL;
|
||||
ALint i, num_resamplers;
|
||||
const char **strings = NULL;
|
||||
|
||||
if (alIsExtensionPresent("AL_SOFT_source_resampler") != AL_TRUE)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
alGetStringiSOFT =
|
||||
FUNCTION_CAST(LPALGETSTRINGISOFT, alGetProcAddress("alGetStringiSOFT"));
|
||||
|
||||
if (!alGetStringiSOFT)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
num_resamplers = alGetInteger(AL_NUM_RESAMPLERS_SOFT);
|
||||
|
||||
for (i = 0; i < num_resamplers; i++)
|
||||
{
|
||||
array_push(strings, alGetStringiSOFT(AL_RESAMPLER_NAME_SOFT, i));
|
||||
}
|
||||
|
||||
return strings;
|
||||
}
|
||||
|
||||
static void UpdateUserSoundSettings(void)
|
||||
{
|
||||
SetResampler(oal->sources);
|
||||
I_OAL_SetResampler();
|
||||
|
||||
if (snd_module == SND_MODULE_3D)
|
||||
{
|
||||
|
@ -35,6 +35,8 @@ void I_OAL_ShutdownSound(void);
|
||||
|
||||
void I_OAL_ShutdownModule(void);
|
||||
|
||||
void I_OAL_SetResampler(void);
|
||||
|
||||
void I_OAL_ResetSource2D(int channel);
|
||||
|
||||
void I_OAL_ResetSource3D(int channel, boolean point_source);
|
||||
@ -46,6 +48,8 @@ void I_OAL_UpdateListenerParams(const ALfloat *position,
|
||||
const ALfloat *velocity,
|
||||
const ALfloat *orientation);
|
||||
|
||||
const char **I_OAL_GetResamplerStrings(void);
|
||||
|
||||
boolean I_OAL_InitSound(void);
|
||||
|
||||
boolean I_OAL_ReinitSound(void);
|
||||
|
@ -73,7 +73,7 @@ void I_ShutdownSound(void);
|
||||
//
|
||||
|
||||
extern int forceFlipPan;
|
||||
extern char *snd_resampler;
|
||||
extern int snd_resampler;
|
||||
extern boolean snd_limiter;
|
||||
extern int snd_module;
|
||||
extern boolean snd_hrtf;
|
||||
|
@ -437,8 +437,8 @@ default_t defaults[] = {
|
||||
{
|
||||
"snd_resampler",
|
||||
(config_t *) &snd_resampler, NULL,
|
||||
{.s = "Linear"}, {0}, string, ss_none, wad_no,
|
||||
"Sound resampler"
|
||||
{1}, {0, UL}, number, ss_gen, wad_no,
|
||||
"Sound resampler (0 = Nearest, 1 = Linear, ...)"
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "hu_stuff.h"
|
||||
#include "i_gamepad.h"
|
||||
#include "i_input.h"
|
||||
#include "i_oalsound.h"
|
||||
#include "i_sound.h"
|
||||
#include "i_timer.h"
|
||||
#include "i_video.h"
|
||||
@ -304,6 +305,7 @@ enum
|
||||
|
||||
str_gamma,
|
||||
str_sound_module,
|
||||
str_resampler,
|
||||
|
||||
str_mouse_accel,
|
||||
|
||||
@ -2082,6 +2084,10 @@ static setup_menu_t gen_settings2[] = {
|
||||
// [FG] play sounds in full length
|
||||
{"Disable Sound Cutoffs", S_ONOFF, M_X, M_SPC, {"full_sounds"}},
|
||||
|
||||
{"Resampler", S_CHOICE | S_NEXT_LINE, M_X, M_SPC, {"snd_resampler"}, m_null,
|
||||
input_null, str_resampler, I_OAL_SetResampler},
|
||||
|
||||
MI_GAP,
|
||||
MI_GAP,
|
||||
|
||||
// [FG] music backend
|
||||
@ -2091,6 +2097,13 @@ static setup_menu_t gen_settings2[] = {
|
||||
MI_END
|
||||
};
|
||||
|
||||
static const char **GetResamplerStrings(void)
|
||||
{
|
||||
const char **strings = I_OAL_GetResamplerStrings();
|
||||
DisableItem(!strings, gen_settings2, "snd_resampler");
|
||||
return strings;
|
||||
}
|
||||
|
||||
void MN_UpdateFreeLook(void)
|
||||
{
|
||||
P_UpdateDirectVerticalAiming();
|
||||
@ -3789,6 +3802,7 @@ static const char **selectstrings[] = {
|
||||
NULL, // str_midi_player
|
||||
gamma_strings,
|
||||
sound_module_strings,
|
||||
NULL, // str_resampler
|
||||
NULL, // str_mouse_accel
|
||||
default_skill_strings,
|
||||
default_complevel_strings,
|
||||
@ -3845,6 +3859,7 @@ void MN_InitMenuStrings(void)
|
||||
UpdateHUDModeStrings();
|
||||
selectstrings[str_resolution_scale] = GetResolutionScaleStrings();
|
||||
selectstrings[str_mouse_accel] = GetMouseAccelStrings();
|
||||
selectstrings[str_resampler] = GetResamplerStrings();
|
||||
}
|
||||
|
||||
void MN_SetupResetMenu(void)
|
||||
|
Loading…
x
Reference in New Issue
Block a user