mirror of
https://github.com/Tonejs/Tone.js
synced 2025-01-15 21:33:53 +00:00
phaser uses octaves
instead of depth
.
more consistent with rest of API.
This commit is contained in:
parent
7cc00a024a
commit
d29995a42a
3 changed files with 20 additions and 18 deletions
|
@ -19,6 +19,7 @@
|
||||||
* Scheduable musical events: Tone.Event, Tone.Loop, Tone.Part, Tone.Pattern, Tone.Sequence.
|
* Scheduable musical events: Tone.Event, Tone.Loop, Tone.Part, Tone.Pattern, Tone.Sequence.
|
||||||
* Player's playbackRate is now a signal and Noise includes a playbackRate signal.
|
* Player's playbackRate is now a signal and Noise includes a playbackRate signal.
|
||||||
* All filterEnvelopes use new Tone.FrequencyEnvelope with frequency units and `baseFrequency` and `octaves` instead of `min` and `max`.
|
* All filterEnvelopes use new Tone.FrequencyEnvelope with frequency units and `baseFrequency` and `octaves` instead of `min` and `max`.
|
||||||
|
* Phaser uses "octaves" instead of "depth" to be more consistent across the whole Tone.js API.
|
||||||
|
|
||||||
DEPRECATED:
|
DEPRECATED:
|
||||||
* `setTimeout`, `setInterval`, `setTimeline` in favor of new `schedule`, `scheduleOnce`, and `scheduleRepeat`.
|
* `setTimeout`, `setInterval`, `setTimeline` in favor of new `schedule`, `scheduleOnce`, and `scheduleRepeat`.
|
||||||
|
|
|
@ -12,12 +12,12 @@ function(Tone){
|
||||||
* @extends {Tone.StereoEffect}
|
* @extends {Tone.StereoEffect}
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {Frequency|Object} [frequency] The speed of the phasing.
|
* @param {Frequency|Object} [frequency] The speed of the phasing.
|
||||||
* @param {number} [depth] The depth of the effect.
|
* @param {number} [octaves] The octaves of the effect.
|
||||||
* @param {Frequency} [baseFrequency] The base frequency of the filters.
|
* @param {Frequency} [baseFrequency] The base frequency of the filters.
|
||||||
* @example
|
* @example
|
||||||
* var phaser = new Tone.Phaser({
|
* var phaser = new Tone.Phaser({
|
||||||
* "frequency" : 15,
|
* "frequency" : 15,
|
||||||
* "depth" : 5,
|
* "octaves" : 5,
|
||||||
* "baseFrequency" : 1000
|
* "baseFrequency" : 1000
|
||||||
* }).toMaster();
|
* }).toMaster();
|
||||||
* var synth = new Tone.FMSynth().connect(phaser);
|
* var synth = new Tone.FMSynth().connect(phaser);
|
||||||
|
@ -26,7 +26,7 @@ function(Tone){
|
||||||
Tone.Phaser = function(){
|
Tone.Phaser = function(){
|
||||||
|
|
||||||
//set the defaults
|
//set the defaults
|
||||||
var options = this.optionsObject(arguments, ["frequency", "depth", "baseFrequency"], Tone.Phaser.defaults);
|
var options = this.optionsObject(arguments, ["frequency", "octaves", "baseFrequency"], Tone.Phaser.defaults);
|
||||||
Tone.StereoEffect.call(this, options);
|
Tone.StereoEffect.call(this, options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,11 +52,11 @@ function(Tone){
|
||||||
this._baseFrequency = options.baseFrequency;
|
this._baseFrequency = options.baseFrequency;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the depth of the phasing
|
* the octaves of the phasing
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this._depth = options.depth;
|
this._octaves = options.octaves;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The quality factor of the filters
|
* The quality factor of the filters
|
||||||
|
@ -95,7 +95,7 @@ function(Tone){
|
||||||
this._lfoL.frequency.connect(this._lfoR.frequency);
|
this._lfoL.frequency.connect(this._lfoR.frequency);
|
||||||
//set the options
|
//set the options
|
||||||
this.baseFrequency = options.baseFrequency;
|
this.baseFrequency = options.baseFrequency;
|
||||||
this.depth = options.depth;
|
this.octaves = options.octaves;
|
||||||
//start the lfo
|
//start the lfo
|
||||||
this._lfoL.start();
|
this._lfoL.start();
|
||||||
this._lfoR.start();
|
this._lfoR.start();
|
||||||
|
@ -111,7 +111,7 @@ function(Tone){
|
||||||
*/
|
*/
|
||||||
Tone.Phaser.defaults = {
|
Tone.Phaser.defaults = {
|
||||||
"frequency" : 0.5,
|
"frequency" : 0.5,
|
||||||
"depth" : 10,
|
"octaves" : 3,
|
||||||
"stages" : 10,
|
"stages" : 10,
|
||||||
"Q" : 10,
|
"Q" : 10,
|
||||||
"baseFrequency" : 350,
|
"baseFrequency" : 350,
|
||||||
|
@ -137,18 +137,19 @@ function(Tone){
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The depth of the effect.
|
* The number of octaves the phase goes above
|
||||||
|
* the baseFrequency
|
||||||
* @memberOf Tone.Phaser#
|
* @memberOf Tone.Phaser#
|
||||||
* @type {number}
|
* @type {Positive}
|
||||||
* @name depth
|
* @name octaves
|
||||||
*/
|
*/
|
||||||
Object.defineProperty(Tone.Phaser.prototype, "depth", {
|
Object.defineProperty(Tone.Phaser.prototype, "octaves", {
|
||||||
get : function(){
|
get : function(){
|
||||||
return this._depth;
|
return this._octaves;
|
||||||
},
|
},
|
||||||
set : function(depth){
|
set : function(octaves){
|
||||||
this._depth = depth;
|
this._octaves = octaves;
|
||||||
var max = this._baseFrequency + this._baseFrequency * depth;
|
var max = this._baseFrequency * Math.pow(2, octaves);
|
||||||
this._lfoL.max = max;
|
this._lfoL.max = max;
|
||||||
this._lfoR.max = max;
|
this._lfoR.max = max;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +169,7 @@ function(Tone){
|
||||||
this._baseFrequency = freq;
|
this._baseFrequency = freq;
|
||||||
this._lfoL.min = freq;
|
this._lfoL.min = freq;
|
||||||
this._lfoR.min = freq;
|
this._lfoR.min = freq;
|
||||||
this.depth = this._depth;
|
this.octaves = this._octaves;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,11 @@ define(["Tone/effect/Phaser", "helper/Basic", "helper/EffectTests"], function (P
|
||||||
it ("can get/set the options", function(){
|
it ("can get/set the options", function(){
|
||||||
var phaser = new Phaser();
|
var phaser = new Phaser();
|
||||||
phaser.set({
|
phaser.set({
|
||||||
"depth" : 0.21,
|
"octaves" : 0.21,
|
||||||
"baseFrequency" : 300,
|
"baseFrequency" : 300,
|
||||||
});
|
});
|
||||||
expect(phaser.get().baseFrequency).to.be.closeTo(300, 0.01);
|
expect(phaser.get().baseFrequency).to.be.closeTo(300, 0.01);
|
||||||
expect(phaser.get().depth).to.be.closeTo(0.21, 0.01);
|
expect(phaser.get().octaves).to.be.closeTo(0.21, 0.01);
|
||||||
phaser.dispose();
|
phaser.dispose();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue