![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtMultimedia More...
#include <qaudiobuffer.h>
Public Types | |
typedef QAudioFrameMono< QAudioFormat::UInt8 > | U8M |
This is a predefined specialization for an unsigned 8 bit mono sample. | |
typedef QAudioFrameMono< QAudioFormat::Int16 > | S16M |
typedef QAudioFrameMono< QAudioFormat::Int32 > | S32M |
This is a predefined specialization for a signed 32 bit mono sample. | |
typedef QAudioFrameMono< QAudioFormat::Float > | F32M |
This is a predefined specialization for a 32 bit float mono sample. | |
typedef QAudioFrameStereo< QAudioFormat::UInt8 > | U8S |
This is a predifined specialization for an unsiged 8 bit stereo sample. | |
typedef QAudioFrameStereo< QAudioFormat::Int16 > | S16S |
This is a predefined specialization for a signed stereo 16 bit sample. | |
typedef QAudioFrameStereo< QAudioFormat::Int32 > | S32S |
This is a predifined specialization for a siged 32 bit stereo sample. | |
typedef QAudioFrameStereo< QAudioFormat::Float > | F32S |
This is a predifined specialization for a 32 bit float stereo sample. | |
Public Member Functions | |
QAudioBuffer () noexcept | |
Create a new, empty, invalid buffer. | |
QAudioBuffer (const QAudioBuffer &other) noexcept | |
Creates a new audio buffer from other. | |
QAudioBuffer (const QByteArray &data, const QAudioFormat &format, qint64 startTime=-1) | |
Creates a new audio buffer from the supplied data, in the given format. | |
QAudioBuffer (int numFrames, const QAudioFormat &format, qint64 startTime=-1) | |
Creates a new audio buffer with space for numFrames frames of the given format. | |
~QAudioBuffer () | |
Destroys this audio buffer. | |
QAudioBuffer & | operator= (const QAudioBuffer &other) |
Moves other into this QAudioBuffer. | |
QAudioBuffer (QAudioBuffer &&other) noexcept=default | |
Constructs a QAudioBuffer by moving from other. | |
void | swap (QAudioBuffer &other) noexcept |
Swaps the audio buffer with other. | |
bool | isValid () const noexcept |
Returns true if this is a valid buffer. | |
void | detach () |
Detaches this audio buffers from other copies that might share data with it. | |
QAudioFormat | format () const noexcept |
Returns the \l {QAudioFormat}{format} of this buffer. | |
qsizetype | frameCount () const noexcept |
Returns the number of complete audio frames in this buffer. | |
qsizetype | sampleCount () const noexcept |
Returns the number of samples in this buffer. | |
qsizetype | byteCount () const noexcept |
Returns the size of this buffer, in bytes. | |
qint64 | duration () const noexcept |
Returns the duration of audio in this buffer, in microseconds. | |
qint64 | startTime () const noexcept |
Returns the time in a stream that this buffer starts at (in microseconds). | |
template<typename T> | |
const T * | constData () const |
Returns a pointer to this buffer's data. | |
template<typename T> | |
const T * | data () const |
Returns a pointer to this buffer's data. | |
template<typename T> | |
T * | data () |
Returns a pointer to this buffer's data. | |
\inmodule QtMultimedia
The QAudioBuffer class represents a collection of audio samples with a specific format and sample rate.
QAudioBuffer is used by the QAudioDecoder class to hand decoded audio data over to the application. An audio buffer contains data in a certain QAudioFormat that can be queried using format(). It is also tagged with timing and duration information.
To access the data stored inside the buffer, use the data() or constData() methods.
Audio buffers are explicitly shared, in most cases, you should call detach() before modifying the data.
Definition at line 114 of file qaudiobuffer.h.
This is a predefined specialization for a 32 bit float mono sample.
Definition at line 147 of file qaudiobuffer.h.
This is a predifined specialization for a 32 bit float stereo sample.
Definition at line 152 of file qaudiobuffer.h.
Definition at line 145 of file qaudiobuffer.h.
This is a predefined specialization for a signed stereo 16 bit sample.
Each channel is a {signed short}.
Definition at line 150 of file qaudiobuffer.h.
This is a predefined specialization for a signed 32 bit mono sample.
\typedef QAudioBuffer::S16M This is a predefined specialization for a signed 16 bit mono sample.
i
Definition at line 146 of file qaudiobuffer.h.
This is a predifined specialization for a siged 32 bit stereo sample.
Definition at line 151 of file qaudiobuffer.h.
This is a predefined specialization for an unsigned 8 bit mono sample.
Definition at line 144 of file qaudiobuffer.h.
This is a predifined specialization for an unsiged 8 bit stereo sample.
Definition at line 149 of file qaudiobuffer.h.
|
defaultnoexcept |
Create a new, empty, invalid buffer.
|
defaultnoexcept |
Creates a new audio buffer from other.
Audio buffers are explicitly shared, you should call detach() on the buffer to make a copy that can then be modified.
QAudioBuffer::QAudioBuffer | ( | const QByteArray & | data, |
const QAudioFormat & | format, | ||
qint64 | startTime = -1 ) |
Creates a new audio buffer from the supplied data, in the given format.
The format will determine how the number and sizes of the samples are interpreted from the data.
If the supplied data is not an integer multiple of the calculated frame size, the excess data will not be used.
This audio buffer will copy the contents of data.
startTime (in microseconds) indicates when this buffer starts in the stream. If this buffer is not part of a stream, set it to -1.
Definition at line 74 of file qaudiobuffer.cpp.
QAudioBuffer::QAudioBuffer | ( | int | numFrames, |
const QAudioFormat & | format, | ||
qint64 | startTime = -1 ) |
Creates a new audio buffer with space for numFrames frames of the given format.
The individual samples will be initialized to the default for the format.
startTime (in microseconds) indicates when this buffer starts in the stream. If this buffer is not part of a stream, set it to -1.
Definition at line 90 of file qaudiobuffer.cpp.
|
default |
Destroys this audio buffer.
|
defaultnoexcept |
Constructs a QAudioBuffer by moving from other.
|
noexcept |
Returns the size of this buffer, in bytes.
Definition at line 189 of file qaudiobuffer.cpp.
|
inline |
Returns a pointer to this buffer's data.
You can only read it.
This method is preferred over the const version of \l data() to prevent unnecessary copying.
Note that there is no checking done on the format of the audio buffer - this is simply a convenience function.
Definition at line 154 of file qaudiobuffer.h.
|
inline |
Returns a pointer to this buffer's data.
You can modify the data through the returned pointer.
Since QAudioBuffer objects are explicitly shared, you should usually call detach() before modifying the data through this function.
Note that there is no checking done on the format of the audio buffer - this is simply a convenience function.
Definition at line 160 of file qaudiobuffer.h.
|
inline |
Returns a pointer to this buffer's data.
You can only read it.
You should use the \l constData() function rather than this to prevent accidental deep copying.
Note that there is no checking done on the format of the audio buffer - this is simply a convenience function.
Definition at line 157 of file qaudiobuffer.h.
void QAudioBuffer::detach | ( | ) |
Detaches this audio buffers from other copies that might share data with it.
Definition at line 136 of file qaudiobuffer.cpp.
|
noexcept |
Returns the duration of audio in this buffer, in microseconds.
This depends on the \l format(), and the \l frameCount().
Definition at line 199 of file qaudiobuffer.cpp.
|
noexcept |
Returns the \l {QAudioFormat}{format} of this buffer.
Several properties of this format influence how the \l duration() or \l byteCount() are calculated from the \l frameCount().
Definition at line 150 of file qaudiobuffer.cpp.
|
noexcept |
Returns the number of complete audio frames in this buffer.
An audio frame is an interleaved set of one sample per channel for the same instant in time.
Definition at line 163 of file qaudiobuffer.cpp.
|
inlinenoexcept |
Returns true if this is a valid buffer.
A valid buffer has more than zero frames in it and a valid format.
Definition at line 130 of file qaudiobuffer.h.
|
default |
Moves other into this QAudioBuffer.
Assigns the other buffer to this.
|
noexcept |
Returns the number of samples in this buffer.
If the format of this buffer has multiple channels, then this count includes all channels. This means that a stereo buffer with 1000 samples in total will have 500 left samples and 500 right samples (interleaved), and this function will return 1000.
Definition at line 181 of file qaudiobuffer.cpp.
|
noexcept |
Returns the time in a stream that this buffer starts at (in microseconds).
If this buffer is not part of a stream, this will return -1.
Definition at line 209 of file qaudiobuffer.cpp.
|
inlinenoexcept |
Swaps the audio buffer with other.
Definition at line 127 of file qaudiobuffer.h.