2014-03-11 04:54:40 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// EFFECTS UNIT
|
|
|
|
//
|
|
|
|
// connect the effect to the effectSend and to the effectReturn
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2014-03-16 17:33:56 +00:00
|
|
|
Tone.Effect = function(){
|
2014-03-11 04:54:40 +00:00
|
|
|
//extends Unit
|
2014-03-16 17:33:56 +00:00
|
|
|
Tone.call(this);
|
2014-03-11 23:27:46 +00:00
|
|
|
|
|
|
|
//components
|
2014-03-13 16:47:26 +00:00
|
|
|
this.dry = this.context.createGain();
|
|
|
|
this.effectSend = this.context.createGain();
|
|
|
|
this.effectReturn = this.context.createGain();
|
2014-03-11 23:27:46 +00:00
|
|
|
|
2014-03-11 04:54:40 +00:00
|
|
|
//connections
|
|
|
|
this.input.connect(this.dry);
|
|
|
|
this.dry.connect(this.output);
|
|
|
|
this.input.connect(this.effectSend);
|
|
|
|
this.effectReturn.connect(this.output);
|
2014-03-15 05:02:33 +00:00
|
|
|
|
2014-03-11 23:27:46 +00:00
|
|
|
//some initial values
|
|
|
|
this.setDry(.5);
|
2014-03-11 04:54:40 +00:00
|
|
|
}
|
|
|
|
|
2014-03-16 17:33:56 +00:00
|
|
|
Tone.extend(Tone.Effect, Tone);
|
2014-03-11 04:54:40 +00:00
|
|
|
|
|
|
|
//adjust the dry/wet balance
|
|
|
|
//dryness 0-1
|
2014-03-16 17:33:56 +00:00
|
|
|
Tone.Effect.prototype.setDry = function(dryness, duration){
|
2014-03-13 16:47:26 +00:00
|
|
|
duration = this.defaultArg(duration, this.fadeTime);
|
2014-03-11 23:27:46 +00:00
|
|
|
var dryGain = this.equalPowerGain(dryness);
|
|
|
|
var wetGain = this.equalPowerGain(1 - dryness);
|
|
|
|
this.rampToValue(this.dry.gain, dryGain, duration);
|
|
|
|
this.rampToValue(this.effectSend.gain, wetGain, duration);
|
2014-03-11 04:54:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//adjust the wet/dry balance
|
2014-03-16 17:33:56 +00:00
|
|
|
Tone.Effect.prototype.setWet = function(wetness, duration){
|
2014-03-11 04:54:40 +00:00
|
|
|
this.setDry(1 - wetness);
|
|
|
|
}
|
|
|
|
|
2014-03-16 17:33:56 +00:00
|
|
|
Tone.Effect.prototype.bypass = function(){
|
2014-03-11 04:54:40 +00:00
|
|
|
this.setDry(1);
|
|
|
|
}
|
|
|
|
|
2014-03-16 17:33:56 +00:00
|
|
|
Tone.Effect.prototype.connectEffect = function(effect){
|
2014-03-13 16:47:26 +00:00
|
|
|
this.chain(this.effectSend, effect, this.effectReturn);
|
2014-03-11 04:54:40 +00:00
|
|
|
}
|