2014-06-21 21:34:31 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/effect/FeedbackEffect", "Tone/signal/Signal"], function(Tone){
|
2014-09-04 04:41:40 +00:00
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2014-06-21 21:34:31 +00:00
|
|
|
/**
|
2014-09-05 15:32:33 +00:00
|
|
|
* @class A feedback delay
|
2014-06-21 21:34:31 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @extends {Tone.FeedbackEffect}
|
2014-12-02 06:42:08 +00:00
|
|
|
* @param {Tone.Time|Object} [delayTime=0.25]
|
2014-06-21 21:34:31 +00:00
|
|
|
*/
|
2014-08-25 14:23:37 +00:00
|
|
|
Tone.FeedbackDelay = function(){
|
2014-08-23 17:50:30 +00:00
|
|
|
|
2014-08-25 14:23:37 +00:00
|
|
|
var options = this.optionsObject(arguments, ["delayTime"], Tone.FeedbackDelay.defaults);
|
|
|
|
Tone.FeedbackEffect.call(this, options);
|
2014-06-21 21:34:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tone.Signal to control the delay amount
|
|
|
|
* @type {Tone.Signal}
|
|
|
|
*/
|
2015-02-10 16:40:27 +00:00
|
|
|
this.delayTime = new Tone.Signal(options.delayTime, Tone.Signal.Units.Time);
|
2014-08-23 17:50:30 +00:00
|
|
|
|
2014-06-21 21:34:31 +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);
|
2014-06-21 21:34:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Tone.extend(Tone.FeedbackDelay, Tone.FeedbackEffect);
|
|
|
|
|
2014-08-25 14:23:37 +00:00
|
|
|
/**
|
|
|
|
* [defaults description]
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
Tone.FeedbackDelay.defaults = {
|
|
|
|
"delayTime" : 0.25
|
|
|
|
};
|
2015-02-10 16:40:27 +00:00
|
|
|
|
2014-06-21 21:34:31 +00:00
|
|
|
/**
|
|
|
|
* clean up
|
2015-02-02 18:22:16 +00:00
|
|
|
* @returns {Tone.FeedbackDelay} `this`
|
2014-06-21 21:34:31 +00:00
|
|
|
*/
|
|
|
|
Tone.FeedbackDelay.prototype.dispose = function(){
|
2014-08-23 19:51:21 +00:00
|
|
|
Tone.FeedbackEffect.prototype.dispose.call(this);
|
2014-08-23 17:50:30 +00:00
|
|
|
this.delayTime.dispose();
|
2014-06-21 21:34:31 +00:00
|
|
|
this._delayNode.disconnect();
|
|
|
|
this._delayNode = null;
|
2014-08-23 17:50:30 +00:00
|
|
|
this.delayTime = null;
|
2015-02-02 18:22:16 +00:00
|
|
|
return this;
|
2014-06-21 21:34:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return Tone.FeedbackDelay;
|
|
|
|
});
|