Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: LayoutTests/webaudio/biquad-tail.html

Issue 1285073005: Add special case handling for disconnected BiquadFilter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix typo in expected results. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/webaudio/biquad-tail-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/webaudio/biquad-tail.html
diff --git a/LayoutTests/webaudio/biquad-tail.html b/LayoutTests/webaudio/biquad-tail.html
new file mode 100644
index 0000000000000000000000000000000000000000..6a66c7d6585fe4a81d149c0e21735fb8af0873aa
--- /dev/null
+++ b/LayoutTests/webaudio/biquad-tail.html
@@ -0,0 +1,67 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Test Biquad Tail Output</title>
+ <script src="../resources/js-test.js"></script>
+ <script src="resources/compatibility.js"></script>
+ <script src="resources/audio-testing.js"></script>
+ </head>
+
+ <body>
+ <script>
+ description("Test Biquad Tail Output");
+ window.jsTestIsAsync = true;
+
+ // A high sample rate shows the issue more clearly.
+ var sampleRate = 192000;
+ // Some short duration because we don't need to run the test for very long.
+ var testDurationSec = 0.5;
+ var testDurationFrames = testDurationSec * sampleRate;
+
+ // Amplitude experimentally determined to give a biquad output close to 1. (No attempt was
+ // made to produce exactly 1; it's not needed.)
+ var sourceAmplitude = 100;
+
+ // The output of the biquad filter should not change by more than this much between output
+ // samples. Threshold was determined experimentally.
+ var glitchThreshold = 0.0129;
+
+ // Test that a Biquad filter doesn't have it's output terminated because the input has gone
+ // away. Generally, when a source node is finished, it disconnects itself from any downstream
+ // nodes. This is the correct behavior. Nodes that have no inputs (disconnected) are
+ // generally assumed to output zeroes. This is also desired behavior. However, biquad
+ // filters have memory so they should not suddenly output zeroes when the input is
+ // disconnected. This test checks to see if the output doesn't suddenly change to zero.
+ function runTest() {
+ var context = new OfflineAudioContext(1, testDurationFrames, sampleRate);
+
+ // Create an impulse source.
+ var buffer = context.createBuffer(1, 1, context.sampleRate);
+ buffer.getChannelData(0)[0] = sourceAmplitude;
+ var source = context.createBufferSource();
+ source.buffer = buffer;
+
+ // Create the biquad filter. It doesn't really matter what kind, so the default filter type
+ // and parameters is fine. Connect the source to it.
+ var biquad = context.createBiquadFilter();
+ source.connect(biquad);
+ biquad.connect(context.destination);
+
+ source.start();
+
+ context.startRendering().then(function(result) {
+ // There should be no large discontinuities in the output
+ var success = true;
+ success = success && Should("Biquad output", result.getChannelData(0)).notGlitch(glitchThreshold);
+ if (success)
+ testPassed("Biquad tail output correctly completed.");
+ else
+ testFailed("Biquad tail output not correctly completed.");
+ }).then(finishJSTest);
+ }
+
+ runTest();
+ successfullyParsed = true;
+ </script>
+ </body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/webaudio/biquad-tail-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698