SdlMusic Class Reference
[SDL based classes]

Base class for music (long audio data). More...

#include <sdlfilemusic.h>

Inheritance diagram for SdlMusic:

Inheritance graph
[legend]
Collaboration diagram for SdlMusic:

Collaboration graph
[legend]
List of all members.

Public Member Functions

DECLSPEC SdlMusic (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 DECLSPEC int getVolume ()
 
Returns:
the resource's volume (relative to the global volume), ranges from 0 to 128

virtual int getChannel ()
virtual bool isMusic ()

Static Public Member Functions

static SdlMusicgetPlayingStream ()
static DECLSPEC void setGlbVolume (int v)

Protected Member Functions

DECLSPEC void destroy ()

Static Protected Member Functions

static void onMusicFinished ()

Protected Attributes

Mix_Music * mixMusic
 the source data of the music
int nVolume
 the volume of this resource, relative to the global
bool bPlaying
 playing status of the resource (true if playing)

Static Protected Attributes

static int g_nVolume
 the global volume (range: 0..128)
static SdlMusicmusPlaying
 pointer to the currently playing music or 0, if none is being played

Detailed Description

Base class for music (long audio data).

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


Constructor & Destructor Documentation

SdlMusic::SdlMusic ( 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 SdlMusic::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 SdlMusic::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 SdlMusic::pause (  )  [virtual]

Breaks playing the resource to be continued later.

Implements SdlAudio.

void SdlMusic::resume (  )  [virtual]

Resumes playing the resource, if paused

Implements SdlAudio.

void SdlMusic::stop (  )  [virtual]

Stopps the resource being played.

Implements SdlAudio.

int SdlMusic::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 SdlMusic::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 SdlMusic::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.

virtual int SdlMusic::getChannel (  )  [inline, virtual]

Returns:
the channel, the sound is playing in and -1, if it is currently not playing
Note:
music resources are always played in channel 0, so this will either return zero or minus one.

Implements SdlAudio.

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

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

Implements SdlAudio.

static SdlMusic* SdlMusic::getPlayingStream (  )  [inline, static]

Returns:
the currently playing music resource or NULL, if no music is being played

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

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

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

void SdlMusic::destroy (  )  [protected]

Uninitalizes the music resource. This is automatically called, when deleting the object. It halts playing, if necessary and frees the resource's data (the mixMusic variable).

static void SdlMusic::onMusicFinished (  )  [inline, static, protected]

This method should not be called from your application. It's a callback function, called, when the music-channel finishes 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