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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/resources/audit-util.js

Issue 2186813003: Sub-sample accurate start of OscillatorNode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust thresholds for Mac 10.11 (retina) Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 /** 6 /**
7 * @fileOverview This file includes legacy utility functions for the layout 7 * @fileOverview This file includes legacy utility functions for the layout
8 * test. 8 * test.
9 */ 9 */
10 10
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 var startFrame = timeToSampleFrame(grainOffset, sampleRate); 250 var startFrame = timeToSampleFrame(grainOffset, sampleRate);
251 var endFrame = timeToSampleFrame(grainOffset + duration, sampleRate); 251 var endFrame = timeToSampleFrame(grainOffset + duration, sampleRate);
252 252
253 return endFrame - startFrame; 253 return endFrame - startFrame;
254 } 254 }
255 255
256 // True if the number is not an infinity or NaN 256 // True if the number is not an infinity or NaN
257 function isValidNumber(x) { 257 function isValidNumber(x) {
258 return !isNaN(x) && (x != Infinity) && (x != -Infinity); 258 return !isNaN(x) && (x != Infinity) && (x != -Infinity);
259 } 259 }
260
261 // Compute the (linear) signal-to-noise ratio between |actual| and
262 // |expected|. The result is NOT in dB! If the |actual| and
263 // |expected| have different lengths, the shorter length is used.
264 function computeSNR(actual, expected) {
265 var signalPower = 0;
266 var noisePower = 0;
267
268 var length = Math.min(actual.length, expected.length);
269
270 for (var k = 0; k < length; ++k) {
271 var diff = actual[k] - expected[k];
272 signalPower += expected[k] * expected[k];
273 noisePower += diff * diff;
274 }
275
276 return signalPower / noisePower;
277 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698