Qt 4.8
Public Types | Public Functions | Properties | List of all members
QAudioFormat Class Reference

The QAudioFormat class stores audio parameter information. More...

#include <qaudioformat.h>

Public Types

enum  Endian { BigEndian = QSysInfo::BigEndian, LittleEndian = QSysInfo::LittleEndian }
 
enum  SampleType { Unknown, SignedInt, UnSignedInt, Float }
 

Public Functions

QAudioFormat::Endian byteOrder () const
 Returns the current byteOrder value. More...
 
int channelCount () const
 Returns the current channel count value. More...
 
int channels () const
 Use channelCount() instead. More...
 
QString codec () const
 Returns the current codec value. More...
 
int frequency () const
 Use sampleRate() instead. More...
 
bool isValid () const
 Returns true if all of the parameters are valid. More...
 
bool operator!= (const QAudioFormat &other) const
 Returns true if this QAudioFormat is not equal to the other QAudioFormat; otherwise returns false. More...
 
QAudioFormatoperator= (const QAudioFormat &other)
 Assigns other to this QAudioFormat implementation. More...
 
bool operator== (const QAudioFormat &other) const
 Returns true if this QAudioFormat is equal to the other QAudioFormat; otherwise returns false. More...
 
 QAudioFormat ()
 Construct a new audio format. More...
 
 QAudioFormat (const QAudioFormat &other)
 Construct a new audio format using other. More...
 
int sampleRate () const
 Returns the current sample rate in Hertz. More...
 
int sampleSize () const
 Returns the current sample size value. More...
 
QAudioFormat::SampleType sampleType () const
 Returns the current SampleType value. More...
 
void setByteOrder (QAudioFormat::Endian byteOrder)
 Sets the byteOrder to byteOrder. More...
 
void setChannelCount (int channelCount)
 Sets the channel count to channels. More...
 
void setChannels (int channels)
 Use setChannelCount() instead. More...
 
void setCodec (const QString &codec)
 Sets the codec to codec. More...
 
void setFrequency (int frequency)
 Use setSampleRate() instead. More...
 
void setSampleRate (int sampleRate)
 Sets the sample rate to samplerate Hertz. More...
 
void setSampleSize (int sampleSize)
 Sets the sample size to the sampleSize specified. More...
 
void setSampleType (QAudioFormat::SampleType sampleType)
 Sets the sampleType to sampleType. More...
 
 ~QAudioFormat ()
 Destroy this audio format. More...
 

Properties

QSharedDataPointer< QAudioFormatPrivated
 

Detailed Description

The QAudioFormat class stores audio parameter information.

Attention
Module: QtMultimedia
Since
4.6

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

Definition at line 60 of file qaudioformat.h.

Enumerations

◆ Endian

  • BigEndian samples are big endian byte order
  • LittleEndian samples are little endian byte order
Enumerator
BigEndian 
LittleEndian 

Definition at line 64 of file qaudioformat.h.

64 { BigEndian = QSysInfo::BigEndian, LittleEndian = QSysInfo::LittleEndian };

◆ SampleType

  • Unknown Not Set
  • SignedInt samples are signed integers
  • UnSignedInt samples are unsigned intergers
  • Float samples are floats
Enumerator
Unknown 
SignedInt 
UnSignedInt 
Float 

Definition at line 63 of file qaudioformat.h.

Constructors and Destructors

◆ QAudioFormat() [1/2]

QAudioFormat::QAudioFormat ( )

Construct a new audio format.

Values are initialized as follows:

Definition at line 158 of file qaudioformat.cpp.

158  :
160 {
161 }
QSharedDataPointer< QAudioFormatPrivate > d
Definition: qaudioformat.h:99

◆ QAudioFormat() [2/2]

QAudioFormat::QAudioFormat ( const QAudioFormat other)

Construct a new audio format using other.

Definition at line 167 of file qaudioformat.cpp.

167  :
168  d(other.d)
169 {
170 }
QSharedDataPointer< QAudioFormatPrivate > d
Definition: qaudioformat.h:99

