1 / 20

Game Programming Algorithms and Techniques

Game Programming Algorithms and Techniques. Chapter 6 Sound. 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

rridenhour
Download Presentation

Game Programming Algorithms and Techniques

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Game Programming Algorithms and Techniques Chapter 6 Sound

  2. Chapter 6Objectives • 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 classSoundCue stringname intfalloff intpriority // List of strings of all the sources Listsources; function Play() // Randomly select from sources and play ... end 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", "sources": [ "fs_sand1.wav", "fs_sand2.wav", "fs_sand3.wav" ] }, { "switch": "grass", "sources": [ "fs_grass1.wav", "fs_grass2.wav", "fs_grass3.wav" ] } ] }

  10. Sound Cue Class w/ Switch interfaceISoundCue function Play() end classSwitchableSoundCueimplementsISoundCue stringname intfalloff intpriority stringswitch_name // Hash Map that stores (string,List) pairs // For example ("sand", ["fs_sand1.wav", "fs_sand2.wav", // "fs_sand3.wav"]) HashMapsources function Play() // Grab the current value for switch_name // Lookup list in the hash map and randomly play a sound ... end end

  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 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. Surround Sound A standard 5.1 surround sound speaker configuration A "5.1" system may be configured like so:

  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 • Occlusion • 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)

More Related