author | Karl Tomlinson <karlt+@karlt.net> |
Sat, 02 Dec 2017 21:58:40 +1300 | |
changeset 394946 | 73f34d2e0b70567baeb7a27c1c47dae98ed4548e |
parent 394945 | e5f1e211f5b13f3e7b718acd10235a8984512aa2 |
child 394947 | 2ac1235b3e002dfba1abe16cad3220358624c621 |
push id | 97987 |
push user | nerli@mozilla.com |
push date | Tue, 05 Dec 2017 13:52:50 +0000 |
treeherder | mozilla-inbound@8842dba7396b [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | padenot |
bugs | 1339889 |
milestone | 59.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
|
dom/media/webaudio/test/test_mediaElementAudioSourceNodeFidelity.html | file | annotate | diff | comparison | revisions |
--- 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();