gecko-dev/content/media/webaudio/test/test_audioBufferSourceNodeN...

43 строки
1.2 KiB
HTML
Исходник Обычный вид История

<!DOCTYPE HTML>
<html>
<head>
<title>Test AudioBufferSourceNode</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="webaudio.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
SpecialPowers.setBoolPref("media.webaudio.enabled", true);
var context = new AudioContext();
var expectedBuffer = context.createBuffer(1, 2048, context.sampleRate); // silence
var source = context.createBufferSource();
var sp = context.createScriptProcessor(2048);
source.start(0);
source.buffer = null;
is(source.buffer, null, "Try playing back a null buffer");
source.connect(sp);
sp.connect(context.destination);
sp.onaudioprocess = function(e) {
compareBuffers(e.inputBuffer.getChannelData(0), expectedBuffer.getChannelData(0));
compareBuffers(e.inputBuffer.getChannelData(1), expectedBuffer.getChannelData(0));
sp.onaudioprocess = null;
SpecialPowers.clearUserPref("media.webaudio.enabled");
SimpleTest.finish();
};
});
</script>
</pre>
</body>
</html>