[−][src]Module libpulse_binding::sample
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
Spec | A sample format and attribute specification. |
Enums
Format | Sample format |
Constants
CHANNELS_MAX | Maximum number of allowed channels. |
RATE_MAX | Maximum allowed sample rate. |
SAMPLE_FLOAT32NE | 32 Bit IEEE floating point, native endian. |
SAMPLE_FLOAT32RE | 32 Bit IEEE floating point, reverse endian. |
SAMPLE_FLOAT32 | A Shortcut for |
SAMPLE_S16NE | Signed 16 Bit PCM, native endian. |
SAMPLE_S16RE | Signed 16 Bit PCM, reverse endian. |
SAMPLE_S24NE | Signed 24 Bit PCM packed, native endian. |
SAMPLE_S24RE | Signed 24 Bit PCM, packed reverse endian. |
SAMPLE_S32NE | Signed 32 Bit PCM, native endian. |
SAMPLE_S32RE | Signed 32 Bit PCM, reverse endian. |
SAMPLE_S24_32NE | Signed 24 Bit PCM in LSB of 32 Bit words, native endian. |
SAMPLE_S24_32RE | Signed 24 Bit PCM, in LSB of 32 Bit words, reverse endian. |
Functions
bytes_print | Pretty print a byte size value (i.e. “2.5 MiB”). |
channels_are_valid | Checkss if the channel count is within the supported range. |
format_is_valid | Checks if the given integer is a valid sample format. |
rate_is_valid | Checks if the rate is within the supported range. |