69 lines
1.4 KiB
HTML
69 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
|
|
<html>
|
|
<head>
|
|
<script src="../resources/js-test.js"></script>
|
|
<script src="resources/audio-testing.js"></script>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="description"></div>
|
|
<div id="console"></div>
|
|
|
|
<script>
|
|
description("This test verifies whether down mixing from stereo to mono will cause assertion error.");
|
|
|
|
var sampleRate = 44100.0;
|
|
var renderLengthSeconds = 0.1;
|
|
|
|
var context;
|
|
var toneBuffer;
|
|
var bufferSource;
|
|
|
|
function createDataBuffer(context, lengthInSeconds) {
|
|
var audioBuffer = context.createBuffer(2, lengthInSeconds * sampleRate, sampleRate);
|
|
|
|
var n = audioBuffer.length;
|
|
var data0 = audioBuffer.getChannelData(0);
|
|
var data1 = audioBuffer.getChannelData(1);
|
|
|
|
for (var i = 0; i < n; ++i) {
|
|
data0[i] = 1.0;
|
|
data1[i] = 1.0;
|
|
}
|
|
|
|
return audioBuffer;
|
|
}
|
|
|
|
function testFinished() {
|
|
testPassed("Test no ASSERT error.");
|
|
finishJSTest();
|
|
}
|
|
|
|
function runTest() {
|
|
window.jsTestIsAsync = true;
|
|
|
|
// Create offline audio context, the destination is mono.
|
|
context = new OfflineAudioContext(1, sampleRate * renderLengthSeconds, sampleRate);
|
|
// Create a stereo AudioBuffer.
|
|
toneBuffer = createDataBuffer(context, renderLengthSeconds);
|
|
|
|
bufferSource = context.createBufferSource();
|
|
bufferSource.buffer = toneBuffer;
|
|
|
|
bufferSource.connect(context.destination);
|
|
|
|
bufferSource.start(0);
|
|
|
|
context.oncomplete = testFinished;
|
|
context.startRendering();
|
|
}
|
|
|
|
|
|
runTest();
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|