Open markanini opened 2 years ago
Is the resampling algorithm bad or what's the concrete issue? Proper resampling does not cause aliasing, nor does it "mute the top ends" as long as the target sample rate is above ~40kHz.
This looks perfectly fine to me https://github.com/libsdl-org/SDL/blob/5968f3d828aaf28a28763fce794020fc8239a35a/build-scripts/gen_audio_resampler_filter.c
Purely empirically, changing sndspeed from default 11025 to 44100, it should sound the same if high quality filtering is used. Reason being that the majority of Quake sounds are natively 11025 Hz. Instead it gets brighter which suggests aliasing from a lack of filtering.
Further evidence that something is wrong is the snd_filteringquality having no effect between 1-5 unless sndspeed is at default 11025.
Proper resampling does not cause aliasing, nor does it "mute the top ends" as long as the target sample rate is above ~40kHz.
Agreed. The default setting down samples a small amount of Quake sounds that re natively in 22050Hz, thus muting the top octave.
Further evidence that something is wrong is the snd_filteringquality having no effect between 1-5 unless sndspeed is at default 11025.
Yeah - QS has an internal resampler/lowpass filter after SFX mixing and before the music is mixed in, and it's only implemented for 11025 -> 44100 Hz resampling (so, ~5kHz lowpass). The goal was to emulate the sound of the original game running at the original's default rate of 11025 mixing, but be able to mix in the music before sending the sound to SDL.
https://github.com/Novum/vkQuake/blob/master/Quake/snd_mix.c#L240
(The implementation is a bit weird/inefficient because sounds are loaded at 44100 with nearest filtering, mixed at 44100, then lowpass filtered to 5kHz at the end, before the music is mixed in. Ideally they'd be loaded at 11025 - that would require good-quality resampler than can downsample anything to 11025, mixed at 11025, and then up sampled to 44100 at the end for mixing in the music. AFAIK, the output would be the same as what we have now, though.)
Agreed. The default setting down samples a small amount of Quake sounds that re natively in 22050Hz, thus muting the top octave.
This is true, but I would caution against changing the default mixing rate from 11025 because it'll make the game sound different than vanilla. (e.g. the Quake SFX mix can have a lot of clipping which is not as objectionable sounding at 11025Hz, but annoying at higher sample rates. Two other problems: the hard cutoff when the mixer stops a sound part way through (e.g. firing the nailgun does this a lot) is more annoying at sample rates >11025Hz, and some looping sounds sound OK at 11025Hz but they'll have audible glitches at the loop points if you upsample before looping.)
So I guess the concrete issue is, if you change sndspeed from the default of 11025, the QS code falls back to a nearest resampler before mixing in the music.
I'm pretty sure I don't want to implement OpenAL specifically, but there seems to be some questions open regarding sound, so I'll keep this open for now.
So I guess the concrete issue is, if you change sndspeed from the default of 11025, the QS code falls back to a nearest resampler before mixing in the music.
Maybe a new cvar could be considered that removes that limitation, or emulation of original behavior, call it what you want. I think that would make some people happy that combine custom sounds with the stock ones also.
Just for additional context, indeed increasing the sndspeed
to 44.1 with the original PAKs is frankly a horrible SFX experience - however - using the same with the remastered audio from the rerelease PAK, which does have 44.1KHz somewhat in mind, works well enough overall.
Not sure if this plays a role specifically for this question, but still something interesting to bring up.
I too am a big fan of the ability to do some high-quality Cubic filtering, which OpenAL Soft allows.
I use DSOAL for all games that use DirectSound, specifically for that capability.
SDL2 does high quality filtering, I already established that.
SDL2 does high quality filtering, I already established that.
Indeed. It's not fully used though.
i figure people would argue for openal soft due to binaural hrtf
Any chance of implementing this? The current audio capabilities inherited from QS have some issues.
Handling of mixed sample rates is not optimal. You can only configure it in two ways, to down-sample(default), which mutes the top end of
allEDIT:some sounds, or up-sample with very audible aliasing distortion.Makes surround audio over normal headphones possible, which is a pretty good fit for Quakes gameplay. Here's an example if you want to see what it's about: https://youtu.be/rc5a7dzRvbY?t=25