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

src/sound/sound.cpp File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stratagus.h"
#include "SDL.h"
#include "sound.h"
#include "video.h"
#include "unitsound.h"
#include "unittype.h"
#include "player.h"
#include "unit.h"
#include "sound_server.h"
#include "missile.h"
#include "map.h"
#include "tileset.h"
#include "ui.h"
#include "widgets.h"

Classes

struct  SelectionHandling

sound.cpp - The sound.

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

Function Documentation

static char CalculateStereo ( const CUnit unit  )  [static]

Calculate the stereo value for a unit

static unsigned char CalculateVolume ( bool  isVolume,
int  power,
unsigned char  range 
) [static]

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:
unit Sound initiator
voice Type 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:
name Filename of a sound to play
listener Optional lua callback
Returns:
Channel number the sound is playing on, -1 for error

void PlayGameSound ( CSound sound,
unsigned char  volume 
)

Play a game sound.

Play a game sound

Parameters:
sound Sound to play
volume Volume 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:
missile Sound initiator, missile exploding
sound Sound to be generated

static void PlaySoundFileCallback ( int  channel  )  [static]

Callback for PlaySoundFile

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:
unit Sound initiator, unit speaking
sound Sound to be generated

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:
unit Sound initiator, unit speaking
voice Type of sound wanted (Ready,Die,Yes,...)

CSound* RegisterSound ( const char *  files[],
unsigned  number 
)

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:
files An array of wav files.
number Number 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:
first first part of the group
second second 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:
sound the id of the sound to modify.
range the new range for this sound.

static CSample* SimpleChooseSample ( const CSound sound  )  [static]

silent distance

"Randomly" choose a sample from a sound group.

static unsigned char VolumeForDistance ( unsigned short  d,
unsigned char  range 
) [static]

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

Parameters:
d distance
range range
Returns:
volume for given distance (0..??)


Variable Documentation

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

Distance to Volume Mapping.

flag true callback ccl if stops

Various sounds used in game.

int ViewPointOffset [static]

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