$treeview $search $mathjax
Stratagus
2.2.6
$projectbrief
|
$projectbrief
|
$searchbox |
_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stratagus.h"
#include "SDL.h"
#include "sound_server.h"
#include "iolib.h"
#include "iocompat.h"
Classes | |
struct | SoundChannel |
Channels for sound effects and unit speach. More... | |
sound_server.cpp - The sound server (hardware layer and so on) | |
#define | MaxChannels 32 |
static bool | SoundInitialized |
static bool | MusicPlaying |
is sound initialized | |
static int | EffectsVolume = 128 |
flag true if playing music | |
static int | MusicVolume = 128 |
effects sound volume | |
static bool | MusicEnabled = true |
music volume | |
static bool | EffectsEnabled = true |
static SoundChannel | Channels [MaxChannels] |
static int | NextFreeChannel |
struct { | |
CSample * Sample | |
void(* FinishedCallback )() | |
Music sample. | |
} | MusicChannel |
static int * | MixerBuffer |
static int | MixerBufferSize |
static void | ChannelFinished (int channel) |
static int | ConvertToStereo32 (const char *src, char *dest, int frequency, int chansize, int channels, int bytes) |
static void | MixMusicToStereo32 (int *buffer, int size) |
static int | MixSampleToStereo32 (CSample *sample, int index, unsigned char volume, char stereo, int *buffer, int size) |
static int | MixChannelsToStereo32 (int *buffer, int size) |
static void | ClipMixToStereo16 (const int *mix, int size, short *output) |
static void | MixIntoBuffer (void *buffer, int samples) |
static void | FillAudio (void *, Uint8 *stream, int len) |
static int | FillChannel (CSample *sample, unsigned char volume, char stereo) |
int | SetChannelVolume (int channel, int volume) |
Load a module file. | |
int | SetChannelStereo (int channel, int stereo) |
Set the channel stereo. | |
void | SetChannelFinishedCallback (int channel, void(*callback)(int channel)) |
Set the channel's callback for when a sound finishes playing. | |
CSample * | GetChannelSample (int channel) |
Get the sample playing on a channel. | |
void | StopChannel (int channel) |
Stop a channel. | |
void | StopAllChannels () |
Stop all channels. | |
CSample * | LoadSample (const std::string &name) |
Load a sample. | |
int | PlaySample (CSample *sample) |
Play a sample. | |
int | PlaySoundFile (const std::string &name) |
Play a sound file. | |
void | SetEffectsVolume (int volume) |
Set effects volume. | |
int | GetEffectsVolume () |
Get effects volume. | |
void | SetEffectsEnabled (bool enabled) |
Set effects enabled. | |
bool | IsEffectsEnabled () |
Check if effects are enabled. | |
void | SetMusicFinishedCallback (void(*callback)()) |
Set the music finished callback. | |
int | PlayMusic (CSample *sample) |
Play a music file. | |
int | PlayMusic (const std::string &file) |
Play a music file. | |
void | StopMusic () |
Stop music playing. | |
void | SetMusicVolume (int volume) |
Set music volume. | |
int | GetMusicVolume () |
Get music volume. | |
void | SetMusicEnabled (bool enabled) |
Set music enabled. | |
bool | IsMusicEnabled () |
Check if music is enabled. | |
bool | IsMusicPlaying () |
Check if music is playing. | |
bool | SoundEnabled () |
Check if sound is enabled. | |
static int | InitSdlSound (int freq, int size) |
int | InitSound () |
Initialize the sound card. | |
void | QuitSound () |
Cleanup sound. |
#define MaxChannels 32 |
static void ChannelFinished | ( | int | channel | ) | [static] |
A channel is finished playing
static void ClipMixToStereo16 | ( | const int * | mix, | |
int | size, | |||
short * | output | |||
) | [static] |
Clip mix to output stereo 16 signed bit.
mix | signed 32 bit input. | |
size | number of samples in input. | |
output | clipped 16 signed bit output buffer. |
static int ConvertToStereo32 | ( | const char * | src, | |
char * | dest, | |||
int | frequency, | |||
int | chansize, | |||
int | channels, | |||
int | bytes | |||
) | [static] |
Convert RAW sound data to 44100 hz, Stereo, 16 bits per channel
src | Source buffer | |
dest | Destination buffer | |
frequency | Frequency of source | |
chansize | Bitrate in bytes per channel of source | |
channels | Number of channels of source | |
bytes | Number of compressed bytes to read |
static void FillAudio | ( | void * | , | |
Uint8 * | stream, | |||
int | len | |||
) | [static] |
Fill buffer for the sound card.
udata | the pointer stored in userdata field of SDL_AudioSpec. | |
stream | pointer to buffer you want to fill with information. | |
len | is length of audio buffer in bytes. |
static int FillChannel | ( | CSample * | sample, | |
unsigned char | volume, | |||
char | stereo | |||
) | [static] |
Put a sound request in the next free channel.
CSample* GetChannelSample | ( | int | channel | ) |
Get the sample playing on a channel.
Get the sample playing on a channel
int GetEffectsVolume | ( | ) |
Get effects volume.
Get effects volume
int GetMusicVolume | ( | ) |
Get music volume.
Get music volume
static int InitSdlSound | ( | int | freq, | |
int | size | |||
) | [static] |
Initialize sound card hardware part with SDL.
freq | Sample frequency (44100,22050,11025 hz). | |
size | Sample size (8bit, 16bit) |
int InitSound | ( | ) |
Initialize the sound card.
Initialize sound card.
bool IsEffectsEnabled | ( | ) |
Check if effects are enabled.
Check if effects are enabled
bool IsMusicEnabled | ( | ) |
Check if music is enabled.
Check if music is enabled
bool IsMusicPlaying | ( | ) |
Check if music is playing.
Check if music is playing
CSample* LoadSample | ( | const std::string & | name | ) |
Load a sample.
Load a sample
name | File name of sample (short version). |
static int MixChannelsToStereo32 | ( | int * | buffer, | |
int | size | |||
) | [static] |
Mix channels to stereo 32 bit.
buffer | Buffer for mixed samples. | |
size | Number of samples that fits into buffer. |
static void MixIntoBuffer | ( | void * | buffer, | |
int | samples | |||
) | [static] |
Mix into buffer.
buffer | Buffer to be filled with samples. Buffer must be big enough. | |
samples | Number of samples. |
static void MixMusicToStereo32 | ( | int * | buffer, | |
int | size | |||
) | [static] |
Mix music to stereo 32 bit.
buffer | Buffer for mixed samples. | |
size | Number of samples that fits into buffer. |
static int MixSampleToStereo32 | ( | CSample * | sample, | |
int | index, | |||
unsigned char | volume, | |||
char | stereo, | |||
int * | buffer, | |||
int | size | |||
) | [static] |
Mix sample to buffer.
The input samples are adjusted by the local volume and resampled to the output frequence.
sample | Input sample | |
index | Position into input sample | |
volume | Volume of the input sample | |
stereo | Stereo (left/right) position of sample | |
buffer | Output buffer | |
size | Size of output buffer (in samples per channel) |
int PlayMusic | ( | const std::string & | file | ) |
Play a music file.
Play a music file.
file | Name of music file, format is automatically detected. |
int PlayMusic | ( | CSample * | sample | ) |
Play a music file.
Play a music file.
sample | Music sample. |
int PlaySample | ( | CSample * | sample | ) |
Play a sample.
Play a sound sample
sample | Sample to play |
int PlaySoundFile | ( | const std::string & | name | ) |
Play a sound file.
Play a sound file
name | Filename of a sound to play |
void QuitSound | ( | ) |
Cleanup sound.
Cleanup sound server.
void SetChannelFinishedCallback | ( | int | channel, | |
void(*)(int channel) | callback | |||
) |
Set the channel's callback for when a sound finishes playing.
Set the channel's callback for when a sound finishes playing
channel | Channel to set | |
callback | Callback to call when the sound finishes |
int SetChannelStereo | ( | int | channel, | |
int | stereo | |||
) |
Set the channel stereo.
Set the channel stereo
channel | Channel to set | |
stereo | -128 to 127, out of range will not set the stereo |
int SetChannelVolume | ( | int | channel, | |
int | volume | |||
) |
Load a module file.
Set the channel volume
channel | Channel to set | |
volume | New volume, <0 will not set the volume |
void SetEffectsEnabled | ( | bool | enabled | ) |
Set effects enabled.
Set effects enabled
void SetEffectsVolume | ( | int | volume | ) |
Set effects volume.
Set the global sound volume.
volume | the sound volume 0-255 |
void SetMusicEnabled | ( | bool | enabled | ) |
Set music enabled.
Set music enabled
void SetMusicFinishedCallback | ( | void(*)() | callback | ) |
Set the music finished callback.
Set the music finished callback
void SetMusicVolume | ( | int | volume | ) |
Set music volume.
Set the music volume.
volume | the music volume 0-255 |
bool SoundEnabled | ( | ) |
Check if sound is enabled.
Check if sound is enabled
void StopAllChannels | ( | ) |
Stop all channels.
Stop all channels
void StopChannel | ( | int | channel | ) |
Stop a channel.
Stop a channel
channel | Channel to stop |
void StopMusic | ( | ) |
Stop music playing.
Stop the current playing music.
SoundChannel Channels[MaxChannels] [static] |
bool EffectsEnabled = true [static] |
int EffectsVolume = 128 [static] |
flag true if playing music
void(* FinishedCallback)() |
Music sample.
int* MixerBuffer [static] |
int MixerBufferSize [static] |
struct { ... } MusicChannel [static] |
bool MusicEnabled = true [static] |
music volume
bool MusicPlaying [static] |
is sound initialized
int MusicVolume = 128 [static] |
effects sound volume
int NextFreeChannel [static] |
bool SoundInitialized [static] |