class PSound

A class representing a sound.

Inheritance:


Public Methods

[more] Construction
[more] File functions
[more] Access functions
[more] Miscellaneous functions

Protected Fields

[more]unsigned encoding
Format code
[more]unsigned numChannels
Number of channels eg mono/stereo
[more]unsigned sampleRate
Samples per second
[more]unsigned sampleSize
Number of bits per sample
[more]DWORD dwLastError
Last error code for Load()/Save() functions
[more]PBYTEArray formatInfo
Full info on the format (platform dependent)


Inherited from PBYTEArray:

Public Methods

Overrides from class PObject


Inherited from PBaseArray:

Public Methods

Overrides from class PContainer

New functions for class


Inherited from PAbstractArray:

Protected Fields

oPINDEX elementSize
ochar* theArray
oBOOL allocatedDynamically


Inherited from PContainer:

Public Methods

Common functions for containers

Protected Methods

ovirtual void DestroyContents()
ovirtual void AssignContents(const PContainer & c)
ovoid CopyContents(const PContainer & c)
ovoid CloneContents(const PContainer* src)
ovoid Destruct()


Inherited from PObject:

Public Methods

Run Time Type functions

I/O functions

Public Members

Comparison functions


Documentation

A class representing a sound. A sound is a highly platform dependent entity that is abstracted for use here. Very little manipulation of the sounds are possible.

The most common sound to use is the static function Beep() which emits the system standard "warning" or "attention" sound.

o Construction

o PSound( unsigned numChannels = 1, unsigned sampleRate = 8000, unsigned bitsPerSample = 16, PINDEX bufferSize = 0, const BYTE* data = NULL )
Create a new sound, using the parameters provided. It is expected that the "lowest common denominator" encoding, linear PCM, is used.

All other values for the encoding are platform dependent.

Parameters:
- numChannels Number of channels eg mono/stereo
- sampleRate Samples per second
bitsPerSample - Number of bits per sample
- bufferSize Size of data
data - Pointer to initial data

o PSound( const PFilePath & filename )
Create a new sound, reading from a platform dependent file.
Parameters:
filename - Sound file to load.

oPSound& operator=( const PBYTEArray & data )
Set new data bytes for the sound

o File functions

oBOOL Load( const PFilePath & filename )
Load a platform dependent sound file (eg WAV file for Win32) into the object. Note the whole file must able to be loaded into memory.

Also note that not all possible files are playable by this library. No format conversions between file and driver are performed.

Parameters:
filename - Sound file to load.
Returns:
TRUE if the sound is loaded successfully.

oBOOL Save( const PFilePath & filename )
Save a platform dependent sound file (eg WAV file for Win32) from the object.

Returns:
TRUE if the sound is saved successfully.

o Access functions

oBOOL Play()
Play the sound on the default sound device

ovoid SetFormat( unsigned numChannels, unsigned sampleRate, unsigned bitsPerSample )
Set the internal sound format to linear PCM at the specification in the parameters.
Parameters:
- sampleRate Samples per second
bitsPerSample - Number of bits per sample

ounsigned GetEncoding() const
Get the current encoding. A value of 0 indicates linear PCM, any other value is platform dependent.

ounsigned GetChannels() const
Get the number of channels (mono/stereo) in the sound

ounsigned GetSampleRate() const
Get the sample rate in samples per second

ounsigned GetSampleSize() const
Get the sample size in bits per sample

oDWORD GetErrorCode() const
Get the platform dependent error code from the last file load

oPINDEX GetFormatInfoSize() const
Get the size of the platform dependent format info

oconst void* GetFormatInfoData() const
Get pointer to the platform dependent format info

o Miscellaneous functions

ostatic BOOL PlayFile( const PFilePath & file, BOOL wait = TRUE )
Play a sound file to the default device. If the wait parameter is TRUE then the function does not return until the file has been played. If FALSE then the sound play is begun asynchronously and the function returns immediately.

Parameters:
file - Sound file to play.
wait - Flag to play sound synchronously.
Returns:
TRUE if the sound is playing or has played.

ostatic void Beep()
Play the "standard" warning beep for the platform

ounsigned encoding
Format code

ounsigned numChannels
Number of channels eg mono/stereo

ounsigned sampleRate
Samples per second

ounsigned sampleSize
Number of bits per sample

oDWORD dwLastError
Last error code for Load()/Save() functions

oPBYTEArray formatInfo
Full info on the format (platform dependent)


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.