12
UFCEKU-20-3 Web Games Programming Web Games Programming Game Sound

UFCEKU-20-3Web Games Programming Game Sound. UFCEKU-20-3Web Games Programming Agenda Motivation for using Sound in Games Typical Game Sound Scenarios

Embed Size (px)

Citation preview

Page 1: UFCEKU-20-3Web Games Programming Game Sound. UFCEKU-20-3Web Games Programming Agenda Motivation for using Sound in Games Typical Game Sound Scenarios

UFCEKU-20-3Web Games Programming

Web Games Programming

Game Sound

Page 2: UFCEKU-20-3Web Games Programming Game Sound. UFCEKU-20-3Web Games Programming Agenda Motivation for using Sound in Games Typical Game Sound Scenarios

UFCEKU-20-3Web Games Programming

Agenda

Motivation for using Sound in Games Typical Game Sound Scenarios Acquiring, Editing and Creating Sound Using Sound in ActionScript 3.0 Techniques for Managing Sound in Games Sound Editing Software

Page 3: UFCEKU-20-3Web Games Programming Game Sound. UFCEKU-20-3Web Games Programming Agenda Motivation for using Sound in Games Typical Game Sound Scenarios

UFCEKU-20-3Web Games Programming

Motivation for using Sound in Games

Sound greatly enhances user’s engagement with game through feedback on game action and events and general ambience.

Sounds include Ambient sound - indicate setting to audience (background sound effects) Event sound - sprite collisions - game start and end music, level sounds (hard

sound effects) Sound effects added to convey the scenario - physical noise footsteps

(foley sound effects) Sound not present in nature and impossible to record such as futuristic sounds

(design sound effects) Sound is either Audio or Music

Audio - digitally sampled sound in various formats Music generally refers to MIDI-based sound - good for backdrop to game -

limited by onboard sound device - synthesized sound not as authentic as audio

Page 4: UFCEKU-20-3Web Games Programming Game Sound. UFCEKU-20-3Web Games Programming Agenda Motivation for using Sound in Games Typical Game Sound Scenarios

UFCEKU-20-3Web Games Programming

Audio Sound Characteristics

Audio samples in specific format Resolution (bits), sample rate (hertz), mono or stereo More bits, higher sample rate and stereo is best Compact Disc ‘Red Book Audio’ is = 44100

samples/s × 16 bit/sample × 2 channels Balance between sound quality and file size Low quality sound easily identified by listener - as

compared with low quality visuals - e.g video - viewer more forgiving of lower quality visuals than sound

Page 5: UFCEKU-20-3Web Games Programming Game Sound. UFCEKU-20-3Web Games Programming Agenda Motivation for using Sound in Games Typical Game Sound Scenarios

UFCEKU-20-3Web Games Programming

Popular Sound Formats

Sound formats include .wav, .aif, .mp3, .snd, .wav - ‘wave’ not ‘wav’ (Waveform Audio Format)

Lossless uncompressed format best for retaining ‘first generation’ high quality audio sound libraries

Page 6: UFCEKU-20-3Web Games Programming Game Sound. UFCEKU-20-3Web Games Programming Agenda Motivation for using Sound in Games Typical Game Sound Scenarios

UFCEKU-20-3Web Games Programming

Acquiring, Editing and Creating Sound

Websites see e.g www.pacdv.com Get sound from genre specific or tribute sites Purchase CD library material (BBC sound archives) Create you own with audio software Usually need to edit and compress to use in game

scenario

Page 7: UFCEKU-20-3Web Games Programming Game Sound. UFCEKU-20-3Web Games Programming Agenda Motivation for using Sound in Games Typical Game Sound Scenarios

UFCEKU-20-3Web Games Programming

Sound with ActionScript 3.0

Supports sound for audio with the Sound class SoundChannel class and SoundTransform class

Embedded audio and external audio Embedded audio includes many of the popular formats .wav, .aif

External audio must be in the .mp3 format The Sound class provides the facilitates for loading and

playing audio. An audio instance may be modified by accessing properties via

the SoundTransform class to modify left and right volume levels and pause playback. Supports up to 32 simultaneous channels

Page 8: UFCEKU-20-3Web Games Programming Game Sound. UFCEKU-20-3Web Games Programming Agenda Motivation for using Sound in Games Typical Game Sound Scenarios

