| Index: third_party/WebKit/LayoutTests/webaudio/Oscillator/osc-low-freq.html
|
| diff --git a/third_party/WebKit/LayoutTests/webaudio/Oscillator/osc-low-freq.html b/third_party/WebKit/LayoutTests/webaudio/Oscillator/osc-low-freq.html
|
| index 46d33147e204ed084db251da561b63c7d2f7c437..eae55c594ed65eb3ce5585eaec8397d8e773f028 100644
|
| --- a/third_party/WebKit/LayoutTests/webaudio/Oscillator/osc-low-freq.html
|
| +++ b/third_party/WebKit/LayoutTests/webaudio/Oscillator/osc-low-freq.html
|
| @@ -1,82 +1,85 @@
|
| -<!doctype html>
|
| +<!DOCTYPE html>
|
| <html>
|
| <head>
|
| - <title>Test Custom Oscillator at Very Low Frequency</title>
|
| + <title>
|
| + Test Custom Oscillator at Very Low Frequency
|
| + </title>
|
| <script src="../../resources/testharness.js"></script>
|
| - <script src="../../resources/testharnessreport.js"></script>
|
| + <script src="../../resources/testharnessreport.js"></script>
|
| <script src="../resources/audit-util.js"></script>
|
| <script src="../resources/audit.js"></script>
|
| </head>
|
| -
|
| <body>
|
| - <script>
|
| - // Create a custom oscillator and verify that the parts of a periodic wave that should be
|
| - // ignored really are ignored.
|
| + <script id="layout-test-code">
|
| + // Create a custom oscillator and verify that the parts of a periodic wave
|
| + // that should be ignored really are ignored.
|
|
|
| - var sampleRate = 48000;
|
| + let sampleRate = 48000;
|
|
|
| - // The desired frequency of the oscillator. The value to be used depends on the
|
| - // implementation of the PeriodicWave and should be less than then lowest fundamental
|
| - // frequency. The lowest frequency is the Nyquist frequency divided by the max number of
|
| - // coefficients used for the FFT. In the current implementation, the max number of
|
| - // coefficients is 2048 (for a sample rate of 48 kHz) so the lowest frequency is 24000/2048 =
|
| + // The desired frequency of the oscillator. The value to be used depends
|
| + // on the implementation of the PeriodicWave and should be less than then
|
| + // lowest fundamental frequency. The lowest frequency is the Nyquist
|
| + // frequency divided by the max number of coefficients used for the FFT.
|
| + // In the current implementation, the max number of coefficients is 2048
|
| + // (for a sample rate of 48 kHz) so the lowest frequency is 24000/2048 =
|
| // 11.78 Hz.
|
| - var desiredFrequencyHz = 1;
|
| + let desiredFrequencyHz = 1;
|
|
|
| - // Minimum allowed SNR between the actual oscillator and the expected result. Experimentally
|
| - // determined.
|
| - var snrThreshold = 130;
|
| + // Minimum allowed SNR between the actual oscillator and the expected
|
| + // result. Experimentally determined.
|
| + let snrThreshold = 130;
|
|
|
| - var context;
|
| - var osc;
|
| - var actual;
|
| + let context;
|
| + let osc;
|
| + let actual;
|
|
|
| - var audit = Audit.createTaskRunner();
|
| + let audit = Audit.createTaskRunner();
|
|
|
| // Compute the SNR between the actual result and expected cosine wave
|
| function checkCosineResult(should, result, freq, sampleRate) {
|
| - var signal = 0;
|
| - var noise = 0;
|
| - var omega = 2 * Math.PI * freq / sampleRate;
|
| + let signal = 0;
|
| + let noise = 0;
|
| + let omega = 2 * Math.PI * freq / sampleRate;
|
|
|
| actual = result.getChannelData(0);
|
|
|
| - for (var k = 0; k < actual.length; ++k) {
|
| - var x = Math.cos(omega * k);
|
| - var diff = x - actual[k];
|
| + for (let k = 0; k < actual.length; ++k) {
|
| + let x = Math.cos(omega * k);
|
| + let diff = x - actual[k];
|
| signal += x * x;
|
| noise += diff * diff;
|
| }
|
|
|
| - var snr = 10 * Math.log10(signal / noise);
|
| + let snr = 10 * Math.log10(signal / noise);
|
|
|
| - should(snr, "SNR of " + desiredFrequencyHz + " Hz sine wave")
|
| - .beGreaterThanOrEqualTo(snrThreshold);
|
| + should(snr, 'SNR of ' + desiredFrequencyHz + ' Hz sine wave')
|
| + .beGreaterThanOrEqualTo(snrThreshold);
|
| }
|
|
|
| - audit.define("low-freq-oscillator", (task, should) => {
|
| + audit.define('low-freq-oscillator', (task, should) => {
|
| context = new OfflineAudioContext(1, sampleRate, sampleRate);
|
| osc = context.createOscillator();
|
|
|
| - // Create the custom oscillator. For simplicity of testing, we use just a cosine wave, but
|
| - // the initial elements of the real and imaginary parts are explicitly set to non-zero to
|
| - // test that they are ignored.
|
| - var r = new Float32Array(2);
|
| - var i = new Float32Array(2);
|
| - r[0] = 1; // DC component to be ignored
|
| - r[1] = 1; // Fundamental
|
| - i[0] = 1; // Sine term that doesn't actually exist in a Fourier series
|
| + // Create the custom oscillator. For simplicity of testing, we use just
|
| + // a cosine wave, but the initial elements of the real and imaginary
|
| + // parts are explicitly set to non-zero to test that they are ignored.
|
| + let r = new Float32Array(2);
|
| + let i = new Float32Array(2);
|
| + r[0] = 1; // DC component to be ignored
|
| + r[1] = 1; // Fundamental
|
| + i[0] = 1; // Sine term that doesn't actually exist in a Fourier series
|
| i[1] = 0;
|
| - var wave = context.createPeriodicWave(r, i);
|
| + let wave = context.createPeriodicWave(r, i);
|
|
|
| osc.setPeriodicWave(wave);
|
| osc.frequency.value = desiredFrequencyHz;
|
| osc.connect(context.destination);
|
| osc.start();
|
| - context.startRendering().then(function (buffer) {
|
| - checkCosineResult(should, buffer, desiredFrequencyHz, sampleRate);
|
| - })
|
| - .then(() => task.done());
|
| + context.startRendering()
|
| + .then(function(buffer) {
|
| + checkCosineResult(should, buffer, desiredFrequencyHz, sampleRate);
|
| + })
|
| + .then(() => task.done());
|
| });
|
|
|
| audit.run();
|
|
|