SdlAudio Class Reference
[SDL based classes]

Base class for an audio resource. More...

#include <sdlaudio.h>

Inheritance diagram for SdlAudio:

Inheritance graph
[legend]
List of all members.

Public Types

typedef void(*) CallBack (SdlAudio *, void *)

Public Member Functions

DECLSPEC SdlAudio (const char *name=0)
DECLSPEC void rename (const char *newname)
const char * getName () const
 
Returns:
the name of the resource

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

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

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

virtual int getChannel ()=0
DECLSPEC void setCallBack (CallBack c, void *pData)
virtual bool isMusic ()=0
bool isFailed ()

Protected Member Functions

virtual DECLSPEC void failed ()

Protected Attributes

CallBack cb
 the function to call, when playing finished
void * cbData
 the value to use for the second param of the callback function

Detailed Description

Base class for an audio resource.

This class is used to handle an audio resource (sound, music...).


Member Typedef Documentation

typedef void(*) SdlAudio::CallBack(SdlAudio *, void *)

Function prototype, called on finish playing an audio resource

Parameters:
SdlAudio* pointer to the resource, that just finished playing
void* pointer to any data, as specified in the second param of setCallback()


Constructor & Destructor Documentation

SdlAudio::SdlAudio ( const char *  name = 0  ) 

Constructor. Registers itself in the SdlManager variable.

Parameters:
name the resource's name
See also:
SdlManager::getAudioByName()


Member Function Documentation

void SdlAudio::rename ( const char *  newname  ) 

Changes the name of the audio resource.

Parameters:
newname the new name of the resource

virtual int SdlAudio::play ( int  loops = 0  )  [pure 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)

Implemented in SdlMusic, and SdlSound.

virtual int SdlAudio::fadeIn ( int  ms,
int  loops = 0 
) [pure 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)

Implemented in SdlMusic, and SdlSound.

virtual void SdlAudio::pause (  )  [pure virtual]

Breaks playing the resource to be continued later.

Implemented in SdlMusic, and SdlSound.

virtual void SdlAudio::resume (  )  [pure virtual]

Resumes playing the resource, if paused

Implemented in SdlMusic, and SdlSound.

virtual void SdlAudio::stop (  )  [pure virtual]

Stopps the resource being played.

Implemented in SdlMusic, and SdlSound.

virtual int SdlAudio::fadeOut ( int  ms  )  [pure 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

Implemented in SdlMusic, and SdlSound.

virtual Mix_Fading SdlAudio::fadeStatus (  )  [pure 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

Implemented in SdlMusic, and SdlSound.

virtual void SdlAudio::setVolume ( int  v  )  [pure 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)

Implemented in SdlMusic, and SdlSound.

virtual int SdlAudio::getChannel (  )  [pure virtual]

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

Implemented in SdlMusic, and SdlSound.

void SdlAudio::setCallBack ( CallBack  c,
void *  pData 
)

Sets the callback function, to be called, when the resource halts playing

Parameters:
c is called, when audio-play was halted
pData pointer to anywhere, this value will be given to the callback as second param
Warning:
do not call any audio methods from the callback function

virtual bool SdlAudio::isMusic (  )  [pure virtual]

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

Implemented in SdlMusic, and SdlSound.

bool SdlAudio::isFailed (  )  [inline]

Returns:
false, if the resource was loaded successfully; true, if an error occured.

void SdlAudio::failed (  )  [protected, virtual]

Sets the failed state, call this, if an error occured and the resource could not be initialized.


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