mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
53 lines
1.6 KiB
HTML
53 lines
1.6 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 buffer = context.createBuffer(1, 2048, context.sampleRate);
|
|
for (var i = 0; i < 2048; ++i) {
|
|
buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate);
|
|
}
|
|
|
|
var source = context.createBufferSource();
|
|
|
|
var sp = context.createScriptProcessor(2048);
|
|
source.start(0);
|
|
source.buffer = buffer;
|
|
source.connect(sp);
|
|
sp.connect(context.destination);
|
|
sp.onaudioprocess = function(e) {
|
|
compareBuffers(e.inputBuffer.getChannelData(0), buffer.getChannelData(0));
|
|
compareBuffers(e.inputBuffer.getChannelData(1), buffer.getChannelData(0));
|
|
|
|
// On the next iteration, we'll get a silence buffer
|
|
sp.onaudioprocess = function(e) {
|
|
var emptyBuffer = context.createBuffer(1, 2048, context.sampleRate);
|
|
compareBuffers(e.inputBuffer.getChannelData(0), emptyBuffer.getChannelData(0));
|
|
compareBuffers(e.inputBuffer.getChannelData(1), emptyBuffer.getChannelData(0));
|
|
|
|
sp.onaudioprocess = null;
|
|
sp.disconnect(context.destination);
|
|
|
|
SpecialPowers.clearUserPref("media.webaudio.enabled");
|
|
SimpleTest.finish();
|
|
};
|
|
};
|
|
});
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|