Diff
Modified: trunk/LayoutTests/ChangeLog (265535 => 265536)
--- trunk/LayoutTests/ChangeLog 2020-08-11 23:45:51 UTC (rev 265535)
+++ trunk/LayoutTests/ChangeLog 2020-08-11 23:55:33 UTC (rev 265536)
@@ -1,3 +1,18 @@
+2020-08-11 Chris Dumez <cdu...@apple.com>
+
+ Fix WaveShapperNode's waveshaping curve implementation
+ https://bugs.webkit.org/show_bug.cgi?id=215391
+
+ Reviewed by Darin Adler.
+
+ Fix existing tests to reflect behavior change. I have verified that these tests
+ were failing in Firefox and Chrome before I updated them.
+
+ * webaudio/resources/waveshaper-testing.js:
+ (runWaveShaperOversamplingTest):
+ * webaudio/waveshaper-oversample-2x.html:
+ * webaudio/waveshaper-oversample-4x.html:
+
2020-08-11 Hector Lopez <hector_i_lo...@apple.com>
[ iOS wk2 ] imported/w3c/web-platform-tests/css/css-grid/layout-algorithm/flex-and-intrinsic-sizes-001.html is a flaky timeout
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (265535 => 265536)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2020-08-11 23:45:51 UTC (rev 265535)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2020-08-11 23:55:33 UTC (rev 265536)
@@ -1,5 +1,17 @@
2020-08-11 Chris Dumez <cdu...@apple.com>
+ Fix WaveShapperNode's waveshaping curve implementation
+ https://bugs.webkit.org/show_bug.cgi?id=215391
+
+ Reviewed by Darin Adler.
+
+ Rebaseline WPT tests now that more checks are passing.
+
+ * web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/curve-tests-expected.txt:
+ * web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/waveshaper-limits-expected.txt:
+
+2020-08-11 Chris Dumez <cdu...@apple.com>
+
Fix BiquadFilterNode's lowpass filter
https://bugs.webkit.org/show_bug.cgi?id=215381
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/curve-tests-expected.txt (265535 => 265536)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/curve-tests-expected.txt 2020-08-11 23:45:51 UTC (rev 265535)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/curve-tests-expected.txt 2020-08-11 23:55:33 UTC (rev 265536)
@@ -1,9 +1,9 @@
-FAIL WaveShaperNode - Testing that -1, 0 and +1 map correctly to curve (with 1:1 correlation) assert_approx_equals: Input=0, Curve=[2,-3,4] >>> expected -3 +/- 0.01 but got 0.5
-FAIL WaveShaperNode - Testing interpolation (where inputs don't correlate directly to curve elements) assert_approx_equals: Input=-0.5, Curve=[2,-3,4] >>> expected -0.5 +/- 0.01 but got -1.75
-FAIL WaveShaperNode - Testing out-of-range inputs (should be mapped to the first/last elements of the curve) assert_approx_equals: Input=-1.5, Curve=[2,-3,4] >>> expected 2 +/- 0.01 but got 5.75
-FAIL WaveShaperNode - Testing a 2-element curve (does not have a middle element) assert_approx_equals: Input=0, Curve=[2,-2] >>> expected 0 +/- 0.01 but got -2
-FAIL WaveShaperNode - Testing a 4-element curve (does not have a middle element) assert_approx_equals: Input=0, Curve=[1,2,4,7] >>> expected 3 +/- 0.01 but got 4
-FAIL WaveShaperNode - Testing a huge curve assert_approx_equals: Input=0, Curve=[TooBigToDisplay (60000 elements)] >>> expected 8466.20572879921 +/- 0.01 but got 8466.34765625
+PASS WaveShaperNode - Testing that -1, 0 and +1 map correctly to curve (with 1:1 correlation)
+PASS WaveShaperNode - Testing interpolation (where inputs don't correlate directly to curve elements)
+PASS WaveShaperNode - Testing out-of-range inputs (should be mapped to the first/last elements of the curve)
+PASS WaveShaperNode - Testing a 2-element curve (does not have a middle element)
+PASS WaveShaperNode - Testing a 4-element curve (does not have a middle element)
+PASS WaveShaperNode - Testing a huge curve
PASS WaveShaperNode - Testing null curve (should return input values)
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/waveshaper-limits-expected.txt (265535 => 265536)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/waveshaper-limits-expected.txt 2020-08-11 23:45:51 UTC (rev 265535)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/waveshaper-limits-expected.txt 2020-08-11 23:55:33 UTC (rev 265536)
@@ -3,29 +3,29 @@
PASS Executing "test"
PASS Audit report
PASS > [test] WaveShaperNode including values outside the range of [-1,1]
-FAIL X Max error mapping -1.100000 to -0.150000 is not less than or equal to 0.000001. Got 0.15000003576278687. assert_true: expected true got false
+PASS Max error mapping -1.100000 to 0.000000 is less than or equal to 0.000001.
PASS Max error mapping -1.000000 to 0.000000 is less than or equal to 0.000001.
-FAIL X Max error mapping -0.900000 to 0.150000 is not less than or equal to 0.000001. Got 0.050000034272670746. assert_true: expected true got false
-FAIL X Max error mapping -0.800000 to 0.300000 is not less than or equal to 0.000001. Got 0.09999997913837433. assert_true: expected true got false
-FAIL X Max error mapping -0.700000 to 0.450000 is not less than or equal to 0.000001. Got 0.15000000596046448. assert_true: expected true got false
-FAIL X Max error mapping -0.600000 to 0.600000 is not less than or equal to 0.000001. Got 0.19999995827674866. assert_true: expected true got false
-FAIL X Max error mapping -0.500000 to 0.750000 is not less than or equal to 0.000001. Got 0.25. assert_true: expected true got false
-FAIL X Max error mapping -0.400000 to 0.900000 is not less than or equal to 0.000001. Got 0.30000001192092896. assert_true: expected true got false
-FAIL X Max error mapping -0.300000 to 0.950000 is not less than or equal to 0.000001. Got 0.2500000596046448. assert_true: expected true got false
+PASS Max error mapping -0.900000 to 0.100000 is less than or equal to 0.000001.
+PASS Max error mapping -0.800000 to 0.200000 is less than or equal to 0.000001.
+PASS Max error mapping -0.700000 to 0.300000 is less than or equal to 0.000001.
+PASS Max error mapping -0.600000 to 0.400000 is less than or equal to 0.000001.
+PASS Max error mapping -0.500000 to 0.500000 is less than or equal to 0.000001.
+PASS Max error mapping -0.400000 to 0.600000 is less than or equal to 0.000001.
+PASS Max error mapping -0.300000 to 0.700000 is less than or equal to 0.000001.
PASS Max error mapping -0.200000 to 0.800000 is less than or equal to 0.000001.
-FAIL X Max error mapping -0.100000 to 0.650000 is not less than or equal to 0.000001. Got 0.24999994039535522. assert_true: expected true got false
-FAIL X Max error mapping 0.000000 to 0.500000 is not less than or equal to 0.000001. Got 0.5. assert_true: expected true got false
-FAIL X Max error mapping 0.100000 to 0.350000 is not less than or equal to 0.000001. Got 0.550000011920929. assert_true: expected true got false
-FAIL X Max error mapping 0.200000 to 0.200000 is not less than or equal to 0.000001. Got 0.6000000834465027. assert_true: expected true got false
-FAIL X Max error mapping 0.300000 to 0.050000 is not less than or equal to 0.000001. Got 0.6499999165534973. assert_true: expected true got false
-FAIL X Max error mapping 0.400000 to 0.000000 is not less than or equal to 0.000001. Got 0.6000000238418579. assert_true: expected true got false
-FAIL X Max error mapping 0.500000 to 0.000000 is not less than or equal to 0.000001. Got 0.5. assert_true: expected true got false
-FAIL X Max error mapping 0.600000 to 0.000000 is not less than or equal to 0.000001. Got 0.4000000059604645. assert_true: expected true got false
-FAIL X Max error mapping 0.700000 to 0.000000 is not less than or equal to 0.000001. Got 0.30000001192092896. assert_true: expected true got false
-FAIL X Max error mapping 0.800000 to 0.000000 is not less than or equal to 0.000001. Got 0.20000000298023224. assert_true: expected true got false
-FAIL X Max error mapping 0.900000 to 0.000000 is not less than or equal to 0.000001. Got 0.10000000149011612. assert_true: expected true got false
+PASS Max error mapping -0.100000 to 0.900000 is less than or equal to 0.000001.
+PASS Max error mapping 0.000000 to 1.000000 is less than or equal to 0.000001.
+PASS Max error mapping 0.100000 to 0.900000 is less than or equal to 0.000001.
+PASS Max error mapping 0.200000 to 0.800000 is less than or equal to 0.000001.
+PASS Max error mapping 0.300000 to 0.700000 is less than or equal to 0.000001.
+PASS Max error mapping 0.400000 to 0.600000 is less than or equal to 0.000001.
+PASS Max error mapping 0.500000 to 0.500000 is less than or equal to 0.000001.
+PASS Max error mapping 0.600000 to 0.400000 is less than or equal to 0.000001.
+PASS Max error mapping 0.700000 to 0.300000 is less than or equal to 0.000001.
+PASS Max error mapping 0.800000 to 0.200000 is less than or equal to 0.000001.
+PASS Max error mapping 0.900000 to 0.100000 is less than or equal to 0.000001.
PASS Max error mapping 1.000000 to 0.000000 is less than or equal to 0.000001.
PASS Max error mapping 1.100000 to 0.000000 is less than or equal to 0.000001.
-FAIL < [test] 19 out of 23 assertions were failed. assert_true: expected true got false
-FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 1 tasks were failed. assert_true: expected true got false
+PASS < [test] All assertions passed. (total 23 assertions)
+PASS # AUDIT TASK RUNNER FINISHED: 1 tasks ran successfully.
Modified: trunk/LayoutTests/webaudio/resources/waveshaper-testing.js (265535 => 265536)
--- trunk/LayoutTests/webaudio/resources/waveshaper-testing.js 2020-08-11 23:45:51 UTC (rev 265535)
+++ trunk/LayoutTests/webaudio/resources/waveshaper-testing.js 2020-08-11 23:55:33 UTC (rev 265536)
@@ -138,6 +138,8 @@
return audioBuffer;
}
+window.OfflineAudioContext = window.OfflineAudioContext || window.webkitOfflineAudioContext;
+
function runWaveShaperOversamplingTest(testParams) {
sampleRate = testParams.sampleRate;
nyquist = 0.5 * sampleRate;
@@ -154,7 +156,7 @@
// Create offline audio context.
var numberOfRenderFrames = sampleRate * lengthInSeconds;
- context = new webkitOfflineAudioContext(1, numberOfRenderFrames, sampleRate);
+ context = new OfflineAudioContext(1, numberOfRenderFrames, sampleRate);
// source -> waveshaper -> destination
var source = context.createBufferSource();
Modified: trunk/LayoutTests/webaudio/waveshaper-oversample-2x.html (265535 => 265536)
--- trunk/LayoutTests/webaudio/waveshaper-oversample-2x.html 2020-08-11 23:45:51 UTC (rev 265535)
+++ trunk/LayoutTests/webaudio/waveshaper-oversample-2x.html 2020-08-11 23:55:33 UTC (rev 265536)
@@ -23,7 +23,7 @@
// Should generate harmonics at 9000, 18000, 27000, 36000
// The last two should be filtered out with the 2x oversampling.
"fundamentalFrequency": 9000,
- "acceptableAliasingThresholdDecibels": -85
+ "acceptableAliasingThresholdDecibels": -75.3
};
runWaveShaperOversamplingTest(testParams);
Modified: trunk/LayoutTests/webaudio/waveshaper-oversample-4x.html (265535 => 265536)
--- trunk/LayoutTests/webaudio/waveshaper-oversample-4x.html 2020-08-11 23:45:51 UTC (rev 265535)
+++ trunk/LayoutTests/webaudio/waveshaper-oversample-4x.html 2020-08-11 23:55:33 UTC (rev 265536)
@@ -23,7 +23,7 @@
// Should generate harmonics at 18000, 36000, 54000, 72000
// All except for 18000 should be filtered out with the 4x oversampling.
"fundamentalFrequency": 18000,
- "acceptableAliasingThresholdDecibels": -85
+ "acceptableAliasingThresholdDecibels": -79.88
};
runWaveShaperOversamplingTest(testParams);
Modified: trunk/Source/WebCore/ChangeLog (265535 => 265536)
--- trunk/Source/WebCore/ChangeLog 2020-08-11 23:45:51 UTC (rev 265535)
+++ trunk/Source/WebCore/ChangeLog 2020-08-11 23:55:33 UTC (rev 265536)
@@ -1,3 +1,18 @@
+2020-08-11 Chris Dumez <cdu...@apple.com>
+
+ Fix WaveShapperNode's waveshaping curve implementation
+ https://bugs.webkit.org/show_bug.cgi?id=215391
+
+ Reviewed by Darin Adler.
+
+ Fix WaveShapperNode's waveshaping curve implementation using the algorithm in the specification:
+ - https://www.w3.org/TR/webaudio/#dom-waveshapernode-curve
+
+ No new tests, rebaselined existing tests.
+
+ * Modules/webaudio/WaveShaperDSPKernel.cpp:
+ (WebCore::WaveShaperDSPKernel::processCurve):
+
2020-08-11 Simon Fraser <simon.fra...@apple.com>
Have render tree dumps show overflow information
Modified: trunk/Source/WebCore/Modules/webaudio/WaveShaperDSPKernel.cpp (265535 => 265536)
--- trunk/Source/WebCore/Modules/webaudio/WaveShaperDSPKernel.cpp 2020-08-11 23:45:51 UTC (rev 265535)
+++ trunk/Source/WebCore/Modules/webaudio/WaveShaperDSPKernel.cpp 2020-08-11 23:55:33 UTC (rev 265536)
@@ -101,25 +101,17 @@
for (unsigned i = 0; i < framesToProcess; ++i) {
const float input = source[i];
- // Calculate a virtual index based on input -1 -> +1 with 0 being at the center of the curve data.
- // Then linearly interpolate between the two points in the curve.
- double virtualIndex = 0.5 * (input + 1) * curveLength;
- int index1 = static_cast<int>(virtualIndex);
- int index2 = index1 + 1;
- double interpolationFactor = virtualIndex - index1;
-
- // Clip index to the input range of the curve.
- // This takes care of input outside of nominal range -1 -> +1
- index1 = std::max(index1, 0);
- index1 = std::min(index1, curveLength - 1);
- index2 = std::max(index2, 0);
- index2 = std::min(index2, curveLength - 1);
-
- double value1 = curveData[index1];
- double value2 = curveData[index2];
-
- double output = (1.0 - interpolationFactor) * value1 + interpolationFactor * value2;
- destination[i] = output;
+ float v = (curveLength - 1) * 0.5 * (input + 1);
+ if (v < 0)
+ destination[i] = curveData[0];
+ else if (v >= curveLength - 1)
+ destination[i] = curveData[curveLength - 1];
+ else {
+ float k = floorf(v);
+ float f = v - k;
+ unsigned kIndex = k;
+ destination[i] = (1 - f) * curveData[kIndex] + f * curveData[kIndex + 1];
+ }
}
}