Tone.js/Tone/effect/FeedbackDelay.js

68 lines
1.6 KiB
JavaScript
Raw Normal View History

define(["Tone/core/Tone", "Tone/effect/FeedbackEffect", "Tone/signal/Signal"], function(Tone){
"use strict";
/**
2015-06-14 04:54:17 +00:00
* @class A feedback delay.
*
* @constructor
* @extends {Tone.FeedbackEffect}
2015-06-14 00:20:36 +00:00
* @param {Time} [delayTime=0.25] The delay time in seconds.
2015-02-27 21:53:10 +00:00
* @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(){
2014-08-23 17:50:30 +00:00
2015-02-27 21:53:10 +00:00
var options = this.optionsObject(arguments, ["delayTime", "feedback"], Tone.FeedbackDelay.defaults);
Tone.FeedbackEffect.call(this, options);
/**
* Tone.Signal to control the delay amount
2015-06-13 23:50:39 +00:00
* @type {Time}
* @signal
*/
this.delayTime = new Tone.Signal(options.delayTime, Tone.Type.Time);
2014-08-23 17:50:30 +00:00
/**
* the delay node
* @type {DelayNode}
* @private
*/
this._delayNode = this.context.createDelay(4);
// connect it up
this.connectEffect(this._delayNode);
2014-08-23 17:50:30 +00:00
this.delayTime.connect(this._delayNode.delayTime);
2015-04-18 14:54:08 +00:00
this._readOnly(["delayTime"]);
};
Tone.extend(Tone.FeedbackDelay, Tone.FeedbackEffect);
/**
2015-02-27 21:53:10 +00:00
* The default values.
* @const
* @static
* @type {Object}
*/
Tone.FeedbackDelay.defaults = {
2015-02-27 21:53:10 +00:00
"delayTime" : 0.25,
2014-08-25 13:57:36 +00:00
};
/**
* clean up
* @returns {Tone.FeedbackDelay} this
*/
Tone.FeedbackDelay.prototype.dispose = function(){
Tone.FeedbackEffect.prototype.dispose.call(this);
2014-08-23 17:50:30 +00:00
this.delayTime.dispose();
this._delayNode.disconnect();
this._delayNode = null;
2015-04-18 14:54:08 +00:00
this._writable(["delayTime"]);
2014-08-23 17:50:30 +00:00
this.delayTime = null;
2015-02-02 18:22:16 +00:00
return this;
};
return Tone.FeedbackDelay;
});