Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QAudioBuffer Class

The QAudioBuffer class represents a collection of audio samples with a specific format and sample rate. More...

 #include <QAudioBuffer>

Public Types

class StereoSample
typedef S16S
typedef S16U
typedef S32F
typedef S8S
typedef S8U

Public Functions

QAudioBuffer()
QAudioBuffer(const QAudioBuffer & other)
QAudioBuffer(const QByteArray & data, const QAudioFormat & format, qint64 startTime = -1)
QAudioBuffer(int numSamples, const QAudioFormat & format, qint64 startTime = -1)
~QAudioBuffer()
int byteCount() const
const void * constData() const
const T * constData() const
const void * data() const
void * data()
const T * data() const
T * data()
qint64 duration() const
QAudioFormat format() const
bool isValid() const
int sampleCount() const
qint64 startTime() const
QAudioBuffer & operator=(const QAudioBuffer & other)

Detailed Description

The QAudioBuffer class represents a collection of audio samples with a specific format and sample rate.

Member Type Documentation

typedef QAudioBuffer::S16S

This is a predefined specialization for a signed stereo 16 bit sample. Each channel is a signed short.

typedef QAudioBuffer::S16U

This is a predefined specialization for an unsigned stereo 16 bit sample. Each channel is an unsigned short.

typedef QAudioBuffer::S32F

This is a predefined specialization for an 32 bit float sample. Each channel is a float.

typedef QAudioBuffer::S8S

This is a predefined specialization for a signed stereo 8 bit sample. Each channel is a signed char.

typedef QAudioBuffer::S8U

This is a predefined specialization for an unsigned stereo 8 bit sample. Each channel is an unsigned char.

Member Function Documentation

QAudioBuffer::QAudioBuffer()

Create a new, empty, invalid buffer.

QAudioBuffer::QAudioBuffer(const QAudioBuffer & other)

Creates a new audio buffer from other. Generally this will have copy-on-write semantics - a copy will only be made when it has to be.

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 sample 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.

QAudioBuffer::QAudioBuffer(int numSamples, const QAudioFormat & format, qint64 startTime = -1)

Creates a new audio buffer with space for numSamples samples of the given format. The 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.

QAudioBuffer::~QAudioBuffer()

Destroys this audio buffer.

int QAudioBuffer::byteCount() const

Returns the size of this buffer, in bytes.

const void * QAudioBuffer::constData() const

Returns a pointer to this buffer's data. You can only read it.

This method is preferred over the const version of data() to prevent unnecessary copying.

There is also a templatized version of this constData() function that allows you to retrieve a specific type of read-only pointer to the data. Note that there is no checking done on the format of the audio buffer - this is simply a convenience function.

 // With a 16bit sample buffer:
 const quint16 *data = buffer->constData<quint16>();

const T * QAudioBuffer::constData() const

const void * QAudioBuffer::data() const

Returns a pointer to this buffer's data. You can only read it.

You should use the constData() function rather than this to prevent accidental deep copying.

There is also a templatized version of this data() function that allows you to retrieve a specific type of read-only pointer to the data. Note that there is no checking done on the format of the audio buffer - this is simply a convenience function.

 // With a 16bit sample const buffer:
 const quint16 *data = buffer->data<quint16>();

void * QAudioBuffer::data()

Returns a pointer to this buffer's data. You can modify the data through the returned pointer.

Since QAudioBuffers can share the actual sample data, calling this function will result in a deep copy being made if there are any other buffers using the sample. You should avoid calling this unless you really need to modify the data.

This pointer will remain valid until the underlying storage is detached. In particular, if you obtain a pointer, and then copy this audio buffer, changing data through this pointer may change both buffer instances. Calling data() on either instance will again cause a deep copy to be made, which may invalidate the pointers returned from this function previously.

There is also a templatized version of data() allows you to retrieve a specific type of pointer to the data. Note that there is no checking done on the format of the audio buffer - this is simply a convenience function.

 // With a 16bit sample buffer:
 quint16 *data = buffer->data<quint16>(); // May cause deep copy

const T * QAudioBuffer::data() const

T * QAudioBuffer::data()

qint64 QAudioBuffer::duration() const

Returns the duration of audio in this buffer, in microseconds.

This depends on the /l format(), and the sampleCount().

QAudioFormat QAudioBuffer::format() const

Returns the format of this buffer.

Several properties of this format influence how the duration() or byteCount() are calculated from the sampleCount().

bool QAudioBuffer::isValid() const

Returns true if this is a valid buffer. A valid buffer has more than zero samples in it and a valid format.

int QAudioBuffer::sampleCount() const

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.

qint64 QAudioBuffer::startTime() const

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.

QAudioBuffer & QAudioBuffer::operator=(const QAudioBuffer & other)

Assigns the other buffer to this.

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web