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. ...
Get SFML Game Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.