Data formats

Updated: May 06, 2022

The QNX Sound Architecture supports a variety of data formats.

Data format constants

The <sys/asound.h> header file defines two sets of constants for the data formats. The two sets are related (and easily converted between) but serve different purposes:

SND_PCM_SFMT_*
A single selection from the set of data formats. For a list of the supported formats, see snd_pcm_get_format_name() in the “Audio Library” chapter.
SND_PCM_FMT_*
A group of (one or more) formats within a single variable. This is useful for specifying the format capabilities of a device, for example.

Generally, the SND_PCM_FMT_* constants are used to convey information about raw potential, and the SND_PCM_SFMT_* constants are used to select and report a specific configuration.

You can build a format from its width and other attributes, by calling snd_pcm_build_linear_format().

You can use these functions to check the characteristics of a format:

24-bit audio format

Data for 24-bit audio is represented as either 3 bytes or 4 bytes.

In most cases, audio files store 24-bit data as 3 bytes.

Because your hardware likely requires 32-bit aligned data access, the 24-bit data is usually converted to 4 bytes. The 24-bit sample in the 32-bit integer can have one of the following types of alignment: