SuperTuxKart
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SFXBuffer Class Reference

The buffer (data) for one kind of sound effects. More...

#include <sfx_buffer.hpp>

Public Member Functions

 SFXBuffer (const std::string &file, bool positional, float rolloff, float max_width, float gain)
 Creates a sfx. More...
 
 SFXBuffer (const std::string &file, const XMLNode *node)
 Constructor getting the sfx parameters from an XML node. More...
 
bool load ()
 load the buffer from file into OpenAL. More...
 
void unload ()
 Frees the loaded buffer. More...
 
bool isLoaded () const
 
ALuint getBufferID () const
 Only returns a valid buffer if isLoaded() returned true.
 
bool isPositional () const
 Returns if the buffer is positional. More...
 
float getRolloff () const
 Returns the rolloff value of this buffer. More...
 
float getGain () const
 Returns the gain for this sfx. More...
 
float getMaxDist () const
 Returns the maximum distance this sfx can be heard. More...
 
const std::string & getFileName () const
 Returns the file name of this buffer. More...
 
void setPositional (bool positional)
 Sets if this buffer is positional or not. More...
 
float getDuration () const
 Returns how long this buffer will play. More...
 

Private Member Functions

bool loadVorbisBuffer (const std::string &name, ALuint buffer)
 Load a vorbis file into an OpenAL buffer based on a routine by Peter Mulholland, used with permission (quote : "Feel free to use")
 

Private Attributes

bool m_loaded
 Whether the contents of the file was loaded.
 
std::string m_file
 The file that contains the OGG audio data.
 
ALuint m_buffer
 The openal buffer id. More...
 
bool m_positional
 If the sound is positional. More...
 
float m_rolloff
 The roll-off value. More...
 
float m_gain
 The volume gain value. More...
 
float m_max_dist
 Maximum distance the sfx can be heard. More...
 
float m_duration
 Duration of the sfx. More...
 

Detailed Description

The buffer (data) for one kind of sound effects.

Constructor & Destructor Documentation

◆ SFXBuffer() [1/2]

SFXBuffer::SFXBuffer ( const std::string &  file,
bool  positional,
float  rolloff,
float  max_dist,
float  gain 
)

Creates a sfx.

The parameter are taken from the parameters:

Parameters
fileFile name of the buffer.
positionalIf the sfx is positional.
rolloffRolloff value of this sfx.
max_distMaximum distance the sfx can be heard.
gainGain value of this sfx.

◆ SFXBuffer() [2/2]

SFXBuffer::SFXBuffer ( const std::string &  file,
const XMLNode node 
)

Constructor getting the sfx parameters from an XML node.

Parameters
fileFile name of the data.
nodeXML Node with the data for this sfx.

Member Function Documentation

◆ getDuration()

float SFXBuffer::getDuration ( ) const
inline

Returns how long this buffer will play.

◆ getFileName()

const std::string& SFXBuffer::getFileName ( ) const
inline

Returns the file name of this buffer.

◆ getGain()

float SFXBuffer::getGain ( ) const
inline

Returns the gain for this sfx.

◆ getMaxDist()

float SFXBuffer::getMaxDist ( ) const
inline

Returns the maximum distance this sfx can be heard.

◆ getRolloff()

float SFXBuffer::getRolloff ( ) const
inline

Returns the rolloff value of this buffer.

◆ isLoaded()

bool SFXBuffer::isLoaded ( ) const
inline
Returns
whether this buffer was loaded from disk

◆ isPositional()

bool SFXBuffer::isPositional ( ) const
inline

Returns if the buffer is positional.

◆ load()

bool SFXBuffer::load ( )

load the buffer from file into OpenAL.

Note
If this buffer is already loaded, this call does nothing and returns false.
Returns
Whether loading was successful.

◆ setPositional()

void SFXBuffer::setPositional ( bool  positional)
inline

Sets if this buffer is positional or not.

◆ unload()

void SFXBuffer::unload ( )

Frees the loaded buffer.

Cannot appear in destructor because copy-constructors may be used, and the OpenAL source must not be deleted on a copy

Member Data Documentation

◆ m_buffer

ALuint SFXBuffer::m_buffer
private

The openal buffer id.

◆ m_duration

float SFXBuffer::m_duration
private

Duration of the sfx.

◆ m_gain

float SFXBuffer::m_gain
private

The volume gain value.

◆ m_max_dist

float SFXBuffer::m_max_dist
private

Maximum distance the sfx can be heard.

◆ m_positional

bool SFXBuffer::m_positional
private

If the sound is positional.

◆ m_rolloff

float SFXBuffer::m_rolloff
private

The roll-off value.


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