Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (266793 => 266794)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2020-09-09 18:41:01 UTC (rev 266793)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2020-09-09 18:46:00 UTC (rev 266794)
@@ -1,5 +1,17 @@
2020-09-09 Chris Dumez <[email protected]>
+ Stop performing "de-zippering" when applying gain
+ https://bugs.webkit.org/show_bug.cgi?id=216288
+
+ Reviewed by Darin Adler.
+
+ Rebaseline WPT tests that are now passing.
+
+ * web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-connections-expected.txt:
+ * web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-gain-expected.txt:
+
+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
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-connections-expected.txt (266793 => 266794)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-connections-expected.txt 2020-09-09 18:41:01 UTC (rev 266793)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-connections-expected.txt 2020-09-09 18:46:00 UTC (rev 266794)
@@ -5,56 +5,14 @@
PASS Audit report
PASS > [Gain] k-rate GainNode.gain
PASS gain[0:128] contains only the constant 2.
-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 gain[128:256] contains only the constant 129.875.
+PASS gain[256:384] contains only the constant 257.75.
+PASS gain[384:512] contains only the constant 385.625.
+PASS gain[512:640] contains only the constant 513.5.
+PASS gain[640:768] contains only the constant 641.375.
+PASS gain[768:896] contains only the constant 769.25.
+PASS gain[896:1024] contains only the constant 897.125.
+PASS < [Gain] All assertions passed. (total 8 assertions)
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.
@@ -65,5 +23,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)
-FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 2 tasks were failed. assert_true: expected true got false
+PASS # AUDIT TASK RUNNER FINISHED: 2 tasks ran successfully.
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-gain-expected.txt (266793 => 266794)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-gain-expected.txt 2020-09-09 18:41:01 UTC (rev 266793)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-gain-expected.txt 2020-09-09 18:46:00 UTC (rev 266794)
@@ -10,7 +10,7 @@
PASS GainNode: a-rate node:gain.linearRampToValueAtTime(0,1) did not throw an exception.
PASS GainNode: Output of k-rate GainNode is identical to the array [0,0.3387378752231598,0.6374238133430481,0.860741913318634,0.9822871088981628,0.9876880049705505,0.8763063549995422,0.6613117456436157,0.3681243062019348,0.03141050040721893,-0.3090170621871948,-0.6129071116447449,-0.8443278670310974,-0.9759165644645691,-0.9921145439147949,-0.8910062313079834...].
PASS GainNode: Output of a-rate GainNode is identical to the array [0,0.3386955261230469,0.6372644901275635,0.8604191541671753,0.9817959666252136,0.9870706796646118,0.875649094581604,0.6607331037521362,0.367756187915802,0.03137516602873802,-0.3086307942867279,-0.6120643615722656,-0.8430613875389099,-0.974330723285675,-0.9903783798217773,-0.8893356323242188...].
-PASS GainNode: Difference between a-rate and k-rate GainNode is not constantly 0 (contains 7999 different values).
+PASS GainNode: Difference between a-rate and k-rate GainNode is not constantly 0 (contains 7937 different values).
PASS < [Test k-rate GainNode] All assertions passed. (total 8 assertions)
PASS # AUDIT TASK RUNNER FINISHED: 1 tasks ran successfully.
Modified: trunk/Source/WebCore/ChangeLog (266793 => 266794)
--- trunk/Source/WebCore/ChangeLog 2020-09-09 18:41:01 UTC (rev 266793)
+++ trunk/Source/WebCore/ChangeLog 2020-09-09 18:46:00 UTC (rev 266794)
@@ -1,5 +1,38 @@
2020-09-09 Chris Dumez <[email protected]>
+ Stop performing "de-zippering" when applying gain
+ https://bugs.webkit.org/show_bug.cgi?id=216288
+
+ Reviewed by Darin Adler.
+
+ Stop performing "de-zippering" when applying gain. The latest specification does not indicate we
+ should perform de-zippering and Blink does not either. This is causing us to fail a WPT test.
+
+ No new tests, rebaselined existing test.
+
+ * Modules/webaudio/AudioBufferSourceNode.cpp:
+ (WebCore::AudioBufferSourceNode::process):
+ (WebCore::AudioBufferSourceNode::reset):
+ * Modules/webaudio/AudioBufferSourceNode.h:
+ * Modules/webaudio/GainNode.cpp:
+ (WebCore::GainNode::process):
+ (WebCore::GainNode::reset):
+ * Modules/webaudio/GainNode.h:
+ * Modules/webaudio/PannerNode.cpp:
+ (WebCore::PannerNode::process):
+ (WebCore::PannerNode::reset):
+ * Modules/webaudio/PannerNode.h:
+ * Modules/webaudio/WebKitAudioPannerNode.cpp:
+ (WebCore::WebKitAudioPannerNode::WebKitAudioPannerNode):
+ (WebCore::WebKitAudioPannerNode::process):
+ (WebCore::WebKitAudioPannerNode::reset):
+ * Modules/webaudio/WebKitAudioPannerNode.h:
+ * platform/audio/AudioBus.cpp:
+ (WebCore::AudioBus::copyWithGainFrom):
+ * platform/audio/AudioBus.h:
+
+2020-09-09 Chris Dumez <[email protected]>
+
ASSERTION FAILED: m_finishedNodes.isEmpty() in AudioContext destructor
https://bugs.webkit.org/show_bug.cgi?id=105870
Modified: trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp (266793 => 266794)
--- trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp 2020-09-09 18:41:01 UTC (rev 266793)
+++ trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp 2020-09-09 18:46:00 UTC (rev 266794)
@@ -146,7 +146,7 @@
// Apply the gain (in-place) to the output bus.
float totalGain = legacyGainValue() * m_buffer->gain();
- outputBus.copyWithGainFrom(outputBus, &m_lastGain, totalGain);
+ outputBus.copyWithGainFrom(outputBus, totalGain);
outputBus.clearSilentFlag();
}
@@ -420,7 +420,6 @@
void AudioBufferSourceNode::reset()
{
m_virtualReadIndex = 0;
- m_lastGain = legacyGainValue();
}
ExceptionOr<void> AudioBufferSourceNode::setBuffer(RefPtr<AudioBuffer>&& buffer)
Modified: trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h (266793 => 266794)
--- trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h 2020-09-09 18:41:01 UTC (rev 266793)
+++ trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h 2020-09-09 18:46:00 UTC (rev 266794)
@@ -139,9 +139,6 @@
// It incorporates the base pitch rate, any sample-rate conversion factor from the buffer, and any doppler shift from an associated panner node.
double totalPitchRate();
- // m_lastGain provides continuity when we dynamically adjust the gain.
- float m_lastGain { 1.0 };
-
// We optionally keep track of a panner node which has a doppler shift that is incorporated into
// the pitch rate. We manually manage ref-counting because we want to use RefTypeConnection.
PannerNodeBase* m_pannerNode { nullptr };
Modified: trunk/Source/WebCore/Modules/webaudio/GainNode.cpp (266793 => 266794)
--- trunk/Source/WebCore/Modules/webaudio/GainNode.cpp 2020-09-09 18:41:01 UTC (rev 266793)
+++ trunk/Source/WebCore/Modules/webaudio/GainNode.cpp 2020-09-09 18:46:00 UTC (rev 266794)
@@ -93,12 +93,11 @@
} else {
// Apply the gain with de-zippering into the output bus.
float gain = this->gain().hasSampleAccurateValues() ? this->gain().finalValue() : this->gain().value();
- if (!m_lastGain && m_lastGain == gain) {
- // If the gain is 0 (and we've converged on dezippering), just zero the bus and set
- // the silence hint.
+ if (!gain) {
+ // If the gain is 0 just zero the bus.
outputBus->zero();
} else
- outputBus->copyWithGainFrom(*inputBus, &m_lastGain, gain);
+ outputBus->copyWithGainFrom(*inputBus, gain);
}
}
}
@@ -105,8 +104,6 @@
void GainNode::reset()
{
- // Snap directly to desired gain.
- m_lastGain = gain().value();
}
// FIXME: this can go away when we do mixing with gain directly in summing junction of AudioNodeInput
Modified: trunk/Source/WebCore/Modules/webaudio/GainNode.h (266793 => 266794)
--- trunk/Source/WebCore/Modules/webaudio/GainNode.h 2020-09-09 18:41:01 UTC (rev 266793)
+++ trunk/Source/WebCore/Modules/webaudio/GainNode.h 2020-09-09 18:46:00 UTC (rev 266794)
@@ -58,7 +58,6 @@
explicit GainNode(BaseAudioContext&);
- float m_lastGain { 1.0 }; // for de-zippering
AudioFloatArray m_sampleAccurateGainValues;
Ref<AudioParam> m_gain;
};
Modified: trunk/Source/WebCore/Modules/webaudio/PannerNode.cpp (266793 => 266794)
--- trunk/Source/WebCore/Modules/webaudio/PannerNode.cpp 2020-09-09 18:41:01 UTC (rev 266793)
+++ trunk/Source/WebCore/Modules/webaudio/PannerNode.cpp 2020-09-09 18:46:00 UTC (rev 266794)
@@ -177,12 +177,8 @@
// Get the distance and cone gain.
double totalGain = distanceConeGain();
- // Snap to desired gain at the beginning.
- if (m_lastGain == -1.0)
- m_lastGain = totalGain;
-
- // Apply gain in-place with de-zippering.
- destination->copyWithGainFrom(*destination, &m_lastGain, totalGain);
+ // Apply gain in-place.
+ destination->copyWithGainFrom(*destination, totalGain);
}
void PannerNode::processSampleAccurateValues(AudioBus* destination, const AudioBus* source, size_t framesToProcess)
@@ -261,7 +257,6 @@
void PannerNode::reset()
{
- m_lastGain = -1.0; // force to snap to initial gain
if (m_panner.get())
m_panner->reset();
}
Modified: trunk/Source/WebCore/Modules/webaudio/PannerNode.h (266793 => 266794)
--- trunk/Source/WebCore/Modules/webaudio/PannerNode.h 2020-09-09 18:41:01 UTC (rev 266793)
+++ trunk/Source/WebCore/Modules/webaudio/PannerNode.h 2020-09-09 18:46:00 UTC (rev 266794)
@@ -153,7 +153,6 @@
// Gain
DistanceEffect m_distanceEffect;
ConeEffect m_coneEffect;
- float m_lastGain { -1.0 };
Ref<AudioParam> m_positionX;
Ref<AudioParam> m_positionY;
Modified: trunk/Source/WebCore/Modules/webaudio/WebKitAudioPannerNode.cpp (266793 => 266794)
--- trunk/Source/WebCore/Modules/webaudio/WebKitAudioPannerNode.cpp 2020-09-09 18:41:01 UTC (rev 266793)
+++ trunk/Source/WebCore/Modules/webaudio/WebKitAudioPannerNode.cpp 2020-09-09 18:46:00 UTC (rev 266794)
@@ -51,7 +51,6 @@
WebKitAudioPannerNode::WebKitAudioPannerNode(WebKitAudioContext& context)
: PannerNodeBase(context)
, m_panningModel(PanningModelType::HRTF)
- , m_lastGain(-1.0)
, m_connectionCount(0)
{
setNodeType(NodeTypePanner);
@@ -132,17 +131,12 @@
// Get the distance and cone gain.
double totalGain = distanceConeGain();
- // Snap to desired gain at the beginning.
- if (m_lastGain == -1.0)
- m_lastGain = totalGain;
-
- // Apply gain in-place with de-zippering.
- destination->copyWithGainFrom(*destination, &m_lastGain, totalGain);
+ // Apply gain in-place.
+ destination->copyWithGainFrom(*destination, totalGain);
}
void WebKitAudioPannerNode::reset()
{
- m_lastGain = -1.0; // force to snap to initial gain
if (m_panner.get())
m_panner->reset();
}
Modified: trunk/Source/WebCore/Modules/webaudio/WebKitAudioPannerNode.h (266793 => 266794)
--- trunk/Source/WebCore/Modules/webaudio/WebKitAudioPannerNode.h 2020-09-09 18:41:01 UTC (rev 266793)
+++ trunk/Source/WebCore/Modules/webaudio/WebKitAudioPannerNode.h 2020-09-09 18:46:00 UTC (rev 266794)
@@ -139,7 +139,6 @@
// Gain
DistanceEffect m_distanceEffect;
ConeEffect m_coneEffect;
- float m_lastGain;
// HRTF Database loader
RefPtr<HRTFDatabaseLoader> m_hrtfDatabaseLoader;
Modified: trunk/Source/WebCore/platform/audio/AudioBus.cpp (266793 => 266794)
--- trunk/Source/WebCore/platform/audio/AudioBus.cpp 2020-09-09 18:41:01 UTC (rev 266793)
+++ trunk/Source/WebCore/platform/audio/AudioBus.cpp 2020-09-09 18:46:00 UTC (rev 266794)
@@ -437,7 +437,7 @@
}
}
-void AudioBus::copyWithGainFrom(const AudioBus &sourceBus, float* lastMixGain, float targetGain)
+void AudioBus::copyWithGainFrom(const AudioBus& sourceBus, float gain)
{
if (!topologyMatches(sourceBus)) {
ASSERT_NOT_REACHED();
@@ -456,7 +456,7 @@
return;
// If it is copying from the same bus and no need to change gain, just return.
- if (this == &sourceBus && *lastMixGain == targetGain && targetGain == 1)
+ if (this == &sourceBus && gain == 1)
return;
AudioBus& sourceBusSafe = const_cast<AudioBus&>(sourceBus);
@@ -468,67 +468,19 @@
destinations[i] = channel(i)->mutableData();
}
- // We don't want to suddenly change the gain from mixing one time slice to the next,
- // so we "de-zipper" by slowly changing the gain each sample-frame until we've achieved the target gain.
-
- // Take master bus gain into account as well as the targetGain.
- float totalDesiredGain = static_cast<float>(m_busGain * targetGain);
-
- // First time, snap directly to totalDesiredGain.
- float gain = static_cast<float>(m_isFirstTime ? totalDesiredGain : *lastMixGain);
- m_isFirstTime = false;
-
- const float DezipperRate = 0.005f;
unsigned framesToProcess = length();
- // If the gain is within epsilon of totalDesiredGain, we can skip dezippering.
- // FIXME: this value may need tweaking.
- const float epsilon = 0.001f;
- float gainDiff = fabs(totalDesiredGain - gain);
-
- // Number of frames to de-zipper before we are close enough to the target gain.
- // FIXME: framesToDezipper could be smaller when target gain is close enough within this process loop.
- unsigned framesToDezipper = (gainDiff < epsilon) ? 0 : framesToProcess;
-
- if (framesToDezipper) {
- if (!m_dezipperGainValues.get() || m_dezipperGainValues->size() < framesToDezipper)
- m_dezipperGainValues = makeUnique<AudioFloatArray>(framesToDezipper);
-
- float* gainValues = m_dezipperGainValues->data();
- for (unsigned i = 0; i < framesToDezipper; ++i) {
- gain += (totalDesiredGain - gain) * DezipperRate;
-
- // FIXME: If we are clever enough in calculating the framesToDezipper value, we can probably get
- // rid of this DenormalDisabler::flushDenormalFloatToZero() call.
- gain = DenormalDisabler::flushDenormalFloatToZero(gain);
- *gainValues++ = gain;
- }
-
- for (unsigned channelIndex = 0; channelIndex < numberOfChannels; ++channelIndex) {
- vmul(sources[channelIndex], 1, m_dezipperGainValues->data(), 1, destinations[channelIndex], 1, framesToDezipper);
- sources[channelIndex] += framesToDezipper;
- destinations[channelIndex] += framesToDezipper;
- }
- } else
- gain = totalDesiredGain;
-
- // Apply constant gain after de-zippering has converged on target gain.
- if (framesToDezipper < framesToProcess) {
- // Handle gains of 0 and 1 (exactly) specially.
- if (gain == 1) {
- for (unsigned channelIndex = 0; channelIndex < numberOfChannels; ++channelIndex)
- memcpy(destinations[channelIndex], sources[channelIndex], (framesToProcess - framesToDezipper) * sizeof(*destinations[channelIndex]));
- } else if (!gain) {
- for (unsigned channelIndex = 0; channelIndex < numberOfChannels; ++channelIndex)
- memset(destinations[channelIndex], 0, (framesToProcess - framesToDezipper) * sizeof(*destinations[channelIndex]));
- } else {
- for (unsigned channelIndex = 0; channelIndex < numberOfChannels; ++channelIndex)
- vsmul(sources[channelIndex], 1, &gain, destinations[channelIndex], 1, framesToProcess - framesToDezipper);
- }
+ // Handle gains of 0 and 1 (exactly) specially.
+ if (gain == 1) {
+ for (unsigned channelIndex = 0; channelIndex < numberOfChannels; ++channelIndex)
+ memcpy(destinations[channelIndex], sources[channelIndex], framesToProcess * sizeof(*destinations[channelIndex]));
+ } else if (!gain) {
+ for (unsigned channelIndex = 0; channelIndex < numberOfChannels; ++channelIndex)
+ memset(destinations[channelIndex], 0, framesToProcess * sizeof(*destinations[channelIndex]));
+ } else {
+ for (unsigned channelIndex = 0; channelIndex < numberOfChannels; ++channelIndex)
+ vsmul(sources[channelIndex], 1, &gain, destinations[channelIndex], 1, framesToProcess);
}
-
- // Save the target gain as the starting point for next time around.
- *lastMixGain = gain;
}
void AudioBus::copyWithSampleAccurateGainValuesFrom(const AudioBus &sourceBus, float* gainValues, unsigned numberOfGainValues)
Modified: trunk/Source/WebCore/platform/audio/AudioBus.h (266793 => 266794)
--- trunk/Source/WebCore/platform/audio/AudioBus.h 2020-09-09 18:41:01 UTC (rev 266793)
+++ trunk/Source/WebCore/platform/audio/AudioBus.h 2020-09-09 18:46:00 UTC (rev 266794)
@@ -134,10 +134,8 @@
void sumFrom(const AudioBus& sourceBus, ChannelInterpretation = ChannelInterpretation::Speakers);
// Copy each channel from sourceBus into our corresponding channel.
- // We scale by targetGain (and our own internal gain m_busGain), performing "de-zippering" to smoothly change from *lastMixGain to (targetGain*m_busGain).
- // The caller is responsible for setting up lastMixGain to point to storage which is unique for every "stream" which will be applied to this bus.
- // This represents the dezippering memory.
- void copyWithGainFrom(const AudioBus &sourceBus, float* lastMixGain, float targetGain);
+ // We scale by targetGain (and our own internal gain m_busGain).
+ void copyWithGainFrom(const AudioBus& sourceBus, float targetGain);
// Copies the sourceBus by scaling with sample-accurate gain values.
void copyWithSampleAccurateGainValuesFrom(const AudioBus &sourceBus, float* gainValues, unsigned numberOfGainValues);