Module libpulse_binding::sample
source · Expand description
Constants and routines for sample type handling.
Overview
PulseAudio is capable of handling a multitude of sample formats, rates and channels, transparently converting and mixing them as needed.
Sample Formats
PulseAudio supports the following sample formats:
U8
- Unsigned 8 bit integer PCM.S16LE
- Signed 16 integer bit PCM, little endian.S16BE
- Signed 16 integer bit PCM, big endian.FLOAT32LE
- 32 bit IEEE floating point PCM, little endian.FLOAT32BE
- 32 bit IEEE floating point PCM, big endian.ALAW
- 8 bit a-Law.ULAW
- 8 bit mu-Law.S32LE
- Signed 32 bit integer PCM, little endian.S32BE
- Signed 32 bit integer PCM, big endian.S24LE
- Signed 24 bit integer PCM packed, little endian.S24BE
- Signed 24 bit integer PCM packed, big endian.S24_32LE
- Signed 24 bit integer PCM in LSB of 32 bit words, little endian.S24_32BE
- Signed 24 bit integer PCM in LSB of 32 bit words, big endian.
The floating point sample formats have the range from -1.0
to 1.0
.
Sample Rates
PulseAudio supports any sample rate between 1 Hz and 192000 Hz. There is no point trying to exceed the sample rate of the output device though as the signal will only get downsampled, consuming CPU on the machine running the server.
Channels
PulseAudio supports up to 32 individual channels. The order of the channels is up to the
application, but they must be continuous. To map channels to speakers, see
channelmap
.
Calculations
The PulseAudio library contains a number of convenience functions to do calculations on sample formats:
Spec::bytes_per_second()
: The number of bytes one second of audio will take given a sample format.Spec::frame_size()
: The size, in bytes, of one frame (i.e. one set of samples, one for each channel).Spec::sample_size()
: The size, in bytes, of one sample.Spec::bytes_to_usec()
: Calculate the time it would take to play a buffer of a certain size.
Structs
- A sample format and attribute specification.
Enums
- Sample format.
Constants
- CHANNELS_MAXDeprecatedMaximum number of allowed channels.
- RATE_MAXDeprecatedMaximum allowed sample rate.
- SAMPLE_FLOAT32DeprecatedA shortcut for
SAMPLE_FLOAT32NE
. - SAMPLE_FLOAT32NEDeprecated32-bit IEEE floating point, native endian.
- SAMPLE_FLOAT32REDeprecated32-bit IEEE floating point, reverse endian.
- SAMPLE_S16NEDeprecatedSigned 16-bit PCM, native endian.
- SAMPLE_S16REDeprecatedSigned 16-bit PCM reverse endian.
- SAMPLE_S24NEDeprecatedSigned 24-bit PCM packed, native endian.
- SAMPLE_S24REDeprecatedSigned 24-bit PCM, packed reverse endian.
- SAMPLE_S24_32NEDeprecatedSigned 24-bit PCM in LSB of 32-bit words, native endian.
- SAMPLE_S24_32REDeprecatedSigned 24-bit PCM, in LSB of 32-bit words, reverse endian.
- SAMPLE_S32NEDeprecatedSigned 32-bit PCM, native endian.
- SAMPLE_S32REDeprecatedSigned 32-bit PCM, reverse endian.
Functions
- Pretty print a byte size value (i.e. “2.5 MiB”).