Chapter 9. Cranking Up the Bass – Music and Sound Effects
Since the beginning of video games, sound has been a central media in games. Many games can be recognized only by listening to them. In the last few years, game industries have chosen to neglect audio in favor of better graphics; yet audio takes a very important part in a wide range of games. Independent studios in particular often put a huge effort in making games unique in their art style, which includes audio, graphics, and story. If used appropriately, music themes and sounds can have a tremendous impact on the atmosphere conveyed by a game.
In this chapter, we are going to cover the technical background of embedding audio into a game, taking the opportunity to have a closer look at SFML's Audio module. We are going to do the following:
Play different music themes in the background
Play sound effects that correspond to game events such as explosions
Position sound effects in the 2D world to convey a feeling of spatial sound