mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-26 11:33:09 +00:00
gate uses just smoothing instead of attack/release
This commit is contained in:
parent
8cb4fc32d9
commit
982bc16b71
3 changed files with 15 additions and 34 deletions
|
@ -7,7 +7,7 @@
|
|||
* Tone.Meter uses RMS instead of peak (thanks [@Idicious](https://github.com/Idicious))
|
||||
* Tone.Sampler supports polyphonic syntax (thanks [@zfan40](https://github.com/zfan40))
|
||||
* Building files with [webpack](https://webpack.js.org/)
|
||||
* Follower uses a single "smoothing" value instead of separate attacks and releases
|
||||
* Follower/Gate uses a single "smoothing" value instead of separate attacks and releases
|
||||
|
||||
|
||||
### r12
|
||||
|
|
|
@ -11,8 +11,7 @@ define(["Tone/core/Tone", "Tone/component/Follower", "Tone/signal/GreaterThan",
|
|||
* @constructor
|
||||
* @extends {Tone.AudioNode}
|
||||
* @param {Decibels|Object} [threshold] The threshold above which the gate will open.
|
||||
* @param {Time=} attack The follower's attack time
|
||||
* @param {Time=} release The follower's release time
|
||||
* @param {Time=} smoothing The follower's smoothing time
|
||||
* @example
|
||||
* var gate = new Tone.Gate(-30, 0.2, 0.3).toMaster();
|
||||
* var mic = new Tone.UserMedia().connect(gate);
|
||||
|
@ -21,7 +20,7 @@ define(["Tone/core/Tone", "Tone/component/Follower", "Tone/signal/GreaterThan",
|
|||
*/
|
||||
Tone.Gate = function(){
|
||||
|
||||
var options = Tone.defaults(arguments, ["threshold", "attack", "release"], Tone.Gate);
|
||||
var options = Tone.defaults(arguments, ["threshold", "smoothing"], Tone.Gate);
|
||||
Tone.AudioNode.call(this);
|
||||
this.createInsOuts(1, 1);
|
||||
|
||||
|
@ -29,7 +28,7 @@ define(["Tone/core/Tone", "Tone/component/Follower", "Tone/signal/GreaterThan",
|
|||
* @type {Tone.Follower}
|
||||
* @private
|
||||
*/
|
||||
this._follower = new Tone.Follower(options.attack, options.release);
|
||||
this._follower = new Tone.Follower(options.smoothing);
|
||||
|
||||
/**
|
||||
* @type {Tone.GreaterThan}
|
||||
|
@ -51,8 +50,7 @@ define(["Tone/core/Tone", "Tone/component/Follower", "Tone/signal/GreaterThan",
|
|||
* @type {Object}
|
||||
*/
|
||||
Tone.Gate.defaults = {
|
||||
"attack" : 0.1,
|
||||
"release" : 0.1,
|
||||
"smoothing" : 0.1,
|
||||
"threshold" : -40
|
||||
};
|
||||
|
||||
|
@ -72,32 +70,17 @@ define(["Tone/core/Tone", "Tone/component/Follower", "Tone/signal/GreaterThan",
|
|||
});
|
||||
|
||||
/**
|
||||
* The attack speed of the gate
|
||||
* The attack/decay speed of the gate
|
||||
* @memberOf Tone.Gate#
|
||||
* @type {Time}
|
||||
* @name attack
|
||||
* @name smoothing
|
||||
*/
|
||||
Object.defineProperty(Tone.Gate.prototype, "attack", {
|
||||
Object.defineProperty(Tone.Gate.prototype, "smoothing", {
|
||||
get : function(){
|
||||
return this._follower.attack;
|
||||
return this._follower.smoothing;
|
||||
},
|
||||
set : function(attackTime){
|
||||
this._follower.attack = attackTime;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* The release speed of the gate
|
||||
* @memberOf Tone.Gate#
|
||||
* @type {Time}
|
||||
* @name release
|
||||
*/
|
||||
Object.defineProperty(Tone.Gate.prototype, "release", {
|
||||
get : function(){
|
||||
return this._follower.release;
|
||||
},
|
||||
set : function(releaseTime){
|
||||
this._follower.release = releaseTime;
|
||||
set : function(smoothingTime){
|
||||
this._follower.smoothing = smoothingTime;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -17,23 +17,21 @@ function(Gate, Basic, Offline, Test, Signal, PassAudio, Tone){
|
|||
it("handles getter/setter as Object", function(){
|
||||
var gate = new Gate();
|
||||
var values = {
|
||||
"attack" : 0.2,
|
||||
"release" : 0.4,
|
||||
"smoothing" : 0.2,
|
||||
"threshold" : -20
|
||||
};
|
||||
gate.set(values);
|
||||
expect(gate.get().attack).to.be.closeTo(0.2, 0.001);
|
||||
expect(gate.get().release).to.be.closeTo(0.4, 0.001);
|
||||
expect(gate.get().smoothing).to.be.closeTo(0.2, 0.001);
|
||||
expect(gate.get().threshold).to.be.closeTo(-20, 0.1);
|
||||
gate.dispose();
|
||||
});
|
||||
|
||||
it("can be constructed with an object", function(){
|
||||
var gate = new Gate({
|
||||
"release" : 0.3,
|
||||
"smoothing" : 0.3,
|
||||
"threshold" : -5
|
||||
});
|
||||
expect(gate.release).to.be.closeTo(0.3, 0.001);
|
||||
expect(gate.smoothing).to.be.closeTo(0.3, 0.001);
|
||||
expect(gate.threshold).to.be.closeTo(-5, 0.1);
|
||||
gate.dispose();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue