Bug 78386 - Round off error in setValueCurveAtTime
Summary: Round off error in setValueCurveAtTime
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Audio (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Raymond Toy
URL:
Keywords:
Depends on: 77666
Blocks:
  Show dependency treegraph
 
Reported: 2012-02-10 14:03 PST by Raymond Toy
Modified: 2012-03-02 09:58 PST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Raymond Toy 2012-02-10 14:03:34 PST
There is a round-off error in setValueCurveAtTime.  When calling setValueCurveAtTime(curve, 0.0, 0.3) with a sample rate of 44100 and the curve data being sample-frame spaced of exactly the right length, the output has one sample duplicated, causing the rest of the values to be shifted.

This is caused by a roundoff error at the line:

   unsigned curveIndex = static_cast<unsigned>(curveVirtualIndex);

In this particular example, curveVirtualIndex = 895.9999 instead of 896 due to roundoff.  The curveIndex is set to 895 which causes curve[895] to be output.  But it was already output the previous time, so the output is duplicated and the output has the curve values shifted by one.

Rounding curveVirtualIndex instead of truncating fixes this.
Comment 1 Raymond Toy 2012-02-21 14:22:31 PST
It might be easiest to fix this in bug 77666, which is how this error was found.
Comment 2 Raymond Toy 2012-03-02 09:58:02 PST
This was fixed in bug 77666.  Closing this out now.