bitbrain / scope

A 3D space network arena shooter
GNU General Public License v2.0
1 stars 0 forks source link

Create sound manager #34

Closed bitbrain closed 8 years ago

bitbrain commented 8 years ago

This manager handles music and sound by listening to game events.

This manager should also support 3D sounds by changing pitch, panning and volume properly, depending on where the camera currently is.

Calculating panning

Here is speudo code to calculate the panning value of each audio effect:

vec3 side = cross(listener.up, listener.look_at);
side.normalize();
float x = dot(source.position - listener.position, side);
// You can now use this value to determine the pan, e.g. by using a linear mapping:
float pan = clamp(x / max_pan_distance, -1, 1);