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

Sound input stream. More...

#include <base/sound/SoundInputStream.h>

Inherits Object.

Public Member Functions

 SoundInputStream (unsigned int samplingRate, unsigned int channels)
 
unsigned int available () const noexcept
 
unsigned int getChannels () const noexcept
 
unsigned int getRate () const noexcept
 
unsigned int getPosition () const noexcept
 
void resume () noexcept
 
void pause () noexcept
 
void reset () noexcept
 
unsigned int read (void *buffer, unsigned int size)
 
 ~SoundInputStream () noexcept
 

Detailed Description

Sound input stream.

Sound input stream.

See also
SoundOutputStream
Version
1.0

Constructor & Destructor Documentation

◆ SoundInputStream()

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

Initializes the sound input 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).

◆ ~SoundInputStream()

SoundInputStream::~SoundInputStream ( )
noexcept

Destructs the stream object.

Member Function Documentation

◆ available()

unsigned int SoundInputStream::available ( ) const
noexcept

Returns the number of available samples.

◆ getChannels()

unsigned int SoundInputStream::getChannels ( ) const
noexcept

Returns the number of channels (greater than 0).

◆ getPosition()

unsigned int SoundInputStream::getPosition ( ) const
noexcept

Returns the total number of samples since the last resume.

◆ getRate()

unsigned int SoundInputStream::getRate ( ) const
noexcept

Returns the sampling rate (samples per second).

◆ pause()

void SoundInputStream::pause ( )
noexcept

Stops the sampling.

◆ read()

unsigned int SoundInputStream::read ( void *  buffer,
unsigned int  size 
)

Fills the specified buffer with bytes from the stream. In blocking mode the method does not return until all bytes have been read. In non-blocking mode the total bytes read may be any number below or equal to the requested number of bytes. Attempting to read beyond the end of a stream in blocking mode results in an EndOfFile exception.

Parameters
bufferThe buffer to receive the bytes.
sizeThe size of the buffer.
Returns
The actual number of bytes read from the stream.

◆ reset()

void SoundInputStream::reset ( )
noexcept

Resets the device.

◆ resume()

void SoundInputStream::resume ( )
noexcept

Starts the sampling.