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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/BiquadFilter/tail-time-lowshelf.html

Issue 2862373002: Compute tail time from Biquad coefficients (Closed)
Patch Set: Initialize tail_time_ in constructor Created 3 years, 7 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
Index: third_party/WebKit/LayoutTests/webaudio/BiquadFilter/tail-time-lowshelf.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/BiquadFilter/tail-time-lowshelf.html b/third_party/WebKit/LayoutTests/webaudio/BiquadFilter/tail-time-lowshelf.html
new file mode 100644
index 0000000000000000000000000000000000000000..b8af1f33f2a940e8bfb89bf9c721f69de3f941b6
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/webaudio/BiquadFilter/tail-time-lowshelf.html
@@ -0,0 +1,83 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Test Biquad Tail-Time</title>
+ <script src="../../resources/testharness.js"></script>
+ <script src="../../resources/testharnessreport.js"></script>
+ <script src="../resources/audit-util.js"></script>
+ <script src="../resources/audit.js"></script>
+ <script src="../resources/biquad-filters.js"></script>
+ <script src="test-tail-time.js"></script>
+ </head>
+
+ <body>
+ <script>
+ let audit = Audit.createTaskRunner();
+
+ let sampleRate = 16384;
+ let renderSeconds = 1;
+ let renderFrames = renderSeconds * sampleRate;
+ let renderQuantumFrames = 128;
+
+ // For a lowshelf filter:
+ // b0 = A*[(A+1)−(A−1)*cos(w0)+2*as*sqrt(A)]
+ // b1 = 2*A*[(A+1)-(A-1)*cos(w0)]
+ // b2 = A*[(A+1)−(A−1)*cos(w0)-2*as*sqrt(A)]
+ // a0 = (A+1)+(A-1)*cos(w0)+2*as*sqrt(A)
+ // a1 = -2*[(A-1)+(A+1)*cos(w0)]
+ // a2 = (A+1)+(A-1)*cos(w0)-2*as*sqrt(A)
+ //
+ // where as = sin(w0)/sqrt(2), w0 = 2*%pi*f0/Fs, and A = 10^(G/40)
+ //
+ // The poles of this filter are
+ //
+ // -a2/(2*a0) +/- sqrt(a1^2-4*a0*a2)/(2*a0).
+ //
+ // Thus, the poles depend on the sign of d = a1^2-4*a0*a2 =
+ // 16*A*(as^2-sin(w0)^2) = -8*A*sin(w0)^2. Thus, the poles are always
+ // complex except if w0 = 0, in which case there is a repeated pole at 0.
+
+ // Array of tests to run. |descripton| is the task description for
+ // audit.define. |parameters| is option for |testTailTime|.
+ let tests = [
+ {
+ descripton:
+ {label: 'lowshelf-complex-roots', description: 'complex roots'},
+ parameters: {
+ prefix: 'Lowshelf complex roots',
+ filterOptions:
+ {type: 'lowshelf', gain: 40, frequency: sampleRate / 8},
+ // Node computed tail frame is 75.5 frames, which matches the actual
+ // tail, so tail output should be exactly zero.
+ threshold: 0
+ },
+ },
+ {
+ descripton: {
+ label: 'lowshelf-repeated-roots',
+ description: 'repeated real root'
+ },
+ parameters: {
+ prefix: 'Lowshelf repeated roots',
+ filterOptions:
+ {type: 'lowshelf', Q: 1 / 20, gain: 40, frequency: 0},
+ // Node computed tail frame is 2 frames, which matches the actual
+ // tail, so tail output should be exactly zero.
+ threshold: 0
+ },
+ },
+ ];
+
+ // Define an appropriate task for each test.
+ tests.forEach(entry => {
+ audit.define(entry.descripton, (task, should) => {
+ let context = new OfflineAudioContext(1, renderFrames, sampleRate);
+ testTailTime(should, context, entry.parameters)
+ .then(() => task.done());
+ });
+ });
+
+ audit.run();
+ </script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698