Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AudioBufferSourceNode: Implement linear extrapolation for endpoints #300

Open
collares opened this issue Aug 20, 2019 · 2 comments
Open
Labels
bug Something isn't working webaudio

Comments

@collares
Copy link
Contributor

collares commented Aug 20, 2019

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

let next_sample = *self.buffers[chan as usize].get(prev + 1).unwrap_or(&0.0);

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
Copy link
Contributor Author

@Manishearth Manishearth added bug Something isn't working webaudio labels Aug 20, 2019
@Manishearth
Copy link
Member

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.

@collares collares changed the title AudioBufferSourceNode: Decide if we should interpolate with silence after last sample AudioBufferSourceNode: Implement linear extrapolation for endpoints Sep 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working webaudio
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants