____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       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"

sound_server.h File Reference

The sound server header file. More...

Go to the source code of this file.

Classes

class  CSample

Defines

#define MaxVolume   255
#define SOUND_BUFFER_SIZE   65536

Enumerations

enum  _play_audio_flags_ { PlayAudioStream = 1, PlayAudioPreLoad = 2, PlayAudioLoadInMemory = 4, PlayAudioLoadOnDemand = 8 }

Functions

CSampleLoadWav (const std::string &name, int flags)
 Load a wav file.
CSampleLoadVorbis (const std::string &name, int flags)
 Load a vorbis file.
int SetChannelVolume (int channel, int volume)
 Set the channel stereo.
int SetChannelStereo (int channel, int stereo)
 Set the channel's callback for when a sound finishes playing.
void SetChannelFinishedCallback (int channel, void(*callback)(int channel))
 Get the sample playing on a channel.
CSampleGetChannelSample (int channel)
 Stop a channel.
void StopChannel (int channel)
 Stop all channels.
void StopAllChannels ()
 Load a sample.
CSampleLoadSample (const std::string &name)
 Play a sample.
int PlaySample (CSample *sample)
 Play a sound file.
int PlaySoundFile (const std::string &name)
 Set effects volume.
void SetEffectsVolume (int volume)
 Get effects volume.
int GetEffectsVolume (void)
 Set effects enabled.
void SetEffectsEnabled (bool enabled)
 Check if effects are enabled.
bool IsEffectsEnabled (void)
 Set the music finished callback.
void SetMusicFinishedCallback (void(*callback)(void))
 Play a music file.
int PlayMusic (CSample *sample)
 Play a music file.
int PlayMusic (const std::string &file)
 Stop music playing.
void StopMusic (void)
 Set music volume.
void SetMusicVolume (int volume)
 Get music volume.
int GetMusicVolume (void)
 Set music enabled.
void SetMusicEnabled (bool enabled)
 Check if music is enabled.
bool IsMusicEnabled (void)
 Check if music is playing.
bool IsMusicPlaying (void)
 Check if sound is enabled.
bool SoundEnabled (void)
 Initialize the sound card.
int InitSound (void)
 Cleanup sound.
void QuitSound (void)


Detailed Description

The sound server header file.

Definition in file sound_server.h.


Define Documentation

#define MaxVolume   255

#define SOUND_BUFFER_SIZE   65536


Enumeration Type Documentation

Play audio flags.

Enumerator:
PlayAudioStream  Stream the file from medium.
PlayAudioPreLoad  Load compressed in memory.
PlayAudioLoadInMemory  Preload file into memory.
PlayAudioLoadOnDemand  Load only if needed.

Definition at line 65 of file sound_server.h.


Function Documentation

CSample* GetChannelSample ( int  channel  ) 

Stop a channel.

Get the sample playing on a channel

Definition at line 465 of file sound_server.cpp.

References MaxChannels, and SoundChannel::Sample.

Referenced by PlaySoundFileCallback().

int GetEffectsVolume ( void   ) 

Set effects enabled.

Get effects volume

Definition at line 596 of file sound_server.cpp.

References EffectsVolume.

Referenced by tolua_stratagus_GetEffectsVolume00().

int GetMusicVolume ( void   ) 

Set music enabled.

Get music volume

Definition at line 723 of file sound_server.cpp.

References MusicVolume.

Referenced by tolua_stratagus_GetMusicVolume00(), and UiToggleMusic().

int InitSound ( void   ) 

Cleanup sound.

Initialize sound card.

Returns:
True if failure, false if everything ok.

Definition at line 810 of file sound_server.cpp.

References InitSdlSound(), MaxChannels, SoundChannel::Point, and SoundInitialized.

Referenced by main1().

bool IsEffectsEnabled ( void   ) 

Set the music finished callback.

Check if effects are enabled

Definition at line 612 of file sound_server.cpp.

References EffectsEnabled.

