mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 08:38:00 +00:00
range test when setting rolloff
This commit is contained in:
parent
35bc3f410b
commit
46a567c7f0
1 changed files with 7 additions and 5 deletions
|
@ -90,8 +90,8 @@ define(["Tone/core/Tone", "Tone/signal/Signal"], function(Tone){
|
|||
*/
|
||||
Tone.Filter.prototype.setType = function(type){
|
||||
this._type = type;
|
||||
for (var i = 0; i < this._filters.lenght; i++){
|
||||
this._filter[i].type = type;
|
||||
for (var i = 0; i < this._filters.length; i++){
|
||||
this._filters[i].type = type;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -111,15 +111,17 @@ define(["Tone/core/Tone", "Tone/signal/Signal"], function(Tone){
|
|||
* -12, -24, and -48.
|
||||
*/
|
||||
Tone.Filter.prototype.setRolloff = function(rolloff){
|
||||
var cascadingCount = Math.log(rolloff / -12) / Math.LN2 + 1;
|
||||
//check the rolloff is valid
|
||||
if (cascadingCount % 1 !== 0){
|
||||
throw new RangeError("Filter rolloff can only be -12, -24, or -48");
|
||||
}
|
||||
//first disconnect the filters and throw them away
|
||||
this.input.disconnect();
|
||||
for (var i = 0; i < this._filters.length; i++) {
|
||||
this._filters[i].disconnect();
|
||||
this._filters[i] = null;
|
||||
}
|
||||
this._filters = null;
|
||||
//make new filters
|
||||
var cascadingCount = rolloff / -12;
|
||||
this._filters = new Array(cascadingCount);
|
||||
for (var count = 0; count < cascadingCount; count++){
|
||||
var filter = this.context.createBiquadFilter();
|
||||
|
|
Loading…
Reference in a new issue