QAudioFormat Class
The QAudioFormat class stores audio stream parameter information. More...
| Header: | #include <QAudioFormat> |
| qmake: | QT += multimedia |
Public Types
| enum | Endian { BigEndian, LittleEndian } |
| enum | SampleType { Unknown, SignedInt, UnSignedInt, Float } |
Detailed Description
An audio format specifies how data in an audio stream is arranged, i.e, how the stream is to be interpreted. The encoding itself is specified by the codec() used for the stream.
In addition to the encoding, QAudioFormat contains other parameters that further specify how the audio sample data is arranged. These are the frequency, the number of channels, the sample size, the sample type, and the byte order. The following table describes these in more detail.
| Parameter | Description |
|---|---|
| Sample Rate | Samples per second of audio data in Hertz. |
| Number of channels | The number of audio channels (typically one for mono or two for stereo) |
| Sample size | How much data is stored in each sample (typically 8 or 16 bits) |
| Sample type | Numerical representation of sample (typically signed integer, unsigned integer or float) |
| Byte order | Byte ordering of sample (typically little endian, big endian) |
This class is typically used in conjunction with QAudioInput or QAudioOutput to allow you to specify the parameters of the audio stream being read or written, or with QAudioBuffer when dealing with samples in memory.
You can obtain audio formats compatible with the audio device used through functions in QAudioDeviceInfo. This class also lets you query available parameter values for a device, so that you can set the parameters yourself. See the QAudioDeviceInfo class description for details. You need to know the format of the audio streams you wish to play or record.
In the common case of interleaved linear PCM data, the codec will be "audio/pcm", and the samples for all channels will be interleaved. One sample for each channel for the same instant in time is referred to as a frame in Qt Multimedia (and other places).
Member Type Documentation
enum QAudioFormat::Endian
| Constant | Value | Description |
|---|---|---|
QAudioFormat::BigEndian | QSysInfo::BigEndian | Samples are big endian byte order |
QAudioFormat::LittleEndian | QSysInfo::LittleEndian | Samples are little endian byte order |
enum QAudioFormat::SampleType
| Constant | Value | Description |
|---|---|---|
QAudioFormat::Unknown | 0 | Not Set |
QAudioFormat::SignedInt | 1 | Samples are signed integers |
QAudioFormat::UnSignedInt | 2 | Samples are unsigned intergers |
QAudioFormat::Float | 3 | Samples are floats |