Module libpulse_binding::sample [] [src]

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:

Structs

Spec

A sample format and attribute specification

Enums

Format

Sample format

Constants

BYTES_PRINT_MAX

The maximum length of strings returned by bytes_print, as per the underlying C function. Please note that this value can change with any release without warning and without being considered API or ABI breakage. You should not use this definition anywhere where it might become part of an ABI.

CHANNELS_MAX

Maximum number of allowed channels

RATE_MAX

Maximum allowed sample rate

SAMPLE_FLOAT32

A Shortcut for SAMPLE_FLOAT32NE

SAMPLE_FLOAT32NE

32 Bit IEEE floating point, native endian

SAMPLE_FLOAT32RE

32 Bit IEEE floating point, reverse endian

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_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.

SAMPLE_S32NE

Signed 32 Bit PCM, native endian

SAMPLE_S32RE

Signed 32 Bit PCM, reverse endian

SPEC_PRINT_MAX

The maximum length of strings returned by Spec::print, as per the underlying C function. Please note that this value can change with any release without warning and without being considered API or ABI breakage. You should not use this definition anywhere where it might become part of an ABI.

Functions

bytes_print

Pretty print a byte size value (i.e. "2.5 MiB")

channels_are_valid

Returns true if the channel count is within the supported range.

format_is_be

Returns true when the specified format is big endian, false if little endian. Returns None when endianness does not apply to this format, or if unknown.

format_is_le

Returns true when the specified format is little endian, false if big endian. Returns None when endianness does not apply to this format, or if unknown.

format_is_ne

Is format native endian?

format_is_re

Is format reverse of native endian?

format_is_valid

Returns true if the given integer is a valid sample format.

format_to_string

Returns a descriptive string for the specified sample format.

parse_format

Parse a sample format text. Inverse of format_to_string.

rate_is_valid

Returns true if the rate is within the supported range.

size_of_format

Similar to Spec::sample_size but take a sample format instead of full sample spec.

Type Definitions

Usecs

Type for usec specifications (unsigned). Always 64 bit.