QAudioFormat Class Reference

[ QtMultimedia module]

The QAudioFormat class stores audio parameter information. 更多...

类型

方法

Special Methods


详细描述

The QAudioFormat class stores audio parameter information.

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 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 描述
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)

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. Qt does not set up formats for you.


类型文档编制

QAudioFormat.Endian

常量 描述
QAudioFormat.BigEndian QSysInfo.BigEndian samples are big endian byte order
QAudioFormat.LittleEndian QSysInfo.LittleEndian samples are little endian byte order

QAudioFormat.SampleType

常量 描述
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

方法文档编制

QAudioFormat.__init__ ( self )

Construct a new audio format.

Values are initialized as follows:

QAudioFormat.__init__ ( self , QAudioFormat   other )

Construct a new audio format using other .

Endian QAudioFormat.byteOrder ( self )

Returns the current byteOrder value.

另请参阅 setByteOrder ().

int QAudioFormat.channelCount ( self )

Returns the current channel count value.

该函数在 Qt 4.7 引入。

另请参阅 setChannelCount ().

int QAudioFormat.channels ( self )

QString QAudioFormat.codec ( self )

Returns the current codec value.

另请参阅 setCodec () 和 QAudioDeviceInfo.supportedCodecs ().

int QAudioFormat.frequency ( self )

bool QAudioFormat.isValid ( self )

Returns true if all of the parameters are valid.

int QAudioFormat.sampleRate ( self )

Returns the current sample rate in Hertz.

该函数在 Qt 4.7 引入。

另请参阅 setSampleRate ().

int QAudioFormat.sampleSize ( self )

Returns the current sample size value.

另请参阅 setSampleSize ().

SampleType QAudioFormat.sampleType ( self )

返回当前 SampleType 值。

另请参阅 setSampleType ().

QAudioFormat.setByteOrder ( self , Endian   byteOrder )

Sets the byteOrder to byteOrder .

另请参阅 byteOrder ().

QAudioFormat.setChannelCount ( self , int  channelCount )

Sets the channel count to channels .

该函数在 Qt 4.7 引入。

另请参阅 channelCount ().

QAudioFormat.setChannels ( self , int  channels )

QAudioFormat.setCodec ( self , QString  codec )

Sets the codec to codec .

另请参阅 codec () and QAudioDeviceInfo.supportedCodecs ().

QAudioFormat.setFrequency ( self , int  frequency )

QAudioFormat.setSampleRate ( self , int  sampleRate )

Sets the sample rate to samplerate Hertz.

该函数在 Qt 4.7 引入。

另请参阅 sampleRate ().

QAudioFormat.setSampleSize ( self , int  sampleSize )

Sets the sample size to the sampleSize 指定。

另请参阅 sampleSize ().

QAudioFormat.setSampleType ( self , SampleType   sampleType )

Sets the sampleType to sampleType .

另请参阅 sampleType ().

bool QAudioFormat.__eq__ ( self , QAudioFormat   other )

bool QAudioFormat.__ne__ ( self , QAudioFormat   other )