From 267f1befc0d3216befead34b1fa73dc26fce6f6e Mon Sep 17 00:00:00 2001 From: Yotam Mann Date: Sat, 14 Dec 2019 11:53:12 -0500 Subject: [PATCH] Simplifying Freeverb dispose --- Tone/core/clock/TickParam.ts | 3 ++- Tone/core/clock/Transport.ts | 2 +- Tone/effect/Freeverb.ts | 12 +++--------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Tone/core/clock/TickParam.ts b/Tone/core/clock/TickParam.ts index 8171ee0b..b9ed6255 100644 --- a/Tone/core/clock/TickParam.ts +++ b/Tone/core/clock/TickParam.ts @@ -265,6 +265,7 @@ export class TickParam extends Param // might be necessary to clear all the previous values const currentVal = this.value; this._multiplier = m; - this.value = currentVal; + this.cancelScheduledValues(0); + this.setValueAtTime(currentVal, 0); } } diff --git a/Tone/core/clock/Transport.ts b/Tone/core/clock/Transport.ts index edc3eb98..a68a4115 100644 --- a/Tone/core/clock/Transport.ts +++ b/Tone/core/clock/Transport.ts @@ -178,7 +178,7 @@ export class Transport extends ToneWithContext implements Emit this._bindClockEvents(); this.bpm = this._clock.frequency as unknown as TickParam<"bpm">; this._clock.frequency.multiplier = options.ppq; - this.bpm.value = options.bpm; + this.bpm.setValueAtTime(options.bpm, 0); readOnly(this, "bpm"); this._timeSignature = options.timeSignature; diff --git a/Tone/effect/Freeverb.ts b/Tone/effect/Freeverb.ts index b586261c..15c8ffef 100644 --- a/Tone/effect/Freeverb.ts +++ b/Tone/effect/Freeverb.ts @@ -128,15 +128,9 @@ export class Freeverb extends StereoEffect { dispose(): this { super.dispose(); - for (let al = 0; al < this._allpassFiltersL.length; al++) { - this._allpassFiltersL[al].disconnect(); - } - for (let ar = 0; ar < this._allpassFiltersR.length; ar++) { - this._allpassFiltersR[ar].disconnect(); - } - for (let cf = 0; cf < this._combFilters.length; cf++) { - this._combFilters[cf].dispose(); - } + this._allpassFiltersL.forEach(al => al.disconnect()); + this._allpassFiltersR.forEach(ar => ar.disconnect()); + this._combFilters.forEach(cf => cf.dispose()); this.roomSize.dispose(); return this; }