Mana
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SoundEffect Class Reference

Defines a class for loading and storing sound effects. More...

#include <soundeffect.h>

Inheritance diagram for SoundEffect:
Resource

Public Member Functions

 ~SoundEffect () override
 
int play (int loops, int volume, int channel=-1)
 Plays the sample.
 
- Public Member Functions inherited from Resource
 Resource ()=default
 
void incRef ()
 Increments the internal reference count.
 
void decRef (OrphanPolicy orphanPolicy=DeleteLater)
 Decrements the reference count.
 
const std::string & getIdPath () const
 Return the path identifying this resource.
 

Static Public Member Functions

static SoundEffectload (SDL_RWops *rw)
 Loads a sample from a buffer in memory.
 

Protected Member Functions

 SoundEffect (Mix_Chunk *soundEffect)
 
- Protected Member Functions inherited from Resource
virtual ~Resource ()=default
 

Protected Attributes

Mix_Chunk * mChunk
 

Additional Inherited Members

- Public Types inherited from Resource
enum  OrphanPolicy { DeleteLater , DeleteImmediately }
 

Detailed Description

Defines a class for loading and storing sound effects.

Definition at line 31 of file soundeffect.h.

Constructor & Destructor Documentation

◆ ~SoundEffect()

SoundEffect::~SoundEffect ( )
override

Definition at line 26 of file soundeffect.cpp.

◆ SoundEffect()

SoundEffect::SoundEffect ( Mix_Chunk *  soundEffect)
inlineprotected

Definition at line 59 of file soundeffect.h.

Member Function Documentation

◆ load()

SoundEffect * SoundEffect::load ( SDL_RWops *  rw)
static

Loads a sample from a buffer in memory.

Parameters
rwThe SDL_RWops to load the sample data from.
Returns
nullptr if the an error occurred, a valid pointer otherwise.

Definition at line 31 of file soundeffect.cpp.

◆ play()

int SoundEffect::play ( int  loops,
int  volume,
int  channel = -1 
)

Plays the sample.

Parameters
loopsNumber of times to repeat the playback.
volumeSample playback volume.
channelSample playback channel.
Returns
which channel was used to play the sound, or -1 if sound could not be played.

Definition at line 43 of file soundeffect.cpp.

Member Data Documentation

◆ mChunk

Mix_Chunk* SoundEffect::mChunk
protected

Definition at line 61 of file soundeffect.h.


The documentation for this class was generated from the following files: