2018-02-15 16:41:01 +00:00
|
|
|
define(["Test", "Tone/core/Tone", "Tone/core/Delay", "helper/PassAudio"], function(Test, Tone, Delay, PassAudio) {
|
2015-08-16 18:23:40 +00:00
|
|
|
|
|
|
|
describe("Delay", function(){
|
|
|
|
|
|
|
|
it("can be created and disposed", function(){
|
|
|
|
var delay = new Delay();
|
|
|
|
delay.dispose();
|
|
|
|
Test.wasDisposed(delay);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("handles input and output connections", function(){
|
|
|
|
var delay = new Delay();
|
|
|
|
delay.connect(Test);
|
|
|
|
Test.connect(delay);
|
|
|
|
Test.connect(delay.delayTime);
|
|
|
|
delay.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("can set delay time", function(){
|
|
|
|
var delay = new Delay();
|
|
|
|
delay.delayTime.value = 0.2;
|
|
|
|
expect(delay.delayTime.value).to.be.closeTo(0.2, 0.001);
|
|
|
|
delay.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("can be constructed with an options object", function(){
|
|
|
|
var delay = new Delay({
|
2015-11-02 14:31:12 +00:00
|
|
|
"delayTime" : 0.3,
|
2015-08-16 18:23:40 +00:00
|
|
|
"maxDelay" : 2
|
|
|
|
});
|
|
|
|
expect(delay.delayTime.value).to.be.closeTo(0.3, 0.001);
|
2018-02-15 16:41:01 +00:00
|
|
|
expect(delay.maxDelay).to.equal(2);
|
2015-08-16 18:23:40 +00:00
|
|
|
delay.dispose();
|
2017-12-06 18:16:22 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("if the constructor delay time is greater than maxDelay, use that as the maxDelay time", function(){
|
|
|
|
var delay = new Delay(3);
|
|
|
|
expect(delay.delayTime.value).to.be.closeTo(3, 0.001);
|
|
|
|
delay.dispose();
|
2015-08-16 18:23:40 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("can returns state from 'get' method", function(){
|
|
|
|
var delay = new Delay({
|
2015-11-02 14:31:12 +00:00
|
|
|
"delayTime" : 0.4,
|
2015-08-16 18:23:40 +00:00
|
|
|
"maxDelay" : 2
|
|
|
|
});
|
|
|
|
var values = delay.get();
|
2015-11-02 14:31:12 +00:00
|
|
|
expect(values.delayTime).to.be.closeTo(0.4, 0.001);
|
2015-08-16 18:23:40 +00:00
|
|
|
delay.dispose();
|
|
|
|
});
|
|
|
|
|
2015-10-23 17:49:26 +00:00
|
|
|
it("accepts Time in constructor", function(){
|
|
|
|
var delay = new Delay("4n");
|
2015-11-02 14:31:12 +00:00
|
|
|
expect(delay.delayTime.value).to.be.closeTo(delay.toSeconds("4n"), 0.001);
|
2015-10-23 17:49:26 +00:00
|
|
|
delay.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("accepts Time in options object", function(){
|
|
|
|
var delay = new Delay({
|
2015-11-02 14:31:12 +00:00
|
|
|
"delayTime" : "8t"
|
2015-10-23 17:49:26 +00:00
|
|
|
});
|
2015-11-02 14:31:12 +00:00
|
|
|
expect(delay.delayTime.value).to.be.closeTo(delay.toSeconds("8t"), 0.001);
|
2015-10-23 17:49:26 +00:00
|
|
|
delay.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("can set Time", function(){
|
|
|
|
var delay = new Delay();
|
2015-11-02 14:31:12 +00:00
|
|
|
delay.delayTime.value = "16n";
|
|
|
|
expect(delay.delayTime.value).to.be.closeTo(delay.toSeconds("16n"), 0.001);
|
2015-10-23 17:49:26 +00:00
|
|
|
delay.dispose();
|
|
|
|
});
|
|
|
|
|
2017-12-30 16:26:29 +00:00
|
|
|
it("passes audio through", function(){
|
2017-02-19 20:29:01 +00:00
|
|
|
return PassAudio(function(input){
|
|
|
|
var delay = new Delay(0).toMaster();
|
|
|
|
input.connect(delay);
|
2015-08-18 20:32:01 +00:00
|
|
|
});
|
2018-02-15 16:41:01 +00:00
|
|
|
});
|
2015-08-18 20:32:01 +00:00
|
|
|
|
2015-08-16 18:23:40 +00:00
|
|
|
});
|
2017-12-30 16:26:29 +00:00
|
|
|
});
|