You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Poor resampling quality when using AudioContext sampleRate parameter
https://bugs.webkit.org/show_bug.cgi?id=219201
Reviewed by Geoff Garen.
Source/WebCore:
MultiChannelResampler uses a SincResampler per audio channel. In MultiChannelResampler::process(),
it was calling SincResampler::process() for each channel, which would potentially end up calling
MultiChannelResampler::ChannelProvider::provideInput() to provide channel data used for resampling.
The issue was that MultiChannelResampler::ChannelProvider::provideInput() is implemented in such
a way that things will break if provideInput() gets called more than once per channel. When using
an AudioContext's sample rate larger than the hardware sample rate, provideInput() was getting
called more than once per channel and this resulted in very poor resampling quality.
To address the issue, MultiChannelResampler::process() now processes the data in chunks that
are small enough to guarantee that MultiChannelResampler::ChannelProvider::provideInput() will
never get called more than once per audio channel.
The fix is based on the corresponding MultiChannelResampler / SincResampler implementation in
Chrome:
- https://github.com/chromium/chromium/blob/master/media/base/multi_channel_resampler.cc
- https://github.com/chromium/chromium/blob/master/media/base/sinc_resampler.cc
Tests: webaudio/audiocontext-large-samplerate.html
webaudio/audiocontext-low-samplerate.html
* platform/audio/MultiChannelResampler.cpp:
(WebCore::MultiChannelResampler::ChannelProvider::setProvider):
(WebCore::MultiChannelResampler::ChannelProvider::setCurrentChannel):
(WebCore::MultiChannelResampler::process):
* platform/audio/MultiChannelResampler.h:
* platform/audio/SincResampler.cpp:
(WebCore::calculateChunkSize):
(WebCore::SincResampler::updateRegions):
* platform/audio/SincResampler.h:
LayoutTests:
Add layout test coverage that would hit assertions in debug.
* webaudio/audiocontext-large-samplerate-expected.txt: Added.
* webaudio/audiocontext-large-samplerate.html: Added.
* webaudio/audiocontext-low-samplerate-expected.txt: Added.
* webaudio/audiocontext-low-samplerate.html: Added.
Canonical link: https://commits.webkit.org/231850@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270141 268f45cc-cd09-0410-ab3c-d52691b4dbfc
0 commit comments