Title: [266788] trunk
Revision
266788
Author
[email protected]
Date
2020-09-09 11:00:29 -0700 (Wed, 09 Sep 2020)

Log Message

AudioParam.linearRampToValueAtTime() / exponentialRampToValueAtTime() have no effect when there is no preceding event
https://bugs.webkit.org/show_bug.cgi?id=216284

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-connections-expected.txt:
Rebaseline test that is now failing because of the fix. The test was not actually running as intended because
it relies on AudioParam.linearRampToValueAtTime(), which was not working until now. I have investigated this
failure and it is actually due to a bug in our AudioBus::copyWithGainFrom() implementation. I will land a
follow-up fix for this.

* web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-constant-source-expected.txt:
Rebaseline test now that output is different (still passing).

* web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/detune-limiting-expected.txt:
Rebaseline test that is passing thanks to the fix.

Source/WebCore:

AudioParam.linearRampToValueAtTime() / exponentialRampToValueAtTime() have no effect when there is no preceding event
in the timeline. This is incorrect. We should insert an implicit SetValue event in the timeline if the ramp event is
the first one.

No new tests, rebaselined existing test.

* Modules/webaudio/AudioParam.cpp:
* Modules/webaudio/AudioParamTimeline.cpp:
(WebCore::AudioParamTimeline::linearRampToValueAtTime):
(WebCore::AudioParamTimeline::exponentialRampToValueAtTime):
* Modules/webaudio/AudioParamTimeline.h:

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (266787 => 266788)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-09-09 17:42:00 UTC (rev 266787)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-09-09 18:00:29 UTC (rev 266788)
@@ -1,3 +1,22 @@
+2020-09-09  Chris Dumez  <[email protected]>
+
+        AudioParam.linearRampToValueAtTime() / exponentialRampToValueAtTime() have no effect when there is no preceding event
+        https://bugs.webkit.org/show_bug.cgi?id=216284
+
+        Reviewed by Darin Adler.
+
+        * web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-connections-expected.txt:
+        Rebaseline test that is now failing because of the fix. The test was not actually running as intended because
+        it relies on AudioParam.linearRampToValueAtTime(), which was not working until now. I have investigated this
+        failure and it is actually due to a bug in our AudioBus::copyWithGainFrom() implementation. I will land a
+        follow-up fix for this.
+
+        * web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-constant-source-expected.txt:
+        Rebaseline test now that output is different (still passing).
+
+        * web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/detune-limiting-expected.txt:
+        Rebaseline test that is passing thanks to the fix.
+
 2020-09-09  Alex Christensen  <[email protected]>
 
         Import selection web platform tests

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-connections-expected.txt (266787 => 266788)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-connections-expected.txt	2020-09-09 17:42:00 UTC (rev 266787)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-connections-expected.txt	2020-09-09 18:00:29 UTC (rev 266788)
@@ -5,14 +5,56 @@
 PASS Audit report 
 PASS > [Gain] k-rate GainNode.gain 
 PASS   gain[0:128] contains only the constant 2. 
