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

PLMMusic Class Reference

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

#include <PLMMusic.hpp>

Inheritance diagram for PLMMusic:

Inheritance graph
[legend]
List of all members.

Public Types

enum  { FORMAT_UNK = 0, FORMAT_DEF = 1 }

Public Methods

 PLMMusic ()
 PLMMusic (char *filename)
int Format () const
int Freq () const
bool Stereo () const
int Channels () const
const u8 * Data () const
const u8 * NextData ()
u32 BufferLength () const
u32 Length () const
u32 Samples () const
float Time () const
void ChangeFormat (int format, int freq, int channels)
void SetMixerFormat ()
int OutFormat () const
int OutFreq () const
bool OutStereo () const
int OutChannels () const
void Restart ()
u32 GetPosition ()
void SetPosition (u32 pos)
virtual bool Load (PLMResFile &src, int format=PLMResource::FORMAT_UNK)
virtual bool LoadName (const char *filename, int format=PLMResource::FORMAT_UNK)
virtual bool Save (PLMResFile &dest, int format=PLMResource::FORMAT_DEF)
virtual u32 MemoryUsed () const
void PrintInfo () const
virtual bool SaveName (const char *filename, int format=FORMAT_DEF)

Protected Methods

void Clear ()

Detailed Description

A streamed sound buffer to be played by the mixer.

Notes:

  • this class only holds a small part of the whole audio data, and decode the rest of the data on demand (when NextData() is called)
  • a single PLMMusic object can NOT be used more than ONE time by the mixer simultaneously, you have to create other instances and load the same file.
  • you can load a music from a PLMResFile (that can be a standard file, a file inside an archive or from memory), but since all data is not loaded at once, the file MUST stay open until all music has been played. The music object keeps a pointer on the file until it is destroyed or another file is loaded (Load()). For the same reason, you can not use LoadName() since the file would be closed immediately.
  • you can check the main parameters (data format, frequency, stereo)
  • Save() is not implemented, and can not be since the whole data is never fully loaded.
  • the only file format available for now is OGG.


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

PLMMusic::PLMMusic  
 

Create an empty music object.

PLMMusic::PLMMusic char *    filename
 

Create and load a music from filename (OGG format).


Member Function Documentation

int PLMMusic::Format   [inline]
 

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

int PLMMusic::Freq   [inline]
 

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

bool PLMMusic::Stereo   [inline]
 

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

int PLMMusic::Channels   [inline]
 

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

const u8 * PLMMusic::Data   [inline]
 

Get a read-only pointer on the current audio data.

const u8* PLMMusic::NextData  
 

Fill the buffer with the next decoded section and return a pointer on it.

Returns:
a pointer on the current data, if any available, or NULL if the end is reached, then call once again to restart.

u32 PLMMusic::BufferLength   [inline]
 

Get the size of the current buffer in bytes (decoded data).

This size is modified each time the object is asked to decode a new section of the stream with NextData().

u32 PLMMusic::Length   [inline]
 

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

u32 PLMMusic::Samples   [inline]
 

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

float PLMMusic::Time   [inline]
 

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

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

Set the current configuration wanted for the music.

The data is not modified immediately but will be automatically converted when it is read (by NextData()) if necessary.

void PLMMusic::SetMixerFormat  
 

Modify current settings to use the same configuration as the mixer.

Nothing is modified immediately but the data is automatically converted when it is read (by NextData()) if necessary.

int PLMMusic::OutFormat   [inline]
 

Get the output format (set with ChangeFormat() or SetMixerFormat()).

int PLMMusic::OutFreq   [inline]
 

Get the output frequency (set with ChangeFormat() or SetMixerFormat()).

bool PLMMusic::OutStereo   [inline]
 

Get the output mono/stereo mode (set with ChangeFormat() or SetMixerFormat()).

int PLMMusic::OutChannels   [inline]
 

Get the output number of channels (set with ChangeFormat() or SetMixerFormat()).

void PLMMusic::Restart   [inline]
 

Set current position to the beginning. Called by the mixer when added.

u32 PLMMusic::GetPosition  
 

Get the current position in the stream, in samples.

void PLMMusic::SetPosition u32    pos
 

Change the current position in the stream.

This method is meant to be used by the mixer only. Never modify while the music played by the mixer.

Parameters:
pos  the position to set, in samples.

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

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

Implements PLMResource.

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

Load data from the file filename.

Reimplemented from PLMResource.

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

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

Implements PLMResource.

virtual u32 PLMMusic::MemoryUsed   [virtual]
 

Get the total amount of memory used by this resource.

Implements PLMResource.

void PLMMusic::PrintInfo  
 

Print some information on current log.

void PLMMusic::Clear   [protected]
 

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

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:
  • PLMMusic.hpp

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