O'Reilly logo

SFML Essentials by Milcho G. Milchev

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

sf::SoundSource and audio in 3D

As discussed earlier, the Sound and SoundStream classes are derived from SoundSource. First we will talk about some general features, and then give examples of how to use sound spatialization (in other words, 3D sounds).

Common audio features

As we create more and more complex scenes, we want more from our sounds and music. For example, some sounds might be louder than others, and we would like to lower their volume when we play them in the game. We can do that with SoundSource::setVolume(). The supported volume values are from 0 (mute) to 100 (full volume), and every sound source starts with a default value of 100. We can get the current volume with SoundSource::getVolume().

Another characteristic of sound is pitch. ...

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