| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 | |
| 3 <html> | |
| 4 <head> | |
| 5 <script src="../resources/js-test.js"></script> | |
| 6 <script src="resources/audit-util.js"></script> | |
| 7 <script src="resources/audio-testing.js"></script> | |
| 8 </head> | |
| 9 | |
| 10 <body> | |
| 11 | |
| 12 <div id="description"></div> | |
| 13 <div id="console"></div> | |
| 14 | |
| 15 <script> | |
| 16 description("This test verifies whether down mixing from stereo to mono will cau
se assertion error."); | |
| 17 | |
| 18 var sampleRate = 44100.0; | |
| 19 var renderLengthSeconds = 0.1; | |
| 20 | |
| 21 var context; | |
| 22 var toneBuffer; | |
| 23 var bufferSource; | |
| 24 | |
| 25 function createDataBuffer(context, lengthInSeconds) { | |
| 26 var audioBuffer = context.createBuffer(2, lengthInSeconds * sampleRate, samp
leRate); | |
| 27 | |
| 28 var n = audioBuffer.length; | |
| 29 var data0 = audioBuffer.getChannelData(0); | |
| 30 var data1 = audioBuffer.getChannelData(1); | |
| 31 | |
| 32 for (var i = 0; i < n; ++i) { | |
| 33 data0[i] = 1.0; | |
| 34 data1[i] = 1.0; | |
| 35 } | |
| 36 | |
| 37 return audioBuffer; | |
| 38 } | |
| 39 | |
| 40 function testFinished() { | |
| 41 testPassed("Test no ASSERT error."); | |
| 42 finishJSTest(); | |
| 43 } | |
| 44 | |
| 45 function runTest() { | |
| 46 if (window.testRunner) { | |
| 47 testRunner.dumpAsText(); | |
| 48 testRunner.waitUntilDone(); | |
| 49 } | |
| 50 | |
| 51 window.jsTestIsAsync = true; | |
| 52 | |
| 53 // Create offline audio context, the destination is mono. | |
| 54 context = new OfflineAudioContext(1, sampleRate * renderLengthSeconds, sampl
eRate); | |
| 55 // Create a stereo AudioBuffer. | |
| 56 toneBuffer = createDataBuffer(context, renderLengthSeconds); | |
| 57 | |
| 58 bufferSource = context.createBufferSource(); | |
| 59 bufferSource.buffer = toneBuffer; | |
| 60 | |
| 61 bufferSource.connect(context.destination); | |
| 62 | |
| 63 bufferSource.start(0); | |
| 64 | |
| 65 context.oncomplete = testFinished; | |
| 66 context.startRendering(); | |
| 67 } | |
| 68 | |
| 69 | |
| 70 runTest(); | |
| 71 | |
| 72 </script> | |
| 73 | |
| 74 </body> | |
| 75 </html> | |
| OLD | NEW |