Game Development Reference
Audio module - overview
Until now, we have so far only used the window, graphics, and system modules of SFML.
The window module handles native OS windows as well as the features associated with
them. The graphics module makes it easy for us to draw objects on the screen. The system
module holds the vector classes as well as encapsulating the features of an OS behind com-
mon classes such as the Clock and Time classes, which deal with time.
There are two more modules inside SFML—audio and network. We will talk about the net-
work module in the last chapter of this topic. This chapter is mostly dedicated to the audio
module and its features.
The most important classes in this module are sf::Sound and sf::Music . They give
us a way to play sounds and music. There is also a feature which allows you to play 3D
sounds, which means that the sounds are played from different directions depending on the
listener's position and orientation. We will explore all of these features in depth in this
chapter. There are a few more things that the module contains, which are beyond the scope
of this topic, such as the SoundRecorder class, which can record sounds from an input
device (a microphone for example).
That being said, we are now ready to start with the audio module. The first thing that we
need to talk about is the fact that there are two different classes through which you can play
audio—the Sound and the Music class. From the outside, it seems that they are doing the
same thing—playing an audio file; however, as the saying goes "Don't judge a topic by its