mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Merge branch 'adjustable-sound-buffer' into 'master'
Add snd_mixingbuffersize cvar See merge request KartKrew/Kart!2329
This commit is contained in:
commit
b9cee38adb
5 changed files with 24 additions and 9 deletions
|
|
@ -409,6 +409,11 @@ consvar_t cv_netticbuffer = Player("netticbuffer", "1").min_max(0, 3);
|
||||||
void SetChannelsNum(void);
|
void SetChannelsNum(void);
|
||||||
consvar_t cv_numChannels = Player("snd_channels", "64").values(CV_Unsigned).onchange(SetChannelsNum);
|
consvar_t cv_numChannels = Player("snd_channels", "64").values(CV_Unsigned).onchange(SetChannelsNum);
|
||||||
|
|
||||||
|
extern CV_PossibleValue_t soundmixingbuffersize_cons_t[];
|
||||||
|
consvar_t cv_soundmixingbuffersize = Player("snd_mixingbuffersize", "2048")
|
||||||
|
.values(soundmixingbuffersize_cons_t)
|
||||||
|
.onchange_noinit([]() { COM_ImmedExecute("restartaudio"); });
|
||||||
|
|
||||||
extern CV_PossibleValue_t perfstats_cons_t[];
|
extern CV_PossibleValue_t perfstats_cons_t[];
|
||||||
consvar_t cv_perfstats = Player("perfstats", "Off").dont_save().values(perfstats_cons_t);
|
consvar_t cv_perfstats = Player("perfstats", "Off").dont_save().values(perfstats_cons_t);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -304,6 +304,9 @@ menuitem_t OPTIONS_Sound[] =
|
||||||
{IT_STRING | IT_CVAR, "Hear Tabbed-out", "Keep playing game audio when the window is out of focus (FOCUS LOST).",
|
{IT_STRING | IT_CVAR, "Hear Tabbed-out", "Keep playing game audio when the window is out of focus (FOCUS LOST).",
|
||||||
NULL, {.cvar = &cv_bgaudio}, 0, 0},
|
NULL, {.cvar = &cv_bgaudio}, 0, 0},
|
||||||
|
|
||||||
|
{IT_STRING | IT_CVAR, "Mixing Buffer Size", "Audio buffer size. Higher is faster but more delay.",
|
||||||
|
NULL, {.cvar = &cv_soundmixingbuffersize}, 0, 0},
|
||||||
|
|
||||||
{IT_SPACE | IT_NOTHING, NULL, NULL,
|
{IT_SPACE | IT_NOTHING, NULL, NULL,
|
||||||
NULL, {NULL}, 0, 0},
|
NULL, {NULL}, 0, 0},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,15 @@
|
||||||
|
|
||||||
extern consvar_t cv_mastervolume;
|
extern consvar_t cv_mastervolume;
|
||||||
|
|
||||||
|
CV_PossibleValue_t soundmixingbuffersize_cons_t[] = {
|
||||||
|
{256, "256"},
|
||||||
|
{512, "512"},
|
||||||
|
{1024, "1024"},
|
||||||
|
{2048, "2048"},
|
||||||
|
{4096, "4096"},
|
||||||
|
{0, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
static boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 *vol, INT32 *sep, INT32 *pitch, sfxinfo_t *sfxinfo);
|
static boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 *vol, INT32 *sep, INT32 *pitch, sfxinfo_t *sfxinfo);
|
||||||
|
|
||||||
static void Command_Tunes_f(void);
|
static void Command_Tunes_f(void);
|
||||||
|
|
@ -2424,8 +2433,6 @@ static void Command_RestartAudio_f(void)
|
||||||
S_SetMusicVolume();
|
S_SetMusicVolume();
|
||||||
S_SetMasterVolume();
|
S_SetMasterVolume();
|
||||||
|
|
||||||
S_StartSound(NULL, sfx_strpst);
|
|
||||||
|
|
||||||
S_AttemptToRestoreMusic();
|
S_AttemptToRestoreMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ extern consvar_t cv_soundvolume, cv_closedcaptioning, cv_digmusicvolume;
|
||||||
|
|
||||||
extern consvar_t surround;
|
extern consvar_t surround;
|
||||||
extern consvar_t cv_numChannels;
|
extern consvar_t cv_numChannels;
|
||||||
|
extern CV_PossibleValue_t soundmixingbuffersize_cons_t[];
|
||||||
|
extern consvar_t cv_soundmixingbuffersize;
|
||||||
|
|
||||||
extern consvar_t cv_gamedigimusic;
|
extern consvar_t cv_gamedigimusic;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ void initialize_sound()
|
||||||
SDL_AudioSpec desired;
|
SDL_AudioSpec desired;
|
||||||
desired.format = AUDIO_F32SYS;
|
desired.format = AUDIO_F32SYS;
|
||||||
desired.channels = 2;
|
desired.channels = 2;
|
||||||
desired.samples = 1024;
|
desired.samples = cv_soundmixingbuffersize.value;
|
||||||
desired.freq = 44100;
|
desired.freq = 44100;
|
||||||
desired.callback = audio_callback;
|
desired.callback = audio_callback;
|
||||||
|
|
||||||
|
|
@ -215,6 +215,7 @@ void initialize_sound()
|
||||||
master->add_source(gain_sound_effects);
|
master->add_source(gain_sound_effects);
|
||||||
master->add_source(gain_music_channel);
|
master->add_source(gain_music_channel);
|
||||||
mixer_music->add_source(gain_music_player);
|
mixer_music->add_source(gain_music_player);
|
||||||
|
sound_effect_channels.clear();
|
||||||
for (size_t i = 0; i < static_cast<size_t>(cv_numChannels.value); i++)
|
for (size_t i = 0; i < static_cast<size_t>(cv_numChannels.value); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<SoundEffectPlayer> player = make_shared<SoundEffectPlayer>();
|
shared_ptr<SoundEffectPlayer> player = make_shared<SoundEffectPlayer>();
|
||||||
|
|
@ -236,13 +237,10 @@ void I_StartupSound(void)
|
||||||
|
|
||||||
void I_ShutdownSound(void)
|
void I_ShutdownSound(void)
|
||||||
{
|
{
|
||||||
SdlAudioLockHandle _;
|
SDL_CloseAudio();
|
||||||
|
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||||
|
|
||||||
for (auto& channel : sound_effect_channels)
|
sound_started = false;
|
||||||
{
|
|
||||||
if (channel)
|
|
||||||
*channel = audio::SoundEffectPlayer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void I_UpdateSound(void)
|
void I_UpdateSound(void)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue