Skip to content

Fix audio panning#1940

Merged
oy merged 2 commits intoteeworlds:masterfrom
Speedy-Consoles:master
Jan 2, 2019
Merged

Fix audio panning#1940
oy merged 2 commits intoteeworlds:masterfrom
Speedy-Consoles:master

Conversation

@Speedy-Consoles
Copy link
Copy Markdown
Contributor

Closes #1939.
The big mistake seems to be using Dist instead of dx in

if(dx < 0)
	a -= (Dist/m_MaxDistance)/2.0f;
else
	a += (Dist/m_MaxDistance)/2.0f;

I also don't see a reason to use the sine here.

@msiglreith
Copy link
Copy Markdown
Contributor

The big mistake seems to be using Dist instead of dx in

yeap, my bad.

I also don't see a reason to use the sine here.

grafik
Yield those graphs, which should result in a constant perceived sound volume (squares of gains) independent of the position (pan more to left or right speaker) excluding the linear distance based falloff

@Speedy-Consoles
Copy link
Copy Markdown
Contributor Author

I see, but shouldn't we be using square-law panning instead of sine-law panning, so the "perceived sound volume" of each channel is still linear with dx? I think sine-law panning would make sense, if we were using an angle as pan value, but we're using a distance.

@msiglreith
Copy link
Copy Markdown
Contributor

I'm not aware of an additional property which would justify sqrt or sin/cos over the other. I guess it boils down to preference of the listener here, but I'm no audio engineer so I'm fine with both.

@Speedy-Consoles
Copy link
Copy Markdown
Contributor Author

I'm no audio engineer either, but i'm pretty sure it should be the square root instead. The difference in both would be, whether your pan value is proportional to the angle or the x coordinate of the sound source. The latter is the case here.

@oy oy merged commit d6cb666 into teeworlds:master Jan 2, 2019
@teetow
Copy link
Copy Markdown
Contributor

teetow commented Jan 6, 2019

Quick comment: Our design was that on-screen sounds should play more or less centered, with a "dead zone" around the player that should roughly cover the screen. As soon as a source leaves the screen, th panning should become noticeable.

Dunno what has been done to the game since, but I always thought that design made sense.

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

Successfully merging this pull request may close these issues.

4 participants