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

Basics of SFML sound

Anything audio related falls into one of two categories within SFML: sf::Sound that represents short sound effects, or sf::Music that is used to play longer audio tracks. It's prudent that we understand how these two classes are used before continuing further. Let's talk about each one individually.

Playing sounds

The sf::Sound class is extremely lightweight and should only ever be used to play short sound effects that don't take up a lot of memory. The way it stores and utilizes actual audio files is by using a sf::SoundBuffer instance. It is analogous to sf::Sprite and the way it uses an instance of sf::Texture for drawing. The sf::SoundBuffer is used to hold audio data in memory, which the sf::Sound class then reads and plays ...

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