diff --git a/Tone/component/channel/Panner.test.ts b/Tone/component/channel/Panner.test.ts index ae7b05b6b..de5dd5f3b 100644 --- a/Tone/component/channel/Panner.test.ts +++ b/Tone/component/channel/Panner.test.ts @@ -67,5 +67,20 @@ describe("Panner", () => { expect(r[0]).to.be.closeTo(0.707, 0.01); }); }); + + it("can chain two panners when channelCount is 2", () => { + return Offline(() => { + const panner1 = new Panner({ + channelCount: 2, + }).toDestination(); + const panner0 = new Panner(-1).connect(panner1); + new Signal(1).connect(panner0); + }, 0.1, 2).then((buffer) => { + const l = buffer.toArray()[0]; + const r = buffer.toArray()[1]; + expect(l[0]).to.be.closeTo(1, 0.01); + expect(r[0]).to.be.closeTo(0, 0.01); + }); + }); }); }); diff --git a/Tone/component/channel/Panner.ts b/Tone/component/channel/Panner.ts index f306755dd..f660823f9 100644 --- a/Tone/component/channel/Panner.ts +++ b/Tone/component/channel/Panner.ts @@ -6,6 +6,7 @@ import { readOnly } from "../../core/util/Interface"; interface TonePannerOptions extends ToneAudioNodeOptions { pan: AudioRange; + channelCount: number; } /** @@ -55,7 +56,7 @@ export class Panner extends ToneAudioNode { // this is necessary for standardized-audio-context // doesn't make any difference for the native AudioContext // https://github.com/chrisguttandin/standardized-audio-context/issues/647 - this._panner.channelCount = 1; + this._panner.channelCount = options.channelCount; this._panner.channelCountMode = "explicit"; // initial value @@ -65,6 +66,7 @@ export class Panner extends ToneAudioNode { static getDefaults(): TonePannerOptions { return Object.assign(ToneAudioNode.getDefaults(), { pan: 0, + channelCount: 1, }); }