-
Notifications
You must be signed in to change notification settings - Fork 33
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
StereoPannerNode sums input signal and outputs incorrect value #647
Comments
It took me a while to realize it but this is actually caused by a known limitation. The StereoPannerNode for Safari is implemented in a way which requires the number of channels of the input signal to be known. Therefore the Could you work around that limitation and set the channelCount in your code? |
I think i could work with that limitation, i'm still a little confused about how i get the desired output. When i used your suggestion, i still get sig.channelCount = 1;
sig.channelCountMode = "explicit"; I updated that codesandbox to illustrate the updated behavior. |
Oh, sorry. My bad. The channelCount needs to be set on the |
Updated to setting the panner to channelCount = 1 and channelCountMode = 'explicit' and i get correct values: https://codesandbox.io/s/stereo-panner-sum-issue-zpm0u It does seem counter intuitive to me that the stereo panner would be set to channelCount = 1 and then output a stereo output. Does channelCount and channelCountMode dictate only how 'input' connections are handled internally? i thought they also define the output channelCount. |
Yes I totally agree that it is not so intuitive. The The output will always have two channels. There is no way to configure that. I think the spec only indirectly says what I tried to summarize above. But it does say: "This attribute has no effect for nodes with no inputs." about the |
This solution is working for me in both std-audio-context and the native AudioContext. going to close. thanks for your help! |
i've found a case where setting the channelCountMode and channelCount in such a way introduces a new issue. This is related to Tonejs/Tone.js#609. If you chain two StereoPannerNodes, the panning of the first one is no longer respected. Here's an example: https://codesandbox.io/s/std-issue-647-kmysk If you remove the channelCount and channelCountMode it works as expected. Let me know what you think is the best way to deal with this. |
I think the behavior is correct. The first I hope this helps. Let me know if I misunderstood something. |
Right the behavior does seem like the expected one to me as well. My question is that i had added this line to Panner.ts in Tone.js to solve for the original bug, but now that same behavior has introduced this strange side effect that you can't chain two panners. I think if i remove that line, then i'll reintroduce this bug into Tone.js, but if i keep it then Panner is not chainable with itself. |
Does it work if you set the |
When i set it to 2, it reintroduces the original channel summing issue You can see this behaves differently if you're using standardized-audio-context vs when you're using Chrome's AudioContext. |
Ah, I see. Sorry that was a stupid idea. Would it work for Tone.js if the user has to make that decision? Only the user knows what is connected to the Panner. Otherwise we would have to do some tracing to identify the input. |
Hi @tambien, given that you closed the related issue, can we close this as well? |
sure! i think the current solution is a bit of a bandaid, but seems like the issue won’t be fully resolved until safari implements the stereo panner node natively. |
Here's a minimal example using standardized-audio-context.
When you run this with the raw AudioContext it outputs:
But with stdAudioContext you get:
It seems like the ConstantSourceNode is getting connected twice in the input channel which makes the output be input * 2. At
pan = 0
, the output is 1 and 1 in both channels where it should be closer to 0.707 in both channels.The text was updated successfully, but these errors were encountered: