SdlSound Class Reference
[SDL based classes]

Base class for sounds (short audio data). More...

#include <sdlfilesound.h>

Inheritance diagram for SdlSound:

Inheritance graph
[legend]
Collaboration diagram for SdlSound:

Collaboration graph
[legend]
List of all members.

Public Member Functions

DECLSPEC SdlSound (const char *name)
virtual DECLSPEC int play (int loops=0)
virtual DECLSPEC int fadeIn (int ms, int loops=0)
virtual DECLSPEC bool isPlaying ()
 
Returns:
true, if the resource is currently being played; false otherwise

virtual DECLSPEC void pause ()
virtual DECLSPEC bool isPaused ()
 
Returns:
true, if the resource is currently paused; false otherwise

virtual DECLSPEC void resume ()
virtual DECLSPEC void stop ()
virtual DECLSPEC int fadeOut (int ms)
virtual DECLSPEC Mix_Fading fadeStatus ()
virtual DECLSPEC void setVolume (int v)
virtual int getVolume ()
 
Returns:
the resource's volume (relative to the global volume), ranges from 0 to 128

virtual DECLSPEC int getChannel ()
virtual bool isMusic ()

Static Public Member Functions

static DECLSPEC void setGlbVolume (int v)

Protected Member Functions

DECLSPEC void destroy ()

Static Protected Member Functions

static void onChannelFinished (int channel)

Protected Attributes

Mix_Chunk * mixSound
 the source data of the sound
int nChannel
 the channel, where it is playing or -1, if not playing
int nVolume
 the volume of this resource, relative to the global

Static Protected Attributes

static int g_nVolume
 the global volume (range: 0..128)
static list< SdlSound * > lPlayingSounds
 list containing all playing sound resources

Detailed Description

Base class for sounds (short audio data).

This class is the base class for all sound resources. They are used to play audio data, that takes not much memory.


Constructor & Destructor Documentation

SdlSound::SdlSound ( const char *  name  ) 

Constructor. Registers itself in the SdlManager.

Parameters:
name the resource's name
See also:
SdlAudio::SdlAudio( const char *name )


Member Function Documentation

int SdlSound::play ( int  loops = 0  )  [virtual]

Plays the resource.

Parameters:
loops the amount, how often to repeat the sound; to repeat it infinitely it has to be -1
Returns:
the channel, it is played in (zero, if music)

Implements SdlAudio.

int SdlSound::fadeIn ( int  ms,
int  loops = 0 
) [virtual]

Starts playing the resource silently and turns louder

Parameters:
ms the time in msecs of the fade, after that, it has the final volume
loops the amount, how often to repeat the sound; to repeat it infinitely it has to be -1
Returns:
the channel, it is played in (zero, if music)

Implements SdlAudio.

void SdlSound::pause (  )  [virtual]

Breaks playing the resource to be continued later.

Implements SdlAudio.

void SdlSound::resume (  )  [virtual]

Resumes playing the resource, if paused

Implements SdlAudio.

void SdlSound::stop (  )  [virtual]

Stopps the resource being played.

Implements SdlAudio.

int SdlSound::fadeOut ( int  ms  )  [virtual]

Turns the volume silentlier and then stopps playing.

Parameters:
ms the time in msecs of the fade
Returns:
1, if it was playing; 0, if not

Implements SdlAudio.

Mix_Fading SdlSound::fadeStatus (  )  [virtual]

Returns:
MIX_NO_FADE, if the sound is currently not fading
MIX_FADING_IN, if the sound is fading in
MIX_FADING_OUT, if the sound is fading out

Implements SdlAudio.

void SdlSound::setVolume ( int  v  )  [virtual]

Sets the volume of the resource, when being played. The value is relative to the global volume.

Parameters:
v the volume, the range is from 0 to 128; if negative, the volume is just recalculated (you usually do not need recalculation, because it makes only sense internally, when changing the global volume)

Implements SdlAudio.

int SdlSound::getChannel (  )  [virtual]

Returns:
the channel, the sound is playing in and -1, if it is currently not playing

Implements SdlAudio.

virtual bool SdlSound::isMusic (  )  [inline, virtual]

Returns:
true, if the class is derived from SdlMusic; false, if it is derived from SdlSound

Implements SdlAudio.

void SdlSound::setGlbVolume ( int  v  )  [static]

Changes the global volume, which is used as reference in all SdlSound derived classes.

Parameters:
v the volume to set (range 0 (quiet) to 128 (loudest))
Note:
all playing sounds' volumes are updated automatically

void SdlSound::destroy (  )  [protected]

Uninitalizes the sound resource. This is automatically called, when deleting the object. It halts playing, if necessary and frees the sound data (the mixSound variable).

static void SdlSound::onChannelFinished ( int  channel  )  [inline, static, protected]

This method should not be called from your application. It's a callback function, called, when a channel finishes playing

Parameters:
channel the channel, that just finished playing


The documentation for this class was generated from the following files:
Generated on Wed May 9 17:36:33 2007 for netrinjo by  doxygen 1.5.1