-PASS   gain[128:256] contains only the constant 2. 
-PASS   gain[256:384] contains only the constant 2. 
-PASS   gain[384:512] contains only the constant 2. 
-PASS   gain[512:640] contains only the constant 2. 
-PASS   gain[640:768] contains only the constant 2. 
-PASS   gain[768:896] contains only the constant 2. 
-PASS   gain[896:1024] contains only the constant 2. 
-PASS < [Gain] All assertions passed. (total 8 assertions) 
+FAIL X gain[128:256]: Expected 129.875 for all values but found 128 unexpected values: 
+	Index	Actual
+	[0]	2.6393749713897705
+	[1]	3.2755532264709473
+	[2]	3.908550500869751
+	[3]	4.538382530212402
+	...and 124 more errors. assert_true: expected true got false
+FAIL X gain[256:384]: Expected 257.75 for all values but found 128 unexpected values: 
+	Index	Actual
+	[0]	63.5316047668457
+	[1]	64.50269317626953
+	[2]	65.46893310546875
+	[3]	66.43033599853516
+	...and 124 more errors. assert_true: expected true got false
+FAIL X gain[384:512]: Expected 385.625 for all values but found 128 unexpected values: 
+	Index	Actual
+	[0]	156.14376831054688
+	[1]	157.29116821289062
+	[2]	158.43283081054688
+	[3]	159.56878662109375
+	...and 124 more errors. assert_true: expected true got false
+FAIL X gain[512:640]: Expected 513.5 for all values but found 128 unexpected values: 
+	Index	Actual
+	[0]	265.45477294921875
+	[1]	266.69500732421875
+	[2]	267.9290466308594
+	[3]	269.1568908691406
+	...and 124 more errors. assert_true: expected true got false
+FAIL X gain[640:768]: Expected 641.375 for all values but found 128 unexpected values: 
+	Index	Actual
+	[0]	383.5567626953125
+	[1]	384.8458557128906
+	[2]	386.1285095214844
+	[3]	387.4047546386719
+	...and 124 more errors. assert_true: expected true got false
+FAIL X gain[768:896]: Expected 769.25 for all values but found 128 unexpected values: 
+	Index	Actual
+	[0]	506.286865234375
+	[1]	507.6016845703125
+	[2]	508.909912109375
+	[3]	510.21160888671875
+	...and 124 more errors. assert_true: expected true got false
+FAIL X gain[896:1024]: Expected 897.125 for all values but found 128 unexpected values: 
+	Index	Actual
+	[0]	631.4533081054688
+	[1]	632.7816772460938
+	[2]	634.1033935546875
+	[3]	635.4185180664062
+	...and 124 more errors. assert_true: expected true got false
+FAIL < [Gain] 7 out of 8 assertions were failed. assert_true: expected true got false
 PASS > [StereoPanner] k-rate StereoPannerNode.pan 
 PASS   pan[0:128] contains only the constant 0.5. 
 PASS   pan[128:256] contains only the constant 0.5879377722740173. 
@@ -23,5 +65,5 @@
 PASS   pan[768:896] contains only the constant 0.6532814502716064. 
 PASS   pan[896:1024] contains only the constant 0.5879377722740173. 
 PASS < [StereoPanner] All assertions passed. (total 8 assertions) 
-PASS # AUDIT TASK RUNNER FINISHED: 2 tasks ran successfully. 
+FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 2 tasks were failed. assert_true: expected true got false
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-constant-source-expected.txt (266787 => 266788)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-constant-source-expected.txt	2020-09-09 17:42:00 UTC (rev 266787)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-constant-source-expected.txt	2020-09-09 18:00:29 UTC (rev 266788)
@@ -30,13 +30,13 @@
 PASS < [ConstantSourceNode.offset k-rate automation] All assertions passed. (total 8 assertions) 
 PASS > [ConstantSource.offset] Verify k-rate automation matches k-rate input 
 PASS   ConstantSource.offset k-rate input: output[0:128] contains only the constant 2. 
