the gamedesigninitiative at cornell university Lecture 15 Game Audio

Similar documents
For Mac and iphone. James McCartney Core Audio Engineer. Eric Allamanche Core Audio Engineer

Export Audio Mixdown

Chapter 5.5 Audio Programming

ITP 342 Mobile App Dev. Audio

Fundamental of Digital Media Design. Introduction to Audio

Recording Studio User Manual

UNDERSTANDING MUSIC & VIDEO FORMATS

Digital Audio Basics

Level Editor. Should be stable (as of Sunday) Will be updating the source code if you want to make tweaks to it for your final

Completing the Multimedia Architecture

Streaming Media. Advanced Audio. Erik Noreke Standardization Consultant Chair, OpenSL ES. Copyright Khronos Group, Page 1

Skill Area 214: Use a Multimedia Software. Software Application (SWA)

Lecture #3: Digital Music and Sound

Audio for Everybody. OCPUG/PATACS 21 January Tom Gutnick. Copyright by Tom Gutnick. All rights reserved.

Super UA Q&A 2015/03/16

Compressed Audio Demystified by Hendrik Gideonse and Connor Smith. All Rights Reserved.

Delivering an Exceptional Audio Experience

Squeeze Play: The State of Ady0 Cmprshn. Scott Selfon Senior Development Lead Xbox Advanced Technology Group Microsoft

Introduction into Game Programming (CSC329)

WaveLab Pro 9.5 WaveLab Elements 9.5

Introducing Audio Signal Processing & Audio Coding. Dr Michael Mason Senior Manager, CE Technology Dolby Australia Pty Ltd

ITP 342 Mobile App Dev. Audio

5: Music Compression. Music Coding. Mark Handley

WaveLab Pro 9.5 WaveLab Elements 9.5

VS1063 ENCODER DEMONSTRATION

Computing in the Modern World

Reference8 Pro music player Fast Operation Guide

ITNP80: Multimedia! Sound-II!

Optimizing Audio for Mobile Development. Ben Houge Berklee College of Music Music Technology Innovation Valencia, Spain

3.01C Multimedia Elements and Guidelines Explore multimedia systems, elements and presentations.

Audio Compression. Audio Compression. Absolute Threshold. CD quality audio:

Java Sound API Programmer s Guide

About sounds and Animate CC

DigiPen Institute of Technology

OpenMAX AL, OpenSL ES

Lecture 19 Media Formats

Sources:

GUIDELINES FOR THE CREATION OF DIGITAL COLLECTIONS

Using Sweep: Fun with Scrubby

CHAPTER 10: SOUND AND VIDEO EDITING

Multimedia applications

Sometimes dreams come true

ZED / Sonar Trouble shooter

Audio Queue Services. Dave

Introducing Audio Signal Processing & Audio Coding. Dr Michael Mason Snr Staff Eng., Team Lead (Applied Research) Dolby Australia Pty Ltd

ENHANCEMENT IMPLEMENTATION ON

CS 4455: Video Game Design & Implementation

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL II)

What s New in Audio. Media #WWDC17. Akshatha Nagesh, AudioEngine-eer Béla Balázs, Audio Artisan Torrey Holbrook Walker, Audio/MIDI Black Ops

CAPTURING AUDIO DATA FAQS

3 Sound / Audio. CS 5513 Multimedia Systems Spring 2009 LECTURE. Imran Ihsan Principal Design Consultant

Amazing Audacity: Session 1

TEAC HR Audio Player. Music Playback Software for TEAC USB AUDIO DAC Devices OWNER S MANUAL

Digital Audio. Amplitude Analogue signal

QUICKSTART GUIDE ENGLISH ( 3 9 ) MANUAL DE INICIO RÁPIDO ESPAÑOL ( ) GUIDE D UTILISATION RAPIDE FRANÇAIS ( )

Design Brief CD15 Prisma Compact Disc and Digital Music Player

Memory Management: High-Level Overview

AAMS Auto Audio Mastering System V3 Manual

Audio issues in MIR evaluation

TEAC HR Audio Player. Music Playback Software for TEAC USB AUDIO DAC Devices OWNER S MANUAL

Contents. Introduction 7. What Is Core Audio? 10. Core Audio Essentials 19. Organization of This Document 8 See Also 8

2.1 Transcoding audio files

Design Brief CD35 Prisma Compact Disc and Digital Music Player

Selection tool - for selecting the range of audio you want to edit or listen to.

08 Sound. Multimedia Systems. Nature of Sound, Store Audio, Sound Editing, MIDI

GUIDELINES FOR THE CREATION OF DIGITAL COLLECTIONS

