Bug 100885 - Automating gain AudioParam with linearRampToValueAtTime introduces buzzing distortion
Summary: Automating gain AudioParam with linearRampToValueAtTime introduces buzzing di...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Audio (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Chris Rogers
URL:
Keywords:
Depends on: 80337 76919
Blocks:
  Show dependency treegraph
 
Reported: 2012-10-31 14:08 PDT by Matt Grounds
Modified: 2012-11-06 10:01 PST (History)
7 users (show)

See Also:


Attachments
Regression HTML page with debug FFT and time output to show distortion. (1.60 KB, text/html)
2012-10-31 14:08 PDT, Matt Grounds
no flags Details
Patch (8.29 KB, patch)
2012-11-02 15:34 PDT, Chris Rogers
kbr: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Grounds 2012-10-31 14:08:45 PDT
Created attachment 171716 [details]
Regression HTML page with debug FFT and time output to show distortion.

There seems to be a problem with the implementation of linearRampToValueAtTime in AudioParamTimeline.cpp, which on the GainNode causes a buzzing distortion to begin when audioContext.currentTime reaches certain powers of 2. This suggests it has something to do with representing time as a floating point number during the for loop which calculates the sample accurate values.

I have confirmed the bug with the nightly build on the following platforms:
Windows XP - Intel Core 4 Quad 6600
Mac OS X Snow Leopard - Intel Core 2 Duo

The problem is significantly worse on the Windows platform. On both platforms, distortion can be seen in the FFT view after 128.0s. But on Windows, after 256.0s an extremely audible buzzing begins. I presume this is because there are differences in the floating point code generated by the Visual Studio and gcc compilers?

This makes it next to impossible to use ADSR style envelopes on parameters, since they cannot be relied upon without introducing distortion.

I have attached a regression HTML page which demonstrates the problem.
Comment 1 Chris Rogers 2012-11-01 20:52:32 PDT
Matt, thanks for taking the time to make such a nice reduced test.

I've been able to repro, and am taking a look...
Comment 2 Chris Rogers 2012-11-02 15:34:39 PDT
Created attachment 172160 [details]
Patch
Comment 3 Kenneth Russell 2012-11-02 15:41:56 PDT
Comment on attachment 172160 [details]
Patch

Interesting. Looks fine. r=me
Comment 4 Chris Rogers 2012-11-02 16:11:26 PDT
Committed r133365: <http://trac.webkit.org/changeset/133365>
Comment 5 Matt Grounds 2012-11-06 10:01:36 PST
Thanks for taking the time to deal with this so quickly Chris. I have tested with nightly build r133576 on OS X, and the problem seems to be fixed. I will test on Windows once there is a new nightly build (the Windows buildbot seems to have been broken since 16th October)