-PASS   ConstantSource.offset k-rate input: output[128:256] contains only the constant 2. 
-PASS   ConstantSource.offset k-rate input: output[256:384] contains only the constant 2. 
-PASS   ConstantSource.offset k-rate input: output[384:512] contains only the constant 2. 
-PASS   ConstantSource.offset k-rate input: output[512:640] contains only the constant 2. 
-PASS   ConstantSource.offset k-rate input: output[640:768] contains only the constant 2. 
-PASS   ConstantSource.offset k-rate input: output[768:896] contains only the constant 2. 
-PASS   ConstantSource.offset k-rate input: output[896:1024] contains only the constant 2. 
+PASS   ConstantSource.offset k-rate input: output[128:256] contains only the constant 129.875. 
+PASS   ConstantSource.offset k-rate input: output[256:384] contains only the constant 257.75. 
+PASS   ConstantSource.offset k-rate input: output[384:512] contains only the constant 385.625. 
+PASS   ConstantSource.offset k-rate input: output[512:640] contains only the constant 513.5. 
+PASS   ConstantSource.offset k-rate input: output[640:768] contains only the constant 641.375. 
+PASS   ConstantSource.offset k-rate input: output[768:896] contains only the constant 769.25. 
+PASS   ConstantSource.offset k-rate input: output[896:1024] contains only the constant 897.125. 
 PASS < [ConstantSource.offset] All assertions passed. (total 8 assertions) 
 PASS # AUDIT TASK RUNNER FINISHED: 3 tasks ran successfully. 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/detune-limiting-expected.txt (266787 => 266788)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/detune-limiting-expected.txt	2020-09-09 17:42:00 UTC (rev 266787)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/detune-limiting-expected.txt	2020-09-09 18:00:29 UTC (rev 266788)
@@ -12,13 +12,7 @@
 PASS > [detune automation] Oscillator output with detune automation should be zero above Nyquist 
 PASS   Frame where detuned oscillator reaches Nyquist is equal to 5. 
 PASS   osc[0:4] is not constantly 0 (contains 4 different values). 
-FAIL X osc[5:]: Expected 0 for all values but found 2752 unexpected values: 
-	Index	Actual
-	[0]	0.0007123718387447298
-	[1]	0.000854848010931164
-	[2]	0.0009973249398171902
-	[3]	0.0011398025089874864
-	...and 2748 more errors. assert_true: expected true got false
-FAIL < [detune automation] 1 out of 3 assertions were failed. assert_true: expected true got false
-FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 2 tasks were failed. assert_true: expected true got false
+PASS   osc[5:] contains only the constant 0. 
+PASS < [detune automation] All assertions passed. (total 3 assertions) 
+PASS # AUDIT TASK RUNNER FINISHED: 2 tasks ran successfully. 
 

Modified: trunk/Source/WebCore/ChangeLog (266787 => 266788)


--- trunk/Source/WebCore/ChangeLog	2020-09-09 17:42:00 UTC (rev 266787)
+++ trunk/Source/WebCore/ChangeLog	2020-09-09 18:00:29 UTC (rev 266788)
@@ -1,3 +1,22 @@
+2020-09-09  Chris Dumez  <[email protected]>
+
+        AudioParam.linearRampToValueAtTime() / exponentialRampToValueAtTime() have no effect when there is no preceding event
+        https://bugs.webkit.org/show_bug.cgi?id=216284
+
+        Reviewed by Darin Adler.
+
+        AudioParam.linearRampToValueAtTime() / exponentialRampToValueAtTime() have no effect when there is no preceding event
+        in the timeline. This is incorrect. We should insert an implicit SetValue event in the timeline if the ramp event is
+        the first one.
+
+        No new tests, rebaselined existing test.
+
+        * Modules/webaudio/AudioParam.cpp:
+        * Modules/webaudio/AudioParamTimeline.cpp:
+        (WebCore::AudioParamTimeline::linearRampToValueAtTime):
+        (WebCore::AudioParamTimeline::exponentialRampToValueAtTime):
+        * Modules/webaudio/AudioParamTimeline.h:
+
 2020-09-09  Andres Gonzalez  <[email protected]>
 
         AccessibilityMenuList and MenuListPopup notifications need to be posted asynchronously.

Modified: trunk/Source/WebCore/Modules/webaudio/AudioParam.cpp (266787 => 266788)


--- trunk/Source/WebCore/Modules/webaudio/AudioParam.cpp	2020-09-09 17:42:00 UTC (rev 266787)
+++ trunk/Source/WebCore/Modules/webaudio/AudioParam.cpp	2020-09-09 18:00:29 UTC (rev 266788)
@@ -152,7 +152,7 @@
         return Exception { RangeError, "endTime must be a positive value"_s };
 
     endTime = std::max(endTime, context().currentTime());
