feature(audio): resample N64 audio to native 48 kHz output#1106
Closed
bassdr wants to merge 1 commit into
Closed
Conversation
42bdd6a to
7f74473
Compare
This was referenced May 30, 2026
39b0efd to
d3da2f8
Compare
d3da2f8 to
c5c6ecf
Compare
Add AudioResampler, a polyphase windowed-sinc resampler supporting arbitrary integer ratios. Designed for N64 audio upsampling from 32000 Hz to 48000 Hz (exact ratio 3/2, P=3 Q=2, 8 taps/phase, Kaiser window beta=6, ~60 dB stopband attenuation). - AudioSettings gains SourceSampleRate (default 0 = passthrough) - AudioPlayer::Play() resamples transparently before DoPlay() when SourceSampleRate != SampleRate - GetDesiredBuffered() scales from source rate to output rate so OTRAudio_Thread fill logic remains coherent - Resample output uses a fixed std::array<int16_t, 16384> — no heap allocation on the audio hot path - Default SampleRate changed from 44100 to 48000 Hz - AudioPlayer destructor made virtual to fix UB in derived class dtors
c5c6ecf to
a7cdd52
Compare
Author
|
Changes moved in HarbourMasters/Shipwright#6668, now self-contained, not needed in LUS anymore. |
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.
Shipwright audio engine produces PCM at 32 kHz — the console's native sample rate. Most modern audio devices run at 48 kHz. Without explicit resampling, the OS or driver performs an implicit conversion of unknown quality, often introducing aliasing artifacts.
This PR adds a clean resampling step inside AudioPlayer::Play(), between the game's audio engine and the backend (SDL, PipeWire, WASAPI, CoreAudio). The resampler is transparent to all backends — they simply open the device at 48 kHz as they would normally.
The 32 kHz → 48 kHz ratio is exactly 3/2, which allows a compact polyphase filter (8 taps per phase) with good stopband rejection (~60 dB). The output buffer is stack-allocated to avoid any heap allocation on the audio hot path.