____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
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"
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 | |
| CSample * | LoadWav (const std::string &name, int flags) |
| Load a wav file. | |
| CSample * | LoadVorbis (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. | |
| CSample * | GetChannelSample (int channel) |
| Stop a channel. | |
| void | StopChannel (int channel) |
| Stop all channels. | |
| void | StopAllChannels () |
| Load a sample. | |
| CSample * | LoadSample (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) |
Definition in file sound_server.h.
| #define MaxVolume 255 |
Definition at line 38 of file sound_server.h.
Referenced by CalculateVolume(), MixMusicToStereo32(), MixSampleToStereo32(), PlayFile(), SetChannelVolume(), SetEffectsVolume(), SetMusicVolume(), and VolumeForDistance().
| #define SOUND_BUFFER_SIZE 65536 |
Definition at line 39 of file sound_server.h.
Referenced by LoadVorbis(), LoadWav(), MixSampleToStereo32(), CSampleWavStream::Read(), and VorbisStreamRead().
| enum _play_audio_flags_ |
Play audio flags.
| 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.
| 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.
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
| name | File name of sample (short version). |
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.
| name | File name. | |
| flags | Load flags. |
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 | |||
| ) |
Load a wav file.
Load wav.
| name | File name. | |
| flags | Load flags. |
Definition at line 186 of file wav.cpp.
References Assert, CSample::BitsPerSample, WavFMT::BitsPerSample, CSample::Buffer, WavFMT::ByteRate, CSample::Channels, WavFMT::Channels, WavData::ChunkRem, CL_OPEN_READ, CFile::close(), DATA, data, WavFMT::Encoding, FMT, WavFMT::FMTchunk, WavFMT::FMTlength, CSample::Frequency, WavFMT::Frequency, CSample::Len, WavChunk::Length, WavChunk::Magic, CFile::open(), PlayAudioStream, CSample::Pos, CFile::read(), RIFF, CSample::SampleSize, WavFMT::SampleSize, CFile::seek(), SOUND_BUFFER_SIZE, WAV_MONO, WAV_PCM_CODE, WAV_STEREO, WAVE, and WavData::WavFile.
Referenced by LoadSample(), and PlayMusic().
| int PlayMusic | ( | const std::string & | file | ) |
Stop music playing.
Play a music file.
| file | Name of music file, format is automatically detected. |
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.
| sample | Music sample. |
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
| sample | Sample to play |
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
| name | Filename of a sound to play |
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
| 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
| channel | Channel to set | |
| stereo | -128 to 127, out of range will not set the stereo |
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
| channel | Channel to set | |
| volume | New volume, <0 will not set the volume |
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.
| 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.
| 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
| 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().
1.5.6