mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-26 19:43:12 +00:00
throws error when polysynth is used with a non monophonic class
fixes #939
This commit is contained in:
parent
3f835efce6
commit
4f5353e7f0
2 changed files with 8 additions and 0 deletions
|
@ -278,6 +278,13 @@ describe("PolySynth", () => {
|
||||||
polySynth.dispose();
|
polySynth.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("throws an error when used without a monophonic synth", () => {
|
||||||
|
expect(() => {
|
||||||
|
// @ts-ignore
|
||||||
|
new PolySynth(PluckSynth);
|
||||||
|
}).throws(Error)
|
||||||
|
});
|
||||||
|
|
||||||
it("can pass in the volume", () => {
|
it("can pass in the volume", () => {
|
||||||
const polySynth = new PolySynth({
|
const polySynth = new PolySynth({
|
||||||
volume: -12,
|
volume: -12,
|
||||||
|
|
|
@ -176,6 +176,7 @@ export class PolySynth<Voice extends Monophonic<any> = Synth> extends Instrument
|
||||||
context: this.context,
|
context: this.context,
|
||||||
onsilence: this._makeVoiceAvailable.bind(this),
|
onsilence: this._makeVoiceAvailable.bind(this),
|
||||||
}));
|
}));
|
||||||
|
assert(voice instanceof Monophonic, "Voice must extend Monophonic class");
|
||||||
voice.connect(this.output);
|
voice.connect(this.output);
|
||||||
this._voices.push(voice);
|
this._voices.push(voice);
|
||||||
return voice;
|
return voice;
|
||||||
|
|
Loading…
Reference in a new issue