68 unsigned bitsPerSample = 16,
69 PINDEX bufferSize = 0,
70 const BYTE * data = NULL
126 unsigned bitsPerSample
273 unsigned numChannels = 1,
274 unsigned sampleRate = 8000,
275 unsigned bitsPerSample = 16
337 unsigned numChannels = 1,
338 unsigned sampleRate = 8000,
339 unsigned bitsPerSample = 16,
381 unsigned numChannels = 1,
382 unsigned sampleRate = 8000,
383 unsigned bitsPerSample = 16
445 unsigned numChannels = 1,
446 unsigned sampleRate = 8000,
447 unsigned bitsPerSample = 16
791 #define PCREATE_SOUND_PLUGIN(name, className) \
792 static PSoundChannelPluginServiceDescriptor<className> className##_descriptor; \
793 PCREATE_PLUGIN(name, PSoundChannel, &className##_descriptor)
797 #elif defined(__BEOS__)
801 #if defined(P_DIRECTSOUND)
805 #if defined(P_WAVFILE)
810 #endif // PTLIB_SOUND_H
Directions GetDirection() const
Get the direction of the channel.
Definition: sound.h:410
static PSoundChannel * CreateOpenedChannel(const PString &driverName, const PString &deviceName, Directions direction, unsigned numChannels=1, unsigned sampleRate=8000, unsigned bitsPerSample=16, PPluginManager *pluginMgr=NULL)
Create an opened sound channel that corresponds to the specified names.
virtual PBoolean PlayFile(const PFilePath &file, PBoolean wait=true)
Play a sound file to the open device.
virtual PBoolean Close()
Close the channel, shutting down the link to the data source.
Abstract class for a generalised sound channel, and an implementation of PSoundChannel for old code t...
Definition: sound.h:251
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.
Directions
Definition: sound.h:258
static PBoolean PlayFile(const PFilePath &file, PBoolean wait=true)
Play a sound file to the default device.
virtual PString GetName() const
Get the name of the open channel.
virtual PBoolean WaitForPlayCompletion()
Block calling thread until the sound play begun with PlaySound() or PlayFile() has completed...
unsigned GetChannels() const
Get the number of channels (mono/stereo) in the sound.
Definition: sound.h:135
unsigned GetSampleSize() const
Get the sample size in bits per sample.
Definition: sound.h:141
Directions activeDirection
This is the direction that this sound channel is opened for use in.
Definition: sound.h:776
static void Beep()
Play the "standard" warning beep for the platform.
virtual PBoolean GetVolume(unsigned &volume)
Get the volume of the play/read process.
const void * GetFormatInfoData() const
Get pointer to the platform dependent format info.
Definition: sound.h:150
static PStringArray GetDriversDeviceNames(const PString &driverName, Directions direction, PPluginManager *pluginMgr=NULL)
Get sound devices that correspond to the specified driver name.
virtual PBoolean SetVolume(unsigned volume)
Set the volume of the play/read process.
Definition: pluginmgr.h:57
PSound & operator=(const PBYTEArray &data)
Set new data bytes for the sound.
virtual unsigned GetSampleSize() const
Get the sample size in bits per sample.
PSoundChannel * m_baseChannel
Definition: sound.h:769
virtual PObject * CreateInstance(int) const
Definition: sound.h:787
virtual PBoolean HasPlayCompleted()
Indicate if the sound play begun with PlayBuffer() or PlayFile() has completed.
virtual PINDEX GetLastWriteCount() const
Get number of bytes written in last Write() operation.
This class describes a full description for a file on the particular platform.
Definition: filepath.h:65
virtual PBoolean RecordFile(const PFilePath &file)
Record into the platform dependent sound file all of the buffer's of sound data.
virtual PBoolean Read(void *buf, PINDEX len)
Low level read from the channel.
virtual PBoolean SetFormat(unsigned numChannels=1, unsigned sampleRate=8000, unsigned bitsPerSample=16)
Set the format for play/record.
static PSoundChannel * CreateChannelByName(const PString &deviceName, Directions direction, PPluginManager *pluginMgr=NULL)
This is an array collection class of PString objects.
Definition: pstring.h:2024
virtual PBoolean StartRecording()
Start filling record buffers.
virtual PBoolean AreAllRecordBuffersFull()
Determine if all of the record buffer allocated has been filled.
static PStringArray GetDriverNames(PPluginManager *pluginMgr=NULL)
Get the list of available sound drivers (plug-ins)
virtual PBoolean Abort()
Abort the background playing/recording of the sound channel.
DWORD GetErrorCode() const
Get the platform dependent error code from the last file load.
Definition: sound.h:144
virtual PStringArray GetDeviceNames(int userData) const
Definition: sound.h:788
BOOL PBoolean
Definition: object.h:102
PBoolean Load(const PFilePath &filename)
Load a platform dependent sound file (eg .WAV file for Win32) into the object.
virtual PBoolean IsRecordBufferFull()
Determine if a record buffer has been filled, so that the next Read() call will not block...
virtual PBoolean WaitForRecordBufferFull()
Block the thread until a record buffer has been filled, so that the next Read() call will not block...
PINDEX GetFormatInfoSize() const
Get the size of the platform dependent format info.
Definition: sound.h:147
A class representing a sound.
Definition: sound.h:52
Array of unsigned characters.
Definition: array.h:670
PBoolean Play()
Play the sound on the default sound device.
virtual PBoolean WaitForAllRecordBuffersFull()
Block the thread until all of the record buffer allocated has been filled.
virtual PBoolean Write(const void *buf, PINDEX len)
Low level write (or play) to the channel.
virtual unsigned GetSampleRate() const
Get the sample rate in samples per second.
static PString GetDefaultDevice(Directions dir)
Get the name for the default sound devices/driver that is on this platform.
static PSoundChannel * CreateChannel(const PString &driverName, PPluginManager *pluginMgr=NULL)
Create the sound channel that corresponds to the specified driver name.
PPLUGIN_STATIC_LOAD(FakeVideo, PVideoInputDevice)
Abstract class defining I/O channel semantics.
Definition: channel.h:107
virtual PINDEX GetSize() const
Get the current size of the container.
PINDEX GetLastReadCount() const
Return number of bytes read in last Read() call.
The character string class.
Definition: pstring.h:108
DWORD dwLastError
Last error code for Load()/Save() functions.
Definition: sound.h:182
virtual PBoolean GetBuffers(PINDEX &size, PINDEX &count)
Get the internal buffers for the sound channel I/O.
void SetFormat(unsigned numChannels, unsigned sampleRate, unsigned bitsPerSample)
Set the internal sound format to linear PCM at the specification in the parameters.
PBoolean Save(const PFilePath &filename)
Save a platform dependent sound file (eg .WAV file for Win32) from the object.
unsigned GetEncoding() const
Get the current encoding.
Definition: sound.h:132
unsigned sampleSize
Number of bits per sample.
Definition: sound.h:180
virtual int GetHandle() const
Get the OS specific handle for the PSoundChannel.
PReadWriteMutex m_baseMutex
Definition: sound.h:770
PBYTEArray formatInfo
Full info on the format (platform dependent)
Definition: sound.h:184
virtual bool SetMute(bool mute)
Set the mute state of the play/read process.
virtual unsigned GetChannels() const
Get the number of channels (mono/stereo) in the sound.
static PStringArray GetDeviceNames(const PString &driverName, Directions direction, PPluginManager *pluginMgr=NULL)
Definition: sound.h:302
unsigned sampleRate
Samples per second.
Definition: sound.h:178
virtual const char * GetDirectionText() const
Definition: sound.h:418
virtual PBoolean PlaySound(const PSound &sound, PBoolean wait=true)
Play a sound to the open device.
virtual bool GetMute(bool &mute)
Get the mute state of the play/read process.
This class defines a thread synchronisation object.
Definition: syncthrd.h:251
virtual PBoolean Open(const PString &device, Directions dir, unsigned numChannels=1, unsigned sampleRate=8000, unsigned bitsPerSample=16)
Open the specified device for playing or recording.
PSoundChannel()
Create a sound channel.
virtual PBoolean IsOpen() const
Test if this instance of PSoundChannel is open.
unsigned numChannels
Number of channels eg mono/stereo.
Definition: sound.h:176
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
virtual PBoolean RecordSound(PSound &sound)
Record into the sound object all of the buffer's of sound data.
virtual PBoolean SetBuffers(PINDEX size, PINDEX count=2)
Set the internal buffers for the sound channel I/O.
unsigned encoding
Format code.
Definition: sound.h:174
unsigned GetSampleRate() const
Get the sample rate in samples per second.
Definition: sound.h:138