2019-01-27 18:05:20 +00:00
|
|
|
import Tone from "../core/Tone";
|
|
|
|
import "../effect/FeedbackEffect";
|
|
|
|
import "../signal/Signal";
|
|
|
|
import "../core/Delay";
|
2014-09-04 04:41:40 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
/**
|
|
|
|
* @class Tone.FeedbackDelay is a DelayNode in which part of output
|
|
|
|
* signal is fed back into the delay.
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @extends {Tone.FeedbackEffect}
|
|
|
|
* @param {Time|Object} [delayTime] The delay applied to the incoming signal.
|
|
|
|
* @param {NormalRange=} feedback The amount of the effected signal which
|
|
|
|
* is fed back through the delay.
|
|
|
|
* @example
|
|
|
|
* var feedbackDelay = new Tone.FeedbackDelay("8n", 0.5).toMaster();
|
2019-02-08 15:29:10 +00:00
|
|
|
* var tom = new Tone.MembraneSynth({
|
2019-01-27 18:05:20 +00:00
|
|
|
* "octaves" : 4,
|
|
|
|
* "pitchDecay" : 0.1
|
|
|
|
* }).connect(feedbackDelay);
|
|
|
|
* tom.triggerAttackRelease("A2","32n");
|
|
|
|
*/
|
|
|
|
Tone.FeedbackDelay = function(){
|
|
|
|
|
|
|
|
var options = Tone.defaults(arguments, ["delayTime", "feedback"], Tone.FeedbackDelay);
|
|
|
|
Tone.FeedbackEffect.call(this, options);
|
2018-02-15 16:42:59 +00:00
|
|
|
|
2014-06-21 21:34:31 +00:00
|
|
|
/**
|
2019-01-27 18:05:20 +00:00
|
|
|
* the delay node
|
|
|
|
* @type {Tone.Delay}
|
|
|
|
* @private
|
2014-06-21 21:34:31 +00:00
|
|
|
*/
|
2019-01-27 18:05:20 +00:00
|
|
|
this._delayNode = new Tone.Delay(options.delayTime, options.maxDelay);
|
2014-06-21 21:34:31 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
/**
|
|
|
|
* The delayTime of the DelayNode.
|
|
|
|
* @type {Time}
|
|
|
|
* @signal
|
|
|
|
*/
|
|
|
|
this.delayTime = this._delayNode.delayTime;
|
2016-09-20 04:01:27 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
// connect it up
|
|
|
|
this.connectEffect(this._delayNode);
|
|
|
|
this._readOnly(["delayTime"]);
|
|
|
|
};
|
2014-08-23 17:50:30 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
Tone.extend(Tone.FeedbackDelay, Tone.FeedbackEffect);
|
2014-06-21 21:34:31 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
/**
|
|
|
|
* The default values.
|
|
|
|
* @const
|
|
|
|
* @static
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
Tone.FeedbackDelay.defaults = {
|
|
|
|
"delayTime" : 0.25,
|
|
|
|
"maxDelay" : 1
|
|
|
|
};
|
2014-06-21 21:34:31 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
/**
|
|
|
|
* clean up
|
|
|
|
* @returns {Tone.FeedbackDelay} this
|
|
|
|
*/
|
|
|
|
Tone.FeedbackDelay.prototype.dispose = function(){
|
|
|
|
Tone.FeedbackEffect.prototype.dispose.call(this);
|
|
|
|
this._delayNode.dispose();
|
|
|
|
this._delayNode = null;
|
|
|
|
this._writable(["delayTime"]);
|
|
|
|
this.delayTime = null;
|
|
|
|
return this;
|
|
|
|
};
|
2014-08-25 13:57:36 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
export default Tone.FeedbackDelay;
|
2014-06-21 21:34:31 +00:00
|
|
|
|