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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/BiquadFilter/tail-time-allpass.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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/BiquadFilter/tail-time-bandpass.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/webaudio/BiquadFilter/tail-time-allpass.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/BiquadFilter/tail-time-allpass.html b/third_party/WebKit/LayoutTests/webaudio/BiquadFilter/tail-time-allpass.html
new file mode 100644
index 0000000000000000000000000000000000000000..b902f42a8236fcc77b05748be8fd9f49ee62f863
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/webaudio/BiquadFilter/tail-time-allpass.html
@@ -0,0 +1,103 @@
+<!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;
+
+ // For an allpass filter:
+ // b0 = 1 - alpha
+ // b1 = -2*cos(w0)
+ // b2 = 1 + alpha
+ // a0 = 1 + alpha
+ // a1 = -2*cos(w0)
+ // a2 = 1 - alpha
+ //
+ // where alpha = sin(w0)/(2*Q) and w0 = 2*%pi*f0/Fs.
+ //
+ // Equivalently a1 = -2*cos(w0)/(1+alpha), a2 = (1-alpha)/(1+alpha). The
+ // poles of this filter are at
+ //
+ // (2*Q*cos(w0) +/- sqrt(1-4*Q^2)*sin(w0))/(2*Q + sin(w0))
+ //
+ // Thus, if 1-4*Q^2 < 0, the poles are complex. For 1-4*Q^2 > 0, the
+ // poles are real and distinct. For 1-4*Q^2 = 0, there are two identical
+ // real poles.
+
+ // Array of tests to run. |descripton| is the task description for
+ // audit.define. |parameters| is option for |testTailTime|.
+ let tests = [
+ {
+ description:
+ {label: 'allpass-complex-roots', description: 'complex roots'},
+ parameters: {
+ prefix: 'Complex roots',
+ // Choose a fairly large Q to make the tail long. Frequency is
+ // fairly arbitrary.
+ filterOptions: {type: 'allpass', Q: 200, frequency: sampleRate / 4},
+ // This filter the actual real tail frame is 2317, and the node
+ // computed frame is 2316.81. Thus, the tail output should be
+ // exactly 0.
+ threshold: 0
+ }
+ },
+ {
+ description: {
+ label: 'allpass-real-distinct-roots',
+ description: 'real distinct roots'
+ },
+ parameters: {
+ prefix: 'Distinct roots',
+ filterOptions: {
+ type: 'allpass',
+ Q: 0.001,
+ frequency: sampleRate / 8,
+ },
+ // With this particular filter, the real tail frame is 4822, but
+ // the node way overestimates it to be 7136. Thus, the actual
+ // tail frames won't be exactly zero.
+ threshold: 1 / 32768
+ }
+ },
+ {
+ description: {
+ label: 'allpass-repeated-roots',
+ description: 'repeated real root'
+ },
+ parameters: {
+ prefix: 'Repeated roots',
+ // 1-4*Q^2 = 0 iff Q = 1/2.
+ filterOptions: {type: 'allpass', Q: 0.5, frequency: sampleRate / 8},
+ // The node estimated tail time is 16.8 frames, but the actual is
+ // 106. Thus, the outupt should be exactly 0.
+ threshold: 0
+ }
+ }
+ ];
+
+ // Define an appropriate task for each test.
+ tests.forEach(entry => {
+ audit.define(entry.description, (task, should) => {
+ let context = new OfflineAudioContext(1, renderFrames, sampleRate);
+ testTailTime(should, context, entry.parameters)
+ .then(() => task.done());
+ });
+ });
+
+ audit.run();
+ </script>
+ </body>
+</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/BiquadFilter/tail-time-bandpass.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698