Tone.js/Tone/effect/FeedbackDelay.js
2015-06-13 20:20:36 -04:00

68 lines
No EOL
1.6 KiB
JavaScript

define(["Tone/core/Tone", "Tone/effect/FeedbackEffect", "Tone/signal/Signal"], function(Tone){
"use strict";
/**
* @class A feedback delay
*
* @constructor
* @extends {Tone.FeedbackEffect}
* @param {Time} [delayTime=0.25] The delay time in seconds.
* @param {number=} feedback The amount of the effected signal which
* is fed back through the delay.
* @example
* var feedbackDelay = new Tone.FeedbackDelay("8n", 0.25);
*/
Tone.FeedbackDelay = function(){
var options = this.optionsObject(arguments, ["delayTime", "feedback"], Tone.FeedbackDelay.defaults);
Tone.FeedbackEffect.call(this, options);
/**
* Tone.Signal to control the delay amount
* @type {Time}
* @signal
*/
this.delayTime = new Tone.Signal(options.delayTime, Tone.Type.Time);
/**
* the delay node
* @type {DelayNode}
* @private
*/
this._delayNode = this.context.createDelay(4);
// connect it up
this.connectEffect(this._delayNode);
this.delayTime.connect(this._delayNode.delayTime);
this._readOnly(["delayTime"]);
};
Tone.extend(Tone.FeedbackDelay, Tone.FeedbackEffect);
/**
* The default values.
* @const
* @static
* @type {Object}
*/
Tone.FeedbackDelay.defaults = {
"delayTime" : 0.25,
};
/**
* clean up
* @returns {Tone.FeedbackDelay} `this`
*/
Tone.FeedbackDelay.prototype.dispose = function(){
Tone.FeedbackEffect.prototype.dispose.call(this);
this.delayTime.dispose();
this._delayNode.disconnect();
this._delayNode = null;
this._writable(["delayTime"]);
this.delayTime = null;
return this;
};
return Tone.FeedbackDelay;
});