blob: 7a87880ab45f7347d604b3e7920996c0b0ca1819 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="resources/compatibility.js"></script>
<script src="resources/audio-testing.js"></script>
<script src="resources/merger-testing.js"></script>
</head>
<body>
<script>
description('Test input handling of ChannelMergerNode (non-default).');
window.jsTestIsAsync = true;
var audit = Audit.createTaskRunner();
// Task: Check if an inactive input renders a silent mono channel in the
// output.
audit.defineTask('silent-channel', function (done) {
testMergerInput({
numberOfChannels: 7,
// Create a mono source buffer filled with '1'.
testBufferChannelCount: 1,
// Connect the output of source into the 7th input of merger.
mergerInputIndex: 6,
// 7th channel should be '1'.
expected: [0, 0, 0, 0, 0, 0, 1],
}, done);
});
// Task: Check if a stereo input is being down-mixed to mono channel
// correctly based on the mixing rule.
audit.defineTask('stereo-down-mixing', function (done) {
testMergerInput({
numberOfChannels: 7,
// Create a stereo buffer filled with '1' and '2' for left and right
// channels respectively.
testBufferChannelCount: 2,
// Connect the output of source into the 7th input of merger.
mergerInputIndex: 6,
// The result of summed and down-mixed stereo audio should be 1.5.
// (= 1 * 0.5 + 2 * 0.5)
expected: [0, 0, 0, 0, 0, 0, 1.5],
}, done);
});
// Task: Check if 3-channel input gets processed by the 'discrete' mixing
// rule.
audit.defineTask('undefined-channel-layout', function (done) {
testMergerInput({
numberOfChannels: 7,
// Create a 3-channel buffer filled with '1', '2', and '3' respectively.
testBufferChannelCount: 3,
// Connect the output of source into the 7th input of merger.
mergerInputIndex: 6,
// The result of summed stereo audio should be 1 because 3-channel is
// not a canonical layout, so the input channel 2 and 3 should be
// dropped by 'discrete' mixing rule.
expected: [0, 0, 0, 0, 0, 0, 1],
}, done);
});
audit.defineTask('finish', function (done) {
finishJSTest();
done();
});
audit.runTasks(
'silent-channel',
'stereo-down-mixing',
'undefined-channel-layout',
'finish'
);
successfullyParsed = true;
</script>
</body>
</html>