media icon indicating copy to clipboard operation
media copied to clipboard

AudioBufferSourceNode: Implement linear extrapolation for endpoints

Open collares opened this issue 5 years ago • 2 comments

buffer-resampling.html (WPT test) fails because we interpolate the last sample with 0 when we output a sample with pos corresponding to buffer.len() - 1 < pos < buffer.len(). For playhead positions after the last sample, Chromium implemented linear extrapolation using the last two samples, and this seems to be needed to pass this test using a linear interpolation strategy (Firefox uses truncated sinc interpolation via libspeex-resample). The relevant code is https://github.com/servo/media/blob/86b9a2892af3774e42243ac84394a052719b2bf6/audio/buffer_source_node.rs#L399

Chromium does not support negative playbackRates, as far as I can tell, but in this case we would likely want to do an analogous extrapolation for playhead positions that are slightly before the first buffer sample.

collares avatar Aug 20 '19 16:08 collares

https://github.com/WebAudio/web-audio-api/issues/2032

collares avatar Aug 20 '19 16:08 collares

We should fix the code to match the test here, usually such bugs (when WPT disagrees with the spec) are spec bugs, and it makes sense for that to be the case here.

Manishearth avatar Aug 20 '19 18:08 Manishearth