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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/webaudio/resources/audit-util.js
diff --git a/third_party/WebKit/LayoutTests/webaudio/resources/audit-util.js b/third_party/WebKit/LayoutTests/webaudio/resources/audit-util.js
index 3e261f6d7ad025eb3d21d5b3784d6959d62e6612..74c6972957a5be4e0d4c31175d7d9284d33cfde3 100644
--- a/third_party/WebKit/LayoutTests/webaudio/resources/audit-util.js
+++ b/third_party/WebKit/LayoutTests/webaudio/resources/audit-util.js
@@ -257,3 +257,21 @@ function grainLengthInSampleFrames(grainOffset, duration, sampleRate) {
function isValidNumber(x) {
return !isNaN(x) && (x != Infinity) && (x != -Infinity);
}
+
+// Compute the (linear) signal-to-noise ratio between |actual| and
+// |expected|. The result is NOT in dB! If the |actual| and
+// |expected| have different lengths, the shorter length is used.
+function computeSNR(actual, expected) {
+ var signalPower = 0;
+ var noisePower = 0;
+
+ var length = Math.min(actual.length, expected.length);
+
+ for (var k = 0; k < length; ++k) {
+ var diff = actual[k] - expected[k];
+ signalPower += expected[k] * expected[k];
+ noisePower += diff * diff;
+ }
+
+ return signalPower / noisePower;
+}

Powered by Google App Engine
This is Rietveld 408576698