#include <sound.h>
Inheritance diagram for PSound:
Construction | |
PSound (unsigned numChannels=1, unsigned sampleRate=8000, unsigned bitsPerSample=16, PINDEX bufferSize=0, const BYTE *data=NULL) | |
PSound (const PFilePath &filename) | |
PSound & | operator= (const PBYTEArray &data) |
Public Member Functions | |
File functions | |
BOOL | Load (const PFilePath &filename) |
BOOL | Save (const PFilePath &filename) |
Access functions | |
BOOL | Play () |
Play the sound on the default sound device. | |
BOOL | Play (const PString &device) |
Play the sound to the specified sound device. | |
void | SetFormat (unsigned numChannels, unsigned sampleRate, unsigned bitsPerSample) |
unsigned | GetEncoding () const |
unsigned | GetChannels () const |
Get the number of channels (mono/stereo) in the sound. | |
unsigned | GetSampleRate () const |
Get the sample rate in samples per second. | |
unsigned | GetSampleSize () const |
Get the sample size in bits per sample. | |
DWORD | GetErrorCode () const |
Get the platform dependent error code from the last file load. | |
PINDEX | GetFormatInfoSize () const |
Get the size of the platform dependent format info. | |
const void * | GetFormatInfoData () const |
Get pointer to the platform dependent format info. | |
Static Public Member Functions | |
Miscellaneous functions | |
static BOOL | PlayFile (const PFilePath &file, BOOL wait=TRUE) |
static void | Beep () |
Play the "standard" warning beep for the platform. | |
Protected Attributes | |
unsigned | encoding |
Format code. | |
unsigned | numChannels |
Number of channels eg mono/stereo. | |
unsigned | sampleRate |
Samples per second. | |
unsigned | sampleSize |
Number of bits per sample. | |
DWORD | dwLastError |
Last error code for Load()/Save() functions. | |
PBYTEArray | formatInfo |
Full info on the format (platform dependent). |
The most common sound to use is the static function Beep()# which emits the system standard "warning" or "attention" sound.
PSound::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.
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 |
PSound::PSound | ( | const PFilePath & | filename | ) |
Create a new sound, reading from a platform dependent file.
filename | Sound file to load. |
PSound& PSound::operator= | ( | const PBYTEArray & | data | ) |
Set new data bytes for the sound.
data | New data for sound |
BOOL PSound::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.
filename | Sound file to load. |
BOOL PSound::Save | ( | const PFilePath & | filename | ) |
Save a platform dependent sound file (eg .WAV file for Win32) from the object.
filename | Sound file to load. |
BOOL PSound::Play | ( | ) |
Play the sound on the default sound device.
BOOL PSound::Play | ( | const PString & | device | ) |
Play the sound to the specified sound device.
void PSound::SetFormat | ( | unsigned | numChannels, | |
unsigned | sampleRate, | |||
unsigned | bitsPerSample | |||
) |
Set the internal sound format to linear PCM at the specification in the parameters.
numChannels | Number of channels eg mono/stereo |
sampleRate | Samples per second |
bitsPerSample | Number of bits per sample |
unsigned PSound::GetEncoding | ( | ) | const [inline] |
Get the current encoding. A value of 0 indicates linear PCM, any other value is platform dependent.
unsigned PSound::GetChannels | ( | ) | const [inline] |
Get the number of channels (mono/stereo) in the sound.
unsigned PSound::GetSampleRate | ( | ) | const [inline] |
Get the sample rate in samples per second.
unsigned PSound::GetSampleSize | ( | ) | const [inline] |
Get the sample size in bits per sample.
DWORD PSound::GetErrorCode | ( | ) | const [inline] |
Get the platform dependent error code from the last file load.
PINDEX PSound::GetFormatInfoSize | ( | ) | const [inline] |
Get the size of the platform dependent format info.
const void* PSound::GetFormatInfoData | ( | ) | const [inline] |
Get pointer to the platform dependent format info.
static BOOL PSound::PlayFile | ( | const PFilePath & | file, | |
BOOL | wait = TRUE | |||
) | [static] |
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.
file | Sound file to play. |
wait | Flag to play sound synchronously. |
static void PSound::Beep | ( | ) | [static] |
Play the "standard" warning beep for the platform.
unsigned PSound::encoding [protected] |
Format code.
unsigned PSound::numChannels [protected] |
Number of channels eg mono/stereo.
unsigned PSound::sampleRate [protected] |
Samples per second.
unsigned PSound::sampleSize [protected] |
Number of bits per sample.
DWORD PSound::dwLastError [protected] |
Last error code for Load()/Save() functions.
PBYTEArray PSound::formatInfo [protected] |
Full info on the format (platform dependent).