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

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes
sound_server.h File Reference
#include "sound.h"

Go to the source code of this file.

Classes

class  CSample
 

sound_server.h - The sound server header file.

#define MaxVolume   255
 
#define SOUND_BUFFER_SIZE   65536
 
enum  _play_audio_flags_ { PlayAudioStream = 1, PlayAudioPreLoad = 2, PlayAudioLoadInMemory = 4, PlayAudioLoadOnDemand = 8 }
 
enum  SynthState { StateCleaned = 0, StateInitialized, StatePlaying }
 
CSampleLoadWav (const char *name, int flags)
 
CSampleLoadVorbis (const char *name, int flags)
 Load a wav file. More...
 
CSampleLoadMikMod (const char *name, int flags)
 Load a vorbis file. More...
 
CSampleLoadFluidSynth (const char *name, int flags)
 Load a module file. More...
 
int SetChannelVolume (int channel, int volume)
 Load a MIDI file. More...
 
int SetChannelStereo (int channel, int stereo)
 Set the channel stereo. More...
 
void SetChannelFinishedCallback (int channel, void(*callback)(int channel))
 Set the channel's callback for when a sound finishes playing. More...
 
CSampleGetChannelSample (int channel)
 Get the sample playing on a channel. More...
 
void StopChannel (int channel)
 Stop a channel. More...
 
void StopAllChannels ()
 Stop all channels. More...
 
bool UnitSoundIsPlaying (Origin *origin)
 Check if this unit plays some sound. More...
 
bool SampleIsPlaying (CSample *sample)
 Check, if this sample is already playing. More...
 
CSampleLoadSample (const std::string &name)
 Load a sample. More...
 
int PlaySample (CSample *sample, Origin *origin=NULL)
 Play a sample. More...
 
int PlaySoundFile (const std::string &name)
 Play a sound file. More...
 
void SetEffectsVolume (int volume)
 Set effects volume. More...
 
int GetEffectsVolume ()
 Get effects volume. More...
 
void SetEffectsEnabled (bool enabled)
 Set effects enabled. More...
 
bool IsEffectsEnabled ()
 Check if effects are enabled. More...
 
void SetMusicFinishedCallback (void(*callback)())
 Set the music finished callback. More...
 
int PlayMusic (CSample *sample)
 Play a music file. More...
 
int PlayMusic (const std::string &file)
 Play a music file. More...
 
void StopMusic ()
 Stop music playing. More...
 
void SetMusicVolume (int volume)
 Set music volume. More...
 
int GetMusicVolume ()
 Get music volume. More...
 
void SetMusicEnabled (bool enabled)
 Set music enabled. More...
 
bool IsMusicEnabled ()
 Check if music is enabled. More...
 
bool IsMusicPlaying ()
 Check if music is playing. More...
 
bool SoundEnabled ()
 Check if sound is enabled. More...
 
int InitSound ()
 Initialize the sound card. More...
 
void QuitSound ()
 Cleanup sound. More...
 
SynthState GetFluidSynthState ()
 Gets the state of Fluidsynth player. More...
 
int InitFluidSynth ()
 Init FluidSynth library. More...
 
void CleanFluidSynth (bool reinit=false)
 

Macro Definition Documentation

#define MaxVolume   255
#define SOUND_BUFFER_SIZE   65536

Enumeration Type Documentation

Play audio flags.

Enumerator
PlayAudioStream 
PlayAudioPreLoad 

Stream the file from medium.

PlayAudioLoadInMemory 

Load compressed in memory.

PlayAudioLoadOnDemand 

Preload file into memory.

enum SynthState

Fluidsynth flags

Enumerator
StateCleaned 
StateInitialized 
StatePlaying 

Function Documentation

void CleanFluidSynth ( bool  reinit)

Cleans FluidSynth data

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

SynthState GetFluidSynthState ( )

Gets the state of Fluidsynth player.

Gets the state of Fluidsynth player

int GetMusicVolume ( )

Get music volume.

Get music volume

int InitFluidSynth ( )

Init FluidSynth library.

Inits FluidSynth and loads SF2 soundfont

int InitSound ( )

Initialize the sound card.

Initialize sound card.

Returns
True if failure, false if everything ok.
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* LoadFluidSynth ( const char *  name,
int  flags 
)

Load a module file.

Load MIDI file using FluidSynth library.

Parameters
nameMIDI file.
flagsUnused.
Returns
Returns the loaded sample.
CSample* LoadMikMod ( const char *  name,
int  flags 
)

Load a vorbis file.

Load MikMod.

Parameters
nameFilename of the module.
flagsUnused.
Returns
Returns the loaded sample.
CSample* LoadSample ( const std::string &  name)

Load a sample.

Load a sample

Parameters
nameFile name of sample (short version).
Returns
General sample loaded from file into memory.
Todo:
Add streaming, caching support.
CSample* LoadVorbis ( const char *  name,
int  flags 
)

Load a wav file.

Load vorbis.

Parameters
nameFile name.
flagsLoad flags.
Returns
Returns the loaded sample.
CSample* LoadWav ( const char *  name,
int  flags 
)

Load wav.

Parameters
nameFile name.
flagsLoad flags.
Returns
Returns the loaded sample.
Todo:
Add ADPCM loading support!
int PlayMusic ( CSample sample)

Play a music file.

Play a music file.

Parameters
sampleMusic sample.
Returns
0 if music is playing, -1 if not.
int PlayMusic ( const std::string &  file)

Play a music file.

Play a music file.

Parameters
fileName of music file, format is automatically detected.
Returns
0 if music is playing, -1 if not.
int PlaySample ( CSample sample,
Origin origin 
)

Play a sample.

Play a sound sample

Parameters
sampleSample to play
Returns
Channel number, -1 for error
int PlaySoundFile ( const std::string &  name)

Play a sound file.

Play a sound file

Parameters
nameFilename of a sound to play
Returns
Channel number the sound is playing on, -1 for error
void QuitSound ( )

Cleanup sound.

Cleanup sound server.

bool SampleIsPlaying ( CSample sample)

Check, if this sample is already playing.

Check if this sound is already playing

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

Parameters
channelChannel to set
callbackCallback to call when the sound finishes
int SetChannelStereo ( int  channel,
int  stereo 
)

Set the channel stereo.

Set the channel stereo

Parameters
channelChannel to set
stereo-128 to 127, out of range will not set the stereo
Returns
Current stereo of the channel, -1 for error
int SetChannelVolume ( int  channel,
int  volume 
)

Load a MIDI file.

Set the channel volume

Set the channel volume

Parameters
channelChannel to set
volumeNew volume, <0 will not set the volume
Returns
Current volume of the channel, -1 for error
void SetEffectsEnabled ( bool  enabled)

Set effects enabled.

Set effects enabled

void SetEffectsVolume ( int  volume)

Set effects volume.

Set the global sound volume.

Parameters
volumethe 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.

Parameters
volumethe 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

Parameters
channelChannel to stop
void StopMusic ( )

Stop music playing.

Stop the current playing music.

bool UnitSoundIsPlaying ( Origin origin)

Check if this unit plays some sound.

(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.