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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/Convolver/convolver-response-4-chan.html

Issue 2895963003: Apply layout-test-tidy to LayoutTests/webaudio (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 <title>Test Convolver Channel Outputs for Response with 4 channels</title> 4 <title>
5 Test Convolver Channel Outputs for Response with 4 channels
6 </title>
5 <script src="../../resources/testharness.js"></script> 7 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script> 8 <script src="../../resources/testharnessreport.js"></script>
7 <script src="../resources/audit-util.js"></script> 9 <script src="../resources/audit-util.js"></script>
8 <script src="../resources/audit.js"></script> 10 <script src="../resources/audit.js"></script>
9 </head> 11 </head>
10
11 <body> 12 <body>
12 <script> 13 <script id="layout-test-code">
13 // Test various convolver configurations when the convolver response has 14 // Test various convolver configurations when the convolver response has
14 // a four channels. 15 // a four channels.
15 16
16 // Fairly arbitrary sample rate, except that we want the rate to be a 17 // Fairly arbitrary sample rate, except that we want the rate to be a
17 // power of two so that 1/sampleRate is exactly respresentable as a 18 // power of two so that 1/sampleRate is exactly respresentable as a
18 // single-precision float. 19 // single-precision float.
19 let sampleRate = 8192; 20 let sampleRate = 8192;
20 21
21 // A fairly arbitrary number of frames, except the number of frames should 22 // A fairly arbitrary number of frames, except the number of frames should
22 // be more than a few render quanta. 23 // be more than a few render quanta.
23 let renderFrames = 10 * 128; 24 let renderFrames = 10 * 128;
24 25
25 let audit = Audit.createTaskRunner(); 26 let audit = Audit.createTaskRunner();
26 27
27 // Convolver response 28 // Convolver response
28 let response; 29 let response;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 { 91 {
91 label: '5.1-channel input', 92 label: '5.1-channel input',
92 description: '5.1->2 downmix producing 2-channel output' 93 description: '5.1->2 downmix producing 2-channel output'
93 }, 94 },
94 (task, should) => { 95 (task, should) => {
95 fourChannelResponseTest({numberOfInputs: 6, prefix: '5.1'}, should) 96 fourChannelResponseTest({numberOfInputs: 6, prefix: '5.1'}, should)
96 .then(() => task.done()); 97 .then(() => task.done());
97 }); 98 });
98 99
99 audit.define( 100 audit.define(
100 { 101 {
101 label: 'delayed buffer set', 102 label: 'delayed buffer set',
102 description: 'Delayed set of 4-channel response' 103 description: 'Delayed set of 4-channel response'
103 }, 104 },
104 (task, should) => { 105 (task, should) => {
105 // Don't really care about the output for this test. It's to verify 106 // Don't really care about the output for this test. It's to verify
106 // we don't crash in a debug build when setting the convolver buffer 107 // we don't crash in a debug build when setting the convolver buffer
107 // after creating the graph. 108 // after creating the graph.
108 let context = new OfflineAudioContext(1, renderFrames, sampleRate); 109 let context = new OfflineAudioContext(1, renderFrames, sampleRate);
109 let src = new OscillatorNode(context); 110 let src = new OscillatorNode(context);
110 let convolver = new ConvolverNode(context, { 111 let convolver =
111 disableNormalization: true 112 new ConvolverNode(context, {disableNormalization: true});
113 let buffer = new AudioBuffer({
114 numberOfChannels: 4,
115 length: 4,
116 sampleRate: context.sampleRate
117 });
118
119 // Impulse responses for the convolver aren't important, as long as
120 // it's not all zeroes.
121 for (let k = 0; k < buffer.numberOfChannels; ++k) {
122 buffer.getChannelData(k).fill(1);
123 }
124
125 src.connect(convolver).connect(context.destination);
126
127 // Set the buffer after a few render quanta have passed. The actual
128 // value must be least one, but is otherwise arbitrary.
129 context.suspend(512 / context.sampleRate)
130 .then(() => convolver.buffer = buffer)
131 .then(() => context.resume());
132
133 src.start();
134 context.startRendering()
135 .then(audioBuffer => {
136 // Just make sure output is not silent.
137 should(
138 audioBuffer.getChannelData(0),
139 'Output with delayed setting of convolver buffer')
140 .notBeConstantValueOf(0);
141 })
142 .then(() => task.done());
112 }); 143 });
113 let buffer = new AudioBuffer({
114 numberOfChannels: 4,
115 length: 4,
116 sampleRate: context.sampleRate
117 });
118
119 // Impulse responses for the convolver aren't important, as long as
120 // it's not all zeroes.
121 for (let k = 0; k < buffer.numberOfChannels; ++k) {
122 buffer.getChannelData(k).fill(1);
123 }
124
125 src.connect(convolver).connect(context.destination);
126
127 // Set the buffer after a few render quanta have passed. The actual
128 // value must be least one, but is otherwise arbitrary.
129 context.suspend(512 / context.sampleRate)
130 .then(() => convolver.buffer = buffer)
131 .then(() => context.resume());
132
133 src.start();
134 context.startRendering()
135 .then(audioBuffer => {
136 // Just make sure output is not silent.
137 should(audioBuffer.getChannelData(0),
138 'Output with delayed setting of convolver buffer')
139 .notBeConstantValueOf(0);
140 })
141 .then(() => task.done());
142 });
143 144
144 function fourChannelResponseTest(options, should) { 145 function fourChannelResponseTest(options, should) {
145 // Create an 4-channel offline context. The first two channels are for 146 // Create an 4-channel offline context. The first two channels are for
146 // the stereo output of the convolver and the next two channels are for 147 // the stereo output of the convolver and the next two channels are for
147 // the reference stereo signal. 148 // the reference stereo signal.
148 let context = new OfflineAudioContext(4, renderFrames, sampleRate); 149 let context = new OfflineAudioContext(4, renderFrames, sampleRate);
149 context.destination.channelInterpretation = 'discrete'; 150 context.destination.channelInterpretation = 'discrete';
150 151
151 // Create oscillators for use as the input. The type and frequency is 152 // Create oscillators for use as the input. The type and frequency is
152 // arbitrary except that oscillators must be different. 153 // arbitrary except that oscillators must be different.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 .beEqualToArray(expected0); 252 .beEqualToArray(expected0);
252 should(actual1, options.prefix + ': Channel 1') 253 should(actual1, options.prefix + ': Channel 1')
253 .beEqualToArray(expected1); 254 .beEqualToArray(expected1);
254 }); 255 });
255 } 256 }
256 257
257 audit.run(); 258 audit.run();
258 </script> 259 </script>
259 </body> 260 </body>
260 </html> 261 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698