Base Framework
Public Member Functions | List of all members
SoundOutputStream Class Reference

Sound output stream. More...

#include <base/sound/SoundOutputStream.h>

Inherits Object.

Public Member Functions

 SoundOutputStream (unsigned int samplingRate, unsigned int channels)
 
unsigned int getChannels () const noexcept
 
unsigned int getRate () const noexcept
 
unsigned int getPosition () const noexcept
 
void resume () noexcept
 
void pause () noexcept
 
void reset () noexcept
 
void wait () noexcept
 
unsigned int write (const void *buffer, unsigned int size)
 
 ~SoundOutputStream () noexcept
 

Detailed Description

Sound output stream.

Sound output stream.

See also
SoundInputStream
Version
1.0

Constructor & Destructor Documentation

◆ SoundOutputStream()

SoundOutputStream::SoundOutputStream ( unsigned int  samplingRate,
unsigned int  channels 
)

Initializes the sound output device. Common sampling rates are 5000Hz, 8000Hz, 11025Hz, 22050Hz, 44100Hz, and 48000Hz.

Parameters
samplingRateThe sampling rate specified in samples per second.
channelsThe number of channels (must be greater than 0).

◆ ~SoundOutputStream()

SoundOutputStream::~SoundOutputStream ( )
noexcept

Destructs the stream object.

Member Function Documentation

◆ getChannels()

unsigned int SoundOutputStream::getChannels ( ) const
noexcept

Returns the number of channels (greater than 0).

◆ getPosition()

unsigned int SoundOutputStream::getPosition ( ) const
noexcept

Returns the total number of samples since the last resume.

◆ getRate()

unsigned int SoundOutputStream::getRate ( ) const
noexcept

Returns the sampling rate (samples per second).

◆ pause()

void SoundOutputStream::pause ( )
noexcept

Pauses the stream.

◆ reset()

void SoundOutputStream::reset ( )
noexcept

Resets the device.

◆ resume()

void SoundOutputStream::resume ( )
noexcept

Resumes the stream.

◆ wait()

void SoundOutputStream::wait ( )
noexcept

Wait for all the samples to be played back.

◆ write()

unsigned int SoundOutputStream::write ( const void *  buffer,
unsigned int  size 
)

Writes bytes in buffer to stream.

Parameters
bufferThe buffer containing the bytes to be written.
sizeThe number of bytes to be written.
Returns
The actual number of bytes written.