Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintaining stereo when connecting channels #808

Closed
ChristofferGylin opened this issue Dec 14, 2020 · 3 comments
Closed

Maintaining stereo when connecting channels #808

ChristofferGylin opened this issue Dec 14, 2020 · 3 comments

Comments

@ChristofferGylin
Copy link

Stereo seems to be lost when connecting a Tone.Channel to another Tone.Channel. I´ve created a small example with two oscillators, each connected to a channel that is hard panned left. One of the those channels goes directly toDestination, and this one functions correctly.

The other one is connected to another Tone.Channel, (with no pan) that goes toDestination, and the pan on this one is lost.

Live example:

https://christoffergylin.com/groovebox/channelStereoTest.html

Code:

let channelToDestination = new Tone.Channel().toDestination();
channelToDestination.pan.value = -1;

let channelToChannel = new Tone.Channel();
channelToChannel.pan.value = -1;

let masterChannel = new Tone.Channel().toDestination();

let oscDestination = new Tone.Oscillator('C3', 'square');
let oscChannel = new Tone.Oscillator('C3', 'square');

oscChannel.connect(channelToChannel);
channelToChannel.connect(masterChannel);

oscDestination.connect(channelToDestination);

I tried using split from the first channel, and then sending just one of the splitted channels into the second channel. If I then have full pan in one direction, I get full volume in both speakers, and if I pan the other direction the volume goes down in both speakers. So it seems that that one split signal is going to both the left and right input on the second channel, and without the split, both outputs from channel 1 is probably going to both inputs on channel 2.

@ChristofferGylin
Copy link
Author

I did some further experimentation with a sample that was allready heavily panned (left-right stereo test) to confirm that stereo was infact lost and not just the pan of previous channels, and yes, all stereo information is gone, everything that goes through a Tone.Channel is mono (If I connect the Tone.Player directly toDestination the sample is panned correctly).

I also tried to connect specific outputs to specific inputs between channels like this:

channelToChannel.connect(masterChannel, 0, 0);
channelToChannel.connect(masterChannel, 1, 1);

But trying to connect from any other output than 0 just gives me "Uncaught DOMException", and trying to connect to any other input than 0 gives me:

"Uncaught DOMException: Failed to execute 'connect' on 'AudioNode': input index (1) exceeds number of inputs (1)."

@tambien
Copy link
Contributor

tambien commented Dec 14, 2020

I believe this is the same issue as #609. The solution is to explicitly pass in channelCount = 2 into Tone.Channel like this: Tone.Channel({channelCount: 2}) so that the Panner knows not to mix it down to mono.

@ChristofferGylin
Copy link
Author

That did the trick! Thank you for the help, and sorry for the inconvenience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants