2015-08-28 22:42:08 +00:00
|
|
|
define(["Tone/component/AmplitudeEnvelope", "helper/Basic", "helper/Offline",
|
2017-02-20 04:55:55 +00:00
|
|
|
"Tone/component/Envelope", "Test", "Tone/signal/Signal"],
|
|
|
|
function (AmplitudeEnvelope, Basic, Offline, Envelope, Test, Signal) {
|
2015-08-28 22:42:08 +00:00
|
|
|
describe("AmplitudeEnvelope", function(){
|
|
|
|
|
|
|
|
Basic(AmplitudeEnvelope);
|
|
|
|
|
|
|
|
context("Envelope", function(){
|
|
|
|
|
|
|
|
it("handles input and output connections", function(){
|
|
|
|
var ampEnv = new AmplitudeEnvelope();
|
|
|
|
Test.connect(ampEnv);
|
|
|
|
ampEnv.connect(Test);
|
|
|
|
ampEnv.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
it ("extends envelope", function(){
|
|
|
|
var ampEnv = new AmplitudeEnvelope();
|
|
|
|
expect(ampEnv).to.be.instanceOf(Envelope);
|
|
|
|
ampEnv.dispose();
|
|
|
|
});
|
|
|
|
|
2017-02-20 04:55:55 +00:00
|
|
|
it ("passes no signal before being triggered", function(){
|
|
|
|
return Offline(function(){
|
|
|
|
var ampEnv = new AmplitudeEnvelope().toMaster();
|
|
|
|
new Signal(1).connect(ampEnv);
|
|
|
|
}).then(function(buffer){
|
|
|
|
expect(buffer.isSilent()).to.be.true;
|
2015-08-28 22:42:08 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-02-20 04:55:55 +00:00
|
|
|
it ("passes signal once triggered", function(){
|
|
|
|
return Offline(function(){
|
|
|
|
var ampEnv = new AmplitudeEnvelope().toMaster();
|
|
|
|
new Signal(1).connect(ampEnv);
|
|
|
|
ampEnv.triggerAttack(0.1);
|
|
|
|
}, 0.2).then(function(buffer){
|
|
|
|
expect(buffer.getFirstSoundTime()).to.be.closeTo(0.1, 0.001);
|
2015-08-28 22:42:08 +00:00
|
|
|
});
|
2017-02-20 04:55:55 +00:00
|
|
|
});
|
2015-08-28 22:42:08 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|