bug 1339889 add logging of maximum noise r=padenot
authorKarl Tomlinson <karlt+@karlt.net>
Sat, 02 Dec 2017 21:58:40 +1300
changeset 394914 73f34d2e0b70567baeb7a27c1c47dae98ed4548e
parent 394913 e5f1e211f5b13f3e7b718acd10235a8984512aa2
child 394915 2ac1235b3e002dfba1abe16cad3220358624c621
push id33025
push usershindli@mozilla.com
push dateTue, 05 Dec 2017 09:57:50 +0000
treeherdermozilla-central@390c1aad9d4d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1339889
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1339889 add logging of maximum noise r=padenot MozReview-Commit-ID: 4kPl6Jt8rXS
dom/media/webaudio/test/test_mediaElementAudioSourceNodeFidelity.html
--- a/dom/media/webaudio/test/test_mediaElementAudioSourceNodeFidelity.html
+++ b/dom/media/webaudio/test/test_mediaElementAudioSourceNodeFidelity.html
@@ -41,33 +41,38 @@ function debugCanvas(analyser) {
 }
 
 
 function checkFrequency(an) {
   an.getFloatFrequencyData(frequencyArray);
   // We should have no energy when checking the data largely outside the index
   // for 440Hz (the frequency of the sine wave), start checking an octave above,
   // the Opus compression can add some harmonics to the pure since wave.
-  var index = binIndexForFrequency(880, an);
-  var underTreshold = true;
-  for (var i = index; i < frequencyArray.length; i++) {
-    // Let some slack, there might be some noise here because of int -> float
-    // conversion or the Opus encoding.
-    if (frequencyArray[i] > an.minDecibels + 40) {
-      return false;
+  var maxNoiseIndex = binIndexForFrequency(880, an);
+  for (var i = maxNoiseIndex + 1; i < frequencyArray.length; i++) {
+    if (frequencyArray[i] > frequencyArray[maxNoiseIndex]) {
+       maxNoiseIndex = i;
     }
   }
 
   // On the other hand, we should find a peak at 440Hz. Our sine wave is not
   // attenuated, we're expecting the peak to reach 0dBFs.
-  index = binIndexForFrequency(440, an);
-  info("energy at 440: " + frequencyArray[index] + ", threshold " + (an.maxDecibels - 10));
+  var index = binIndexForFrequency(440, an);
+  info("energy at 440: " + frequencyArray[index] +
+       ", threshold " + (an.maxDecibels - 10) +
+       "; max noise at index " + maxNoiseIndex +
+       ": " + frequencyArray[maxNoiseIndex] );
   if (frequencyArray[index] < (an.maxDecibels - 10)) {
     return false;
   }
+  // Let some slack, there might be some noise here because of int -> float
+  // conversion or the Opus encoding.
+  if (frequencyArray[maxNoiseIndex] > an.minDecibels + 40) {
+    return false;
+  }
 
   return true;
 }
 
 var audioElement = new Audio();
 audioElement.src = 'sine-440-10s.opus'
 audioElement.loop = true;
 var ac = new AudioContext();