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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-downmix.html

Issue 2892803002: Fix layout tests to prevent errors from layout-test-tidy (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/testharness.js"></script> 4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script> 5 <script src="../../resources/testharnessreport.js"></script>
6 <script src="../resources/audit-util.js"></script> 6 <script src="../resources/audit-util.js"></script>
7 <script src="../resources/audit.js"></script> 7 <script src="../resources/audit.js"></script>
8 <script src="../resources/fft.js"></script> 8 <script src="../resources/fft.js"></script>
9 <script src="../resources/realtimeanalyser-testing.js"></script> 9 <script src="../resources/realtimeanalyser-testing.js"></script>
10 <title>Test AnalyserNode Downmixing</title> 10 <title>Test AnalyserNode Downmixing</title>
11 </head> 11 </head>
12 12
13 <body> 13 <body>
14 <script> 14 <script>
15 var sampleRate = 44100; 15 let sampleRate = 44100;
16 var renderFrames = 2048; 16 let renderFrames = 2048;
17 17
18 var audit = Audit.createTaskRunner(); 18 let audit = Audit.createTaskRunner();
19 19
20 var testConfigs = [{ 20 let testConfigs = [{
21 channelCount: 1, 21 channelCount: 1,
22 message: "mono", 22 message: "mono",
23 floatRelError: 6.3283e-8 23 floatRelError: 6.3283e-8
24 }, { 24 }, {
25 channelCount: 2, 25 channelCount: 2,
26 message: "stereo", 26 message: "stereo",
27 floatRelError: 1.1681e-7 27 floatRelError: 1.1681e-7
28 }, { 28 }, {
29 channelCount: 4, 29 channelCount: 4,
30 message: "quad", 30 message: "quad",
(...skipping 18 matching lines...) Expand all
49 } 49 }
50 50
51 audit.run(); 51 audit.run();
52 52
53 // Test downmixing of the AnalyserNode time data. We use the downmixing t hat automatically 53 // Test downmixing of the AnalyserNode time data. We use the downmixing t hat automatically
54 // happens in the destination node to generate the reference data which is compared to the 54 // happens in the destination node to generate the reference data which is compared to the
55 // data that the Analyser node has captured. 55 // data that the Analyser node has captured.
56 function runTest(options, should) { 56 function runTest(options, should) {
57 // Context MUST have exactly one channel so that we downmix the source t o mono to generate 57 // Context MUST have exactly one channel so that we downmix the source t o mono to generate
58 // the reference. 58 // the reference.
59 var context = new OfflineAudioContext(1, renderFrames, sampleRate); 59 let context = new OfflineAudioContext(1, renderFrames, sampleRate);
60 60
61 var channels = options.channelCount || 1; 61 let channels = options.channelCount || 1;
62 var source = context.createBufferSource(); 62 let source = context.createBufferSource();
63 63
64 // The signals in each channel. Doesn't matter much what is in here, but it's best if the 64 // The signals in each channel. Doesn't matter much what is in here, but it's best if the
65 // values aren't linearly increasing so that the average of the values i sn't one of the 65 // values aren't linearly increasing so that the average of the values i sn't one of the
66 // values (in case the implementation does something silly). Only need to support up to 6 66 // values (in case the implementation does something silly). Only need to support up to 6
67 // channels. 67 // channels.
68 var bufferValues = [1, 2, 3, 4, 5, 6].map(function (x) { 68 let bufferValues = [1, 2, 3, 4, 5, 6].map(function (x) {
69 return x * x 69 return x * x
70 });; 70 });;
71 source.buffer = createConstantBuffer(context, renderFrames, bufferValues .slice(0, channels)); 71 source.buffer = createConstantBuffer(context, renderFrames, bufferValues .slice(0, channels));
72 72
73 var analyser = context.createAnalyser(); 73 let analyser = context.createAnalyser();
74 analyser.smoothingTimeConstant = 0; 74 analyser.smoothingTimeConstant = 0;
75 analyser.fftSize = 256; 75 analyser.fftSize = 256;
76 76
77 // Run analyser as an automatic pull node. Do NOT connect to the destina tion. We don't want 77 // Run analyser as an automatic pull node. Do NOT connect to the destina tion. We don't want
78 // the output of the analyser to mix in with the source that is also dir ectly connected to 78 // the output of the analyser to mix in with the source that is also dir ectly connected to
79 // the destination. 79 // the destination.
80 source.connect(analyser); 80 source.connect(analyser);
81 source.connect(context.destination); 81 source.connect(context.destination);
82 82
83 var timeData = new Float32Array(analyser.fftSize); 83 let timeData = new Float32Array(analyser.fftSize);
84 var freqData = new Float32Array(analyser.frequencyBinCount); 84 let freqData = new Float32Array(analyser.frequencyBinCount);
85 85
86 var suspendFrame = analyser.fftSize; 86 let suspendFrame = analyser.fftSize;
87 context.suspend(suspendFrame / context.sampleRate).then(function () { 87 context.suspend(suspendFrame / context.sampleRate).then(function () {
88 analyser.getFloatTimeDomainData(timeData); 88 analyser.getFloatTimeDomainData(timeData);
89 analyser.getFloatFrequencyData(freqData); 89 analyser.getFloatFrequencyData(freqData);
90 }).then(context.resume.bind(context)); 90 }).then(context.resume.bind(context));
91 91
92 source.start(); 92 source.start();
93 return context.startRendering().then(function (renderedBuffer) { 93 return context.startRendering().then(function (renderedBuffer) {
94 var success = true;
95
96 // Verify the time domain data is correct. 94 // Verify the time domain data is correct.
97 var prefix = "Analyser downmix " + options.message + " to mono" 95 let prefix = "Analyser downmix " + options.message + " to mono"
98 should(timeData, prefix + " time data") 96 should(timeData, prefix + " time data")
99 .beEqualToArray(renderedBuffer.getChannelData(0).subarray(0, analyse r.fftSize)); 97 .beEqualToArray(renderedBuffer.getChannelData(0).subarray(0, analyse r.fftSize));
100 98
101 var expectedTimeData = renderedBuffer.getChannelData(0).subarray(0, an alyser.fftSize); 99 let expectedTimeData = renderedBuffer.getChannelData(0).subarray(0, an alyser.fftSize);
102 var fftOrder = Math.floor(Math.log2(analyser.fftSize)); 100 let fftOrder = Math.floor(Math.log2(analyser.fftSize));
103 var expectedFreqData = computeFFTMagnitude(expectedTimeData, fftOrder) .map(linearToDb); 101 let expectedFreqData = computeFFTMagnitude(expectedTimeData, fftOrder) .map(linearToDb);
104 102
105 var success = compareFloatFreq(prefix + " freq data", freqData, 103 compareFloatFreq(prefix + " freq data", freqData,
Raymond Toy 2017/05/19 13:53:37 So, this, along with removing line 94, was the act
hongchan 2017/05/19 16:15:29 |success| is not used anywhere. So I removed them
106 expectedFreqData, should, { 104 expectedFreqData, should, {
107 precision: 6, 105 precision: 6,
108 floatRelError: options.floatRelError, 106 floatRelError: options.floatRelError,
109 }); 107 });
110 }); 108 });
111 } 109 }
112 </script> 110 </script>
113 </body> 111 </body>
114 </html> 112 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698