Referenced by tolua_stratagus_IsEffectsEnabled00(), and UiToggleSound().

bool IsMusicEnabled ( void   ) 

Check if music is playing.

Check if music is enabled

Definition at line 744 of file sound_server.cpp.

References MusicEnabled.

Referenced by CheckMusicFinished(), PlayMusic(), and tolua_stratagus_IsMusicEnabled00().

bool IsMusicPlaying ( void   ) 

Check if sound is enabled.

Check if music is playing

Definition at line 752 of file sound_server.cpp.

References MusicPlaying.

CSample* LoadSample ( const std::string &  name  ) 

Play a sample.

Load a sample

Parameters:
name File name of sample (short version).
Returns:
General sample loaded from file into memory.
Todo:
Add streaming, caching support.

Definition at line 517 of file sound_server.cpp.

References LibraryFileName(), LoadVorbis(), LoadWav(), and PlayAudioLoadInMemory.

Referenced by PlayFile(), PlaySoundFile(), and RegisterSound().

CSample* LoadVorbis ( const std::string &  name,
int  flags 
)

Load a vorbis file.

Set the channel volume

Load vorbis.

Parameters:
name File name.
flags Load flags.
Returns:
Returns the loaded sample.

Definition at line 392 of file ogg.cpp.

References OggData::audio, CSample::Buffer, CSample::Channels, CL_OPEN_READ, CFile::close(), CSampleVorbis::Data, OggData::File, CSample::Frequency, int(), CSample::Len, OggFree(), OggInit(), CFile::open(), PlayAudioStream, CSample::Pos, CFile::read(), CSample::SampleSize, CFile::seek(), SOUND_BUFFER_SIZE, CFile::tell(), OggData::vinfo, and VorbisStreamRead().

Referenced by LoadSample(), PlayMovie(), and PlayMusic().

CSample* LoadWav ( const std::string &  name,
int  flags 
)

int PlayMusic ( const std::string &  file  ) 

Stop music playing.

Play a music file.

Parameters:
file Name of music file, format is automatically detected.
Returns:
0 if music is playing, -1 if not.

Definition at line 656 of file sound_server.cpp.

References _C_, DebugPrint, IsMusicEnabled(), LibraryFileName(), LoadVorbis(), LoadWav(), MusicChannel, MusicPlaying, PlayAudioStream, SoundEnabled(), and StopMusic().

int PlayMusic ( CSample sample  ) 

Play a music file.

Play a music file.

Parameters:
sample Music sample.
Returns:
0 if music is playing, -1 if not.

Definition at line 636 of file sound_server.cpp.

References DebugPrint, MusicChannel, MusicPlaying, and StopMusic().

Referenced by PlayMovie(), ShowTitleScreens(), and tolua_stratagus_PlayMusic00().

int PlaySample ( CSample sample  ) 

Play a sound file.

Play a sound sample

Parameters:
sample Sample to play
Returns:
Channel number, -1 for error

Definition at line 545 of file sound_server.cpp.

References EffectsEnabled, EffectsVolume, FillChannel(), MaxChannels, NextFreeChannel, and SoundEnabled().

Referenced by PlayFile(), PlayGameSound(), PlayMissileSound(), PlaySoundFile(), and PlayUnitSound().

int PlaySoundFile ( const std::string &  name  ) 

Set effects volume.

Play a sound file

Parameters:
name Filename of a sound to play
Returns:
Channel number the sound is playing on, -1 for error

Definition at line 568 of file sound_server.cpp.

References LoadSample(), and PlaySample().

void QuitSound ( void   ) 

Cleanup sound server.

Definition at line 834 of file sound_server.cpp.

References MixerBuffer, and SoundInitialized.

Referenced by Exit().

void SetChannelFinishedCallback ( int  channel,
void(*)(int channel)  callback 
)

Get the sample playing on a channel.

Set the channel's callback for when a sound finishes playing

Parameters:
channel Channel to set
callback Callback to call when the sound finishes

