Skip to content

Commit

Permalink
Don't dispose the synth in the offline context
Browse files Browse the repository at this point in the history
  • Loading branch information
tambien committed Oct 3, 2019
1 parent 81887b9 commit 70d11f4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Tone/instrument/PolySynth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<V> = {
getDefaults: () => VoiceOptions<V>;
Expand Down Expand Up @@ -193,7 +194,9 @@ export class PolySynth<Voice extends Monophonic<any> = 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();
}
}
}

Expand Down

0 comments on commit 70d11f4

Please sign in to comment.