renamed effects->effect. jsdocs on effects

This commit is contained in:
Yotam Mann 2014-06-21 17:34:31 -04:00
parent 07c247ea8b
commit c3ab9a7b0d
15 changed files with 1187 additions and 698 deletions

View file

@ -15,6 +15,7 @@
"AudioContext" : true,
"AudioBufferSourceNode" : false,
"OscillatorNode" : false,
"DelayNode" : false,
"GainNode" : false,
"AudioNode" : false,
"AudioParam" : false,

1319
Tone.js

File diff suppressed because it is too large Load diff

View file

@ -17,7 +17,7 @@ define(["Tone/core/Tone", "Tone/source/Oscillator", "Tone/signal/Scale"], functi
/** @type {GainNode} */
this.input = this.context.createGain();
/** @type {Tone.Oscillator} */
this.oscillator = new Tone.Oscillator(rate, "sine");
this.oscillator = new Tone.Oscillator(this.defaultArg(rate, 1), "sine");
/** @type {Tone.Scale} @private */
this._scaler = new Tone.Scale(this.defaultArg(outputMin, 0), this.defaultArg(outputMax, 1));
/** alias for the output */

89
Tone/effect/AutoPanner.js Normal file
View file

@ -0,0 +1,89 @@
define(["Tone/core/Tone", "Tone/effect/Effect", "Tone/component/LFO", "Tone/component/Panner"], function(Tone){
/**
* AutoPanner is a Tone.Panner with an LFO connected to the pan amount
*
* @constructor
* @extends {Tone.Effect}
* @param { number= } rate (optional) rate in HZ of the left-right pan
* @param { number= } amount (optional) of the pan (0 - 1)
*/
Tone.AutoPanner = function(rate, amount){
Tone.Effect.call(this);
/**
* the lfo which drives the panning
* @type {Tone.LFO}
*/
this.lfo = new Tone.LFO(rate, 0, 1);
/**
* the panner node which does the panning
* @type {Tone.Panner}
*/
this.panner = new Tone.Panner();
//connections
this.connectEffect(this.panner);
this.chain(this.lfo, this.panner.panControl);
//default dry value
this.setDry(this.defaultArg(amount, 1));
};
//extend Effect
Tone.extend(Tone.AutoPanner, Tone.Effect);
/**
* Start the panner
*
* @param {Tone.Time=} Time the panner begins.
*/
Tone.AutoPanner.prototype.start = function(time){
this.lfo.start(time);
};
/**
* Stop the panner
*
* @param {Tone.Time=} time the panner stops.
*/
Tone.AutoPanner.prototype.stop = function(time){
this.lfo.stop(time);
};
/**
* Set the type of oscillator attached to the AutoPanner.
*
* @param {string} type of oscillator the panner is attached to (sine|sawtooth|triangle|square)
*/
Tone.AutoPanner.prototype.setType = function(type){
this.lfo.setType(type);
};
/**
* Set frequency of the oscillator attached to the AutoPanner.
*
* @param {number|string} rate in HZ of the oscillator's frequency.
*/
Tone.AutoPanner.prototype.setFrequency = function(rate){
this.lfo.setFrequency(rate);
};
/**
* pointer to the parent's dipose method
*/
Tone.AutoPanner.prototype._effectDispose = Tone.Effect.prototype.dispose;
/**
* clean up
*/
Tone.AutoPanner.prototype.dispose = function(){
this._effectDispose();
this.lfo.dispose();
this.panner.dispose();
this.lfo = null;
this.panner = null;
};
return Tone.AutoPanner;
});

101
Tone/effect/Effect.js Normal file
View file

@ -0,0 +1,101 @@
define(["Tone/core/Tone", "Tone/component/DryWet"], function(Tone){
/**
* Effect is the base class for effects. connect the effect between
* the effectSend and effectReturn GainNodes. then control the amount of
* effect which goes to the output using the dry/wet control.
*
* @constructor
* @extends {Tone}
* @param {number=} initalDry the starting dry value
* defaults to 0.5 (50% dry / 50% wet)
*/
Tone.Effect = function(initialDry){
Tone.call(this);
/**
* the drywet knob to control the amount of effect
*
* @type {Tone.DryWet}
*/
this.dryWet = new Tone.DryWet();
/**
* connect the effectSend to the input of hte effect
*
* @type {GainNode}
*/
this.effectSend = this.context.createGain();
/**
* connect the output of the effect to the effectReturn
*
* @type {GainNode}
*/
this.effectReturn = this.context.createGain();
//connections
this.input.connect(this.dryWet.dry);
this.input.connect(this.effectSend);
this.effectReturn.connect(this.dryWet.wet);
this.dryWet.connect(this.output);
//setup
this.setDry(this.defaultArg(initialDry, 0.5));
};
Tone.extend(Tone.Effect);
/**
* setDry adjusts the dry / wet balance
* dryness is 0 (100% wet) to 1 (100% dry)
*
* @param {number} dryness
* @param {Tone.Time=} rampTime
*/
Tone.Effect.prototype.setDry = function(dryness, rampTime){
this.dryWet.setDry(dryness, rampTime);
};
/**
* setWet also adjusts the dry / wet balance
* wetVal is 0 (100% dry) to 1 (100% wet)
*
* @param {number} wetness
* @param {Tone.Time=} rampTime
*/
Tone.Effect.prototype.setWet = function(wetVal, rampTime){
this.dryWet.setWet(wetVal, rampTime);
};
/**
* bypass the effect
*/
Tone.Effect.prototype.bypass = function(){
this.setDry(1);
};
/**
* chains the effect in between the effectSend and effectReturn
* @param {Tone} effect
*/
Tone.Effect.prototype.connectEffect = function(effect){
this.chain(this.effectSend, effect, this.effectReturn);
};
/**
* tear down
*/
Tone.Effect.prototype.dispose = function(){
this.dryWet.dispose();
this.input.disconnect();
this.output.disconnect();
this.effectSend.disconnect();
this.effectReturn.disconnect();
this.dryWet = null;
this.input = null;
this.output = null;
this.effectSend = null;
this.effectReturn = null;
};
return Tone.Effect;
});

View file

@ -0,0 +1,65 @@
define(["Tone/core/Tone", "Tone/effect/FeedbackEffect", "Tone/signal/Signal"], function(Tone){
/**
* A feedback delay
*
* @constructor
* @extends {Tone.FeedbackEffect}
* @param {Tone.Time=} delayTime
*/
Tone.FeedbackDelay = function(delayTime){
Tone.FeedbackEffect.call(this);
/**
* Tone.Signal to control the delay amount
* @type {Tone.Signal}
*/
this.delay = new Tone.Signal();
/**
* the delay node
* @type {DelayNode}
* @private
*/
this._delayNode = this.context.createDelay(4);
// connect it up
this.connectEffect(this._delayNode);
this.delay.connect(this._delayNode.delayTime);
//set the initial delay
this.setDelayTime(this.defaultArg(delayTime, 0.25));
};
Tone.extend(Tone.FeedbackDelay, Tone.FeedbackEffect);
/**
* Sets the delay time
*
* @param {Tone.Time} delayTime
* @param {Tone.Time=} rampTime time it takes to reach the desired delayTime
*/
Tone.FeedbackDelay.prototype.setDelayTime = function(delayTime, rampTime){
if (rampTime){
this.delay.linearRampToValueNow(this.toSeconds(delayTime), rampTime);
} else {
this.delay.setValue(this.toSeconds(delayTime));
}
};
/**
* pointer to the feedback effects dispose method
* @borrows Tone.FeedbackDelay._feedbackEffectDispose as Tone.FeedbackEffect.dispose;
*/
Tone.FeedbackDelay.prototype._feedbackEffectDispose = Tone.FeedbackEffect.prototype.dispose;
/**
* clean up
*/
Tone.FeedbackDelay.prototype.dispose = function(){
this._feedbackEffectDispose();
this.delay.dispose();
this._delayNode.disconnect();
this._delayNode = null;
this.delay = null;
};
return Tone.FeedbackDelay;
});

View file

@ -0,0 +1,65 @@
define(["Tone/core/Tone", "Tone/effect/Effect", "Tone/signal/Signal"], function(Tone){
/**
* Feedback Effect (a sound loop between an audio source and its own output)
*
* @constructor
* @extends {Tone.Effect}
* @param {number=} initialFeedback the initial feedback value (defaults to 0.25)
*/
Tone.FeedbackEffect = function(initialFeedback){
Tone.Effect.call(this);
/**
* controls the amount of feedback
* @type {Tone.Signal}
*/
this.feedback = new Tone.Signal(this.defaultArg(initialFeedback, 0.25));
/**
* the gain which controls the feedback
* @type {GainNode}
* @private
*/
this._feedbackGain = this.context.createGain();
//the feedback loop
this.chain(this.effectReturn, this._feedbackGain, this.effectSend);
this.feedback.connect(this._feedbackGain.gain);
};
Tone.extend(Tone.FeedbackEffect, Tone.Effect);
/**
* set the feedback amount
*
* @param {number} value the amount of feedback
* @param {Tone.Time=} rampTime (optionally) set the ramp time it takes
* to reach the new feedback value
*/
Tone.FeedbackEffect.prototype.setFeedback = function(value, rampTime){
if (rampTime){
this.feedback.linearRampToValueNow(value, rampTime);
} else {
this.feedback.setValue(value);
}
};
/**
* the parents dispose method
* @private
* @borrows Tone.Effect.dispose as Tone.FeedbackEffect._effectDispose
*/
Tone.FeedbackEffect.prototype._effectDispose = Tone.Effect.prototype.dispose;
/**
* clean up
*/
Tone.FeedbackEffect.prototype.dispose = function(){
this._effectDispose();
this.feedback.dispose();
this._feedbackGain.disconnect();
this.feedback = null;
this._feedbackGain = null;
};
return Tone.FeedbackEffect;
});

View file

@ -1,32 +1,49 @@
define(["Tone/core/Tone", "Tone/effects/FeedbackDelay"], function(Tone){
define(["Tone/core/Tone", "Tone/effect/FeedbackDelay", "Tone/signal/Split", "Tone/signal/Merge"], function(Tone){
/**
* PingPongDelay is a dual delay effect where the echo is heard first in one channel and next in the opposite channel
*
* @param {Tone.Time} delayTime is the interval between consecutive echos
* PingPongDelay is a dual delay effect where the echo is heard first in one channel and next in the opposite channel
*
* @constructor
* @extends {Tone.Effect}
* @param {Tone.Time=} delayTime is the interval between consecutive echos
*/
Tone.PingPongDelay = function(delayTime){
Tone.StereoSplit.call(this);
Tone.call(this);
//components
/**
* merge the delayed signal
*/
this._merger = new Tone.Merge();
/**
* each channel (left/right) gets a feedback delay
* @type {Tone.FeedbackDelay}
*/
this.leftDelay = new Tone.FeedbackDelay(delayTime);
/**
* @type {Tone.FeedbackDelay}
*/
this.rightDelay = new Tone.FeedbackDelay(delayTime);
//connect it up
this.connectLeft(this.leftDelay);
this.connectRight(this.rightDelay);
this.input.connect(this.leftDelay);
this.input.connect(this.rightDelay);
//disconnect the feedback lines to connect them to the other delay
// http://jvzaudio.files.wordpress.com/2011/04/delay-f43.gif
this.leftDelay.feedback.disconnect();
this.rightDelay.feedback.disconnect();
this.leftDelay.feedback.connect(this.rightDelay.effectSend);
this.rightDelay.feedback.connect(this.leftDelay.effectSend);
this.leftDelay._feedbackGain.disconnect();
this.rightDelay._feedbackGain.disconnect();
this.leftDelay._feedbackGain.connect(this.rightDelay.effectSend);
this.rightDelay._feedbackGain.connect(this.leftDelay.effectSend);
this.leftDelay.connect(this._merger.left);
this.rightDelay.connect(this._merger.right);
this._merger.connect(this.output);
//initial vals;
this.setDelayTime(delayTime);
this.setDelayTime(this.defaultArg(delayTime, 0.25));
};
Tone.extend(Tone.PingPongDelay, Tone.StereoSplit);
Tone.extend(Tone.PingPongDelay);
/**
* setDelayTime

View file

@ -1,76 +0,0 @@
define(["Tone/core/Tone", "Tone/source/Oscillator", "Tone/component/Panner", "Tone/effects/Effect"], function(Tone){
/**
* AutoPanner creates a left-right panner effect (not a 3D panner).
*
* @constructor
* @param { number= } rate (optional) rate in HZ of the left-right pan
* @param { number= } amount (optional) of the pan (0 - 1)
*/
Tone.AutoPanner = function(rate, amount){
Tone.Effect.call(this);
//defaults
amount = this.defaultArg(amount, 1);
rate = this.defaultArg(rate, 1);
//components
this.osc = new Tone.Oscillator(rate);
this.amount = this.context.createGain();
this.panner = new Tone.Panner();
//connections
this.connectEffect(this.panner);
this.chain(this.osc, this.amount, this.panner.control);
};
//extend Effect
Tone.extend(Tone.AutoPanner, Tone.Effect);
/**
* Start the panner
*
* @param {Tone.Time} Time the panner begins.
*/
Tone.AutoPanner.prototype.start = function(time){
this.osc.start(time);
};
/**
* Stop the panner
*
* @param {Tone.Time} time the panner stops.
*/
Tone.AutoPanner.prototype.stop = function(time){
this.osc.stop(time);
};
/**
* Set the type of oscillator attached to the AutoPanner.
*
* @param {string} type of oscillator the panner is attached to (sine|sawtooth|triangle|square)
*/
Tone.AutoPanner.prototype.setType = function(type){
this.osc.setType(type);
};
/**
* Set frequency of the oscillator attached to the AutoPanner.
*
* @param {number|string} rate in HZ of the oscillator's frequency.
*/
Tone.AutoPanner.prototype.setFrequency = function(rate){
this.osc.setFrequency(rate);
};
/**
* Set the amount of the AutoPanner.
*
* @param {number} amount in dB (0 - 1)
*/
Tone.AutoPanner.prototype.setAmount = function(amount){
this.amount.gain.value = amount;
};
return Tone.AutoPanner;
});

View file

@ -1,57 +0,0 @@
define(["Tone/core/Tone", "Tone/component/DryWet"], function(Tone){
/**
* Effect allows you to connect it to the effectSend and to the effectReturn
*/
Tone.Effect = function(){
//extends Unit
Tone.call(this);
//components
this.dryWet = new Tone.DryWet();
this.effectSend = this.context.createGain();
this.effectReturn = this.context.createGain();
//connections
this.input.connect(this.dryWet.dry);
this.input.connect(this.effectSend);
this.effectReturn.connect(this.dryWet.wet);
this.dryWet.connect(this.output);
//setup
this.setDry(0);
};
Tone.extend(Tone.Effect, Tone);
/**
* setDry adjusts the dry / wet balance
* dryness is -1 (100% wet) to 1 (100% dry)
*
* @param {number} dryness
* @param {number=} rampTime
*/
Tone.Effect.prototype.setDry = function(dryness, rampTime){
this.dryWet.setDry(dryness, rampTime);
};
/**
* setWet also adjusts the dry / wet balance
* wetVal is -1 (100% dry) to 1 (100% wet)
*
* @param {number} wetness
* @param {number=} rampTime
*/
Tone.Effect.prototype.setWet = function(wetVal, rampTime){
this.setDry(-wetVal, rampTime);
};
Tone.Effect.prototype.bypass = function(){
this.setDry(1, 0);
};
Tone.Effect.prototype.connectEffect = function(effect){
this.chain(this.effectSend, effect, this.effectReturn);
};
return Tone.Effect;
});

View file

@ -1,29 +0,0 @@
define(["Tone/core/Tone", "Tone/effects/FeedbackEffect"], function(Tone){
/**
* Feedback Delay creates a effect whose feedback is delayed at a given interval
*
* @param {Tone.Time=} delayTime
*/
Tone.FeedbackDelay = function(delayTime){
Tone.FeedbackEffect.call(this);
this.delay = this.context.createDelay(4);
this.delay.delayTime.value = this.toSeconds(this.defaultArg(delayTime, 0.25));
// connect it up
this.connectEffect(this.delay);
};
Tone.extend(Tone.FeedbackDelay, Tone.FeedbackEffect);
/**
* Sets the delay time
*
* @param {Tone.Time} time
*/
Tone.FeedbackDelay.prototype.setDelayTime = function(time){
this.rampToValueNow(this.delay.delayTime, this.toSeconds(time));
};
return Tone.FeedbackDelay;
});

View file

@ -1,24 +0,0 @@
define(["Tone/core/Tone", "Tone/effects/Effect"], function(Tone){
/**
* Feedback Effect (a sound loop between an audio source and its own output)
*/
Tone.FeedbackEffect = function(){
//extends Unit
Tone.Effect.call(this);
this.feedback = this.context.createGain();
//feedback loop
this.chain(this.effectReturn, this.feedback, this.effectSend);
//some initial values
this.setFeedback(0);
};
Tone.extend(Tone.FeedbackEffect, Tone.Effect);
Tone.FeedbackEffect.prototype.setFeedback = function(fback){
this.rampToValueNow(this.feedback.gain, fback);
};
return Tone.FeedbackEffect;
});

View file

@ -2,7 +2,7 @@
<head>
<title>AUTOPANNER</title>
<script type="text/javascript" src='../build/Tone.js'></script>
<script type="text/javascript" src='../Tone.js'></script>
</head>
<body>

View file

@ -2,7 +2,7 @@
<head>
<title>Bit Crush</title>
<script type="text/javascript" src='../build/Tone.js'></script>
<script type="text/javascript" src='../Tone.js'></script>
</head>
<body>

View file

@ -2,7 +2,7 @@
<head>
<title>FEEDBACK DELAY</title>
<script type="text/javascript" src="../build/Tone.js"></script>
<script type="text/javascript" src="../Tone.js"></script>
</head>
<body>
@ -19,12 +19,12 @@
var feedbackDelay = new Tone.FeedbackDelay(.25);
//60% feedback
feedbackDelay.setFeedback(.6);
feedbackDelay.setFeedback(.2);
//connections
player.connect(feedbackDelay);
player.toMaster();
feedbackDelay.toMaster();
feedbackDelay.toMaster();
feedbackDelay.setWet(0.5);
</script>
</body>