5 <script src=
"../resources/js-test.js"></script>
6 <script src=
"resources/compatibility.js"></script>
7 <script src=
"resources/audio-testing.js"></script>
8 <script src=
"resources/merger-testing.js"></script>
13 description('Test input handling of ChannelMergerNode (non-default).');
14 window
.jsTestIsAsync
= true;
16 var audit
= Audit
.createTaskRunner();
19 // Task: Check if an inactive input renders a silent mono channel in the
21 audit
.defineTask('silent-channel', function (done
) {
25 // Create a mono source buffer filled with '1'.
26 testBufferChannelCount
: 1,
28 // Connect the output of source into the 7th input of merger.
31 // 7th channel should be '1'.
32 expected
: [0, 0, 0, 0, 0, 0, 1],
37 // Task: Check if a stereo input is being down-mixed to mono channel
38 // correctly based on the mixing rule.
39 audit
.defineTask('stereo-down-mixing', function (done
) {
43 // Create a stereo buffer filled with '1' and '2' for left and right
44 // channels respectively.
45 testBufferChannelCount
: 2,
47 // Connect the output of source into the 7th input of merger.
50 // The result of summed and down-mixed stereo audio should be 1.5.
51 // (= 1 * 0.5 + 2 * 0.5)
52 expected
: [0, 0, 0, 0, 0, 0, 1.5],
57 // Task: Check if 3-channel input gets processed by the 'discrete' mixing
59 audit
.defineTask('undefined-channel-layout', function (done
) {
63 // Create a 3-channel buffer filled with '1', '2', and '3' respectively.
64 testBufferChannelCount
: 3,
66 // Connect the output of source into the 7th input of merger.
69 // The result of summed stereo audio should be 1 because 3-channel is
70 // not a canonical layout, so the input channel 2 and 3 should be
71 // dropped by 'discrete' mixing rule.
72 expected
: [0, 0, 0, 0, 0, 0, 1],
76 audit
.defineTask('finish', function (done
) {
84 'undefined-channel-layout',
88 successfullyParsed
= true;