Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   Namespace Members   Compound Members  

PLMSound Class Reference

A sound buffer to be played by the mixer. More...

#include <PLMSound.hpp>

Inheritance diagram for PLMSound:

Inheritance graph
[legend]
List of all members.

Public Types

enum  { FORMAT_UNK = 0, FORMAT_DEF = 1 }

Public Methods

 PLMSound ()
 PLMSound (char *filename)
int Format () const
int Freq () const
bool Stereo () const
int Channels () const
const u8 * Data () const
u32 Length () const
u32 Samples () const
float Time () const
void ChangeFormat (int format, int freq, int channels)
void SetMixerFormat ()
virtual bool Load (PLMResFile &src, int format=PLMResource::FORMAT_UNK)
virtual bool Save (PLMResFile &dest, int format=PLMResource::FORMAT_DEF)
virtual u32 MemoryUsed () const
void PrintInfo () const
virtual bool LoadName (const char *filename, int format=FORMAT_UNK)
virtual bool SaveName (const char *filename, int format=FORMAT_DEF)

Protected Methods

void Clear ()

Detailed Description

A sound buffer to be played by the mixer.

Notes:

  • this class simply holds audio data
  • the same PLMSound object can be used in many calls to PLMMixer::PlaySound() to play the same sound many times simultaneously, each one with its own settings and position
  • all the data is loaded in memory at once,
  • you can check the main parameters (data format, frequency, stereo)
  • you can perform conversions to obtain another format
  • it _must_ be converted to the mixer format to be played, simply call SetMixerFormat ().
  • Save() is not implemented (yet?).


Member Enumeration Documentation

anonymous enum [inherited]
 

Enumeration values:
FORMAT_UNK  unknown format (usually for load)
FORMAT_DEF  default format (usually for save)


Constructor & Destructor Documentation

PLMSound::PLMSound  
 

Create an empty sound object.

PLMSound::PLMSound char *    filename
 

Create and load a sound from filename (WAV or OGG format).


Member Function Documentation

int PLMSound::Format   [inline]
 

Get the sound format, one of PLMMixer::FORMAT_* enum.

int PLMSound::Freq   [inline]
 

Get the sound frequency in Hertz (usually 11025, 22050 or 44100 Hz).

bool PLMSound::Stereo   [inline]
 

Check if the sound is stereo (has different data for left and right speakers).

int PLMSound::Channels   [inline]
 

Return the number of output channels (1 = mono, 2 = stereo).

const u8 * PLMSound::Data   [inline]
 

Get a read-only pointer on the audio data.

u32 PLMSound::Length   [inline]
 

Get the total length of the sound (in bytes).

u32 PLMSound::Samples   [inline]
 

Get the total length of the sound (in samples).

float PLMSound::Time   [inline]
 

Get the total length of the sound (in seconds).

void PLMSound::ChangeFormat int    format,
int    freq,
int    channels
 

Convert the audio data into the specified format.

Warning: many conversions may lead to a loss of quality/data.

void PLMSound::SetMixerFormat  
 

Convert into the current mixer format.

virtual bool PLMSound::Load PLMResFile   src,
int    format = PLMResource::FORMAT_UNK
[virtual]
 

Load data from the file src, using a specific format.

Implements PLMResource.

virtual bool PLMSound::Save PLMResFile   dest,
int    format = PLMResource::FORMAT_DEF
[virtual]
 

Save data to the file dest, using a specific format.

Implements PLMResource.

virtual u32 PLMSound::MemoryUsed   [virtual]
 

Get the total amount of memory used by this resource.

Implements PLMResource.

void PLMSound::PrintInfo  
 

Print some information on current log.

void PLMSound::Clear   [protected]
 

Free all the memory used, and set format to invalid value.

virtual bool PLMResource::LoadName const char *    filename,
int    format = FORMAT_UNK
[virtual, inherited]
 

Load data from the file filename.

Reimplemented in PLMMusic.

virtual bool PLMResource::SaveName const char *    filename,
int    format = FORMAT_DEF
[virtual, inherited]
 

Save data to the file filename.


The documentation for this class was generated from the following file:
  • PLMSound.hpp

Generated by Doxygen 1.2.18 on Tue Oct 26 12:07:39 2004.