added s_khz

defaulting to 22.05 KHz on Windows again due to (presumably) chipset/driver issues
chipsets involved: Realtek ALC887, Realtek ALC892
This commit is contained in:
myT 2022-12-27 20:40:03 +01:00
parent e64de08ef2
commit ebfa9346b2
6 changed files with 16 additions and 11 deletions

View file

@ -4,6 +4,8 @@ See the end of this file for known issues.
DD Mmm 20 - 1.53
add: s_khz <22|44> (default: 22) is the sound mixing sampling frequency: 22.05 kHz or 44.1 kHz
add: /writeconfig now has a "-f" option to force writing all CVars (whether archived or not)
add: /imageinfo <imagepath> prints where the image was loaded from and shaders that reference it
@ -87,11 +89,6 @@ chg: com_soundMegs now defaults to 16
chg: the camera's near clip plane distance is now 1 instead of 4
chg: cl_aviFrameRate now defaults to 60
chg: the Windows audio output now has a sampling rate of 44.1 kHz
with this, /video won't have issues with cl_aviFrameRate 60 anymore
chg: with r_backend GL3, depth fade with MSAA now requires GLSL 4.00 at a minimum
depth access is now correctly multi-sampled (less aliasing) and performance has improved as well

View file

@ -2130,7 +2130,7 @@ static const cvarTableItem_t cl_cvars[] =
{ &cl_showTimeDelta, "cl_showTimeDelta", "0", CVAR_TEMP, CVART_BOOL, NULL, NULL, "prints delta adjustment values and events" },
{ &rconPassword, "rconPassword", "", CVAR_TEMP, CVART_STRING, NULL, NULL, help_rconPassword },
{ &cl_timedemo, "timedemo", "0", 0, CVART_BOOL, NULL, NULL, "demo benchmarking mode" },
{ &cl_aviFrameRate, "cl_aviFrameRate", "60", CVAR_ARCHIVE, CVART_INTEGER, "24", "250", help_cl_aviFrameRate },
{ &cl_aviFrameRate, "cl_aviFrameRate", "50", CVAR_ARCHIVE, CVART_INTEGER, "24", "250", help_cl_aviFrameRate },
{ &cl_aviMotionJpeg, "cl_aviMotionJpeg", "1", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, help_cl_aviMotionJpeg },
{ &rconAddress, "rconAddress", "", 0, CVART_STRING, NULL, NULL, help_rconAddress },
{ &cl_maxpackets, "cl_maxpackets", "125", CVAR_ARCHIVE, CVART_INTEGER, "15", "125", "max. packet upload rate" },

View file

@ -65,6 +65,7 @@ static cvar_t* s_show;
static cvar_t* s_mixahead;
static cvar_t* s_mixPreStep;
cvar_t* s_testsound;
cvar_t *s_khz;
static loopSound_t loopSounds[MAX_GENTITIES];
static channel_t *freelist = NULL;
@ -72,6 +73,12 @@ static channel_t *freelist = NULL;
int s_rawend;
portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];
#if defined( _WIN32 )
#define S_KHZ_DEFAULT "22"
#else
#define S_KHZ_DEFAULT "44"
#endif
static void S_Base_SoundInfo()
{
@ -1150,7 +1157,8 @@ static const cvarTableItem_t cl_cvars[] =
{ &s_mixahead, "s_mixahead", "0.2", CVAR_ARCHIVE, CVART_FLOAT },
{ &s_mixPreStep, "s_mixPreStep", "0.05", CVAR_ARCHIVE, CVART_FLOAT },
{ &s_show, "s_show", "0", CVAR_CHEAT, CVART_INTEGER, "0", "2" },
{ &s_testsound, "s_testsound", "0", CVAR_CHEAT, CVART_BOOL }
{ &s_testsound, "s_testsound", "0", CVAR_CHEAT, CVART_BOOL },
{ &s_khz, "s_khz", S_KHZ_DEFAULT, CVAR_ARCHIVE | CVAR_LATCH, CVART_INTEGER, "22", "44" }
};

View file

@ -153,6 +153,7 @@ extern portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];
extern cvar_t *s_volume;
extern cvar_t *s_musicVolume;
extern cvar_t *s_testsound;
extern cvar_t *s_khz;
qbool S_LoadSound( sfx_t* sfx );

View file

@ -25,11 +25,10 @@ along with Challenge Quake 3. If not, see <https://www.gnu.org/licenses/>.
#include <SDL2/SDL.h>
// @TODO: cvars for freq and samples?
// @TODO: cvar for samples?
// @TODO: cvar for the device name? ("alsa", "pulseaudio", etc)
static const int bits = 16;
static const int channels = 2;
static const int freq = 44100; // got issues with 22050 in the VM
static const int samples = 2048;
static const SDL_AudioFormat format = AUDIO_S16SYS;
@ -98,7 +97,7 @@ qbool Sys_S_Init()
// open the default audio device
SDL_AudioSpec desired;
memset(&desired, 0, sizeof(desired));
desired.freq = freq;
desired.freq = s_khz->integer == 44 ? 44100 : 22050;
desired.format = format;
desired.samples = samples;
desired.channels = channels;

View file

@ -139,7 +139,7 @@ static qbool SNDDMA_InitDS()
// create the secondary buffer we'll actually work with
dma.channels = 2;
dma.samplebits = 16;
dma.speed = 44100;
dma.speed = s_khz->integer == 44 ? 44100 : 22050;
memset (&format, 0, sizeof(format));
format.wFormatTag = WAVE_FORMAT_PCM;