Repository navigation
Conversation
…, lower latency * Cinematic audio and streamed music both append to the same raw sample ring. The main menu music is started while the opening logos video is still playing, so the two interleaved (heard as crackling), and the first audio packet of a roq video (~0.5s, 23520 samples at 44.1kHz) was larger than the whole 16384 sample ring. Enlarge the ring to 65536 samples, keep music buffering at its original 16384 look-ahead (MUSIC_RAW_LOOKAHEAD) and don't stream music while a cinematic with a soundtrack is playing (CIN_IsPlayingAudio). * ResampleSfx used nearest-neighbour conversion, which mirrors high frequencies back into the audible range (harsh, gritty 11/22kHz sounds). New s_quality cvar: 0 linear/averaging, 1 cubic, 2 windowed-sinc (default). Costs roughly 0.35s extra per map load, nothing during play. Cinematic audio is linearly interpolated instead of repeating samples. * Replace hard clipping of the mix with a soft limiter that only acts above 0.75 of full scale (quiet sound is untouched), and report clipping in the developer log. * Latency: the SDL callback buffer defaults to ~11ms instead of ~23ms (the mix ring is kept at its previous size), and the mix pre-step adapts to the device buffer and recent frame times (s_mixPreStepAuto, default on; s_mixPreStep stays the upper bound, 0.05). Roughly halves the delay between an event and its sound. Tested on JO SP (intro, new game cinematics and briefing, map loads, 144Hz/125fps caps). JA SP and the MP engine (shares sdl_sound.cpp) were build-tested only. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes crackling audio during cinematics (heard in the opening logos) and improves SP sound quality and latency.
Changes
MUSIC_RAW_LOOKAHEAD), and music is not streamed while a cinematic with a soundtrack is playing (CIN_IsPlayingAudio). Frame rate was ruled out as a cause (tested caps of 30/125/250 and vsync).ResampleSfxused nearest-neighbour conversion, which mirrors high frequencies into the audible range (harsh, gritty 11/22 kHz sounds). News_qualitycvar: 0 linear/averaging, 1 cubic, 2 windowed-sinc (default). Costs ~0.35 s extra per map load (233 sounds: 373 ms vs 20 ms ats_quality 0), nothing during play. Cinematic audio is linearly interpolated instead of repeating samples.s_quality 0is the cheap option for slow machines.developer 1the log reports when the mix exceeds full scale.s_sdlDevSampsstill overrides), and the mix pre-step adapts to the device buffer and recent frame times (s_mixPreStepAuto, default 1;s_mixPreStepstays the upper bound, default 0.05). The pre-step settled at ~30 ms at 125 fps and ~28 ms at 144 fps.s_mixPreStepAuto 0restores the old fixed behaviour.Not included: native 48 kHz output. Voice lines under
sound/chars/stay MP3-compressed and are decoded on the fly by mp3code, which only outputs 44.1/22.05/11.025 kHz, so that would need a separate change.Testing
sdl_sound.cpp) and JO SP build cleanly. JA SP and MP were not run, and Windows/macOS were not tested. The 32-bit MSVC OpenAL code path was not touched or tested.Notes
Original code, contributed under the project's GPLv2 license (the spline, sinc and window formulas are standard math, no third-party code was copied). Written with AI assistance (Claude Code) and reviewed/tested by the submitter.
🤖 Generated with Claude Code