mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1141282 - Test the type of the attributes of the DynamicCompressoNode, and make sure it returns sane values. r=ehsan
This commit is contained in:
parent
ada66aa858
commit
1a25b47c65
@ -16,21 +16,15 @@ function near(a, b, 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 osc = context.createOscillator();
|
||||
var sp = context.createScriptProcessor();
|
||||
|
||||
var compressor = context.createDynamicsCompressor();
|
||||
|
||||
source.buffer = buffer;
|
||||
|
||||
source.connect(compressor);
|
||||
compressor.connect(destination);
|
||||
osc.connect(compressor);
|
||||
osc.connect(sp);
|
||||
compressor.connect(context.destination);
|
||||
|
||||
is(compressor.channelCount, 2, "compressor node has 2 input channels by default");
|
||||
is(compressor.channelCountMode, "explicit", "Correct channelCountMode for the compressor node");
|
||||
@ -38,22 +32,36 @@ addLoadEvent(function() {
|
||||
|
||||
// Verify default values
|
||||
with (compressor) {
|
||||
ok(threshold instanceof AudioParam, "treshold is an AudioParam");
|
||||
near(threshold.defaultValue, -24, "Correct default value for threshold");
|
||||
ok(knee instanceof AudioParam, "knee is an AudioParam");
|
||||
near(knee.defaultValue, 30, "Correct default value for knee");
|
||||
ok(ratio instanceof AudioParam, "knee is an AudioParam");
|
||||
near(ratio.defaultValue, 12, "Correct default value for ratio");
|
||||
is(typeof reduction, "number", "reduction is a number");
|
||||
near(reduction, 0, "Correct default value for reduction");
|
||||
ok(attack instanceof AudioParam, "attack is an AudioParam");
|
||||
near(attack.defaultValue, 0.003, "Correct default value for attack");
|
||||
ok(release instanceof AudioParam, "release is an AudioParam");
|
||||
near(release.defaultValue, 0.25, "Correct default value for release");
|
||||
}
|
||||
|
||||
source.start(0);
|
||||
SimpleTest.executeSoon(function() {
|
||||
source.stop(0);
|
||||
source.disconnect();
|
||||
compressor.disconnect();
|
||||
compressor.threshold.value = -80;
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
osc.start();
|
||||
var iteration = 0;
|
||||
sp.onaudioprocess = function(e) {
|
||||
if (iteration > 10) {
|
||||
ok(compressor.reduction < 0,
|
||||
"Feeding a full-scale sine to a compressor should result in an db" +
|
||||
"reduction.");
|
||||
sp.onaudioprocess = null;
|
||||
osc.stop(0);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
iteration++;
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user