2019-01-27 18:05:20 +00:00
|
|
|
import AutoPanner from "Tone/effect/AutoPanner";
|
|
|
|
import Basic from "helper/Basic";
|
|
|
|
import EffectTests from "helper/EffectTests";
|
|
|
|
import Offline from "helper/Offline";
|
2017-12-29 19:05:34 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
describe("AutoPanner", function(){
|
|
|
|
Basic(AutoPanner);
|
|
|
|
EffectTests(AutoPanner);
|
2015-08-26 14:29:35 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
context("API", function(){
|
2015-08-26 14:29:35 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can pass in options in the constructor", function(){
|
|
|
|
var autoPanner = new AutoPanner({
|
|
|
|
"type" : "sawtooth",
|
|
|
|
"depth" : 0.2
|
|
|
|
});
|
|
|
|
expect(autoPanner.depth.value).to.be.closeTo(0.2, 0.01);
|
|
|
|
expect(autoPanner.type).to.equal("sawtooth");
|
|
|
|
autoPanner.dispose();
|
|
|
|
});
|
2015-08-26 14:29:35 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can be started and stopped", function(){
|
|
|
|
var autoPanner = new AutoPanner();
|
|
|
|
autoPanner.start().stop("+0.2");
|
|
|
|
autoPanner.dispose();
|
|
|
|
});
|
2015-08-26 14:29:35 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can get/set the options", function(){
|
|
|
|
var autoPanner = new AutoPanner();
|
|
|
|
autoPanner.set({
|
|
|
|
"frequency" : 2.4,
|
|
|
|
"type" : "triangle"
|
|
|
|
});
|
|
|
|
expect(autoPanner.get().frequency).to.be.closeTo(2.4, 0.01);
|
|
|
|
expect(autoPanner.get().type).to.equal("triangle");
|
|
|
|
autoPanner.dispose();
|
|
|
|
});
|
2015-08-26 14:29:35 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can set the frequency and depth", function(){
|
|
|
|
var autoPanner = new AutoPanner();
|
|
|
|
autoPanner.depth.value = 0.4;
|
|
|
|
autoPanner.frequency.value = 0.4;
|
|
|
|
expect(autoPanner.depth.value).to.be.closeTo(0.4, 0.01);
|
|
|
|
expect(autoPanner.frequency.value).to.be.closeTo(0.4, 0.01);
|
|
|
|
autoPanner.dispose();
|
|
|
|
});
|
2017-12-29 19:05:34 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can sync the frequency to the Transport", function(){
|
|
|
|
return Offline(function(Transport){
|
|
|
|
var panner = new AutoPanner(2);
|
|
|
|
panner.sync();
|
|
|
|
panner.frequency.toMaster();
|
|
|
|
Transport.bpm.setValueAtTime(Transport.bpm.value * 2, 0.05);
|
|
|
|
// Transport.start(0)
|
|
|
|
}, 0.1).then(function(buffer){
|
|
|
|
expect(buffer.getValueAtTime(0)).to.be.closeTo(2, 0.1);
|
|
|
|
expect(buffer.getValueAtTime(0.05)).to.be.closeTo(4, 0.1);
|
|
|
|
});
|
|
|
|
});
|
2017-12-29 19:05:34 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can unsync the frequency to the Transport", function(){
|
|
|
|
return Offline(function(Transport){
|
|
|
|
var panner = new AutoPanner(2);
|
|
|
|
panner.sync();
|
|
|
|
panner.frequency.toMaster();
|
|
|
|
Transport.bpm.setValueAtTime(Transport.bpm.value * 2, 0.05);
|
|
|
|
panner.unsync();
|
|
|
|
// Transport.start(0)
|
|
|
|
}, 0.1).then(function(buffer){
|
|
|
|
expect(buffer.getValueAtTime(0)).to.be.closeTo(2, 0.1);
|
|
|
|
expect(buffer.getValueAtTime(0.05)).to.be.closeTo(2, 0.1);
|
2017-12-29 19:05:34 +00:00
|
|
|
});
|
2015-08-26 14:29:35 +00:00
|
|
|
});
|
|
|
|
});
|
2019-01-27 18:05:20 +00:00
|
|
|
});
|
|
|
|
|