O'Reilly logo

SFML Game Development By Example by Raimondas Pupius

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sound spatialization

Both sf::Sound and sf::Music also support spatial positioning. It takes advantage of left and right audio channels and makes it feel like the sound is actually playing around you. There is a catch, though. Every sound or music instance that is desired to be spatial has to only have a single channel. It is more commonly known as a monophonic or mono sound, as opposed to stereo that already decides how the speakers are used.

The way sounds are perceived in three-dimensional space is manipulated through a single, static class: sf::Listener. It's static because there can only ever be one listener per application. The main two aspects of this class we're interested in are the position and direction of the listener. Keep in mind ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required