class PSoundChannel |
A class representing a sound channel.
Overrides from class PObject
Information functions
Reading functions
Writing functions
Miscellaneous functions
Error functions
Run Time Type functions
I/O functions
Comparison functions
A class representing a sound channel. This class is provided mainly for the playback or recording of sounds on the system.A sound driver is either playing or recording. If simultaneous playing and recording is desired, two instances of PSoundChannel must be created.
The sound is buffered and the size and number of buffers should be set before playing/recording. Each call to Write() will use one buffer, so care needs to be taken not to use a large number of small writes but tailor the buffers to the size of each write you make.
Similarly for reading, an entire buffer must be read before any of it is available to a Read() call. Note that once a buffer is filled you can read it a byte at a time if desired, but as soon as all the data in the buffer is used returned, the next read will wait until the entire next buffer is read from the hardware. So again, tailor the number and size of buffers to the application. To avoid being blocked until the buffer fills, you can use the StartRecording() function to initiate the buffer filling, and the IsRecordingBufferFull() function to determine when the Read() function will no longer block.
Note that this sound channel is implicitly a linear PCM channel. No data conversion is performed on data to/from the channel.
Note that if the PlayFile() function is used, this may be overridden by information in the file being played.
Note that with Linux OSS, the size is always rounded up to the nearest power of two, so 20000 => 32768.
Note if the driver is closed of the object destroyed then the sound play is aborted.
Also note that not all possible sounds and sound files are playable by this library. No format conversions between sound object and driver are performed.
Note if the driver is closed of the object destroyed then the sound play is aborted.
Also note that not all possible sounds and sound files are playable by this library. No format conversions between sound object and driver are performed.
For the Win32 platform, the most efficient way to record a PSound is to use the SetBuffers() function to set a single buffer of the desired size and then do the recording. For Linux OSS this can cause problems as the buffers are rounded up to a power of two, so to gain more accuracy you need a number of smaller buffers.
Note that this function will block until all of the data is buffered. If you wish to do this asynchronously, use StartRecording() and AreAllrecordBuffersFull() to determine when you can call RecordSound() without blocking.
Note that this function will block until all of the data is buffered. If you wish to do this asynchronously, use StartRecording() and AreAllrecordBuffersFull() to determine when you can call RecordSound() without blocking.
Alphabetic index HTML hierarchy of classes or Java