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

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 CSampleSimpleChooseSample (const CSound &sound)
 silent distance More...
 
static CSampleChooseSample (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)
 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

static char CalculateStereo ( const CUnit unit)
static

Calculate the stereo value for a unit

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.

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

Choose the sample to play

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
void InitSoundClient ( )

Initialize client side of the sound layer.

Lookup the sound id's for the game sounds.

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
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
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
static void PlaySoundFileCallback ( int  channel)
static

Callback for PlaySoundFile

void PlayUnitSound ( const CUnit unit,
UnitVoiceGroup  voice 
)

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,...)
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
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.
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
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.
static CSample* SimpleChooseSample ( const CSound sound)
static

silent distance

"Randomly" choose a sample from a sound group.

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

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

Distance to Volume Mapping.

flag true callback ccl if stops

GameSound GameSounds

Various sounds used in game.

SelectionHandling SelectionHandler

FIXME: docu.

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.