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

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.
 
bool m_positional
 If the sound is positional.
 
float m_rolloff
 The roll-off value.
 
float m_gain
 The volume gain value.
 
float m_max_dist
 Maximum distance the sfx can be heard.
 
float m_duration
 Duration of the sfx.
 

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

◆ isLoaded()

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

◆ 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.

◆ 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


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