Definition at line 453 of file sound_server.cpp.

References SoundChannel::FinishedCallback, and MaxChannels.

Referenced by PlayFile().

int SetChannelStereo ( int  channel,
int  stereo 
)

Set the channel's callback for when a sound finishes playing.

Set the channel stereo

Parameters:
channel Channel to set
stereo -128 to 127, out of range will not set the stereo
Returns:
Current stereo of the channel, -1 for error

Definition at line 423 of file sound_server.cpp.

References MaxChannels, and SoundChannel::Stereo.

Referenced by PlayMissileSound(), PlayUnitSound(), and tolua_stratagus_SetChannelStereo00().

int SetChannelVolume ( int  channel,
int  volume 
)

Set the channel stereo.

Set the channel volume

Parameters:
channel Channel to set
volume New volume, <0 will not set the volume
Returns:
Current volume of the channel, -1 for error

Definition at line 393 of file sound_server.cpp.

References MaxChannels, MaxVolume, and SoundChannel::Volume.

Referenced by PlayFile(), PlayGameSound(), PlayMissileSound(), PlayUnitSound(), and tolua_stratagus_SetChannelVolume00().

void SetEffectsEnabled ( bool  enabled  ) 

Check if effects are enabled.

Set effects enabled

Definition at line 604 of file sound_server.cpp.

References EffectsEnabled.

Referenced by tolua_stratagus_SetEffectsEnabled00(), and UiToggleSound().

void SetEffectsVolume ( int  volume  ) 

Get effects volume.

Set the global sound volume.

Parameters:
volume the sound volume 0-255

Definition at line 582 of file sound_server.cpp.

References EffectsVolume, and MaxVolume.

Referenced by tolua_stratagus_SetEffectsVolume00().

void SetMusicEnabled ( bool  enabled  ) 

Check if music is enabled.

Set music enabled

Definition at line 731 of file sound_server.cpp.

References MusicEnabled, and StopMusic().

Referenced by tolua_stratagus_SetMusicEnabled00(), and UiToggleSound().

void SetMusicFinishedCallback ( void(*)(void)  callback  ) 

Play a music file.

Set the music finished callback

Definition at line 624 of file sound_server.cpp.

References MusicChannel.

Referenced by InitMusic().

void SetMusicVolume ( int  volume  ) 

Get music volume.

Set the music volume.

Parameters:
volume the music volume 0-255

Definition at line 709 of file sound_server.cpp.

References MaxVolume, and MusicVolume.

Referenced by tolua_stratagus_SetMusicVolume00(), and UiToggleMusic().

bool SoundEnabled ( void   ) 

Initialize the sound card.

Check if sound is enabled

Definition at line 764 of file sound_server.cpp.

References SoundInitialized.

Referenced by CheckMusicFinished(), ChooseSample(), CreateGame(), InitSoundClient(), LoadModules(), MapUnitSounds(), PlayMusic(), PlaySample(), UiToggleMusic(), and UiToggleSound().

void StopAllChannels (  ) 

Load a sample.

Stop all channels

Definition at line 495 of file sound_server.cpp.

References ChannelFinished(), and MaxChannels.

Referenced by tolua_stratagus_StopAllChannels00().

void StopChannel ( int  channel  ) 

Stop all channels.

Stop a channel

Parameters:
channel Channel to stop

Definition at line 479 of file sound_server.cpp.

References ChannelFinished(), and MaxChannels.

Referenced by tolua_stratagus_StopChannel00().

void StopMusic ( void   ) 

Set music volume.

Stop the current playing music.

Definition at line 691 of file sound_server.cpp.

References MusicChannel, and MusicPlaying.

Referenced by CheckMusicFinished(), Exit(), PlayMovie(), PlayMusic(), SetMusicEnabled(), ShowTitleScreens(), and tolua_stratagus_StopMusic00().


Generated on Sat Feb 21 00:28:19 2009 for Bos Wars by  doxygen 1.5.6