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

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

Issue 2623063002: Revert of Sub-sample accurate start of OscillatorNode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 var startFrame = timeToSampleFrame(grainOffset, sampleRate); 266 var startFrame = timeToSampleFrame(grainOffset, sampleRate);
267 var endFrame = timeToSampleFrame(grainOffset + duration, sampleRate); 267 var endFrame = timeToSampleFrame(grainOffset + duration, sampleRate);
268 268
269 return endFrame - startFrame; 269 return endFrame - startFrame;
270 } 270 }
271 271
272 // True if the number is not an infinity or NaN 272 // True if the number is not an infinity or NaN
273 function isValidNumber(x) { 273 function isValidNumber(x) {
274 return !isNaN(x) && (x != Infinity) && (x != -Infinity); 274 return !isNaN(x) && (x != Infinity) && (x != -Infinity);
275 } 275 }
276
277 // Compute the (linear) signal-to-noise ratio between |actual| and
278 // |expected|. The result is NOT in dB! If the |actual| and
279 // |expected| have different lengths, the shorter length is used.
280 function computeSNR(actual, expected) {
281 var signalPower = 0;
282 var noisePower = 0;
283
284 var length = Math.min(actual.length, expected.length);
285
286 for (var k = 0; k < length; ++k) {
287 var diff = actual[k] - expected[k];
288 signalPower += expected[k] * expected[k];
289 noisePower += diff * diff;
290 }
291
292 return signalPower / noisePower;
293 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698