Tone.js/test/component/Gate.js

68 lines
1.8 KiB
JavaScript
Raw Normal View History

2018-05-18 16:07:20 +00:00
define(["Tone/component/Gate", "helper/Basic", "helper/Offline", "helper/Test",
2017-10-26 04:48:51 +00:00
"Tone/signal/Signal", "helper/PassAudio", "Tone/type/Type"],
2018-05-18 16:07:20 +00:00
function(Gate, Basic, Offline, Test, Signal, PassAudio, Tone){
2015-08-28 22:42:44 +00:00
describe("Gate", function(){
Basic(Gate);
context("Signal Gating", function(){
it("handles input and output connections", function(){
var gate = new Gate();
Test.connect(gate);
gate.connect(Test);
gate.dispose();
});
it("handles getter/setter as Object", function(){
var gate = new Gate();
var values = {
"attack" : 0.2,
"release" : 0.4,
"threshold" : -20
};
gate.set(values);
expect(gate.get().attack).to.be.closeTo(0.2, 0.001);
expect(gate.get().release).to.be.closeTo(0.4, 0.001);
expect(gate.get().threshold).to.be.closeTo(-20, 0.1);
gate.dispose();
});
it("can be constructed with an object", function(){
var gate = new Gate({
"release" : 0.3,
"threshold" : -5
});
expect(gate.release).to.be.closeTo(0.3, 0.001);
expect(gate.threshold).to.be.closeTo(-5, 0.1);
gate.dispose();
});
it("gates the incoming signal when below the threshold", function(){
return Offline(function(){
var gate = new Gate(-9);
var sig = new Signal(-10, Tone.Type.Decibels);
sig.connect(gate);
gate.toMaster();
}).then(function(buffer){
expect(buffer.isSilent()).to.be.true;
2015-08-28 22:42:44 +00:00
});
});
2015-08-28 22:42:44 +00:00
it("passes the incoming signal when above the threshold", function(){
it("gates the incoming signal when below the threshold", function(){
return Offline(function(){
var gate = new Gate(-11);
var sig = new Signal(-10, Tone.Type.Decibels);
sig.connect(gate);
gate.toMaster();
}).then(function(buffer){
expect(buffer.min()).to.be.above(0);
});
2015-08-28 22:42:44 +00:00
});
});
});
});
});