UFCEKU-20-3Web Games Programming

Sound with ActionScript 3.0

// set up buttonsbutton1.addEventListener(MouseEvent.CLICK, playLibrarySound);button2.addEventListener(MouseEvent.CLICK, playExternalSound);

// load external sound so it is readyvar soundTwo:Sound = new Sound();var externalSoundFile:URLRequest = new URLRequest("PlayingSounds.mp3");soundTwo.load(externalSoundFile);

// function to play the library soundfunction playLibrarySound(event:Event) {

var soundOne:SoundOne = new SoundOne();var channel:SoundChannel = soundOne.play();

}

// function to play the external soundfunction playExternalSound(event:Event) {

soundTwo.play();}

Page 9: UFCEKU-20-3Web Games Programming Game Sound. UFCEKU-20-3Web Games Programming Agenda Motivation for using Sound in Games Typical Game Sound Scenarios

UFCEKU-20-3Web Games Programming

Adjusting Sound Volume// load external sound file into a sound objectvar aSound:Sound = new Sound(new URLRequest(song.mp3));

// create a sound channel based on the loaded soundvar soundChannelOne:SoundChannel = aSound.play();

//create a sound channel transform (adjuster)var channelOneControl:SoundTransform = new SoundTransform();

// use the transform to adjust volume levelchannelOneControl.volume = .5 // (0-1);

// assign this adjustment to the sound channel associated with song.mp3soundChannelOne.soundTransform = channelOneControl;

What a Mission!

Page 10: UFCEKU-20-3Web Games Programming Game Sound. UFCEKU-20-3Web Games Programming Agenda Motivation for using Sound in Games Typical Game Sound Scenarios

UFCEKU-20-3Web Games Programming

Techniques for Managing Sound in Games

Load audio into an array and play random sounds for events to add variety

Implement the notion of spatialized sound by increasing / decreasing the volume as objects change their proximity to each other

Page 11: UFCEKU-20-3Web Games Programming Game Sound. UFCEKU-20-3Web Games Programming Agenda Motivation for using Sound in Games Typical Game Sound Scenarios

UFCEKU-20-3Web Games Programming

// create an array to hold the soundsvar eventSounds:Array = new Array;

// create five sound variablesvar soundOne:Sound = new Sound();var soundTwo:Sound = new Sound();var soundThree:Sound = new Sound();var soundFour:Sound = new Sound();var soundFive:Sound = new Sound();

// create variables for the external audio filesvar externalSoundFile1:URLRequest = new URLRequest("./mp3/alert.mp3");var externalSoundFile2:URLRequest = new URLRequest("./mp3/alarm.mp3");var externalSoundFile3:URLRequest = new URLRequest("./mp3/warning.mp3");var externalSoundFile4:URLRequest = new URLRequest("./mp3/ambient_one.mp3");var externalSoundFile5:URLRequest = new URLRequest("./mp3/ambient_two.mp3");

//load the external audio into the sound variablessoundOne.load(externalSoundFile1);soundTwo.load(externalSoundFile2);soundThree.load(externalSoundFile3);soundFour.load(externalSoundFile4);soundFive.load(externalSoundFile5);

// place sounds into the arrayeventSounds[1] = soundOne;eventSounds[2] = soundTwo;eventSounds[3] = soundThree;eventSounds[4] = soundFour;eventSounds[5] = soundFive;

// function to play random sounds from the arrayfunction playSound() { var randomNumber = getRandomNumber(5) eventSounds[randomNumber].play(0,0); // startTime, loops,

}

Page 12: UFCEKU-20-3Web Games Programming Game Sound. UFCEKU-20-3Web Games Programming Agenda Motivation for using Sound in Games Typical Game Sound Scenarios

UFCEKU-20-3Web Games Programming

Sound Production Software

Audacity (Editor) http://audacity.sourceforge.net/

cross platform open source Excellent support for wide range of audio formats and encoding into

.mp3 ( need lame encoder) MuLab (Sequencer and Synthesis) http://www.mutools.com

Cross platform with capable free versions 32 and 64 bit Windows versions Wide range of preset synthesized sounds including sequences and

effects Supports VST plugins