зеркало из https://github.com/mozilla/gecko-dev.git
63 строки
1.9 KiB
HTML
63 строки
1.9 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Test DynamicsCompressorNode</title>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
</head>
|
|
<body>
|
|
<pre id="test">
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
function near(a, b, msg) {
|
|
ok(Math.abs(a - b) < 1e-4, msg);
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
addLoadEvent(function() {
|
|
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 destination = context.destination;
|
|
|
|
var source = context.createBufferSource();
|
|
|
|
var compressor = context.createDynamicsCompressor();
|
|
|
|
source.buffer = buffer;
|
|
|
|
source.connect(compressor);
|
|
compressor.connect(destination);
|
|
|
|
is(compressor.channelCount, 2, "compressor node has 2 input channels by default");
|
|
is(compressor.channelCountMode, "explicit", "Correct channelCountMode for the compressor node");
|
|
is(compressor.channelInterpretation, "speakers", "Correct channelCountInterpretation for the compressor node");
|
|
|
|
// Verify default values
|
|
with (compressor) {
|
|
near(threshold.defaultValue, -24, "Correct default value for threshold");
|
|
near(knee.defaultValue, 30, "Correct default value for knee");
|
|
near(ratio.defaultValue, 12, "Correct default value for ratio");
|
|
near(reduction.defaultValue, 0, "Correct default value for reduction");
|
|
near(attack.defaultValue, 0.003, "Correct default value for attack");
|
|
near(release.defaultValue, 0.25, "Correct default value for release");
|
|
}
|
|
|
|
source.start(0);
|
|
SimpleTest.executeSoon(function() {
|
|
source.stop(0);
|
|
source.disconnect();
|
|
compressor.disconnect();
|
|
|
|
SimpleTest.finish();
|
|
});
|
|
});
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|