QAudioFormatclass stores audio stream parameter information. 更多 …
def
__eq__
(other)
def
__ne__
(other)
def
byteOrder
()
def
bytesForDuration
(duration)
def
bytesForFrames
(frameCount)
def
bytesPerFrame
()
def
channelCount
()
def
codec
()
def
durationForBytes
(byteCount)
def
durationForFrames
(frameCount)
def
framesForBytes
(byteCount)
def
framesForDuration
(duration)
def
isValid
()
def
sampleRate
()
def
sampleSize
()
def
sampleType
()
def
setByteOrder
(byteOrder)
def
setChannelCount
(channelCount)
def
setCodec
(codec)
def
setSampleRate
(sampleRate)
def
setSampleSize
(sampleSize)
def
setSampleType
(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,
QAudioFormatcontains 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
描述
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
QAudioInputorQAudioOutputto allow you to specify the parameters of the audio stream being read or written, or withQAudioBufferwhen 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 theQAudioDeviceInfoclass 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
¶
QAudioFormat(other)
- param other
Construct a new audio format.
Values are initialized as follows:
sampleRate()
= -1
channelCount()
= -1
sampleSize()
= -1
byteOrder()
=
Endian
(
ByteOrder
)
sampleType()
=
未知
codec()
= “”
Construct a new audio format using
other
.
PySide2.QtMultimedia.QAudioFormat.
SampleType
¶
|
常量 |
描述 |
|---|---|
|
QAudioFormat.Unknown |
Not Set |
|
QAudioFormat.SignedInt |
Samples are signed integers |
|
QAudioFormat.UnSignedInt |
Samples are unsigned intergers |
|
QAudioFormat.Float |
Samples are floats |
PySide2.QtMultimedia.QAudioFormat.
Endian
¶
|
常量 |
描述 |
|---|---|
|
QAudioFormat.BigEndian |
Samples are big endian byte order |
|
QAudioFormat.LittleEndian |
Samples are little endian byte order |
PySide2.QtMultimedia.QAudioFormat.
byteOrder
(
)
¶
Returns the current value.
另请参阅
PySide2.QtMultimedia.QAudioFormat.
bytesForDuration
(
duration
)
¶
duration
–
qint64
qint32
Returns the number of bytes required for this audio format for
duration
微秒。
Returns 0 if this format is not valid.
Note that some rounding may occur if
duration
is not an exact fraction of the
sampleRate()
.
另请参阅
PySide2.QtMultimedia.QAudioFormat.
bytesForFrames
(
frameCount
)
¶
frameCount
–
qint32
qint32
Returns the number of bytes required for
frameCount
frames of this format.
Returns 0 if this format is not valid.
另请参阅
PySide2.QtMultimedia.QAudioFormat.
bytesPerFrame
(
)
¶
int
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.
PySide2.QtMultimedia.QAudioFormat.
channelCount
(
)
¶
int
Returns the current channel count value.
另请参阅
PySide2.QtMultimedia.QAudioFormat.
codec
(
)
¶
unicode
Returns the current codec identifier.
PySide2.QtMultimedia.QAudioFormat.
durationForBytes
(
byteCount
)
¶
byteCount
–
qint32
qint64
Returns the number of microseconds represented by
bytes
in this format.
Returns 0 if this format is not valid.
Note that some rounding may occur if
bytes
is not an exact multiple of the number of bytes per frame.
另请参阅
PySide2.QtMultimedia.QAudioFormat.
durationForFrames
(
frameCount
)
¶
frameCount
–
qint32
qint64
Return the number of microseconds represented by
frameCount
frames in this format.
PySide2.QtMultimedia.QAudioFormat.
framesForBytes
(
byteCount
)
¶
byteCount
–
qint32
qint32
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.
另请参阅
PySide2.QtMultimedia.QAudioFormat.
framesForDuration
(
duration
)
¶
duration
–
qint64
qint32
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()
.
PySide2.QtMultimedia.QAudioFormat.
isValid
(
)
¶
bool
Returns true if all of the parameters are valid.
PySide2.QtMultimedia.QAudioFormat.
__ne__
(
other
)
¶
other
–
QAudioFormat
bool
返回 true,若此
QAudioFormat
is not equal to the
other
QAudioFormat
;否则返回 false。
All elements of
QAudioFormat
are used for the comparison.
PySide2.QtMultimedia.QAudioFormat.
__eq__
(
other
)
¶
other
–
QAudioFormat
bool
返回 true,若此
QAudioFormat
is equal to the
other
QAudioFormat
;否则返回 false。
All elements of
QAudioFormat
are used for the comparison.
PySide2.QtMultimedia.QAudioFormat.
sampleRate
(
)
¶
int
Returns the current sample rate in Hertz.
另请参阅
PySide2.QtMultimedia.QAudioFormat.
sampleSize
(
)
¶
int
Returns the current sample size value, in bits.
PySide2.QtMultimedia.QAudioFormat.
sampleType
(
)
¶
返回当前
SampleType
值。
另请参阅
PySide2.QtMultimedia.QAudioFormat.
setByteOrder
(
byteOrder
)
¶
byteOrder
–
Endian
设置
byteOrder
to
byteOrder
.
另请参阅
PySide2.QtMultimedia.QAudioFormat.
setChannelCount
(
channelCount
)
¶
channelCount
–
int
Sets the channel count to
channels
.
另请参阅
PySide2.QtMultimedia.QAudioFormat.
setCodec
(
codec
)
¶
codec – unicode
Sets the codec to
codec
.
The parameter to this function should be one of the types reported by the
supportedCodecs()
function for the audio device you are working with.
另请参阅
PySide2.QtMultimedia.QAudioFormat.
setSampleRate
(
sampleRate
)
¶
sampleRate
–
int
Sets the sample rate to
samplerate
Hertz.
另请参阅
PySide2.QtMultimedia.QAudioFormat.
setSampleSize
(
sampleSize
)
¶
sampleSize
–
int
Sets the sample size to the
sampleSize
specified, in bits.
This is typically 8 or 16, but some systems may support higher sample sizes.
另请参阅
PySide2.QtMultimedia.QAudioFormat.
setSampleType
(
sampleType
)
¶
sampleType
–
SampleType
设置
sampleType
to
sampleType
.
另请参阅