mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
64 lines
1.7 KiB
HTML
64 lines
1.7 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Test AudioParam.linearRampToValue</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 V0 = 0.1;
|
|
var V1 = 0.9;
|
|
var T0 = 0;
|
|
var T1 = 2048 / context.sampleRate;
|
|
|
|
var sourceBuffer = context.createBuffer(1, 2048, context.sampleRate);
|
|
for (var i = 0; i < 2048; ++i) {
|
|
sourceBuffer.getChannelData(0)[i] = 1;
|
|
}
|
|
var expectedBuffer = context.createBuffer(1, 2048, context.sampleRate);
|
|
for (var i = 0; i < 2048; ++i) {
|
|
var t = i / context.sampleRate;
|
|
expectedBuffer.getChannelData(0)[i] = V0 + (V1 - V0) * ((t - T0) / (T1 - T0));
|
|
}
|
|
|
|
var destination = context.destination;
|
|
|
|
var source = context.createBufferSource();
|
|
source.buffer = sourceBuffer;
|
|
|
|
var gain = context.createGain();
|
|
gain.gain.setValueAtTime(V0, 0);
|
|
gain.gain.linearRampToValueAtTime(V1, 2048/context.sampleRate);
|
|
|
|
var sp = context.createScriptProcessor(2048, 1);
|
|
source.connect(gain);
|
|
gain.connect(sp);
|
|
sp.connect(destination);
|
|
|
|
source.start(0);
|
|
sp.onaudioprocess = function(e) {
|
|
is(e.inputBuffer.numberOfChannels, 1, "Correct input channel count");
|
|
compareBuffers(e.inputBuffer.getChannelData(0), expectedBuffer.getChannelData(0));
|
|
|
|
sp.onaudioprocess = null;
|
|
|
|
SpecialPowers.clearUserPref("media.webaudio.enabled");
|
|
SimpleTest.finish();
|
|
};
|
|
});
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|