sound engine evaluation for computer games

21
Sound Engine Evaluation for Computer Games Case Study: fmod Jyun-Ming Chen

Upload: mae

Post on 09-Jan-2016

33 views

Category:

Documents


1 download

DESCRIPTION

Sound Engine Evaluation for Computer Games. Case Study: fmod Jyun-Ming Chen. Typical Game Loop. Roles of music/sound BGM (background music) Sound effect. Microsoft SDK. Need more sophisticated tools!. BGM (Midi) mciSendCommand ( … ) Sound (Wave) sndPlaySound See msdn for details - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Sound Engine Evaluation for Computer Games

Sound Engine Evaluation for Computer Games

Case Study: fmod

Jyun-Ming Chen

Page 2: Sound Engine Evaluation for Computer Games

Fall 2010 2

Typical Game Loop

Roles of music/soundBGM (background music)Sound effect

Page 3: Sound Engine Evaluation for Computer Games

Fall 2010 3

Microsoft SDK

BGM (Midi) mciSendCommand (…)

Sound (Wave) sndPlaySound

See msdn for details

Ex: midi_wav.zip on webhd2/game-ex

Need more sophisticated tools!

Page 4: Sound Engine Evaluation for Computer Games

Fall 2010 4

Check List

BGM File formats supported:

mid, mp3, mod, … Looping Early termination Volume control

Sound effects File formats supported Trigger mechanism Reverb and other DSP

FX (e.g., room effects) Pre-load to avoid delay

in first play

General Mixing capability (how

many sounds can be mixed at one time)

Spatial sound Position: 3D vs. panning Velocity: Doppler

supported? Occlusion?!

Sync capability sound to action Action to sound

Others CPU overhead

Page 5: Sound Engine Evaluation for Computer Games

Fall 2010 5

Case Study: fmod

Cross platform audio library (Win32, Linux, mac, WinCE, PS2, Xbox, …)Free unless for commercial use

Page 6: Sound Engine Evaluation for Computer Games

Fall 2010 6

DocumentationFSOUND: for sound

effect

FMUSIC: for bgm

Page 7: Sound Engine Evaluation for Computer Games

Fall 2010 7

FSOUND API

Page 8: Sound Engine Evaluation for Computer Games

Fall 2010 8

InitializationRequired for

both FMUSIC & FSOUND

Page 9: Sound Engine Evaluation for Computer Games

Fall 2010 9

FSOUND_Sample

Load, FreeSetMode: LOOP normal | bidi | offGet/SetLoopPointsGetLengthGet/SetMinMaxDistance (min is the distance where the sound starts to attenuate) increase the min_distance of a sound to make it

'louder' in a 3d world, and decrease it to make it 'quieter' in a 3d world.

Page 10: Sound Engine Evaluation for Computer Games

Fall 2010 10

FSOUND_Stream

If the PCM data (wav) or compressed file (ogg, mp3, …) is too big to be read in as a sample, we can use stream functions to read it (decompress it on-the-fly)Certain functionalities are restricted

Page 11: Sound Engine Evaluation for Computer Games

Fall 2010 11

Channel Functions

FSOUND_PlaySound, PlaySoundEx FSOUND_FREE: Choose a free channel to play in Returns the channel selected Extended version can play paused (allow

attributes to be changed, then play)

FSOUND_SetFrequency (channel, 11025);FSOUND_SetVolume(channel, 255);FSOUND_SetPan(channel, 255); FSOUND_SetPaused(channel, FALSE);FSOUND_StopSound

Page 12: Sound Engine Evaluation for Computer Games

Fall 2010 12

FMUSIC (mid, mod; mp3)

LoadSongPlaySong: can play more than one music (yes, but why?)SetPausedSetLooping: default TRUESetPanSeparation, SetMasterSpeed, SetMasterVolumeStopSong, StopAllSongsFreeSongSetReverb (midi only)

Page 13: Sound Engine Evaluation for Computer Games

OpenGL Tests

Webhd2/game-ex/fmod_opengl_tests

Page 14: Sound Engine Evaluation for Computer Games

Fall 2010 14

Basics

Page 15: Sound Engine Evaluation for Computer Games

Fall 2010 15

BgmusicFMUSIC PLAYS S3M AND MID; NOT MP3 (sequenced file, not PCM-type)

OK for mod files

Page 16: Sound Engine Evaluation for Computer Games

Fall 2010 16

Stream

Works for mp3, ogg, wavOnly wav can store cue point (for sync)

Page 17: Sound Engine Evaluation for Computer Games

Fall 2010 17

3dsound

FSOUND_Update():

This updates the 3d sound engine, and should be called whether sound source or listener changes position

Page 18: Sound Engine Evaluation for Computer Games

Fall 2010 18

Listener Attributes

Float *posFloat *Vel (per second) NULL to ignore

Fx, fy, fz (forward orientation unit vector)Tx, ty, tz (top-up orientation unit vector)

x

y

z

Global Axes in Fmod

Left-handed

Page 19: Sound Engine Evaluation for Computer Games

Fall 2010 19

Doppler FSOUND_3D_SetDopplerFactor (4.0);

Page 20: Sound Engine Evaluation for Computer Games

Commonly Used APIs

Fall 2010 20

Init and Close

Load and Free sample

Page 21: Sound Engine Evaluation for Computer Games

Sound API

Fall 2010 21