$treeview $search $mathjax
Stratagus  2.2.7
$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/include/sound.h File Reference

#include "unitsound.h"

Go to the source code of this file.


Classes

class  GameSound
class  CSound
struct  Origin

sound.h - The sound header file.

#define MaxSampleVolume   255
#define NO_SOUND   0
#define ONE_SOUND   0
#define TWO_GROUPS   1
#define INFINITE_SOUND_RANGE   255
#define MAX_SOUND_RANGE   254
#define CallbackMusicOn()   CallbackMusic = true;
 Turn music stopped callback on.
#define CallbackMusicOff()   CallbackMusic = false;
 Turn music stopped callback off.
enum  UnitVoiceGroup {
  VoiceSelected, VoiceAcknowledging, VoiceReady, VoiceHelpMe,
  VoiceDying, VoiceWorkCompleted, VoiceBuilding, VoiceDocking,
  VoiceRepairing, VoiceHarvesting, VoiceAttack
}
GameSound GameSounds
bool CallbackMusic
 Game sound configuration.
int DistanceSilent
 flag true callback ccl if stops
void PlayUnitSound (const CUnit &unit, UnitVoiceGroup unit_voice_group)
 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.
int PlayFile (const std::string &name, LuaActionListener *listener=NULL)
 Play a sound file.
void SetSoundRange (CSound *sound, unsigned char range)
 Modify the range of a given sound.
CSoundRegisterSound (const std::vector< std::string > &files)
 Register a sound (can be a simple sound or a group).
CSoundRegisterTwoGroups (CSound *first, CSound *second)
 Create a special sound group with two sounds.
void InitSoundClient ()
 Initialize client side of the sound layer.
void CheckMusicFinished (bool force=false)
 Check if music is finished and play the next song.
void InitMusic ()
 Initialize music.
void MapSound (const std::string &sound_name, CSound *id)
 Map sound to identifier.
CSoundSoundForName (const std::string &sound_name)
 Get the sound id bound to an identifier.
CSoundMakeSound (const std::string &sound_name, const std::vector< std::string > &files)
 Make a sound bound to identifier.
CSoundMakeSoundGroup (const std::string &name, CSound *first, CSound *second)
 Make a sound group bound to identifier.
void SoundCclRegister ()
 register ccl features

Define Documentation

 
#define CallbackMusicOff (  )     CallbackMusic = false;

Turn music stopped callback off.

 
#define CallbackMusicOn (  )     CallbackMusic = true;

Turn music stopped callback on.

#define INFINITE_SOUND_RANGE   255

the range value that makes a sound volume distance independent

#define MAX_SOUND_RANGE   254

the maximum range value

#define MaxSampleVolume   255

#define NO_SOUND   0

#define ONE_SOUND   0

A possible value for Number in the Sound struct: means a simple sound

#define TWO_GROUPS   1

A possible value for Number in the Sound struct: means a double group (for selection/annoyed sounds)


Enumeration Type Documentation

Voice groups for a unit

Enumerator:
VoiceSelected 
VoiceAcknowledging  If selected.
VoiceReady  Acknowledge command.
VoiceHelpMe  Command completed.
VoiceDying  If attacked.
VoiceWorkCompleted  If killed.
VoiceBuilding  only worker, work completed
VoiceDocking  only for building under construction
VoiceRepairing  only for transport reaching coast
VoiceHarvesting  repairing
VoiceAttack  harvesting

Attack command


Function Documentation

void CheckMusicFinished ( bool  force  ) 

Check if music is finished and play the next song.

Check if music is finished and play the next song

void InitMusic (  ) 

Initialize music.

Init music

void InitSoundClient (  ) 

Initialize client side of the sound layer.

Lookup the sound id's for the game sounds.

CSound* MakeSound ( const std::string &  name,
const std::vector< std::string > &  files 
)

Make a sound bound to identifier.

Ask the sound server to register a sound and store the mapping between its name and its id. Register a sound group (or an unique sound if nb==1) and get the corresponding sound id.

Parameters:
name name of this sound group (Freed by caller).
file list of sound file names
nb number of sounds
Returns:
the sound id of the created group

CSound* MakeSoundGroup ( const std::string &  name,
CSound first,
CSound second 
)

Make a sound group bound to identifier.

Ask the sound server to build a special sound group.

Register two sound groups together to make a special sound (for selection). Return the corresponding id after registering it under a given name.

Parameters:
name the name of the group (handled by caller).
first id of the first group
second id of the second group
Returns:
Registered sound identifier.

void MapSound ( const std::string &  name,
CSound id 
)

Map sound to identifier.

Add a new mapping (sound name to sound id) in the hash table Create a new mapping between a name and an already valid sound id.

Parameters:
name Name of the sound (now freed by caller!).
id Sound identifier.

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

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 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:
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.

void SoundCclRegister (  ) 

register ccl features

Register CCL features for sound.

CSound* SoundForName ( const std::string &  name  ) 

Get the sound id bound to an identifier.

Maps a sound name to its id

Parameters:
name Sound name.
Returns:
Sound identifier for this name.


Variable Documentation

Game sound configuration.

flag true callback ccl if stops

global range control (max cut off distance for sound)

Various sounds used in game.

(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.