2016-09-20 04:01:27 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/effect/FeedbackEffect", "Tone/signal/Signal", "Tone/core/Delay"], function(Tone){
|
2014-09-04 04:41:40 +00:00
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2014-06-21 21:34:31 +00:00
|
|
|
/**
|
2015-06-22 05:20:57 +00:00
|
|
|
* @class Tone.FeedbackDelay is a DelayNode in which part of output
|
|
|
|
* signal is fed back into the delay.
|
2014-06-21 21:34:31 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @extends {Tone.FeedbackEffect}
|
2015-06-22 05:20:57 +00:00
|
|
|
* @param {Time|Object} [delayTime] The delay applied to the incoming signal.
|
|
|
|
* @param {NormalRange=} feedback The amount of the effected signal which
|
2015-02-27 21:53:10 +00:00
|
|
|
* is fed back through the delay.
|
|
|
|
* @example
|
2015-07-04 16:40:33 +00:00
|
|
|
* var feedbackDelay = new Tone.FeedbackDelay("8n", 0.5).toMaster();
|
|
|
|
* var tom = new Tone.DrumSynth({
|
|
|
|
* "octaves" : 4,
|
|
|
|
* "pitchDecay" : 0.1
|
|
|
|
* }).connect(feedbackDelay);
|
|
|
|
* tom.triggerAttackRelease("A2","32n");
|
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
|
|
|
|
2017-04-26 03:18:08 +00:00
|
|
|
var options = Tone.defaults(arguments, ["delayTime", "feedback"], Tone.FeedbackDelay);
|
2014-08-25 14:23:37 +00:00
|
|
|
Tone.FeedbackEffect.call(this, options);
|
2014-06-21 21:34:31 +00:00
|
|
|
|
2016-09-20 04:01:27 +00:00
|
|
|
/**
|
|
|
|
* the delay node
|
|
|
|
* @type {Tone.Delay}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this._delayNode = new Tone.Delay(options.delayTime);
|
|
|
|
|
2014-06-21 21:34:31 +00:00
|
|
|
/**
|
2015-06-22 05:20:57 +00:00
|
|
|
* The delayTime of the DelayNode.
|
2015-06-13 23:50:39 +00:00
|
|
|
* @type {Time}
|
|
|
|
* @signal
|
2014-06-21 21:34:31 +00:00
|
|
|
*/
|
2016-09-20 04:01:27 +00:00
|
|
|
this.delayTime = this._delayNode.delayTime;
|
2014-08-23 17:50:30 +00:00
|
|
|
|
2014-06-21 21:34:31 +00:00
|
|
|
|
|
|
|
// connect it up
|
|
|
|
this.connectEffect(this._delayNode);
|
2015-04-18 14:54:08 +00:00
|
|
|
this._readOnly(["delayTime"]);
|
2014-06-21 21:34:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Tone.extend(Tone.FeedbackDelay, Tone.FeedbackEffect);
|
|
|
|
|
2014-08-25 14:23:37 +00:00
|
|
|
/**
|
2015-02-27 21:53:10 +00:00
|
|
|
* The default values.
|
|
|
|
* @const
|
|
|
|
* @static
|
2014-08-25 14:23:37 +00:00
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
Tone.FeedbackDelay.defaults = {
|
2015-02-27 21:53:10 +00:00
|
|
|
"delayTime" : 0.25,
|
2014-08-25 13:57:36 +00:00
|
|
|
};
|
|
|
|
|
2014-06-21 21:34:31 +00:00
|
|
|
/**
|
|
|
|
* clean up
|
2015-06-14 00:54:29 +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);
|
2016-09-20 04:01:27 +00:00
|
|
|
this._delayNode.dispose();
|
2014-06-21 21:34:31 +00:00
|
|
|
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;
|
2014-06-21 21:34:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return Tone.FeedbackDelay;
|
|
|
|
});
|