CopperSpice API
1.9.2
|
The QAudioFormat class stores audio stream parameter information. More...
Public Types | |
enum | Endian |
enum | SampleType |
Public Methods | |
QAudioFormat () | |
QAudioFormat (const QAudioFormat &other) | |
~QAudioFormat () | |
QAudioFormat::Endian | byteOrder () const |
qint32 | bytesForDuration (qint64 duration) const |
qint32 | bytesForFrames (qint32 frameCount) const |
int | bytesPerFrame () const |
int | channelCount () const |
QString | codec () const |
qint64 | durationForBytes (qint32 byteCount) const |
qint64 | durationForFrames (qint32 frameCount) const |
qint32 | framesForBytes (qint32 byteCount) const |
qint32 | framesForDuration (qint64 duration) const |
bool | isValid () const |
bool | operator!= (const QAudioFormat &other) const |
QAudioFormat & | operator= (const QAudioFormat &other) |
bool | operator== (const QAudioFormat &other) const |
int | sampleRate () const |
int | sampleSize () const |
QAudioFormat::SampleType | sampleType () const |
void | setByteOrder (QAudioFormat::Endian byteOrder) |
void | setChannelCount (int channelCount) |
void | setCodec (const QString &codec) |
void | setSampleRate (int sampleRate) |
void | setSampleSize (int sampleSize) |
void | setSampleType (QAudioFormat::SampleType sampleType) |
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. 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.
enum QAudioFormat::Endian |
Enums for describing the format of samples.
Constant | Value | Description |
---|---|---|
QAudioFormat::BigEndian | QSysInfo::BigEndian | Samples are big endian byte order |
QAudioFormat::LittleEndian | QSysInfo::LittleEndian | Samples are little endian byte order |
Enums for describing the format of samples.
Constant | Value | Description |
---|---|---|
QAudioFormat:Unknown | 0 | Not Set |
QAudioFormat:SignedInt | 1 | Samples are signed integers |
QAudioFormat:UnSignedInt | 2 | Samples are unsigned integers |
QAudioFormat:Float | 3 | Samples are floats |
QAudioFormat::QAudioFormat | ( | ) |
Construct a new audio format with values are initialized as shown.
QAudioFormat::QAudioFormat | ( | const QAudioFormat & | other | ) |
Construct a new audio format using other.
QAudioFormat::~QAudioFormat | ( | ) |
Destroy this audio format.
QAudioFormat::Endian QAudioFormat::byteOrder | ( | ) | const |
Returns the current byteOrder value.
Returns the number of bytes required for this audio format for duration microseconds. Returns 0 if this format is not valid. Some rounding may occur if duration is not an exact fraction of the sampleRate().
Returns the number of bytes required for frameCount frames of this format. Returns 0 if this format is not valid.
int QAudioFormat::bytesPerFrame | ( | ) | const |
Returns the number of bytes required to represent one frame (a sample in each channel) in this format. Returns 0 if this format is invalid.
int QAudioFormat::channelCount | ( | ) | const |
Returns the current channel count value.
QString QAudioFormat::codec | ( | ) | const |
Returns the current codec identifier.
Returns the number of microseconds represented by byteCountss in this format. Returns 0 if this format is not valid. Some rounding may occur if bytes is not an exact multiple of the number of bytes per frame.
Return the number of microseconds represented by frameCount frames in this format.
Returns the number of frames represented by byteCount in this format. Each frame has one sample per channel. Some rounding may occur if byteCount is not an exact multiple of the number of bytes per frame.
Returns the number of frames required to represent duration microseconds in this format.
Some rounding may occur if duration is not an exact fraction of the sampleRate().
bool QAudioFormat::isValid | ( | ) | const |
Returns true if all of the parameters are valid.
bool QAudioFormat::operator!= | ( | const QAudioFormat & | other | ) | const |
Returns true if this QAudioFormat is not equal to the other QAudioFormat, otherwise returns false. All elements of QAudioFormat are used for the comparison.
QAudioFormat & QAudioFormat::operator= | ( | const QAudioFormat & | other | ) |
Copy assigns from other and returns a reference to this object.
bool QAudioFormat::operator== | ( | const QAudioFormat & | other | ) | const |
Returns true if this QAudioFormat is equal to the other QAudioFormat, otherwise returns false. All elements of QAudioFormat are used for the comparison.
int QAudioFormat::sampleRate | ( | ) | const |
Returns the current sample rate in Hertz.
int QAudioFormat::sampleSize | ( | ) | const |
Returns the current sample size value, in bits.
QAudioFormat::SampleType QAudioFormat::sampleType | ( | ) | const |
Returns the current SampleType value.
void QAudioFormat::setByteOrder | ( | QAudioFormat::Endian | byteOrder | ) |
void QAudioFormat::setChannelCount | ( | int | channelCount | ) |
Sets the channel count to channelCount.
void QAudioFormat::setCodec | ( | const QString & | codec | ) |
Sets the codec to the given codec. The codec should be one of the types reported by the QAudioDeviceInfo::supportedCodecs() method for the audio device you are working with.
void QAudioFormat::setSampleRate | ( | int | sampleRate | ) |
Sets the sample rate to sampleRate Hertz.
void QAudioFormat::setSampleSize | ( | int | sampleSize | ) |
Sets the sample size to the sampleSize specified, in bits. This is typically 8 or 16, but some systems may support higher sample sizes.
void QAudioFormat::setSampleType | ( | QAudioFormat::SampleType | sampleType | ) |
Sets the sampleType to sampleType.