Sounds in 3D space
The most interesting part about sound effects is yet to come. An immersive atmosphere only builds up if sounds are properly located within the game world. Like graphical objects, sounds can have a position.
The coordinate system for sounds is three-dimensional. SFML's sound API works with the sf::Vector3f type, a 3D vector with the members x, y, and z. SFML internally uses Open Audio Library (OpenAL), an interface for low-level audio functionality, which is also the origin of the sound spatialization concepts we are going to discuss here.
Spatializing sounds means nothing more than to locate them in the 3D space, that is, to give them a spatial representation.
The listener
The audition of spatial sound effects depends on the listener. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access