◆ ~QAudioFormat()

QAudioFormat::~QAudioFormat ( )

Destroy this audio format.

Definition at line 176 of file qaudioformat.cpp.

177 {
178 }

Functions

◆ byteOrder()

QAudioFormat::Endian QAudioFormat::byteOrder ( ) const

◆ channelCount()

int QAudioFormat::channelCount ( ) const

Returns the current channel count value.

Since
4.7

Definition at line 310 of file qaudioformat.cpp.

311 {
312  return d->channels;
313 }
QSharedDataPointer< QAudioFormatPrivate > d
Definition: qaudioformat.h:99

◆ channels()

int QAudioFormat::channels ( ) const

◆ codec()

QString QAudioFormat::codec ( ) const

Returns the current codec value.

See also
QAudioDeviceInfo::supportedCodecs()

Definition at line 364 of file qaudioformat.cpp.

Referenced by operator<<(), QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(), setCodec(), and QAudioDeviceInfoInternal::testSettings().

365 {
366  return d->codec;
367 }
QSharedDataPointer< QAudioFormatPrivate > d
Definition: qaudioformat.h:99

◆ frequency()

int QAudioFormat::frequency ( ) const

◆ isValid()

bool QAudioFormat::isValid ( ) const

Returns true if all of the parameters are valid.

Definition at line 223 of file qaudioformat.cpp.

Referenced by QAudioOutputPrivate::freeBlocks(), QAudioInputPrivate::freeBlocks(), QAudioInputPrivate::open(), QAudioOutputPrivate::open(), and QAudioDeviceInfoInternal::QAudioDeviceInfoInternal().

224 {
225  return d->frequency != -1 && d->channels != -1 && d->sampleSize != -1 &&
227 }
QAudioFormat::SampleType sampleType
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QSharedDataPointer< QAudioFormatPrivate > d
Definition: qaudioformat.h:99

◆ operator!=()

bool QAudioFormat::operator!= ( const QAudioFormat other) const

Returns true if this QAudioFormat is not equal to the other QAudioFormat; otherwise returns false.

All elements of QAudioFormat are used for the comparison.

Definition at line 214 of file qaudioformat.cpp.

215 {
216  return !(*this == other);
217 }

◆ operator=()

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

Assigns other to this QAudioFormat implementation.

Definition at line 184 of file qaudioformat.cpp.

185 {
186  d = other.d;
187  return *this;
188 }
QSharedDataPointer< QAudioFormatPrivate > d
Definition: qaudioformat.h:99

◆ operator==()

bool QAudioFormat::operator== ( const QAudioFormat other) const

Returns true if this QAudioFormat is equal to the other QAudioFormat; otherwise returns false.

All elements of QAudioFormat are used for the comparison.

Definition at line 197 of file qaudioformat.cpp.

198 {
199  return d->frequency == other.d->frequency &&
200  d->channels == other.d->channels &&
201  d->sampleSize == other.d->sampleSize &&
202  d->byteOrder == other.d->byteOrder &&
203  d->codec == other.d->codec &&
204  d->sampleType == other.d->sampleType;
205 }
QAudioFormat::SampleType sampleType
QSharedDataPointer< QAudioFormatPrivate > d
Definition: qaudioformat.h:99
QAudioFormat::Endian byteOrder

◆ sampleRate()

int QAudioFormat::sampleRate ( ) const

Returns the current sample rate in Hertz.

Since
4.7

Definition at line 260 of file qaudioformat.cpp.

261 {
262  return d->frequency;
263 }
QSharedDataPointer< QAudioFormatPrivate > d
Definition: qaudioformat.h:99

◆ sampleSize()

int QAudioFormat::sampleSize ( ) const

◆ sampleType()

QAudioFormat::SampleType QAudioFormat::sampleType ( ) const

◆ setByteOrder()

void QAudioFormat::setByteOrder ( QAudioFormat::Endian  byteOrder)

Sets the byteOrder to byteOrder.

Definition at line 373 of file qaudioformat.cpp.