-    auto result = m_timeline.linearRampToValueAtTime(value, Seconds { endTime });
+    auto result = m_timeline.linearRampToValueAtTime(value, Seconds { endTime }, m_value, Seconds { context().currentTime() });
     if (result.hasException())
         return result.releaseException();
     return *this;
@@ -166,7 +166,7 @@
         return Exception { RangeError, "endTime must be a positive value"_s };
 
     endTime = std::max(endTime, context().currentTime());
-    auto result = m_timeline.exponentialRampToValueAtTime(value, Seconds { endTime });
+    auto result = m_timeline.exponentialRampToValueAtTime(value, Seconds { endTime }, m_value, Seconds { context().currentTime() });
     if (result.hasException())
         return result.releaseException();
     return *this;

Modified: trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.cpp (266787 => 266788)


--- trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.cpp	2020-09-09 17:42:00 UTC (rev 266787)
+++ trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.cpp	2020-09-09 18:00:29 UTC (rev 266788)
@@ -69,16 +69,26 @@
     return insertEvent(ParamEvent::createSetValueEvent(value, time));
 }
 
-ExceptionOr<void> AudioParamTimeline::linearRampToValueAtTime(float value, Seconds time)
+ExceptionOr<void> AudioParamTimeline::linearRampToValueAtTime(float targetValue, Seconds endTime, float currentValue, Seconds currentTime)
 {
     auto locker = holdLock(m_eventsMutex);
-    return insertEvent(ParamEvent::createLinearRampEvent(value, time));
+
+    // Linear ramp events need a preceding event so that they have an initial value.
+    if (m_events.isEmpty())
+        insertEvent(ParamEvent::createSetValueEvent(currentValue, currentTime));
+
+    return insertEvent(ParamEvent::createLinearRampEvent(targetValue, endTime));
 }
 
-ExceptionOr<void> AudioParamTimeline::exponentialRampToValueAtTime(float value, Seconds time)
+ExceptionOr<void> AudioParamTimeline::exponentialRampToValueAtTime(float targetValue, Seconds endTime, float currentValue, Seconds currentTime)
 {
     auto locker = holdLock(m_eventsMutex);
-    return insertEvent(ParamEvent::createExponentialRampEvent(value, time));
+
+    // Exponential ramp events need a preceding event so that they have an initial value.
+    if (m_events.isEmpty())
+        insertEvent(ParamEvent::createSetValueEvent(currentValue, currentTime));
+
+    return insertEvent(ParamEvent::createExponentialRampEvent(targetValue, endTime));
 }
 
 ExceptionOr<void> AudioParamTimeline::setTargetAtTime(float target, Seconds time, float timeConstant)

Modified: trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.h (266787 => 266788)


--- trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.h	2020-09-09 17:42:00 UTC (rev 266787)
+++ trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.h	2020-09-09 18:00:29 UTC (rev 266788)
@@ -44,8 +44,8 @@
     }
 
     ExceptionOr<void> setValueAtTime(float value, Seconds time);
-    ExceptionOr<void> linearRampToValueAtTime(float value, Seconds time);
-    ExceptionOr<void> exponentialRampToValueAtTime(float value, Seconds time);
+    ExceptionOr<void> linearRampToValueAtTime(float targetValue, Seconds endTime, float currentValue, Seconds currentTime);
+    ExceptionOr<void> exponentialRampToValueAtTime(float targetValue, Seconds endTime, float currentValue, Seconds currentTime);
     ExceptionOr<void> setTargetAtTime(float target, Seconds time, float timeConstant);
     ExceptionOr<void> setValueCurveAtTime(Vector<float>&& curve, Seconds time, Seconds duration);
     void cancelScheduledValues(Seconds cancelTime);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to