MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

Sample Format Specifications

Overview

PulseAudio is capable of handling a multitude of sample formats, rates and channels, transparently converting and mixing them as needed.

Sample Format

PulseAudio supports the following sample formats:

  • PA_SAMPLE_U8 - Unsigned 8 bit integer PCM.
  • PA_SAMPLE_S16LE - Signed 16 integer bit PCM, little endian.
  • PA_SAMPLE_S16BE - Signed 16 integer bit PCM, big endian.
  • PA_SAMPLE_FLOAT32LE - 32 bit IEEE floating point PCM, little endian.
  • PA_SAMPLE_FLOAT32BE - 32 bit IEEE floating point PCM, big endian.
  • PA_SAMPLE_ALAW - 8 bit a-Law.
  • PA_SAMPLE_ULAW - 8 bit mu-Law.
  • PA_SAMPLE_S32LE - Signed 32 bit integer PCM, little endian.
  • PA_SAMPLE_S32BE - Signed 32 bit integer PCM, big endian.
  • PA_SAMPLE_S24LE - Signed 24 bit integer PCM packed, little endian.
  • PA_SAMPLE_S24BE - Signed 24 bit integer PCM packed, big endian.
  • PA_SAMPLE_S24_32LE - Signed 24 bit integer PCM in LSB of 32 bit words, little endian.
  • PA_SAMPLE_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.

The sample formats that are sensitive to endianness have convenience macros for native endian (NE), and reverse endian (RE).

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 continous. To map channels to speakers, see Channel Maps.

Calculations

The PulseAudio library contains a number of convenience functions to do calculations on sample formats:

  • pa_bytes_per_second() - The number of bytes one second of audio will take given a sample format.
  • pa_frame_size() - The size, in bytes, of one frame (i.e. one set of samples, one for each channel).
  • pa_sample_size() - The size, in bytes, of one sample.
  • pa_bytes_to_usec() - Calculate the time it would take to play a buffer of a certain size.

Convenience Functions

The library also contains a couple of other convenience functions:

  • pa_sample_spec_valid() - Tests if a sample format specification is valid.
  • pa_sample_spec_equal() - Tests if the sample format specifications are identical.
  • pa_sample_format_to_string() - Return a textual description of a sample format.
  • pa_parse_sample_format() - Parse a text string into a sample format.
  • pa_sample_spec_snprint() - Create a textual description of a complete sample format specification.
  • pa_bytes_snprint() - Pretty print a byte value (e.g. 2.5 MiB).

Several copyright owners
GNU Lesser General Public License v2.1
MeeGo 1.2 Harmattan API