Sounding Better Than Ever: High Quality Audio. Simon Forrest Connected Home Marketing

计算原理导论. Introduction to Computing Principles 智能与计算学部刘志磊

_APP B_549_10/31/06. Appendix B. Producing for Multimedia and the Web

USER GUIDE FOR PREDICTION ERROR METHOD OF ADAPTIVE FEEDBACK CANCELLER ON ios PLATFORM FOR HEARING AID APPLICATIONS

Embedding Audio into your RX Application

DIGITIZING ANALOG AUDIO SOURCES USING AUDACITY

Core Audio. MSDOSX : Lecture 20

Parametric Coding of Spatial Audio

Aud-X 5.1 Help.

CS 074 The Digital World. Digital Audio

X3M. ExcelValley. MIDI + USB Sound Module: Supports hardware wavetable synthesis + audio. playback, multifunctional MIDI DIN connector.

Audio over IP devices System description Ed 2.0

Be sure you have Audacity AND the LAME Encoder installed. Both are available in the Software Installation Center.

A project is the basic file type in Cubase, in the same way that a document is the basic file type in Microsoft Word.

Preparing Music and Narration for AV s

Multimedia Technology

OWNER S MANUAL. 1 Overview

Multi-Room Music Servers

Design Brief SC15 Prisma

Introducing working with sounds in Audacity

VLSI Solution. VS10XX - Plugins. Plugins, Applications. Plugins. Description. Applications. Patches. In Development. Public Document.

GETTING STARTED WITH DJCONTROL INSTINCT AND DJUCED UK US

Windows Accessories Menu Volume Settings and Windows Media Player

Mul$media Techniques in Android. Some of the informa$on in this sec$on is adapted from WiseAndroid.com

HTML 5 and CSS 3, Illustrated Complete. Unit K: Incorporating Video and Audio

AET 1380 Digital Audio Formats

REVIEW: PROCEDURES FOR PRODUCING AUDIO

Lecture 16 Perceptual Audio Coding

AudioTools AWE. User Manual

OneClick Video Converter Free Version

Apple Core Audio Format Specification 1.0

Revision 4.1.x /2.x.x [ ] Creating Media for Modulo Player & Kinetic

Principles of Audio Coding

MULTIMEDIA APPLICATIONS I ARKANSAS CAREER AND TECHNOLOGY EDUCATION, BUSINESS/MARKETING TECHNOLOGY, MULTIMEDIA APPLICATIONS I

Transcription:

Lecture 15

The Role of Audio in Games Engagement Entertains player Music/Soundtrack Enhances realism Sound effects Establishes atmosphere Ambient sounds Or reasons? 2

The Role of Audio in Games Feedback Indicate off-screen action Indicate player should move Highlight on-screen action Call attention to an NPC Increase reaction time Players react to sound faster Or reasons? 3

History of Sound in Games Basic Sounds Arcade games Early handhelds Early consoles 4

Early Sounds: Wizard of Wor 5

History of Sound in Games Basic Sounds Recorded Sound Samples Arcade games Early handhelds Early consoles Starts w/ MIDI 5 th generation (Playstation) Early PCs 6

History of Sound in Games Basic Sounds Recorded Sound Samples Some Variability of Samples Arcade games Early handhelds Early consoles Starts w/ MIDI 5 th generation (Playstation) Early PCs Sample selection Volume Pitch Stereo pan 7

History of Sound in Games Basic Sounds Recorded Sound Samples Some Variability of Samples More Variability of Samples Arcade games Starts w/ MIDI Sample selection Multiple samples Early handhelds 5 th generation Volume Reverb models Early consoles (Playstation) Pitch Sound filters Early PCs Stereo pan Surround sound 8

The Technical Challenges Sound formats are not (really) cross-platform It is not as easy as choosing MP3 Android, ios favor different formats Sound playback APIs are not standardized CUGL is a layer over many different APIs So behavior is not same on all platforms Sound playback crosses frame boundaries Mixing sound with animation has challenges 9

File Format vs Data Format File Format The data storage format Has data or than audio Many have many encodings.caf holds MP3 and PCM Examples:.mp3,.wav.aac,.mp4,.m4a (Apple).flac,.ogg (Linux) Data Format The actual audio encoding Basic audio codec Bit rate (# of bits/unit time) Sample rate (digitizes an analog signal) Examples: MP3, Linear PCM AAC, HE-AAC, ALAC FLAC, Vorbis 10

Data Formats and Platforms Format Description ios Android MP3 You know what this is Yes Yes (HE-)AAC A lossy codec, Apple s MP3 alternative Yes Yes Linear PCM Completely uncompressed sound Yes Yes MIDI NOT SOUND; Data for an instrument Yes Yes Vorbis Xiph.org s alternative to MP3 No Yes ALAC Apple s lossless codec (but compressed) Yes No FLAC Xiph.org s alternative lossless codec No Yes ilbc Internet low bit-rate codec (VOIP) Yes No IMA4 Super compression for 16 bit audio Yes No µ-law Like PCM, but optimized for speech Yes No 11

The Associated File Formats Format MP3 (HE-)AAC Linear PCM MIDI File Types.mp3.aac,.mp4,.m4a.wav.mid Any or file format is not cross-platform Apple/iOS is pushing.caf file Stands for Core Audio Format Supports MP3, (HE-)AAC, PCM, ALAC, etc But not cross-platform 12

The Associated File Formats Format MP3 (HE-)AAC Linear PCM MIDI File Types.mp3.aac,.mp4,.m4a.wav.mid Uncompressed Limited support due to patent issues Any or file format is not cross-platform Apple/iOS is pushing.caf file Stands for Core Audio Format Supports MP3, (HE-)AAC, PCM, ALAC, etc But not cross-platform 13

Linear PCM Format Sound data is an array of sample values 0.5 0.2-0.1 0.3-0.5 0.0-0.2-0.2 0.0-0.6 0.2-0.3 0.4 0.0 A sample is an amplitude of a sound wave Values are normalized -1.0 to 1.0 (so y are floats) 14

Linear PCM Format Sound data is an array of sample values 0.5 0.2-0.1 0.3-0.5 0.0-0.2-0.2 0.0-0.6 0.2-0.3 0.4 0.0 A sample is an amplitude of a sound wave Values Sometimes are normalized encoded as -1.0 shorts to 1.0 or bytes (so y MIN are to floats) MAX 15

Linear PCM Format Sound data is an array of sample values 0.5 0.2-0.1 0.3-0.5 0.0-0.2-0.2 0.0-0.6 0.2-0.3 0.4 0.0 Magnitude of amplitude is volume 0 is lowest volume (silence) 1 is maximum volume of sound card Multiply by number 0 to 1 to change global volume 16

Linear PCM Format Sound data is an array of sample values 0.5 0.2-0.1 0.3-0.5 0.0-0.2-0.2 0.0-0.6 0.2-0.3 0.4 0.0 Magnitude of amplitude is volume 0 is lowest volume (silence) 1 is maximum volume of sound card Multiply by number 0 to 1 to change global volume 17

Linear PCM Format Samples are organized into (interleaved) channels 0.5 0.2-0.1 0.3-0.5 0.0-0.2-0.2 0.0-0.6 0.2-0.3 0.4 0.0 frame Each channel is essentially a speaker Mono sound has one channel Stereo sound has two channels 5.1 surround sound is six channels A frame is set of simultaneous samples Each sample is in a separate frame 18

Linear PCM Format The sample rate is frames per second 1 second # frames Example: 0.5 seconds of stereo at 44.1 khz 0.5 s * 44100 f/s = 22050 frames 2 samples/frame * 22050 frames = 44100 samples 4 bytes/sample * 44100 samples = 176.4 kbytes 1 minute of stereo CD sound is 21 MB! 19

Playing Sound Directly PCM data buffer Game Loop Sound Card 20

Playing Sound Directly Write PCM chunk to buffer PCM data buffer Game Loop Sound Card 21

The Latency Problem Buffer is really a queue Output from queue front Playback writes to end Creates a playback delay Latency: amount of delay Some latency must exist Okay if latency framerate Android latency is 100 ms! Buffering is a necessary evil Keeps playback smooth Allows real-time effects delay Sound Source Playback Buffer Sound Card 22

Playing Sound Directly Write PCM chunk to buffer PCM data buffer Game Loop Sound Card Choice of buffer size is important! Too large: long latency until next sound plays Too small: buffers swap too fast, causing audible pops 23

How Streaming Works All sound cards only play PCM data Or files (MP3 etc.) are decoded into PCM data But data is paged-in like memory in an OS This is how OGG support was added to CUGL Sound File Streaming Buffer Sound Engine Append PCM Page Retrieve PCM Page 24

How Streaming Works Sound File Streaming Buffer Sound Card Page size set by file format Chunk size set by audio API Sound: Sound asset that is preloaded as full PCM Music: Sound asset that is streamed as PCM pages 25

Handling Multiple Sounds PCM Data PCM Data Literally! PCM Data PCM Data Sound Card PCM Data 26

Handling Multiple Sounds PCM Data PCM Data PCM Data PCM Data PCM Data Literally! Sound Card Can create values outside of -1 to 1 This causes clipping/distortion Common if many simultaneous sounds Audio engineer must balance properly 27

We Want Something Simpler! Want ability to play and track sounds Functions to load sound into card buffer Functions to detect if sound has finished Want ability to modify active sounds Functions for volume and pitch adjustment Functions for stereo panning (e.g. left/right channels) Functions to pause, resume, or loop sound Want ability to mix sounds toger Functions to add toger sound data quickly Background process for dynamic volume adjustment 28

We Want Something Simpler! Want ability to play and track sounds Functions to load sound into card buffer Functions to detect if sound has finished Want ability to modify active sounds Functions for volume and pitch adjustment Functions for stereo panning (e.g. left/right channels) Functions to pause, resume, or loop sound This is purpose of a sound engine Want ability to mix sounds toger Functions to add toger sound data quickly Background process for dynamic volume adjustment 29

OpenAL Cross-Platform Sound Engines Created in 2000 by Loki Software for Linux Was an attempt to make a sound standard Loki went under; last stable release in 2005 Apple supported, but HARD deprecated in ios 9 FMOD/WWISE Industry standard for game development Mobile support is possible but not easy Not free; but no cost for low-volume sales 30

Proprietary Sound Engines Apple AVFoundation API to support modern sound processing Mainly designed for music/audio creation apps But very useful for games and playback apps OpenSL ES Directed by Khronos Group (OpenGL) Substantially less advanced than or APIs Really only has support in Android space 31

What about SDL? CUGL is on top of SDL SDL has its own audio API Works on all platforms But re are many problems Mixer is ancient (only one update since 2009) The 2017 update is horrible and broke everything No real hardware optimizations at all Significant audio delay due to buffer strategy 32

Solution: Cross-Platform Wrappers AudioEngine: Wrapper to hide platform OS X, ios: AVFoundation Windows: XAudio2 (similar to AVFoundation) Android: OpenSL ES Linux/Or: SDL Audio Limited by most primitive API In this case SDL Audio (or OpenSL ES) Result is an last-gen sound API 33

Solution: Cross-Platform Wrappers AudioEngine: Wrapper to hide platform OS X, ios: AVFoundation Windows: XAudio2 (similar to AVFoundation) Actually, all but Apple use SDL Android: OpenSL ES Linux/Or: SDL Audio Limited by most primitive API In this case SDL Audio (or OpenSL ES) Result is an last-gen sound API 34

Playing a Sound Playback may include multiple sounds Sounds may play simultaneously (offset) Simultaneous sounds may be same asset Asset (source) vs. Instance (playback) Playback crosses frame boundaries It may span multiple animation frames Need to know when it stops playing May need to stop (or pause) it early 35

Classic Model: Channels Channel Channel Channel Mixer Channel Channel 36

Classic Model: Channels Channel Channel Channel Engine has fixed number of channels (historically 24) Mixer Channel Channel 37

Classic Model: Channels Channel Channel Channel Channel Sound Engine has fixed number of channels (historically 24) Load sound into channel to play it Mixer 38

Classic Model: Channels Channel Channel Channel Channel Sound Engine has fixed number of channels (historically 24) Load sound into channel to play it Mixer 39

Playing a Sound with Channels Request a sound channel for your asset If none is available, sound fails to play Orwise, it gives you an id for a channel Load asset into channel (but might stream) Play sound channel Playing is a property of channel, not asset Channel has or properties, like volume Release channel when sound is done This is usually done automatically 40

Application Design Channel Channel Channel Channel Sound Need to remember channel id Mixer 41

Stopping Sounds Would like to know when a sound is finished To free up channel (if not automatic) To stop any associated animation To start a follow-up sound Two main approaches Polling: Call an isplaying() method/function Callback: Pass a function when play AudioEngine only allows polling approach 42

SDL Mixer API /** * @return channel id for sound playback * * If no channel is available, returns -1 * @param channel The requested channel (-1 for first available) * @param chunk The PCM data (WAV or stream page) * @param loops The number of times to loop sound */ int Mix_PlayChannel(int channel, Mix_Chunk *chunk, int loops); int Mix_HaltChannel(int channel); int Mix_FadeOutChannel(int channel, int ms); int Mix_Volume(int channel, int volume); void Mix_Playing(int channel); Need to remember channel id 43

Why This is Undesirable Tightly couples architecture to sound engine All controllers need to know this channel id Playback must communicate id to all controllers Instances usually have a semantic meaning Example: Torpedo #3, Ship/crate collision Meaning is independent of channel assigned Would prefer to represent m by this meaning Solution: Refer to instances by keys 44

The AudioEngine Alternative /** * Plays given sound as a sound effect (paging out as necessary) * * @param key reference key for sound effect * @param sound sound effect file to play * @param loop Wher to loop indefinitely * @param volume The sound volume */ void playeffect(string key, const std::shared_ptr<sound>& sound); void stopeffect(string key); void seteffectvolume(string key, float volume); void geteffectstate(string key); Refer to instance logically 45

Problem with Channel Model All controls are embedded in channel Example: Volume, looping, play position Restricted to a predetermined set of controls Modern games want custom sound-processing User defined sound filters (low pass, reverb) Advanced equalizer support Support for surround and 3D sound Procedural sound generation 46

DSP Processing: The Mixer DAG Source Effect Effect Mixer Source Effect Effect Source Source Mixer Effect Main Mixer 47

DSP Processing: The Mixer DAG Source Effect Effect Mixer Source Effect Effect Source Source Mixer Effect Main Mixer Channel model is a special case of this DAG 48

Example: UDK Kismet 49

AVFoundation Implementation Load with file or PCM data AVAudioPlayerNode AVAudioPlayerNode AVAudioNode AVAudioNode AVAudioMixerNoder 50

AVAudioUnitEQ Provided AVAudioNodes Support for equalizer and low pass/high pass filters AVAudioUnitDistortion Support for custom distortion effects AVAudioUnitReverb Support for custom reverb effects AVAudioEnvironmentNode Support for positional and 3D audio 51

Positional Audio: Surround Sound Sub Left Front Center Right Front Left Surround Player Right Surround 52 Left Rear Surround Right Rear Surround

Positional Audio: Surround Sound Sub Left Front Center Right Front Left Surround Right Surround 53 Left Rear Surround Right Rear Surround

Positional Audio: Surround Sound Sub Left Front Center Right Front Original source must be mono to work properly Left Surround Right Surround 54 Left Rear Surround Right Rear Surround

AVAudioEnvironmentNode API Property position listenerposition listenervectororientation obstruction occlusion reverbblend renderingalgorithm Description Location of sound source Location of listener Facing orientation of listener # decibels to reduce sound from source (Affects direct sound, but not reverb) # decibels to reduce sound from source (Affects direct sound, but not reverb) Amount reverb to add to scene The type of rendering algorithm to use 55

AVAudioEnvironmentNode API Property Description position Location of sound source listenerposition Location of listener listenervectororientation Facing orientation of listener obstruction # decibels to reduce sound from source Does not (Affects direct sound, but not reverb) occlusion compute # decibels to reduce sound from source physics (Affects direct sound, but not reverb) reverbblend Amount reverb to add to scene renderingalgorithm The type of rendering algorithm to use 56

Modeling Sound Environments Must compute obstacle/occlusion values separately 57

Advanced: Reverb Calculations Uses audio raytracing Also material reflection No AVFoundation support 58

Advanced: Reverb Calculations Uses audio raytracing Also material reflection No AVFoundation support Area of active development in AAA games 59

AVAudioEnvironmentNode API Property position listenerposition listenervectororientation obstruction occlusion reverbblend renderingalgorithm Description Location of sound source Location of listener Facing orientation of listener # decibels to reduce sound from source (Affects direct sound, but not reverb) So what # decibels does to reduce sound from source this actually (Affects do? direct sound, but not reverb) Amount reverb to add to scene The type of rendering algorithm to use 60

AVAudio3DMixingRenderingAlgorithm AVAudio3DMixingRenderingAlgorithmStereoPassThrough Turns off positional rendering and uses source encoding AVAudio3DMixingRenderingAlgorithmEqualPowerPanning Pans volume across two stereo channels AVAudio3DMixingRenderingAlgorithmSoundField Positional audio for surround sound AVAudio3DMixingRenderingAlgorithmSphericalHead Binaural synsis assuming a spherical head AVAudio3DMixingRenderingAlgorithmHRTF Binaural synsis with Head Related Transfer Function 61

Positional sound is fakey Essentially volume control Cannot pinpoint source Goal: realistic perception Track sound parallax Account for shape of head Limited to headphones Cannot do speakers (yet) Example: Papa Sangre Binarual Synsis 62

Example: Papa Sangre 63

Summary Audio design is about creating soundscapes Music, sound effects, and dialogue Combining sounds requires a sound engine Cross-platform support is a problem Licensing issues prevent a cross-platform format Very little standardization in sound APIs Best engines use digital signal processing (DSP) Mixer graph is a DAG supporting sound effects Some limited support for positional audio 64