On Tue Mar 10 20:02:36 2026 +0000, Matteo Bruni wrote:
This patch isn't changing much functionally (I think?), but the existing approach of "unbounded stretching" of the filter seems a bit sketchy to me and this change depends on it (it's "hardcoding" that assumption). IIUC that stretching effectively raises the filter's cutoff frequency to the buffer's frequency, which can become too high for the mixing sample rate and thus introduce aliasing. As I remember, other resamplers usually limit the scaling to some maximum amount to avoid this kind of issue. I guess in practice this is going to be a somewhat exotic case (e.g. nowadays downsampling is probably rarer than upsampling to begin with, also the highest sample rate is bounded at `DSBFREQUENCY_MAX`) but I'm a bit wary of hardcoding it in this way. As I understand it, this is a very important piece of the whole optimization idea and I might be misinterpreting things, so I'm certainly interested in hearing from you. Stretching the filter actually lowers its cutoff frequency. By doing this, we remove the higher frequencies that would cause aliasing when the sampling rate is reduced. The stretching must be unbounded if we want alias-free downsampling over the entire range of input frequencies.
A comment in OpenAL Soft (I haven't examined other resamplers) states that they limit the scaling to reduce the CPU usage, but I think it's also required by the downsampling algorithm they are using. It has the same basic structure as the upsampling algorithm and requires a precomputed table of scaled versions of the FIR. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10255#note_131789