2014-04-05 00:24:19 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// AUTO PANNER
|
|
|
|
//
|
|
|
|
// not a 3d panner. just LR
|
|
|
|
//
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-04-06 20:51:30 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/source/Oscillator", "Tone/component/Panner", "Tone/effects/Effect"], function(Tone){
|
2014-04-05 00:24:19 +00:00
|
|
|
|
|
|
|
|
2014-04-06 00:47:59 +00:00
|
|
|
Tone.AutoPanner = function(rate, amount){
|
|
|
|
Tone.Effect.call(this);
|
2014-04-05 00:24:19 +00:00
|
|
|
|
2014-04-06 00:47:59 +00:00
|
|
|
//defaults
|
|
|
|
amount = this.defaultArg(amount, 1);
|
|
|
|
rate = this.defaultArg(rate, 1);
|
2014-04-05 00:24:19 +00:00
|
|
|
|
2014-04-06 00:47:59 +00:00
|
|
|
//components
|
|
|
|
this.osc = new Tone.Oscillator(rate);
|
|
|
|
this.amount = this.context.createGain();
|
|
|
|
this.panner = new Tone.Panner();
|
2014-04-05 00:24:19 +00:00
|
|
|
|
2014-04-06 00:47:59 +00:00
|
|
|
//connections
|
|
|
|
this.connectEffect(this.panner);
|
|
|
|
this.chain(this.osc, this.amount, this.panner.control);
|
|
|
|
}
|
2014-04-05 00:24:19 +00:00
|
|
|
|
2014-04-06 00:47:59 +00:00
|
|
|
//extend Effect
|
|
|
|
Tone.extend(Tone.AutoPanner, Tone.Effect);
|
2014-04-05 00:24:19 +00:00
|
|
|
|
2014-04-06 00:47:59 +00:00
|
|
|
Tone.AutoPanner.prototype.start = function(time){
|
|
|
|
this.osc.start(time);
|
|
|
|
}
|
2014-04-05 00:24:19 +00:00
|
|
|
|
2014-04-06 00:47:59 +00:00
|
|
|
Tone.AutoPanner.prototype.stop = function(time){
|
|
|
|
this.osc.stop(time);
|
|
|
|
}
|
2014-04-05 00:24:19 +00:00
|
|
|
|
2014-04-06 00:47:59 +00:00
|
|
|
Tone.AutoPanner.prototype.setType = function(type){
|
|
|
|
this.osc.setType(type);
|
|
|
|
}
|
2014-04-05 00:24:19 +00:00
|
|
|
|
2014-04-06 00:47:59 +00:00
|
|
|
Tone.AutoPanner.prototype.setRate = function(rate){
|
|
|
|
this.osc.setRate(rate);
|
|
|
|
}
|
2014-04-05 00:24:19 +00:00
|
|
|
|
2014-04-06 00:47:59 +00:00
|
|
|
Tone.AutoPanner.prototype.setAmount = function(amount){
|
|
|
|
this.amount.gain.value = amount;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Tone.AutoPanner;
|
|
|
|
});
|