The QAudioFormat 類存儲音頻流參數信息。 更多...
| 頭: | #include <QAudioFormat> |
| qmake: | QT += multimedia |
| enum | Endian { BigEndian, LittleEndian } |
| enum | SampleType { Unknown, SignedInt, UnSignedInt, Float } |
| 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 bytes ) const |
| qint64 | durationForFrames (qint32 frameCount ) const |
| qint32 | framesForBytes (qint32 byteCount ) const |
| qint32 | framesForDuration (qint64 duration ) const |
| bool | isValid () const |
| int | sampleRate () const |
| int | sampleSize () const |
| QAudioFormat::SampleType | sampleType () const |
| void | setByteOrder (QAudioFormat::Endian byteOrder ) |
| void | setChannelCount (int channels ) |
| void | setCodec (const QString & codec ) |
| void | setSampleRate (int samplerate ) |
| void | setSampleSize (int sampleSize ) |
| void | setSampleType (QAudioFormat::SampleType sampleType ) |
| bool | operator!= (const QAudioFormat & other ) const |
| QAudioFormat & | operator= (const QAudioFormat & other ) |
| bool | operator== (const QAudioFormat & other ) const |
The QAudioFormat 類存儲音頻流參數信息。
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.
除編碼外, 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.
| 參數 | 描述 |
|---|---|
| 采樣率 | Samples per second of audio data in Hertz. |
| 通道數 | The number of audio channels (typically one for mono or two for stereo) |
| 采樣大小 | How much data is stored in each sample (typically 8 or 16 bits) |
| 采樣類型 | Numerical representation of sample (typically signed integer, unsigned integer or float) |
| 字節序 | 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).
| 常量 | 值 | 描述 |
|---|---|---|
QAudioFormat::BigEndian
|
QSysInfo::BigEndian
|
Samples are big endian byte order |
QAudioFormat::LittleEndian
|
QSysInfo::LittleEndian
|
Samples are little endian byte order |
| 常量 | 值 | 描述 |
|---|---|---|
QAudioFormat::Unknown
|
0
|
不設置 |
QAudioFormat::SignedInt
|
1
|
采樣是有符號整數 |
QAudioFormat::UnSignedInt
|
2
|
采樣是無符號整數 |
QAudioFormat::Float
|
3
|
采樣是浮點數 |
構建新的音頻格式。
值的初始化如下:
codec()
= ""
構造新的音頻格式使用 other .
銷毀此音頻格式。
Returns the current byteOrder value.
另請參閱 setByteOrder ().
Returns the number of bytes required for this audio format for duration 微秒。
返迴 0 若此格式無效。
Note that some rounding may occur if duration is not an exact fraction of the sampleRate ().
另請參閱 durationForBytes ().
Returns the number of bytes required for frameCount frames of this format.
返迴 0 若此格式無效。
另請參閱 bytesForDuration ().
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.
返迴當前通道計數值。
另請參閱 setChannelCount ().
返迴當前編解碼器標識符。
另請參閱 setCodec () 和 QAudioDeviceInfo::supportedCodecs ().
Returns the number of microseconds represented by bytes in this format.
返迴 0 若此格式無效。
Note that some rounding may occur if bytes is not an exact multiple of the number of bytes per frame.
另請參閱 bytesForDuration ().
Return the number of microseconds represented by frameCount frames in this format.
Returns the number of frames represented by byteCount in this format.
Note that some rounding may occur if byteCount is not an exact multiple of the number of bytes per frame.
Each frame has one sample per channel.
另請參閱 framesForDuration ().
Returns the number of frames required to represent duration microseconds in this format.
Note that some rounding may occur if duration is not an exact fraction of the sampleRate ().
Returns true if all of the parameters are valid.
返迴當前采樣率 (以赫茲為單位)。
另請參閱 setSampleRate ().
返迴當前采樣大小值 (以位為單位)。
另請參閱 setSampleSize () 和 bytesPerFrame ().
返迴當前 SampleType 值。
另請參閱 setSampleType ().
設置 byteOrder to byteOrder .
另請參閱 byteOrder ().
將通道計數設為 channels .
另請參閱 channelCount ().
將編解碼器設為 codec .
The parameter to this function should be one of the types reported by the QAudioDeviceInfo::supportedCodecs () function for the audio device you are working with.
另請參閱 codec () 和 QAudioDeviceInfo::supportedCodecs ().
Sets the sample rate to samplerate Hertz.
另請參閱 sampleRate ().
Sets the sample size to the sampleSize specified, in bits.
This is typically 8 or 16, but some systems may support higher sample sizes.
另請參閱 sampleSize ().
設置 sampleType to sampleType .
另請參閱 sampleType ().
返迴 true,若此 QAudioFormat is not equal to the other QAudioFormat ;否則返迴 false。
All elements of QAudioFormat are used for the comparison.
賦值 other 到此 QAudioFormat 實現。
返迴 true,若此 QAudioFormat is equal to the other QAudioFormat ;否則返迴 false。
All elements of QAudioFormat are used for the comparison.