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 ...
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