Presentation is loading. Please wait.

Presentation is loading. Please wait.

Game Programming Algorithms and Techniques

Similar presentations


Presentation on theme: "Game Programming Algorithms and Techniques"— Presentation transcript:

1 Game Programming Algorithms and Techniques
Chapter 6 Sound

2 Chapter 6 Objectives Basic Sound
Learn the difference between source data and sound cues Creating switches to select from different sets of sounds 3D Sounds Placing the listener in the world Surround sound principles Digital Signal Processing Basic DSP effects How to mark regions Other Topics What's the Doppler effect, and how is it used in games? Difference between sound occlusion and obstruction

3 Source Data Original audio files created by sound designer.
File formats: Sound effects generally use uncompressed formats such as WAV. Music/dialogue is usually compressed with MP3 or OGG. Two ways sounds can be played: Loaded fully into memory (usually for small files). Streamed off of the disk (for larger files).

4 Sound Cue Maps to one or more source data files
Says how or when particular source data should play What's triggered by gameplay code

5 Sound Cue Example: Explosion
Explosion sound cue

6 Storing Sound Cue Data One possibility is JSON. Here’s an example: {
"name": "explosion", "falloff": 150, "priority": 10, "sources": [ "explosion1.wav", "explosion2.wav", "explosion3.wav" ] }

7 Basic Sound Cue Class Would correspond to the type of data in a basic cue class SoundCue string name int falloff int priority // List of strings of all the sources List sources; function Play() // Randomly select from sources and play ... end

8 Sound Switch Suppose we have different footstep sounds depending on the surface the character walks on. We want to be able to switch between different sets of sounds, depending on surface. To do this, we need a switch.

9 Sound Cue Data w/ Switch
{ "name": "footstep", "falloff": 25, "priority": "low", "switch_name": "foot_surface", "sources": [ "switch": "sand", "fs_sand1.wav", "fs_sand2.wav", "fs_sand3.wav" ] }, "switch": "grass", "fs_grass1.wav", "fs_grass2.wav", "fs_grass3.wav" }

10 Sound Cue Class w/ Switch
interface ISoundCue function Play() end class SwitchableSoundCue implements ISoundCue string name int falloff int priority string switch_name // Hash Map that stores (string,List) pairs // For example ("sand", ["fs_sand1.wav", "fs_sand2.wav", // "fs_sand3.wav"]) HashMap sources // Grab the current value for switch_name // Lookup list in the hash map and randomly play a sound ...

11 3D Sounds A listener is what hears a sound:
Think of it as a virtual microphone in the world. An emitter is what emits a sound: For instance, a fireplace would have an emitter that emits the sound of crackling fire.

12 Listener/Emitter Diagram
Sound listener and emitter; in this case, the sound effect should be heard on the right.

13 Listener Position FPS – At the camera Cutscene – At the camera
Third person – Not always at the camera!

14 Listener position in a third-person game.

15 Falloff How volume of a sound decreases as it gets further from the listener. Decibel Unit of sound measurement Logarithmic scale The falloff will depend on the sound—an explosion would have less of a falloff than a footstep.

16 A standard 5.1 surround sound speaker configuration
A "5.1" system may be configured like so: A standard 5.1 surround sound speaker configuration

17 Digital Signal Processing
Takes sound data and transforms it at runtime Common effects: Reverb (echo) Pitch shift (increase/decrease frequency) Compressor (reduce dynamic range of sound volume levels) Low-pass filter (reduce volume of high-pitch sounds)

18 Doppler Effect As a sound emitter approaches towards the listener, the pitch increases. As it goes away, the pitch decreases.

19 Sound Occlusion/Obstruction
Sound has to travel through wall (or other material) to reach listener. Reduction of high-frequency volumes. Obstruction Sound travels around an object to reach a listener. Causes interaural time difference (sound arrives in each ear at a different time). Fresnel Acoustic Diffraction Used to determine whether a sound is occluded or obstructed.

20 Sound Occlusion/Obstruction, Cont'd
Sound occlusion (a), sound obstruction (b), and Fresnel acoustic diffraction (c)


Download ppt "Game Programming Algorithms and Techniques"

Similar presentations


Ads by Google