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

sound_server.h
Go to the documentation of this file.
1 // _________ __ __
2 // / _____// |_____________ _/ |______ ____ __ __ ______
3 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
4 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
5 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
6 // \/ \/ \//_____/ \/
7 // ______________________ ______________________
8 // T H E W A R B E G I N S
9 // Stratagus - A free fantasy real time strategy game engine
10 //
12 //
13 // (c) Copyright 1998-2005 by Lutz Sammer, Fabrice Rossi, and
14 // Jimmy Salmon
15 //
16 // This program is free software; you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation; only version 2 of the License.
19 //
20 // This program is distributed in the hope that it will be useful,
21 // but WITHOUT ANY WARRANTY; without even the implied warranty of
22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 // GNU General Public License for more details.
24 //
25 // You should have received a copy of the GNU General Public License
26 // along with this program; if not, write to the Free Software
27 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
28 // 02111-1307, USA.
29 //
30 
31 #ifndef __SOUND_SERVER_H__
32 #define __SOUND_SERVER_H__
33 
35 
36 /*----------------------------------------------------------------------------
37 -- Includes
38 ----------------------------------------------------------------------------*/
39 
40 #include "sound.h"
41 
42 /*----------------------------------------------------------------------------
43 -- Definitons
44 ----------------------------------------------------------------------------*/
45 
46 #define MaxVolume 255
47 #define SOUND_BUFFER_SIZE 65536
48 
49 /*----------------------------------------------------------------------------
50 -- Functions
51 ----------------------------------------------------------------------------*/
52 
54 extern int SetChannelVolume(int channel, int volume);
56 extern void SetChannelStereo(int channel, int stereo);
58 extern Mix_Chunk *GetChannelSample(int channel);
60 extern void StopChannel(int channel);
62 extern void StopAllChannels();
63 
65 extern bool UnitSoundIsPlaying(Origin *origin);
67 extern bool SampleIsPlaying(Mix_Chunk *sample);
69 extern Mix_Music *LoadMusic(const std::string &name);
71 extern Mix_Chunk *LoadSample(const std::string &name);
72 extern void FreeSample(Mix_Chunk *sample);
74 extern int PlaySample(Mix_Chunk *sample, Origin *origin = NULL);
76 extern int PlaySample(Mix_Chunk *sample, void (*callback)(int channel));
78 extern int PlaySoundFile(const std::string &name);
79 
81 extern void SetEffectsVolume(int volume);
83 extern int GetEffectsVolume();
85 extern void SetEffectsEnabled(bool enabled);
87 extern bool IsEffectsEnabled();
88 
90 void SetMusicFinishedCallback(void (*callback)());
92 extern int PlayMusic(const std::string &file);
94 extern void StopMusic();
96 extern void SetMusicVolume(int volume);
98 extern int GetMusicVolume();
100 extern void SetMusicEnabled(bool enabled);
102 extern bool IsMusicEnabled();
104 extern bool IsMusicPlaying();
105 
107 extern bool SoundEnabled();
109 extern int InitSound();
111 extern void QuitSound();
112 
113 extern uint32_t SDL_SOUND_FINISHED;
114 extern void HandleSoundEvent(SDL_Event &event);
115 
117 
118 #endif // !__SOUND_SERVER_H__
GetMusicVolume
int GetMusicVolume()
Get music volume.
Definition: sound_server.cpp:614
IsEffectsEnabled
bool IsEffectsEnabled()
Check if effects are enabled.
Definition: sound_server.cpp:538
HandleSoundEvent
void HandleSoundEvent(SDL_Event &event)
Definition: sound_server.cpp:286
SetMusicEnabled
void SetMusicEnabled(bool enabled)
Set music enabled.
Definition: sound_server.cpp:622
InitSound
int InitSound()
Initialize the sound card.
Definition: sound_server.cpp:694
SetMusicVolume
void SetMusicVolume(int volume)
Set music volume.
Definition: sound_server.cpp:601
LoadSample
Mix_Chunk * LoadSample(const std::string &name)
Load a sample.
Definition: sound_server.cpp:435
SetEffectsEnabled
void SetEffectsEnabled(bool enabled)
Set effects enabled.
Definition: sound_server.cpp:530
SetMusicFinishedCallback
void SetMusicFinishedCallback(void(*callback)())
Set the music finished callback.
Definition: sound_server.cpp:550
QuitSound
void QuitSound()
Cleanup sound.
Definition: sound_server.cpp:717
UnitSoundIsPlaying
bool UnitSoundIsPlaying(Origin *origin)
Check if this unit plays some sound.
Definition: sound_server.cpp:254
event
HANDLE event
Definition: midiplayer.c:31
PlaySample
int PlaySample(Mix_Chunk *sample, Origin *origin=NULL)
Play a sample.
Definition: sound_server.cpp:499
PlayMusic
int PlayMusic(const std::string &file)
Play a music file.
Definition: sound_server.cpp:562
GetEffectsVolume
int GetEffectsVolume()
Get effects volume.
Definition: sound_server.cpp:522
IsMusicEnabled
bool IsMusicEnabled()
Check if music is enabled.
Definition: sound_server.cpp:635
StopAllChannels
void StopAllChannels()
Stop all channels.
Definition: sound_server.cpp:353
SetChannelStereo
void SetChannelStereo(int channel, int stereo)
Set the channel stereo.
Definition: sound_server.cpp:312
SDL_SOUND_FINISHED
uint32_t SDL_SOUND_FINISHED
Definition: sound_server.cpp:60
LoadMusic
Mix_Music * LoadMusic(const std::string &name)
Load music.
Definition: sound_server.cpp:415
SetChannelVolume
int SetChannelVolume(int channel, int volume)
Set the channel volume.
Definition: sound_server.cpp:299
SoundEnabled
bool SoundEnabled()
Check if sound is enabled.
Definition: sound_server.cpp:655
SampleIsPlaying
bool SampleIsPlaying(Mix_Chunk *sample)
Check, if this sample is already playing.
Definition: sound_server.cpp:244
Origin
Definition: sound.h:146
StopChannel
void StopChannel(int channel)
Stop a channel.
Definition: sound_server.cpp:345
GetChannelSample
Mix_Chunk * GetChannelSample(int channel)
Get the sample playing on a channel.
Definition: sound_server.cpp:332
FreeSample
void FreeSample(Mix_Chunk *sample)
Definition: sound_server.cpp:451
StopMusic
void StopMusic()
Stop music playing.
Definition: sound_server.cpp:587
PlaySoundFile
int PlaySoundFile(const std::string &name)
Play a sound file.
SetEffectsVolume
void SetEffectsVolume(int volume)
Set effects volume.
Definition: sound_server.cpp:514
sound.h
IsMusicPlaying
bool IsMusicPlaying()
Check if music is playing.
Definition: sound_server.cpp:643
(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.