Index: third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-freq-data-smoothing.html |
diff --git a/third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-freq-data-smoothing.html b/third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-freq-data-smoothing.html |
index 2849dfa86567450c805ea7ae6707965389344417..a20d05e2eee60cdc8983e921c753f2c5e195f69c 100644 |
--- a/third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-freq-data-smoothing.html |
+++ b/third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-freq-data-smoothing.html |
@@ -15,59 +15,58 @@ |
<script> |
// Use a power of two to eliminate any round-off in the computation of the times for |
// context.suspend(). |
- var sampleRate = 32768; |
+ let sampleRate = 32768; |
// The largest FFT size for the analyser node is 32768. We want to render longer than this so |
// that we have at least one complete buffer of data of 32768 samples. |
- var renderFrames = 2 * 32768; |
- var renderDuration = renderFrames / sampleRate; |
+ let renderFrames = 2 * 32768; |
+ let renderDuration = renderFrames / sampleRate; |
- var audit = Audit.createTaskRunner(); |
+ let audit = Audit.createTaskRunner(); |
// Do one basic test of smoothing of the FFT data. |
audit.define("smoothing test", (task, should) => { |
// Test only 512-point FFT. The size isn't too important as long as it's greater than 128 |
// (a rendering quantum). |
- var options = { |
+ let options = { |
order: 9, |
smoothing: 0.5, |
floatRelError: 5.9207e-6 |
}; |
- var success = true; |
+ let success = true; |
- var graph = createGraph(options); |
+ let graph = createGraph(options); |
context = graph.context; |
analyser = graph.analyser; |
- var smoothedFloatResult = new Float32Array(analyser.frequencyBinCount); |
+ let smoothedFloatResult = new Float32Array(analyser.frequencyBinCount); |
smoothedFloatResult.fill(0); |
// Stop after one analyser frame to get the initial FFT |
- var suspendFrame = analyser.fftSize; |
+ let suspendFrame = analyser.fftSize; |
context.suspend(suspendFrame / sampleRate).then(function () { |
- var timeData = new Float32Array(analyser.fftSize); |
- var freqData = new Float32Array(analyser.frequencyBinCount); |
+ let timeData = new Float32Array(analyser.fftSize); |
+ let freqData = new Float32Array(analyser.frequencyBinCount); |
analyser.getFloatTimeDomainData(timeData); |
analyser.getFloatFrequencyData(freqData); |
- var expectedFreq = computeFFTMagnitude(timeData, options.order); |
+ let expectedFreq = computeFFTMagnitude(timeData, options.order); |
smoothFFT(smoothedFloatResult, expectedFreq, options.smoothing); |
- var message = "First " + analyser.fftSize + "-point FFT at frame " + (context.currentTime * |
+ let message = "First " + analyser.fftSize + "-point FFT at frame " + (context.currentTime * |
sampleRate); |
- var comparison = compareFloatFreq(message, freqData, smoothedFloatResult.map( |
+ let comparison = compareFloatFreq(message, freqData, smoothedFloatResult.map( |
linearToDb), should, options); |
success = success && comparison.success; |
// Test the byte frequency data. |
- var byteFreqData = new Uint8Array(analyser.frequencyBinCount); |
- var expectedByteData = new Float32Array(analyser.frequencyBinCount); |
Raymond Toy
2017/05/19 13:53:37
So, the issue here is the double declaration for e
hongchan
2017/05/19 16:15:29
Not only that, the assigning a new array to it is
|
+ let byteFreqData = new Uint8Array(analyser.frequencyBinCount); |
analyser.getByteFrequencyData(byteFreqData); |
// Convert the expected float frequency data to byte data. |
- var expectedByteData = convertFloatToByte(smoothedFloatResult.map(linearToDb), |
+ let expectedByteData = convertFloatToByte(smoothedFloatResult.map(linearToDb), |
analyser.minDecibels, analyser.maxDecibels); |
should(byteFreqData, analyser.fftSize + "-point byte FFT") |
@@ -78,20 +77,20 @@ |
// Skip an analyser frame and grab another to verify that the smoothing is done correctly. |
suspendFrame += 2 * analyser.fftSize; |
context.suspend(suspendFrame / sampleRate).then(function () { |
- var timeData = new Float32Array(analyser.fftSize); |
- var freqDataInDb = new Float32Array(analyser.frequencyBinCount); |
+ let timeData = new Float32Array(analyser.fftSize); |
+ let freqDataInDb = new Float32Array(analyser.frequencyBinCount); |
// Grab the time domain and frequency domain data |
analyser.getFloatTimeDomainData(timeData); |
analyser.getFloatFrequencyData(freqDataInDb); |
- var newFreqData = computeFFTMagnitude(timeData, options.order); |
+ let newFreqData = computeFFTMagnitude(timeData, options.order); |
// Smooth the data together |
smoothFFT(smoothedFloatResult, newFreqData, options.smoothing); |
- var message = "Smoothed " + analyser.fftSize + "-point FFT at frame " + |
+ let message = "Smoothed " + analyser.fftSize + "-point FFT at frame " + |
(context.currentTime * sampleRate); |
- var comparison = compareFloatFreq(message, |
+ let comparison = compareFloatFreq(message, |
freqDataInDb, smoothedFloatResult.map(linearToDb), should, { |
order: options.order, |
smoothing: options.smoothing, |
@@ -100,12 +99,11 @@ |
success = success && comparison.success; |
// Test the byte frequency data. |
- var byteFreqData = new Uint8Array(analyser.frequencyBinCount); |
- var expectedByteData = new Float32Array(analyser.frequencyBinCount); |
+ let byteFreqData = new Uint8Array(analyser.frequencyBinCount); |
analyser.getByteFrequencyData(byteFreqData); |
// Convert the expected float frequency data to byte data. |
- var expectedByteData = convertFloatToByte(smoothedFloatResult.map(linearToDb), |
+ let expectedByteData = convertFloatToByte(smoothedFloatResult.map(linearToDb), |
analyser.minDecibels, analyser.maxDecibels); |
should(byteFreqData, analyser.fftSize + "-point byte FFT") |