Skip to content

Commit

Permalink
replacement of es5 functions to es6 classes feat p5.eqfilter (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
endurance21 authored Aug 15, 2020
1 parent af434c4 commit b326270
Showing 1 changed file with 39 additions and 35 deletions.
74 changes: 39 additions & 35 deletions src/eqFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,48 @@ import p5sound from './master';
*
* @private
*/
var EQFilter = function (freq, res) {
Filter.call(this, 'peaking');
this.disconnect();
this.set(freq, res);
this.biquad.gain.value = 0;
delete this.input;
delete this.output;
delete this._drywet;
delete this.wet;
};
EQFilter.prototype = Object.create(Filter.prototype);
class EQFilter extends Filter {
constructor(freq, res) {
super('peaking');

EQFilter.prototype.amp = function () {
console.warn('`amp()` is not available for p5.EQ bands. Use `.gain()`');
};
EQFilter.prototype.drywet = function () {
console.warn('`drywet()` is not available for p5.EQ bands.');
};
EQFilter.prototype.connect = function (unit) {
var u = unit || p5.soundOut.input;
if (this.biquad) {
this.biquad.connect(u.input ? u.input : u);
} else {
this.output.connect(u.input ? u.input : u);
this.disconnect();
this.set(freq, res);
this.biquad.gain.value = 0;
delete this.input;
delete this.output;
delete this._drywet;
delete this.wet;
}
};

EQFilter.prototype.disconnect = function () {
if (this.biquad) {
this.biquad.disconnect();
amp() {
console.warn('`amp()` is not available for p5.EQ bands. Use `.gain()`');
}
};
EQFilter.prototype.dispose = function () {
// remove reference form soundArray
const index = p5sound.soundArray.indexOf(this);
p5sound.soundArray.splice(index, 1);
this.disconnect();
delete this.biquad;
};

drywet() {
console.warn('`drywet()` is not available for p5.EQ bands.');
}

connect(unit) {
var u = unit || p5.soundOut.input;
if (this.biquad) {
this.biquad.connect(u.input ? u.input : u);
} else {
this.output.connect(u.input ? u.input : u);
}
}
disconnect() {
if (this.biquad) {
this.biquad.disconnect();
}
}

dispose() {
// remove reference form soundArray
const index = p5sound.soundArray.indexOf(this);
p5sound.soundArray.splice(index, 1);
this.disconnect();
delete this.biquad;
}
}

export default EQFilter;

0 comments on commit b326270

Please sign in to comment.