[perf] level 5 connect-leak on vowel
This commit is contained in:
parent
06bf17f444
commit
89a6efb69e
1 changed files with 17 additions and 5 deletions
|
|
@ -45,7 +45,8 @@ if (typeof GainNode !== 'undefined') {
|
||||||
throw new Error('vowel: unknown vowel ' + letter);
|
throw new Error('vowel: unknown vowel ' + letter);
|
||||||
}
|
}
|
||||||
const { gains, qs, freqs } = vowelFormant[letter];
|
const { gains, qs, freqs } = vowelFormant[letter];
|
||||||
const makeupGain = ac.createGain();
|
this.makeupGain = ac.createGain();
|
||||||
|
this.audioNodes = [];
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
const gain = ac.createGain();
|
const gain = ac.createGain();
|
||||||
gain.gain.value = gains[i];
|
gain.gain.value = gains[i];
|
||||||
|
|
@ -53,14 +54,25 @@ if (typeof GainNode !== 'undefined') {
|
||||||
filter.type = 'bandpass';
|
filter.type = 'bandpass';
|
||||||
filter.Q.value = qs[i];
|
filter.Q.value = qs[i];
|
||||||
filter.frequency.value = freqs[i];
|
filter.frequency.value = freqs[i];
|
||||||
this.connect(filter);
|
super.connect(filter);
|
||||||
filter.connect(gain);
|
filter.connect(gain);
|
||||||
gain.connect(makeupGain);
|
this.audioNodes.push(filter);
|
||||||
|
gain.connect(this.makeupGain);
|
||||||
|
this.audioNodes.push(gain);
|
||||||
}
|
}
|
||||||
makeupGain.gain.value = 8; // how much makeup gain to add?
|
this.makeupGain.gain.value = 8; // how much makeup gain to add?
|
||||||
this.connect = (target) => makeupGain.connect(target);
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
connect(target) {
|
||||||
|
this.makeupGain.connect(target);
|
||||||
|
}
|
||||||
|
disconnect() {
|
||||||
|
this.makeupGain.disconnect();
|
||||||
|
this.audioNodes.forEach((n) => n.disconnect());
|
||||||
|
super.disconnect();
|
||||||
|
this.makeupGain = null;
|
||||||
|
this.audioNodes = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioContext.prototype.createVowelFilter = function (letter) {
|
AudioContext.prototype.createVowelFilter = function (letter) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue