CopperSpice API  1.7.2
QAudioBuffer::StereoFrame< T > Class Template Reference

The StereoFrame class provides a simple wrapper for a stereo audio frame. More...

Public Methods

 StereoFrame ()
 
 StereoFrame (T leftSample, T rightSample)
 
average () const
 
void clear ()
 
StereoFrame & operator= (const StereoFrame &other)
 

Public Members

left
 
right
 

Detailed Description

template<typename T>
class QAudioBuffer::StereoFrame< T >

A templated structure lets you treat a block of individual samples as an interleaved stereo stream frame. This is most useful when used with QAudioBuffer::data() functions of QAudioBuffer. Generally the data is accessed as a pointer.

There are some predefined instantiations of this template for working with common stereo sample depths in a convenient way.

This frame structure has left and right members for accessing individual channel data.

// Assuming 'buffer' is an unsigned 16 bit stereo buffer
QAudioBuffer::S16U *frames = buffer->data<QAudioBuffer::S16U>();
for (int i = 0; i < buffer->frameCount(); i++) {
qSwap(frames[i].left, frames[i].right);
}
See also
QAudioBuffer::S8U, QAudioBuffer::S8S, QAudioBuffer::S16S, QAudioBuffer::S16U, QAudioBuffer::S32F

Constructor & Destructor Documentation

template<typename T >
QAudioBuffer::StereoFrame< T >::StereoFrame ( )
inline

Constructs a new frame with the "silent" value for this sample format (0 for signed formats and floats, 0x8* for unsigned formats).

template<typename T >
QAudioBuffer::StereoFrame< T >::StereoFrame ( leftSample,
rightSample 
)
inline

Constructs a new frame with the supplied leftSample and rightSample values.

Method Documentation

template<typename T >
T QAudioBuffer::StereoFrame< T >::average ( ) const
inline

Returns the arithmetic average of the left and right samples.

template<typename T >
void QAudioBuffer::StereoFrame< T >::clear ( )
inline

Sets the values of this frame to the "silent" value.

template<typename T >
StereoFrame & QAudioBuffer::StereoFrame< T >::operator= ( const StereoFrame< T > &  other)
inline

Assigns other to this frame.

Member Data Documentation

template<typename T >
QAudioBuffer::StereoFrame< T >::left

Value for the sample from the left channel.

template<typename T >
QAudioBuffer::StereoFrame< T >::right

Value for the sample from the right channel.