OLD | NEW |
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>Test Convolver Channel Outputs for Response with 4 channels</title> |
5 <script src="../../resources/testharness.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
6 <script src="../../resources/testharnessreport.js"></script> | 6 <script src="../../resources/testharnessreport.js"></script> |
7 <script src="../resources/audit-util.js"></script> | 7 <script src="../resources/audit-util.js"></script> |
8 <script src="../resources/audit.js"></script> | 8 <script src="../resources/audit.js"></script> |
9 </head> | 9 </head> |
10 | 10 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 audit.define( | 89 audit.define( |
90 { | 90 { |
91 label: '5.1-channel input', | 91 label: '5.1-channel input', |
92 description: '5.1->2 downmix producing 2-channel output' | 92 description: '5.1->2 downmix producing 2-channel output' |
93 }, | 93 }, |
94 (task, should) => { | 94 (task, should) => { |
95 fourChannelResponseTest({numberOfInputs: 6, prefix: '5.1'}, should) | 95 fourChannelResponseTest({numberOfInputs: 6, prefix: '5.1'}, should) |
96 .then(() => task.done()); | 96 .then(() => task.done()); |
97 }); | 97 }); |
98 | 98 |
| 99 audit.define( |
| 100 { |
| 101 label: 'delayed buffer set', |
| 102 description: 'Delayed set of 4-channel response' |
| 103 }, |
| 104 (task, should) => { |
| 105 // 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 // after creating the graph. |
| 108 let context = new OfflineAudioContext(1, renderFrames, sampleRate); |
| 109 let src = new OscillatorNode(context); |
| 110 let convolver = new ConvolverNode(context, { |
| 111 disableNormalization: true |
| 112 }); |
| 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 |
99 function fourChannelResponseTest(options, should) { | 144 function fourChannelResponseTest(options, should) { |
100 // Create an 4-channel offline context. The first two channels are for | 145 // Create an 4-channel offline context. The first two channels are for |
101 // the stereo output of the convolver and the next two channels are for | 146 // the stereo output of the convolver and the next two channels are for |
102 // the reference stereo signal. | 147 // the reference stereo signal. |
103 let context = new OfflineAudioContext(4, renderFrames, sampleRate); | 148 let context = new OfflineAudioContext(4, renderFrames, sampleRate); |
104 context.destination.channelInterpretation = 'discrete'; | 149 context.destination.channelInterpretation = 'discrete'; |
105 | 150 |
106 // Create oscillators for use as the input. The type and frequency is | 151 // Create oscillators for use as the input. The type and frequency is |
107 // arbitrary except that oscillators must be different. | 152 // arbitrary except that oscillators must be different. |
108 let src = new Array(options.numberOfInputs); | 153 let src = new Array(options.numberOfInputs); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 .beEqualToArray(expected0); | 251 .beEqualToArray(expected0); |
207 should(actual1, options.prefix + ': Channel 1') | 252 should(actual1, options.prefix + ': Channel 1') |
208 .beEqualToArray(expected1); | 253 .beEqualToArray(expected1); |
209 }); | 254 }); |
210 } | 255 } |
211 | 256 |
212 audit.run(); | 257 audit.run(); |
213 </script> | 258 </script> |
214 </body> | 259 </body> |
215 </html> | 260 </html> |
OLD | NEW |