Skip to content

AudioStreamPlayer3D: Correct amplitude panning #103856

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

Closed
wants to merge 1 commit into from

Conversation

berarma
Copy link
Contributor

@berarma berarma commented Mar 9, 2025

The effective number of speakers was being calculated on uninitialized parameters. It worked by chance for 2 channels, but it fails for more channels.

Before this change the front/center speakers would have less volume and the side speakers would be unbalanced.

I don't have a multiple speaker setup, so my testing is limited to hearing only two channels at a time.

Effective number of speakers calculation for 7.1 before this PR:

channel 0: 4.000000 (front left)
channel 1: 4.000000 ( front right)
channel 2: 4.707107 (center)
channel 3: 3.146447 (rear left)
channel 4: 3.146446 (rear right)
channel 5: 4.000000 (side left)
channel 6: 3.500000 (side right)

And after:

channel 0: 3.853553 (front left)
channel 1: 3.853553 (front right)
channel 2: 4.000000 (center)
channel 3: 3.146447 (rear left)
channel 4: 3.146446 (rear right)
channel 5: 3.500000 (side left)
channel 6: 3.500000 (side right)

@berarma berarma requested a review from a team as a code owner March 9, 2025 10:35
@github-project-automation github-project-automation bot moved this to For team assessment in Audio Issue Triage Mar 9, 2025
@BastiaanOlij BastiaanOlij requested a review from a team March 9, 2025 12:10
@goatchurchprime
Copy link
Contributor

Holy cr#p! That's exactly the bug I found yesterday and was going to do a PR for today.

Were you using #103655 to force the other channels or do you have another method?

The reason it worked in stereo was that it had perpendicular speaker vectors whose dot product was zero.

@berarma
Copy link
Contributor Author

berarma commented Mar 9, 2025

Holy cr#p! That's exactly the bug I found yesterday and was going to do a PR for today.

Were you using #103655 to force the other channels or do you have another method?

The reason it worked in stereo was that it had perpendicular speaker vectors whose dot product was zero.

Wow, that's a coincidence. I came across this accidentally while reading code to understand how multispeaker setups were handled after doing some audio work for my theora seek PR. This code just jumped to sight immediately as a possible obvious mistake.

I had seen your PR when you put it in the chat, and I'm interested, but I didn't follow it. I don't know if it would have helped here. I've just modified the code to output the channels I wanted. But in the end, I relied more on the numbers than the output, just for confirmation that it didn't break.

I had sat on this because I couldn't find any reported issue that I could relate it to. Finally, I could do some tests today, and it confirmed that this was most probably not intended.

I'm definitely interested in some solutions to test different speaker setups. I'll test your PR and comment on it when I can.

@goatchurchprime
Copy link
Contributor

Follow up in Rocket-Chat

@AThousandShips AThousandShips added this to the 4.5 milestone Mar 10, 2025
@akien-mga
Copy link
Member

Superseded by #104853. Thanks for the contribution!

@akien-mga akien-mga closed this Apr 9, 2025
@github-project-automation github-project-automation bot moved this from For team assessment to Done in Audio Issue Triage Apr 9, 2025
@akien-mga akien-mga removed this from the 4.5 milestone Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants