____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"
#include <vector>
#include "unit.h"
#include "unitsound.h"
#include "player.h"
Go to the source code of this file.
Classes | |
| class | GameSound |
| class | CSound |
| struct | Origin |
Defines | |
| #define | MaxSampleVolume 255 |
| Maximum sample volume. | |
| #define | NO_SOUND 0 |
| No valid sound ID. | |
| #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 off. | |
| #define | CallbackMusicOff() CallbackMusic = false; |
Functions | |
| void | PlayUnitSound (const CUnit *unit, UnitVoiceGroup unit_voice_group) |
| < Play a unit sound | |
| void | PlayUnitSound (const CUnit *unit, CSound *sound) |
| Play a missile sound. | |
| void | PlayMissileSound (const Missile *missile, CSound *sound) |
| Play a game sound. | |
| void | PlayGameSound (CSound *sound, unsigned char volume) |
| Play a sound file. | |
| int | PlayFile (const std::string &name, LuaActionListener *listener=NULL) |
| Modify the range of a given sound. | |
| void | SetSoundRange (CSound *sound, unsigned char range) |
| Register a sound (can be a simple sound or a group). | |
| CSound * | RegisterSound (const char *files[], unsigned number) |
| Create a special sound group with two sounds. | |
| CSound * | RegisterTwoGroups (CSound *first, CSound *second) |
| Initialize client side of the sound layer. | |
| void | InitSoundClient (void) |
| void | CheckMusicFinished (bool force=false) |
| < Check if music is finished and play the next song | |
| void | InitMusic (void) |
| Turn music stopped callback on. | |
| void | MapSound (const std::string &sound_name, CSound *id) |
| < Map sound to identifier | |
| CSound * | SoundForName (const std::string &sound_name) |
| Make a sound bound to identifier. | |
| CSound * | MakeSound (const std::string &sound_name, const char *file[], int nb) |
| Make a sound group bound to identifier. | |
| CSound * | MakeSoundGroup (const std::string &name, CSound *first, CSound *second) |
| void | SoundCclRegister (void) |
| < register ccl features | |
Variables | |
| GameSound | GameSounds |
| Game sound configuration. | |
| bool | CallbackMusic |
| flag true callback ccl if stops | |
| int | DistanceSilent |
| silent distance | |
Definition in file sound.h.
| #define CallbackMusicOff | ( | ) | CallbackMusic = false; |
| #define CallbackMusicOn | ( | ) | CallbackMusic = true; |
Turn music stopped callback off.
Definition at line 179 of file sound.h.
Referenced by CreateGame(), and InitModules().
| #define INFINITE_SOUND_RANGE 255 |
the range value that makes a sound volume distance independent
Definition at line 115 of file sound.h.
Referenced by MapUnitSounds(), and VolumeForDistance().
| #define MAX_SOUND_RANGE 254 |
the maximum range value
Definition at line 119 of file sound.h.
Referenced by RegisterSound(), RegisterTwoGroups(), and VolumeForDistance().
| #define MaxSampleVolume 255 |
Maximum sample volume.
Definition at line 56 of file sound.h.
Referenced by CclPlaySound(), CButtonPanel::DoClicked(), EditorCallbackButtonDown(), ParseNetworkCommand(), RescueUnits(), SpellCast(), UIHandleButtonDown(), and UIHandleButtonUp().
| #define NO_SOUND 0 |
No valid sound ID.
Definition at line 57 of file sound.h.
Referenced by ChooseUnitVoiceSound(), RegisterSound(), RegisterTwoGroups(), and SetSoundRange().
| #define ONE_SOUND 0 |
A possible value for Number in the Sound struct: means a simple sound
Definition at line 105 of file sound.h.
Referenced by RegisterSound(), SimpleChooseSample(), and CSound::~CSound().
| #define TWO_GROUPS 1 |
A possible value for Number in the Sound struct: means a double group (for selection/annoyed sounds)
Definition at line 110 of file sound.h.
Referenced by ChooseSample(), RegisterTwoGroups(), and CSound::~CSound().
| void CheckMusicFinished | ( | bool | force | ) |
< Check if music is finished and play the next song
Initialize music
Check if music is finished and play the next song
Definition at line 77 of file music.cpp.
References CallbackMusic, IsMusicEnabled(), Lua, LuaCall(), MusicFinished, MusicFinishedMutex, SoundEnabled(), and StopMusic().
Referenced by EditorMainLoop(), GameMainLoop(), PatchEditorMainLoop(), and UiToggleSound().
| void InitMusic | ( | void | ) |
Turn music stopped callback on.
Init music
Definition at line 101 of file music.cpp.
References MusicFinished, MusicFinishedCallback(), MusicFinishedMutex, and SetMusicFinishedCallback().
Referenced by main1().
| void InitSoundClient | ( | void | ) |
Lookup the sound id's for the game sounds.
Definition at line 482 of file sound.cpp.
References GameSound::BuildingConstruction, GameSound::ChatMessage, GameSound::Click, DistanceSilent, GameSound::Docking, CMapArea::EndX, CMapArea::EndY, GameSounds, CUserInterface::MapArea, SoundConfig::Name, GameSound::PlacementError, GameSound::PlacementSuccess, GameSound::Rescue, SoundConfig::Sound, SoundEnabled(), SoundForName(), TileSizeX, TileSizeY, UI, ViewPointOffset, GameSound::WorkComplete, CMapArea::X, and CMapArea::Y.
Referenced by CreateGame(), and LoadModules().
| CSound* MakeSound | ( | const std::string & | name, | |
| const char * | file[], | |||
| int | nb | |||
| ) |
Make a sound group 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.
| name | name of this sound group (Freed by caller). | |
| file | list of sound file names | |
| nb | number of sounds |
Definition at line 99 of file sound_id.cpp.
References _C_, Assert, DebugPrint, MapSound(), RegisterSound(), and SoundMap.
Referenced by CclMakeSound().
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.
| name | the name of the group (handled by caller). | |
| first | id of the first group | |
| second | id of the second group |
Definition at line 129 of file sound_id.cpp.
References _C_, DebugPrint, MapSound(), RegisterTwoGroups(), and SoundMap.
Referenced by CclMakeSoundGroup().
| void MapSound | ( | const std::string & | name, | |
| CSound * | id | |||
| ) |
< Map sound to identifier
Get the sound id bound to an 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.
| name | Name of the sound (now freed by caller!). | |
| id | Sound identifier. |
Definition at line 64 of file sound_id.cpp.
References SoundMap.
Referenced by CclMapSound(), MakeSound(), and MakeSoundGroup().
| int PlayFile | ( | const std::string & | name, | |
| LuaActionListener * | listener | |||
| ) |
Modify the range of a given sound.
Play a sound file
| name | Filename of a sound to play | |
| listener | Optional lua callback |
Definition at line 386 of file sound.cpp.
References ChannelMap, LoadSample(), MaxVolume, PlaySample(), PlaySoundFileCallback(), SetChannelFinishedCallback(), and SetChannelVolume().
Referenced by tolua_stratagus_PlayFile00().
| void PlayGameSound | ( | CSound * | sound, | |
| unsigned char | volume | |||
| ) |
Play a sound file.
Play a game sound
| sound | Sound to play | |
| volume | Volume level to play the sound |
Definition at line 352 of file sound.cpp.
References CalculateVolume(), ChooseSample(), PlaySample(), CSound::Range, and SetChannelVolume().
Referenced by CclPlaySound(), CButtonPanel::DoClicked(), EditorCallbackButtonDown(), ParseNetworkCommand(), RescueUnits(), SpellCast(), UIHandleButtonDown(), and UIHandleButtonUp().
Play a game sound.
Ask the sound server to play a sound for a missile.
| missile | Sound initiator, missile exploding | |
| sound | Sound to be generated |
Definition at line 323 of file sound.cpp.
References CalculateVolume(), ChooseSample(), MissileType::G, CViewport::MapWidth, CViewport::MapX, PlaySample(), CSound::Range, CUserInterface::SelectedViewport, SetChannelStereo(), SetChannelVolume(), TileSizeX, Missile::Type, UI, ViewPointDistanceToMissile(), CGraphic::Width, and Missile::X.
Referenced by MissileHit().
Play a missile 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).
| unit | Sound initiator, unit speaking | |
| sound | Sound to be generated |
Definition at line 306 of file sound.cpp.
References CalculateStereo(), CalculateVolume(), ChooseSample(), PlaySample(), CSound::Range, SetChannelStereo(), SetChannelVolume(), CUnit::Slot, and ViewPointDistanceToUnit().
| void PlayUnitSound | ( | const CUnit * | unit, | |
| UnitVoiceGroup | voice | |||
| ) |
< Play a unit 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).
| unit | Sound initiator, unit speaking | |
| voice | Type of sound wanted (Ready,Die,Yes,...) |
Definition at line 280 of file sound.cpp.
References CalculateStereo(), CalculateVolume(), ChooseSample(), ChooseUnitVoiceSound(), PlaySample(), CSound::Range, SetChannelStereo(), SetChannelVolume(), CUnit::Slot, ViewPointDistanceToUnit(), VoiceBuilding, and VoiceSelected.
Referenced by DoActionMove(), DoRightButton(), HandleActionBuilt(), HandleActionTrain(), HitUnit(), LetUnitDie(), SendCommand(), UiFindIdleWorker(), UIHandleButtonUp(), and UnitShowAnimationScaled().
| CSound* RegisterSound | ( | const char * | files[], | |
| unsigned | number | |||
| ) |
Create a special sound group with two sounds.
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.
| files | An array of wav files. | |
| number | Number of files belonging together. |
Definition at line 427 of file sound.cpp.
References LoadSample(), MAX_SOUND_RANGE, NO_SOUND, ONE_SOUND, CSound::OneGroup, CSound::OneSound, and CSound::Sound.
Referenced by MakeSound().
Initialize client side of the sound layer.
Ask the sound server to put together two sounds to form a special sound.
| first | first part of the group | |
| second | second part of the group |
Definition at line 463 of file sound.cpp.
References MAX_SOUND_RANGE, NO_SOUND, CSound::Range, CSound::Sound, TWO_GROUPS, and CSound::TwoGroups.
Referenced by MakeSoundGroup().
| void SetSoundRange | ( | CSound * | sound, | |
| unsigned char | range | |||
| ) |
Register a sound (can be a simple sound or a group).
Ask the sound server to change the range of a sound.
| sound | the id of the sound to modify. | |
| range | the new range for this sound. |
Definition at line 410 of file sound.cpp.
References NO_SOUND, and CSound::Range.
Referenced by CclSetSoundRange(), and MapUnitSounds().
| void SoundCclRegister | ( | void | ) |
< register ccl features
Register CCL features for sound.
Definition at line 334 of file script_sound.cpp.
References CclDefineGameSounds(), CclMakeSound(), CclMakeSoundGroup(), CclMapSound(), CclPlaySound(), CclSetGlobalSoundRange(), CclSetSoundRange(), CclSoundForName(), and Lua.
Referenced by InitCcl().
| CSound* SoundForName | ( | const std::string & | name | ) |
Make a sound bound to identifier.
Maps a sound name to its id
| name | Sound name. |
Definition at line 76 of file sound_id.cpp.
References _C_, Assert, DebugPrint, and SoundMap.
Referenced by CclDefineSpell(), CclSoundForName(), MissileType::Init(), InitSoundClient(), MapAnimSounds2(), MapUnitSounds(), and UIHandleButtonUp().
| bool CallbackMusic |
flag true callback ccl if stops
global range control (max cut off distance for sound)
Definition at line 57 of file music.cpp.
Referenced by CheckMusicFinished().
| int DistanceSilent |
silent distance
Definition at line 92 of file sound.cpp.
Referenced by CclSetGlobalSoundRange(), InitSoundClient(), and VolumeForDistance().
Game sound configuration.
Various sounds used in game.
FIXME:
Definition at line 68 of file sound.cpp.
Referenced by CclDefineGameSounds(), ChooseUnitVoiceSound(), CButtonPanel::DoClicked(), EditorCallbackButtonDown(), InitSoundClient(), ParseNetworkCommand(), RescueUnits(), UIHandleButtonDown(), and UIHandleButtonUp().
1.5.6