| OLD | NEW |
| 1 <!doctype html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title> |
| 5 Test Basic Functionality of AudioBuffer.copyFromChannel and |
| 6 AudioBuffer.copyToChannel |
| 7 </title> |
| 4 <script src="../../resources/testharness.js"></script> | 8 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> | 9 <script src="../../resources/testharnessreport.js"></script> |
| 6 <script src="../resources/audit-util.js"></script> | 10 <script src="../resources/audit-util.js"></script> |
| 7 <script src="../resources/audit.js"></script> | 11 <script src="../resources/audit.js"></script> |
| 8 <title>Test Basic Functionality of AudioBuffer.copyFromChannel and AudioBuff
er.copyToChannel</title> | |
| 9 </head> | 12 </head> |
| 10 | |
| 11 <body> | 13 <body> |
| 12 <script> | 14 <script id="layout-test-code"> |
| 13 | |
| 14 | |
| 15 // Define utility routines. | 15 // Define utility routines. |
| 16 | 16 |
| 17 // Initialize the AudioBuffer |buffer| with a ramp signal on each channel.
The ramp starts at | 17 // Initialize the AudioBuffer |buffer| with a ramp signal on each channel. |
| 18 // channel number + 1. | 18 // The ramp starts at channel number + 1. |
| 19 function initializeAudioBufferRamp (buffer) { | 19 function initializeAudioBufferRamp(buffer) { |
| 20 for (var c = 0; c < buffer.numberOfChannels; ++c) { | 20 for (let c = 0; c < buffer.numberOfChannels; ++c) { |
| 21 var d = buffer.getChannelData(c); | 21 let d = buffer.getChannelData(c); |
| 22 for (var k = 0; k < d.length; ++k) { | 22 for (let k = 0; k < d.length; ++k) { |
| 23 d[k] = k + c + 1; | 23 d[k] = k + c + 1; |
| 24 } | 24 } |
| 25 } | 25 } |
| 26 } | 26 } |
| 27 | 27 |
| 28 // Create a Float32Array of length |length| and initialize the array to -1
. | 28 // Create a Float32Array of length |length| and initialize the array to |
| 29 // -1. |
| 29 function createInitializedF32Array(length) { | 30 function createInitializedF32Array(length) { |
| 30 var x = new Float32Array(length); | 31 let x = new Float32Array(length); |
| 31 for (var k = 0; k < length; ++k) { | 32 for (let k = 0; k < length; ++k) { |
| 32 x[k] = -1; | 33 x[k] = -1; |
| 33 } | 34 } |
| 34 return x; | 35 return x; |
| 35 } | 36 } |
| 36 | 37 |
| 37 // Create a Float32Array of length |length| that is initialized to be a ra
mp starting at 1. | 38 // Create a Float32Array of length |length| that is initialized to be a |
| 39 // ramp starting at 1. |
| 38 function createFloat32RampArray(length) { | 40 function createFloat32RampArray(length) { |
| 39 var x = new Float32Array(length); | 41 let x = new Float32Array(length); |
| 40 for (var k = 0; k < x.length; ++k) { | 42 for (let k = 0; k < x.length; ++k) { |
| 41 x[k] = k + 1; | 43 x[k] = k + 1; |
| 42 } | 44 } |
| 43 | 45 |
| 44 return x; | 46 return x; |
| 45 } | 47 } |
| 46 | 48 |
| 47 // Test that the array |x| is a ramp starting at value |start| of length |
length|, starting at | 49 // Test that the array |x| is a ramp starting at value |start| of length |
| 48 // |startIndex| in the array. |startIndex| is optional and defaults to 0.
Any other values | 50 // |length|, starting at |startIndex| in the array. |startIndex| is |
| 49 // must be -1. | 51 // optional and defaults to 0. Any other values must be -1. |
| 50 function shouldBeRamp(should, testName, x, startValue, length, | 52 function shouldBeRamp( |
| 51 startIndex) { | 53 should, testName, x, startValue, length, startIndex) { |
| 52 var k; | 54 let k; |
| 53 var startingIndex = startIndex || 0; | 55 let startingIndex = startIndex || 0; |
| 54 var expected = Array(x.length); | 56 let expected = Array(x.length); |
| 55 | 57 |
| 56 // Fill the expected array with the correct results. | 58 // Fill the expected array with the correct results. |
| 57 | 59 |
| 58 // The initial part (if any) must be -1. | 60 // The initial part (if any) must be -1. |
| 59 for (k = 0; k < startingIndex; ++k) { | 61 for (k = 0; k < startingIndex; ++k) { |
| 60 expected[k] = -1; | 62 expected[k] = -1; |
| 61 } | 63 } |
| 62 | 64 |
| 63 // The second part should be a ramp starting with |startValue| | 65 // The second part should be a ramp starting with |startValue| |
| 64 for (; k < startingIndex + length; ++k) { | 66 for (; k < startingIndex + length; ++k) { |
| 65 expected[k] = startValue + k - startingIndex; | 67 expected[k] = startValue + k - startingIndex; |
| 66 } | 68 } |
| 67 | 69 |
| 68 // The last part (if any) should be -1. | 70 // The last part (if any) should be -1. |
| 69 for (; k < x.length; ++k) { | 71 for (; k < x.length; ++k) { |
| 70 expected[k] = -1; | 72 expected[k] = -1; |
| 71 } | 73 } |
| 72 | 74 |
| 73 should(x, testName, { | 75 should(x, testName, {numberOfArrayLog: 32}).beEqualToArray(expected); |
| 74 numberOfArrayLog: 32 | |
| 75 }).beEqualToArray(expected); | |
| 76 } | 76 } |
| 77 | 77 |
| 78 var audit = Audit.createTaskRunner(); | 78 let audit = Audit.createTaskRunner(); |
| 79 | 79 |
| 80 var context = new AudioContext(); | 80 let context = new AudioContext(); |
| 81 // Temp array for testing exceptions for copyToChannel/copyFromChannel. T
he length is arbitrary. | 81 // Temp array for testing exceptions for copyToChannel/copyFromChannel. |
| 82 var x = new Float32Array(8); | 82 // The length is arbitrary. |
| 83 | 83 let x = new Float32Array(8); |
| 84 // Number of frames in the AudioBuffer for testing. This is pretty arbitr
ary so choose a | 84 |
| 85 // fairly small value. | 85 // Number of frames in the AudioBuffer for testing. This is pretty |
| 86 var bufferLength = 16; | 86 // arbitrary so choose a fairly small value. |
| 87 | 87 let bufferLength = 16; |
| 88 // Number of channels in the AudioBuffer. Also arbitrary, but it should b
e greater than 1 for | 88 |
| 89 // test coverage. | 89 // Number of channels in the AudioBuffer. Also arbitrary, but it should |
| 90 var numberOfChannels = 3; | 90 // be greater than 1 for test coverage. |
| 91 let numberOfChannels = 3; |
| 91 | 92 |
| 92 // AudioBuffer that will be used for testing copyFrom and copyTo. | 93 // AudioBuffer that will be used for testing copyFrom and copyTo. |
| 93 var buffer = context.createBuffer(numberOfChannels, bufferLength, context.
sampleRate); | 94 let buffer = context.createBuffer( |
| 94 | 95 numberOfChannels, bufferLength, context.sampleRate); |
| 95 var initialValues = Array(numberOfChannels); | 96 |
| 97 let initialValues = Array(numberOfChannels); |
| 96 | 98 |
| 97 // Initialize things | 99 // Initialize things |
| 98 audit.define("initialize", (task, should) => { | 100 audit.define('initialize', (task, should) => { |
| 99 // Initialize to -1. | 101 // Initialize to -1. |
| 100 initialValues.fill(-1); | 102 initialValues.fill(-1); |
| 101 should(initialValues, "Initialized values") | 103 should(initialValues, 'Initialized values').beConstantValueOf(-1) |
| 102 .beConstantValueOf(-1) | |
| 103 task.done(); | 104 task.done(); |
| 104 }); | 105 }); |
| 105 | 106 |
| 106 // Test that expected exceptions are signaled for copyFrom. | 107 // Test that expected exceptions are signaled for copyFrom. |
| 107 audit.define("copyFrom-exceptions", (task, should) => { | 108 audit.define('copyFrom-exceptions', (task, should) => { |
| 108 should(AudioBuffer.prototype.copyFromChannel, | 109 should( |
| 109 "AudioBuffer.prototype.copyFromChannel") | 110 AudioBuffer.prototype.copyFromChannel, |
| 110 .exist(); | 111 'AudioBuffer.prototype.copyFromChannel') |
| 111 | 112 .exist(); |
| 112 should(() => { | 113 |
| 113 buffer = context.createBuffer(numberOfChannels, bufferLength, | 114 should( |
| 114 context.sampleRate); | 115 () => { |
| 115 }, | 116 buffer = context.createBuffer( |
| 116 "0: buffer = context.createBuffer(" + numberOfChannels + ", " + | 117 numberOfChannels, bufferLength, context.sampleRate); |
| 117 bufferLength + ", context.sampleRate)") | 118 }, |
| 118 .notThrow(); | 119 '0: buffer = context.createBuffer(' + numberOfChannels + ', ' + |
| 119 should(() => { | 120 bufferLength + ', context.sampleRate)') |
| 120 buffer.copyFromChannel(null, 0); | 121 .notThrow(); |
| 121 }, "1: buffer.copyFromChannel(null, 0)") | 122 should(() => { |
| 122 .throw("TypeError"); | 123 buffer.copyFromChannel(null, 0); |
| 123 should(() => { | 124 }, '1: buffer.copyFromChannel(null, 0)').throw('TypeError'); |
| 124 buffer.copyFromChannel(context, 0); | 125 should(() => { |
| 125 }, "2: buffer.copyFromChannel(context, 0)") | 126 buffer.copyFromChannel(context, 0); |
| 126 .throw("TypeError"); | 127 }, '2: buffer.copyFromChannel(context, 0)').throw('TypeError'); |
| 127 should(() => { | 128 should(() => { |
| 128 buffer.copyFromChannel(x, -1); | 129 buffer.copyFromChannel(x, -1); |
| 129 }, "3: buffer.copyFromChannel(x, -1)") | 130 }, '3: buffer.copyFromChannel(x, -1)').throw('IndexSizeError'); |
| 130 .throw("IndexSizeError"); | 131 should( |
| 131 should(() => { | 132 () => { |
| 132 buffer.copyFromChannel(x, numberOfChannels); | 133 buffer.copyFromChannel(x, numberOfChannels); |
| 133 }, "4: buffer.copyFromChannel(x, " + numberOfChannels + ")") | 134 }, |
| 134 .throw("IndexSizeError");; | 135 '4: buffer.copyFromChannel(x, ' + numberOfChannels + ')') |
| 135 should(() => { | 136 .throw('IndexSizeError'); |
| 136 buffer.copyFromChannel(x, 0, -1); | 137 ; |
| 137 }, "5: buffer.copyFromChannel(x, 0, -1)") | 138 should(() => { |
| 138 .throw("IndexSizeError"); | 139 buffer.copyFromChannel(x, 0, -1); |
| 139 should(() => { | 140 }, '5: buffer.copyFromChannel(x, 0, -1)').throw('IndexSizeError'); |
| 140 buffer.copyFromChannel(x, 0, bufferLength); | 141 should( |
| 141 }, "6: buffer.copyFromChannel(x, 0, " + bufferLength + ")") | 142 () => { |
| 142 .throw("IndexSizeError"); | 143 buffer.copyFromChannel(x, 0, bufferLength); |
| 143 | 144 }, |
| 144 should(() => { | 145 '6: buffer.copyFromChannel(x, 0, ' + bufferLength + ')') |
| 145 buffer.copyFromChannel(x, 3); | 146 .throw('IndexSizeError'); |
| 146 }, "7: buffer.copyFromChannel(x, 3)") | 147 |
| 147 .throw("IndexSizeError"); | 148 should(() => { |
| 149 buffer.copyFromChannel(x, 3); |
| 150 }, '7: buffer.copyFromChannel(x, 3)').throw('IndexSizeError'); |
| 148 | 151 |
| 149 if (window.SharedArrayBuffer) { | 152 if (window.SharedArrayBuffer) { |
| 150 var shared_buffer = new Float32Array(new SharedArrayBuffer(32)); | 153 let shared_buffer = new Float32Array(new SharedArrayBuffer(32)); |
| 151 should(() => { | 154 should( |
| 152 buffer.copyFromChannel(shared_buffer, 0); | 155 () => { |
| 153 }, "8: buffer.copyFromChannel(SharedArrayBuffer view, 0)") | 156 buffer.copyFromChannel(shared_buffer, 0); |
| 154 .throw("TypeError"); | 157 }, |
| 155 | 158 '8: buffer.copyFromChannel(SharedArrayBuffer view, 0)') |
| 156 should(() => { | 159 .throw('TypeError'); |
| 157 buffer.copyFromChannel(shared_buffer, 0, 0); | 160 |
| 158 }, "9: buffer.copyFromChannel(SharedArrayBuffer view, 0, 0)") | 161 should( |
| 159 .throw("TypeError"); | 162 () => { |
| 163 buffer.copyFromChannel(shared_buffer, 0, 0); |
| 164 }, |
| 165 '9: buffer.copyFromChannel(SharedArrayBuffer view, 0, 0)') |
| 166 .throw('TypeError'); |
| 160 } | 167 } |
| 161 | 168 |
| 162 task.done(); | 169 task.done(); |
| 163 }); | 170 }); |
| 164 | 171 |
| 165 // Test that expected exceptions are signaled for copyTo. | 172 // Test that expected exceptions are signaled for copyTo. |
| 166 audit.define("copyTo-exceptions", (task, should) => { | 173 audit.define('copyTo-exceptions', (task, should) => { |
| 167 should(AudioBuffer.prototype.copyToChannel, | 174 should( |
| 168 "AudioBuffer.prototype.copyToChannel") | 175 AudioBuffer.prototype.copyToChannel, |
| 169 .exist(); | 176 'AudioBuffer.prototype.copyToChannel') |
| 170 should(() => { | 177 .exist(); |
| 171 buffer.copyToChannel(null, 0); | 178 should(() => { |
| 172 }, "0: buffer.copyToChannel(null, 0)") | 179 buffer.copyToChannel(null, 0); |
| 173 .throw("TypeError"); | 180 }, '0: buffer.copyToChannel(null, 0)').throw('TypeError'); |
| 174 should(() => { | 181 should(() => { |
| 175 buffer.copyToChannel(context, 0); | 182 buffer.copyToChannel(context, 0); |
| 176 }, "1: buffer.copyToChannel(context, 0)") | 183 }, '1: buffer.copyToChannel(context, 0)').throw('TypeError'); |
| 177 .throw("TypeError"); | 184 should(() => { |
| 178 should(() => { | 185 buffer.copyToChannel(x, -1); |
| 179 buffer.copyToChannel(x, -1); | 186 }, '2: buffer.copyToChannel(x, -1)').throw('IndexSizeError'); |
| 180 }, "2: buffer.copyToChannel(x, -1)") | 187 should( |
| 181 .throw("IndexSizeError"); | 188 () => { |
| 182 should(() => { | 189 buffer.copyToChannel(x, numberOfChannels); |
| 183 buffer.copyToChannel(x, numberOfChannels); | 190 }, |
| 184 }, "3: buffer.copyToChannel(x, " + numberOfChannels + ")") | 191 '3: buffer.copyToChannel(x, ' + numberOfChannels + ')') |
| 185 .throw("IndexSizeError"); | 192 .throw('IndexSizeError'); |
| 186 should(() => { | 193 should(() => { |
| 187 buffer.copyToChannel(x, 0, -1); | 194 buffer.copyToChannel(x, 0, -1); |
| 188 }, "4: buffer.copyToChannel(x, 0, -1)") | 195 }, '4: buffer.copyToChannel(x, 0, -1)').throw('IndexSizeError'); |
| 189 .throw("IndexSizeError"); | 196 should( |
| 190 should(() => { | 197 () => { |
| 191 buffer.copyToChannel(x, 0, bufferLength); | 198 buffer.copyToChannel(x, 0, bufferLength); |
| 192 }, "5: buffer.copyToChannel(x, 0, " + bufferLength + ")") | 199 }, |
| 193 .throw("IndexSizeError"); | 200 '5: buffer.copyToChannel(x, 0, ' + bufferLength + ')') |
| 194 | 201 .throw('IndexSizeError'); |
| 195 should(() => { | 202 |
| 196 buffer.copyToChannel(x, 3); | 203 should(() => { |
| 197 }, "6: buffer.copyToChannel(x, 3)") | 204 buffer.copyToChannel(x, 3); |
| 198 .throw("IndexSizeError"); | 205 }, '6: buffer.copyToChannel(x, 3)').throw('IndexSizeError'); |
| 199 | 206 |
| 200 if (window.SharedArrayBuffer) { | 207 if (window.SharedArrayBuffer) { |
| 201 var shared_buffer = new Float32Array(new SharedArrayBuffer(32)); | 208 let shared_buffer = new Float32Array(new SharedArrayBuffer(32)); |
| 202 should(() => { | 209 should( |
| 203 buffer.copyToChannel(shared_buffer, 0); | 210 () => { |
| 204 }, "7: buffer.copyToChannel(SharedArrayBuffer view, 0)") | 211 buffer.copyToChannel(shared_buffer, 0); |
| 205 .throw("TypeError"); | 212 }, |
| 206 | 213 '7: buffer.copyToChannel(SharedArrayBuffer view, 0)') |
| 207 should(() => { | 214 .throw('TypeError'); |
| 208 buffer.copyToChannel(shared_buffer, 0, 0); | 215 |
| 209 }, "8: buffer.copyToChannel(SharedArrayBuffer view, 0, 0)") | 216 should( |
| 210 .throw("TypeError"); | 217 () => { |
| 218 buffer.copyToChannel(shared_buffer, 0, 0); |
| 219 }, |
| 220 '8: buffer.copyToChannel(SharedArrayBuffer view, 0, 0)') |
| 221 .throw('TypeError'); |
| 211 } | 222 } |
| 212 | 223 |
| 213 task.done(); | 224 task.done(); |
| 214 }); | 225 }); |
| 215 | 226 |
| 216 // Test copyFromChannel | 227 // Test copyFromChannel |
| 217 audit.define("copyFrom-validate", (task, should) => { | 228 audit.define('copyFrom-validate', (task, should) => { |
| 218 // Initialize the AudioBuffer to a ramp for testing copyFrom. | 229 // Initialize the AudioBuffer to a ramp for testing copyFrom. |
| 219 initializeAudioBufferRamp(buffer); | 230 initializeAudioBufferRamp(buffer); |
| 220 | 231 |
| 221 // Test copyFrom operation with a short destination array, filling the d
estination completely. | 232 // Test copyFrom operation with a short destination array, filling the |
| 222 for (var c = 0; c < numberOfChannels; ++c) { | 233 // destination completely. |
| 223 var dst8 = createInitializedF32Array(8); | 234 for (let c = 0; c < numberOfChannels; ++c) { |
| 235 let dst8 = createInitializedF32Array(8); |
| 224 buffer.copyFromChannel(dst8, c); | 236 buffer.copyFromChannel(dst8, c); |
| 225 shouldBeRamp(should, "buffer.copyFromChannel(dst8, " + c + ")", dst8,
c + 1, 8) | 237 shouldBeRamp( |
| 226 } | 238 should, 'buffer.copyFromChannel(dst8, ' + c + ')', dst8, c + 1, 8) |
| 227 | 239 } |
| 228 // Test copyFrom operation with a short destination array using a non-ze
ro start index that | 240 |
| 229 // still fills the destination completely. | 241 // Test copyFrom operation with a short destination array using a |
| 230 for (var c = 0; c < numberOfChannels; ++c) { | 242 // non-zero start index that still fills the destination completely. |
| 231 var dst8 = createInitializedF32Array(8); | 243 for (let c = 0; c < numberOfChannels; ++c) { |
| 244 let dst8 = createInitializedF32Array(8); |
| 232 buffer.copyFromChannel(dst8, c, 1); | 245 buffer.copyFromChannel(dst8, c, 1); |
| 233 shouldBeRamp(should, "buffer.copyFromChannel(dst8, " + c + ", 1)", dst
8, c + 2, 8) | 246 shouldBeRamp( |
| 234 } | 247 should, 'buffer.copyFromChannel(dst8, ' + c + ', 1)', dst8, c + 2, |
| 235 | 248 8) |
| 236 // Test copyFrom operation with a short destination array using a non-ze
ro start index that | 249 } |
| 237 // does not fill the destinatiom completely. The extra elements should
be unchanged. | 250 |
| 238 for (var c = 0; c < numberOfChannels; ++c) { | 251 // Test copyFrom operation with a short destination array using a |
| 239 var dst8 = createInitializedF32Array(8); | 252 // non-zero start index that does not fill the destinatiom completely. |
| 240 var startInChannel = bufferLength - 5; | 253 // The extra elements should be unchanged. |
| 254 for (let c = 0; c < numberOfChannels; ++c) { |
| 255 let dst8 = createInitializedF32Array(8); |
| 256 let startInChannel = bufferLength - 5; |
| 241 buffer.copyFromChannel(dst8, c, startInChannel); | 257 buffer.copyFromChannel(dst8, c, startInChannel); |
| 242 shouldBeRamp(should, "buffer.copyFromChannel(dst8, " + c + ", " + star
tInChannel + ")", dst8, | 258 shouldBeRamp( |
| 243 c + 1 + startInChannel, bufferLength - startInChannel); | 259 should, |
| 244 } | 260 'buffer.copyFromChannel(dst8, ' + c + ', ' + startInChannel + ')', |
| 245 | 261 dst8, c + 1 + startInChannel, bufferLength - startInChannel); |
| 246 // Copy operation with the destination longer than the buffer, leaving t
he trailing elements | 262 } |
| 247 // of the destination untouched. | 263 |
| 248 for (var c = 0; c < numberOfChannels; ++c) { | 264 // Copy operation with the destination longer than the buffer, leaving |
| 249 var dst26 = createInitializedF32Array(bufferLength + 10); | 265 // the trailing elements of the destination untouched. |
| 266 for (let c = 0; c < numberOfChannels; ++c) { |
| 267 let dst26 = createInitializedF32Array(bufferLength + 10); |
| 250 buffer.copyFromChannel(dst26, c); | 268 buffer.copyFromChannel(dst26, c); |
| 251 shouldBeRamp(should, "buffer.copyFromChannel(dst26, " + c + ")", dst26
, | 269 shouldBeRamp( |
| 252 c + 1, bufferLength); | 270 should, 'buffer.copyFromChannel(dst26, ' + c + ')', dst26, c + 1, |
| 271 bufferLength); |
| 253 } | 272 } |
| 254 | 273 |
| 255 task.done(); | 274 task.done(); |
| 256 }); | 275 }); |
| 257 | 276 |
| 258 // Test copyTo | 277 // Test copyTo |
| 259 audit.define("copyTo-validate", (task, should) => { | 278 audit.define('copyTo-validate', (task, should) => { |
| 260 // Create a source consisting of a ramp starting at 1, longer than the A
udioBuffer | 279 // Create a source consisting of a ramp starting at 1, longer than the |
| 261 var src = createFloat32RampArray(bufferLength + 10); | 280 // AudioBuffer |
| 262 | 281 let src = createFloat32RampArray(bufferLength + 10); |
| 263 // Test copyTo with AudioBuffer shorter than Float32Array. The AudioBuff
er should be | 282 |
| 264 // completely filled with the Float32Array. | 283 // Test copyTo with AudioBuffer shorter than Float32Array. The |
| 265 should(() => { | 284 // AudioBuffer should be completely filled with the Float32Array. |
| 266 buffer = createConstantBuffer(context, bufferLength, | 285 should( |
| 267 initialValues); | 286 () => { |
| 268 }, | 287 buffer = |
| 269 "buffer = createConstantBuffer(context, " + bufferLength + ", [" + | 288 createConstantBuffer(context, bufferLength, initialValues); |
| 270 initialValues + "])") | 289 }, |
| 271 .notThrow(); | 290 'buffer = createConstantBuffer(context, ' + bufferLength + ', [' + |
| 272 | 291 initialValues + '])') |
| 273 for (var c = 0; c < numberOfChannels; ++c) { | 292 .notThrow(); |
| 293 |
| 294 for (let c = 0; c < numberOfChannels; ++c) { |
| 274 buffer.copyToChannel(src, c); | 295 buffer.copyToChannel(src, c); |
| 275 shouldBeRamp(should, "buffer.copyToChannel(src, " + c + ")", | 296 shouldBeRamp( |
| 276 buffer.getChannelData(c), 1, bufferLength); | 297 should, 'buffer.copyToChannel(src, ' + c + ')', |
| 277 } | 298 buffer.getChannelData(c), 1, bufferLength); |
| 278 | 299 } |
| 279 // Test copyTo with AudioBuffer longer than the Float32Array. The tail
of the AudioBuffer | 300 |
| 280 // should be unchanged. | 301 // Test copyTo with AudioBuffer longer than the Float32Array. The tail |
| 302 // of the AudioBuffer should be unchanged. |
| 281 buffer = createConstantBuffer(context, bufferLength, initialValues); | 303 buffer = createConstantBuffer(context, bufferLength, initialValues); |
| 282 var src10 = createFloat32RampArray(10); | 304 let src10 = createFloat32RampArray(10); |
| 283 for (var c = 0; c < numberOfChannels; ++c) { | 305 for (let c = 0; c < numberOfChannels; ++c) { |
| 284 buffer.copyToChannel(src10, c); | 306 buffer.copyToChannel(src10, c); |
| 285 shouldBeRamp(should, "buffer.copyToChannel(src10, " + c + ")", | 307 shouldBeRamp( |
| 286 buffer.getChannelData(c), 1, 10); | 308 should, 'buffer.copyToChannel(src10, ' + c + ')', |
| 287 } | 309 buffer.getChannelData(c), 1, 10); |
| 288 | 310 } |
| 289 // Test copyTo with non-default startInChannel. Part of the AudioBuffer
should filled with | 311 |
| 290 // the beginning and end sections untouched. | 312 // Test copyTo with non-default startInChannel. Part of the AudioBuffer |
| 313 // should filled with the beginning and end sections untouched. |
| 291 buffer = createConstantBuffer(context, bufferLength, initialValues); | 314 buffer = createConstantBuffer(context, bufferLength, initialValues); |
| 292 for (var c = 0; c < numberOfChannels; ++c) { | 315 for (let c = 0; c < numberOfChannels; ++c) { |
| 293 var startInChannel = 5; | 316 let startInChannel = 5; |
| 294 buffer.copyToChannel(src10, c, startInChannel); | 317 buffer.copyToChannel(src10, c, startInChannel); |
| 295 | 318 |
| 296 shouldBeRamp(should, "buffer.copyToChannel(src10, " + c + ", " + | 319 shouldBeRamp( |
| 297 startInChannel + ")", | 320 should, |
| 298 buffer.getChannelData(c), 1, src10.length, startInChannel); | 321 'buffer.copyToChannel(src10, ' + c + ', ' + startInChannel + ')', |
| 299 } | 322 buffer.getChannelData(c), 1, src10.length, startInChannel); |
| 300 | 323 } |
| 301 task.done(); | 324 |
| 325 task.done(); |
| 302 }); | 326 }); |
| 303 | 327 |
| 304 audit.run(); | 328 audit.run(); |
| 305 </script> | 329 </script> |
| 306 | |
| 307 </body> | 330 </body> |
| 308 </html> | 331 </html> |
| OLD | NEW |