Referenced by QAudioDeviceInfoInternal::preferredFormat(), QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(), and toQAudioFormat().

374 {
375  d->byteOrder = byteOrder;
376 }
QAudioFormat::Endian byteOrder() const
Returns the current byteOrder value.
QSharedDataPointer< QAudioFormatPrivate > d
Definition: qaudioformat.h:99
QAudioFormat::Endian byteOrder

◆ setChannelCount()

void QAudioFormat::setChannelCount ( int  channels)

Sets the channel count to channels.

Since
4.7

Definition at line 285 of file qaudioformat.cpp.

286 {
287  d->channels = channels;
288 }
QSharedDataPointer< QAudioFormatPrivate > d
Definition: qaudioformat.h:99
int channels() const
Use channelCount() instead.

◆ setChannels()

void QAudioFormat::setChannels ( int  channels)

Use setChannelCount() instead.

Definition at line 299 of file qaudioformat.cpp.

Referenced by QAudioDeviceInfoInternal::preferredFormat(), QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(), and toQAudioFormat().

300 {
301  d->channels = channels;
302 }
QSharedDataPointer< QAudioFormatPrivate > d
Definition: qaudioformat.h:99
int channels() const
Use channelCount() instead.

◆ setCodec()

void QAudioFormat::setCodec ( const QString codec)

Sets the codec to codec.

See also
QAudioDeviceInfo::supportedCodecs()

Definition at line 353 of file qaudioformat.cpp.

Referenced by QAudioDeviceInfo::nearestFormat(), QAudioDeviceInfoInternal::preferredFormat(), QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(), and toQAudioFormat().

354 {
355  d->codec = codec;
356 }
QString codec() const
Returns the current codec value.
QSharedDataPointer< QAudioFormatPrivate > d
Definition: qaudioformat.h:99

◆ setFrequency()

void QAudioFormat::setFrequency ( int  frequency)

Use setSampleRate() instead.

Definition at line 249 of file qaudioformat.cpp.

Referenced by QAudioDeviceInfo::nearestFormat(), QAudioDeviceInfoInternal::preferredFormat(), QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(), and toQAudioFormat().

250 {
251  d->frequency = frequency;
252 }
int frequency() const
Use sampleRate() instead.
QSharedDataPointer< QAudioFormatPrivate > d
Definition: qaudioformat.h:99

◆ setSampleRate()

void QAudioFormat::setSampleRate ( int  samplerate)

Sets the sample rate to samplerate Hertz.

Since
4.7

Definition at line 235 of file qaudioformat.cpp.

236 {
237  d->frequency = samplerate;
238 }
QSharedDataPointer< QAudioFormatPrivate > d
Definition: qaudioformat.h:99

◆ setSampleSize()

void QAudioFormat::setSampleSize ( int  sampleSize)

Sets the sample size to the sampleSize specified.

Definition at line 333 of file qaudioformat.cpp.

Referenced by QAudioDeviceInfo::nearestFormat(), QAudioDeviceInfoInternal::preferredFormat(), QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(), and toQAudioFormat().

334 {
336 }
int sampleSize() const
Returns the current sample size value.
QSharedDataPointer< QAudioFormatPrivate > d
Definition: qaudioformat.h:99

◆ setSampleType()

void QAudioFormat::setSampleType ( QAudioFormat::SampleType  sampleType)

Sets the sampleType to sampleType.

Definition at line 391 of file qaudioformat.cpp.

Referenced by QAudioDeviceInfo::nearestFormat(), QAudioDeviceInfoInternal::preferredFormat(), QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(), and toQAudioFormat().

392 {
394 }
QAudioFormat::SampleType sampleType
QAudioFormat::SampleType sampleType() const
Returns the current SampleType value.
QSharedDataPointer< QAudioFormatPrivate > d
Definition: qaudioformat.h:99

Properties

◆ d

QSharedDataPointer<QAudioFormatPrivate> QAudioFormat::d
private

The documentation for this class was generated from the following files: