2014-04-06 20:51:30 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/signal/Signal", "Tone/signal/Scale"], function(Tone){
|
2014-04-04 17:07:16 +00:00
|
|
|
|
2014-06-15 23:08:32 +00:00
|
|
|
/**
|
|
|
|
* DRY/WET KNOB
|
|
|
|
*
|
|
|
|
* equal power fading control values:
|
2014-06-20 04:57:56 +00:00
|
|
|
* 0 = 100% dry - 0% wet
|
|
|
|
* 1 = 0% dry - 100% wet
|
2014-06-15 23:08:32 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {number} initialDry
|
|
|
|
*/
|
2014-04-05 22:05:42 +00:00
|
|
|
Tone.DryWet = function(initialDry){
|
|
|
|
Tone.call(this);
|
2014-04-04 17:07:16 +00:00
|
|
|
|
2014-04-05 22:05:42 +00:00
|
|
|
//components
|
|
|
|
this.dry = this.context.createGain();
|
|
|
|
this.wet = this.context.createGain();
|
|
|
|
//control signal
|
|
|
|
this.control = new Tone.Signal();
|
2014-04-06 20:51:30 +00:00
|
|
|
this.invert = new Tone.Scale(1, 0);
|
|
|
|
this.normal = new Tone.Scale(0, 1);
|
2014-04-04 18:36:01 +00:00
|
|
|
|
2014-04-05 22:05:42 +00:00
|
|
|
//connections
|
|
|
|
this.dry.connect(this.output);
|
|
|
|
this.wet.connect(this.output);
|
2014-04-06 00:47:59 +00:00
|
|
|
//wet control
|
2014-04-06 20:51:30 +00:00
|
|
|
this.chain(this.control, this.invert, this.wet.gain);
|
2014-04-06 00:47:59 +00:00
|
|
|
//dry control
|
2014-04-06 20:51:30 +00:00
|
|
|
this.chain(this.control, this.normal, this.dry.gain);
|
2014-04-04 17:07:16 +00:00
|
|
|
|
2014-04-05 22:05:42 +00:00
|
|
|
//setup
|
|
|
|
this.dry.gain.value = 0;
|
|
|
|
this.wet.gain.value = 0;
|
|
|
|
this.setDry(0);
|
2014-06-15 23:08:32 +00:00
|
|
|
};
|
2014-04-04 17:07:16 +00:00
|
|
|
|
2014-04-05 22:05:42 +00:00
|
|
|
Tone.extend(Tone.DryWet);
|
2014-04-04 17:07:16 +00:00
|
|
|
|
2014-06-15 23:08:32 +00:00
|
|
|
/**
|
|
|
|
* Set the dry value of the knob
|
|
|
|
*
|
|
|
|
* @param {number} val
|
|
|
|
* @param {Tone.Time} rampTime
|
|
|
|
*/
|
2014-04-05 22:05:42 +00:00
|
|
|
Tone.DryWet.prototype.setDry = function(val, rampTime){
|
|
|
|
rampTime = this.defaultArg(rampTime, 0);
|
2014-04-16 00:05:11 +00:00
|
|
|
this.control.linearRampToValueAtTime(val*2 - 1, this.toSeconds(rampTime));
|
2014-06-15 23:08:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the wet value of the knob
|
|
|
|
*
|
|
|
|
* @param {number} val
|
|
|
|
* @param {Tone.Time} rampTime
|
|
|
|
*/
|
2014-04-05 22:05:42 +00:00
|
|
|
Tone.DryWet.prototype.setWet = function(val, rampTime){
|
2014-04-16 00:05:11 +00:00
|
|
|
this.setDry(1-val, rampTime);
|
2014-06-15 23:08:32 +00:00
|
|
|
};
|
2014-04-05 22:05:42 +00:00
|
|
|
|
|
|
|
return Tone.DryWet;
|
|
|
|
});
|