From 70d11f4b1ad377f0ef0db32560345c23eaf21e49 Mon Sep 17 00:00:00 2001 From: Yotam Mann Date: Thu, 3 Oct 2019 17:34:06 -0400 Subject: [PATCH] Don't dispose the synth in the offline context --- Tone/instrument/PolySynth.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Tone/instrument/PolySynth.ts b/Tone/instrument/PolySynth.ts index 506dfd90d..cac98c29b 100644 --- a/Tone/instrument/PolySynth.ts +++ b/Tone/instrument/PolySynth.ts @@ -10,6 +10,7 @@ import { MetalSynth, MetalSynthOptions } from "./MetalSynth"; import { Monophonic } from "./Monophonic"; import { Synth, SynthOptions } from "./Synth"; import { warn } from "../core/util/Debug"; +import { OfflineContext } from "../core/context/OfflineContext"; type VoiceConstructor = { getDefaults: () => VoiceOptions; @@ -193,7 +194,9 @@ export class PolySynth = Synth> extends Instrument const firstAvail = this._availableVoices.shift() as Voice; const index = this._voices.indexOf(firstAvail); this._voices.splice(index, 1); - firstAvail.dispose(); + if (!(this.context instanceof OfflineContext)) { + firstAvail.dispose(); + } } }