PySide6.QtMultimedia.QAudioBuffer¶
- class QAudioBuffer¶
- The - QAudioBufferclass represents a collection of audio samples with a specific format and sample rate. More…- Synopsis¶- Methods¶- def - __init__()
- def - byteCount()
- def - duration()
- def - format()
- def - frameCount()
- def - isValid()
- def - sampleCount()
- def - startTime()
- def - swap()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- QAudioBufferis used by the- QAudioDecoderclass to hand decoded audio data over to the application. An audio buffer contains data in a certain- QAudioFormatthat 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.- __init__()¶
 - Create a new, empty, invalid buffer. - __init__(other)
- Parameters:
- other – - QAudioBuffer
 
 - 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.- __init__(data, format[, startTime=-1])
- Parameters:
- data – - QByteArray
- format – - QAudioFormat
- startTime – int 
 
 
 - 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 - datais 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.- __init__(numFrames, format[, startTime=-1])
- Parameters:
- numFrames – int 
- format – - QAudioFormat
- startTime – int 
 
 
 - Creates a new audio buffer with space for - numFramesframes 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.- byteCount()¶
- Return type:
- int 
 
 - Returns the size of this buffer, in bytes. - duration()¶
- Return type:
- int 
 
 - Returns the duration of audio in this buffer, in microseconds. - This depends on the - format(), and the- frameCount().- format()¶
- Return type:
 
 - Returns the - formatof this buffer.- Several properties of this format influence how the - duration()or- byteCount()are calculated from the- frameCount().- frameCount()¶
- Return type:
- int 
 
 - 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. - isValid()¶
- Return type:
- bool 
 
 - Returns true if this is a valid buffer. A valid buffer has more than zero frames in it and a valid format. - sampleCount()¶
- Return type:
- int 
 
 - 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. - See also - startTime()¶
- Return type:
- int 
 
 - 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. - swap(other)¶
- Parameters:
- other – - QAudioBuffer
 
 - Swaps the audio buffer with - other.