5 <script src=
"../resources/js-test.js"></script>
6 <script src=
"resources/compatibility.js"></script>
7 <script src=
"resources/audio-testing.js"></script>
12 <div id=
"description"></div>
13 <div id=
"console"></div>
16 description("This test verifies whether down mixing from stereo to mono will cause assertion error.");
18 var sampleRate
= 44100.0;
19 var renderLengthSeconds
= 0.1;
25 function createDataBuffer(context
, lengthInSeconds
) {
26 var audioBuffer
= context
.createBuffer(2, lengthInSeconds
* sampleRate
, sampleRate
);
28 var n
= audioBuffer
.length
;
29 var data0
= audioBuffer
.getChannelData(0);
30 var data1
= audioBuffer
.getChannelData(1);
32 for (var i
= 0; i
< n
; ++i
) {
40 function testFinished() {
41 testPassed("Test no ASSERT error.");
46 if (window
.testRunner
) {
47 testRunner
.dumpAsText();
48 testRunner
.waitUntilDone();
51 window
.jsTestIsAsync
= true;
53 // Create offline audio context, the destination is mono.
54 context
= new OfflineAudioContext(1, sampleRate
* renderLengthSeconds
, sampleRate
);
55 // Create a stereo AudioBuffer.
56 toneBuffer
= createDataBuffer(context
, renderLengthSeconds
);
58 bufferSource
= context
.createBufferSource();
59 bufferSource
.buffer
= toneBuffer
;
61 bufferSource
.connect(context
.destination
);
63 bufferSource
.start(0);
65 context
.oncomplete
= testFinished
;
66 context
.startRendering();