_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

Classes
sound.cpp File Reference
#include "stratagus.h"
#include "sound.h"
#include "action/action_resource.h"
#include "map.h"
#include "missile.h"
#include "sound_server.h"
#include "ui.h"
#include "unit.h"
#include "video.h"
#include "widgets.h"

Classes

struct  SelectionHandling
 

sound.cpp - The sound.

GameSound GameSounds
 
SelectionHandling SelectionHandler
 FIXME: docu. More...
 
static int ViewPointOffset
 
int DistanceSilent
 Distance to Volume Mapping. More...
 
static std::map< int, LuaActionListener * > ChannelMap
 
static std::map< int, Mix_Chunk * > SampleMap
 
static Mix_Chunk * SimpleChooseSample (const CSound &sound)
 silent distance More...
 
static Mix_Chunk * ChooseSample (CSound *sound, bool selection, Origin &source)
 
static CSoundChooseUnitVoiceSound (const CUnit &unit, UnitVoiceGroup voice)
 
unsigned char VolumeForDistance (unsigned short d, unsigned char range)
 
unsigned char CalculateVolume (bool isVolume, int power, unsigned char range)
 Calculates volume level. More...
 
static char CalculateStereo (const CUnit &unit)
 
void PlayUnitSound (const CUnit &unit, UnitVoiceGroup voice, bool sampleUnique)
 Play a unit sound. More...
 
void PlayUnitSound (const CUnit &unit, CSound *sound)
 Play a unit sound. More...
 
void PlayMissileSound (const Missile &missile, CSound *sound)
 Play a missile sound. More...
 
void PlayGameSound (CSound *sound, unsigned char volume, bool always)
 Play a game sound. More...
 
static void PlaySoundFileCallback (int channel)
 
int PlayFile (const std::string &name, LuaActionListener *listener)
 Play a sound file. More...
 
void SetSoundRange (CSound *sound, unsigned char range)
 Modify the range of a given sound. More...
 
CSoundRegisterSound (const std::vector< std::string > &files)
 Register a sound (can be a simple sound or a group) More...
 
CSoundRegisterTwoGroups (CSound *first, CSound *second)
 Create a special sound group with two sounds. More...
 
void InitSoundClient ()
 Initialize client side of the sound layer. More...
 

Function Documentation

◆ CalculateStereo()

static char CalculateStereo ( const CUnit unit)
static

Calculate the stereo value for a unit

◆ CalculateVolume()

unsigned char CalculateVolume ( bool  isVolume,
int  power,
unsigned char  range 
)

Calculates volume level.

Calculate the volume associated with a request, either by clipping the range parameter of this request, or by mapping this range to a volume.

◆ ChooseSample()

static Mix_Chunk* ChooseSample ( CSound sound,
bool  selection,
Origin source 
)
static

Choose the sample to play

◆ ChooseUnitVoiceSound()

static CSound* ChooseUnitVoiceSound ( const CUnit unit,
UnitVoiceGroup  voice 
)
static

Maps a UnitVoiceGroup to a CSound*.

Parameters
unitSound initiator
voiceType of sound wanted
Returns
Sound identifier

◆ InitSoundClient()

void InitSoundClient ( )

Initialize client side of the sound layer.

Lookup the sound id's for the game sounds.

◆ PlayFile()

int PlayFile ( const std::string &  name,
LuaActionListener listener 
)

Play a sound file.

Play a sound file

Parameters
nameFilename of a sound to play
listenerOptional lua callback
Returns
Channel number the sound is playing on, -1 for error

◆ PlayGameSound()

void PlayGameSound ( CSound sound,
unsigned char  volume,
bool  always 
)

Play a game sound.

Play a game sound

Parameters
soundSound to play
volumeVolume level to play the sound

◆ PlayMissileSound()

void PlayMissileSound ( const Missile missile,
CSound sound 
)

Play a missile sound.

Ask the sound server to play a sound for a missile.

Parameters
missileSound initiator, missile exploding
soundSound to be generated

◆ PlaySoundFileCallback()

static void PlaySoundFileCallback ( int  channel)
static

Callback for PlaySoundFile

◆ PlayUnitSound() [1/2]

void PlayUnitSound ( const CUnit unit,
CSound sound 
)

Play a unit sound.

Ask to the sound server to play a sound attached to a unit. The sound server may discard the sound if needed (e.g., when the same unit is already speaking).

Parameters
unitSound initiator, unit speaking
soundSound to be generated

◆ PlayUnitSound() [2/2]

void PlayUnitSound ( const CUnit unit,
UnitVoiceGroup  voice,
bool  sampleUnique 
)

Play a unit sound.

Ask to the sound server to play a sound attached to a unit. The sound server may discard the sound if needed (e.g., when the same unit is already speaking).

Parameters
unitSound initiator, unit speaking
voiceType of sound wanted (Ready,Die,Yes,...)

◆ RegisterSound()

CSound* RegisterSound ( const std::vector< std::string > &  files)

Register a sound (can be a simple sound or a group)

Ask the sound server to register a sound (and currently to load it) and to return an unique identifier for it. The unique identifier is memory pointer of the server.

Parameters
filesAn array of wav files.
numberNumber of files belonging together.
Returns
the sound unique identifier
Todo:
FIXME: Must handle the errors better.

◆ RegisterTwoGroups()

CSound* RegisterTwoGroups ( CSound first,
CSound second 
)

Create a special sound group with two sounds.

Ask the sound server to put together two sounds to form a special sound.

Parameters
firstfirst part of the group
secondsecond part of the group
Returns
the special sound unique identifier

◆ SetSoundRange()

void SetSoundRange ( CSound sound,
unsigned char  range 
)

Modify the range of a given sound.

Ask the sound server to change the range of a sound.

Parameters
soundthe id of the sound to modify.
rangethe new range for this sound.

◆ SimpleChooseSample()

static Mix_Chunk* SimpleChooseSample ( const CSound sound)
static

silent distance

"Randomly" choose a sample from a sound group.

◆ VolumeForDistance()

unsigned char VolumeForDistance ( unsigned short  d,
unsigned char  range 
)

Compute a suitable volume for something taking place at a given distance from the current view point.

Parameters
ddistance
rangerange
Returns
volume for given distance (0..??)

Variable Documentation

◆ ChannelMap

std::map<int, LuaActionListener *> ChannelMap
static

◆ DistanceSilent

int DistanceSilent

Distance to Volume Mapping.

Game sound configuration.

◆ GameSounds

GameSound GameSounds

Various sounds used in game.

◆ SampleMap

std::map<int, Mix_Chunk *> SampleMap
static

◆ SelectionHandler

SelectionHandling SelectionHandler

FIXME: docu.

◆ ViewPointOffset

int ViewPointOffset
static
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.