Allolib  1.0
C++ Components For Interactive Multimedia
al::AudioIO Class Reference

#include <C:/Users/Andres/source/repos/casm_viewer/external/tinc/external/allolib/include/al/io/al_AudioIO.hpp>

Inheritance diagram for al::AudioIO:
al::AudioIOData

Public Types

enum  Backend { PORTAUDIO , RTAUDIO , DUMMY }
 

Public Member Functions

 AudioIO ()
 Creates AudioIO using default I/O devices.
 
void init (void(*callback)(AudioIOData &), void *userData, int framesPerBuf=64, double framesPerSec=44100.0, int outChans=2, int inChans=0)
 
void init (void(*callback)(AudioIOData &), void *userData, AudioDevice &dev, int framesPerBuf=64, double framesPerSec=44100.0, int outChans=2, int inChans=0)
 
void initWithDefaults (void(*callback)(AudioIOData &), void *userData, bool use_out, bool use_in, int framesPerBuffer=256)
 
bool open ()
 Opens audio device.
 
bool close ()
 Closes audio device. Will stop active IO.
 
bool start ()
 Starts the audio IO. Will open audio device if necessary.
 
bool stop ()
 Stops the audio IO.
 
void processAudio ()
 Call callback manually.
 
bool isOpen ()
 Returns true if device has been opened.
 
bool isRunning ()
 Returns true if audio is running.
 
bool autoZeroOut () const
 
int channelsInDevice () const
 Get number of channels opened on input device.
 
int channelsOutDevice () const
 Get number of channels opened on output device.
 
bool clipOut () const
 Returns clipOut setting.
 
double cpu () const
 Returns current CPU usage of audio thread.
 
bool supportsFPS (double fps)
 Return true if fps supported, otherwise false.
 
bool zeroNANs () const
 Returns whether to zero NANs in output buffer going to DAC.
 
void channels (int num, bool forOutput) override
 
void channelsBus (int num) override
 Set number of bus channels.
 
void setStreamName (std::string name)
 Set name of this stream. Currently only has an effect when using jack.
 
void clipOut (bool v)
 Set whether to clip output between -1 and 1.
 
void device (const AudioDevice &v)
 Set input/output device (must be duplex)
 
void deviceIn (const AudioDevice &v)
 Set input device.
 
void deviceOut (const AudioDevice &v)
 Set output device.
 
virtual void framesPerSecond (double v) override
 Set number of frames per second.
 
virtual void framesPerBuffer (unsigned int n) override
 Set number of frames per processing buffer.
 
void zeroNANs (bool v)
 Set whether to zero NANs in output buffer going to DAC.
 
void print () const
 Prints info about current i/o devices to stdout.
 
double time () const
 Get current stream time in seconds.
 
double time (int frame) const
 Get current stream time in seconds of frame.
 
AudioIOappend (AudioCallback &v)
 Add an AudioCallback handler (internal callback is always called first)
 
AudioIOprepend (AudioCallback &v)
 
AudioIOinsertBefore (AudioCallback &v, AudioCallback &beforeThis)
 
AudioIOinsertAfter (AudioCallback &v, AudioCallback &afterThis)
 
AudioIOremove (AudioCallback &v)
 Remove all input event handlers matching argument.
 
unsigned int channelsBus () const
 Get number of allocated bus channels.
 
virtual void channelsBus (int num)
 Set number of bus channels.
 
unsigned int channelsIn () const
 Get effective number of input channels.
 
void channelsIn (int n)
 Set number of input channels.
 
unsigned int channelsOut () const
 Get effective number of output channels.
 
void channelsOut (int n)
 Set number of output channels.
 
uint64_t framesPerBuffer () const
 Get frames/buffer of audio I/O stream.
 
virtual void framesPerBuffer (unsigned int n)
 Set number of frames per processing buffer.
 
double framesPerSecond () const
 Get frames/second of audio I/O streams.
 
virtual void framesPerSecond (double v)
 Set number of frames per second.
 
bool operator() () const
 Iterate frame counter, returning true while more frames.
 
unsigned int frame () const
 Get current frame number.
 
void frame (unsigned int v)
 Set frame count for next iteration.
 
float & bus (unsigned int chan) const
 Get bus sample at current frame iteration on specified channel.
 
float & bus (unsigned int chan, unsigned int frame) const
 Get bus sample at specified channel and frame.
 
float * busBuffer (unsigned int chan=0) const
 Get non-interleaved bus buffer on specified channel.
 
const float & in (unsigned int chan) const
 Get input sample at current frame iteration on specified channel.
 
const float & in (unsigned int chan, unsigned int frame) const
 Get input sample at specified channel and frame.
 
const float * inBuffer (unsigned int chan=0) const
 Get non-interleaved input buffer on specified channel.
 
float & out (unsigned int chan) const
 Get output sample at current frame iteration on specified channel.
 
float & out (unsigned int chan, unsigned int frame) const
 Get output sample at specified channel and frame.
 
float * outBuffer (unsigned int chan=0) const
 Get non-interleaved output buffer on specified channel.
 
void sum (float v, unsigned int chan) const
 Add value to current output sample on specified channel.
 
void sum (float v, unsigned int ch1, unsigned int ch2) const
 Add value to current output sample on specified channels.
 
float & temp (unsigned int frame) const
 Get sample from temporary buffer at specified frame.
 
float * tempBuffer () const
 Get non-interleaved temporary buffer on specified channel.
 
void * user () const
 Get pointer to user data.
 
template<class UserDataType >
UserDataType & user () const
 
void user (void *v)
 Set user data.
 
int channels (bool forOutput) const
 
unsigned int channelsIn () const
 Get effective number of input channels.
 
void channelsIn (int n)
 Set number of input channels.
 
unsigned int channelsOut () const
 Get effective number of output channels.
 
void channelsOut (int n)
 Set number of output channels.
 
unsigned int channelsBus () const
 Get number of allocated bus channels.
 
uint64_t framesPerBuffer () const
 Get frames/buffer of audio I/O stream.
 
double framesPerSecond () const
 Get frames/second of audio I/O streams.
 
double fps () const
 
double secondsPerBuffer () const
 Get seconds/buffer of audio I/O stream.
 
void zeroBus ()
 Zeros all the bus buffers.
 
void zeroOut ()
 Zeros all the internal output buffers.
 
AudioIODatagain (float v)
 
bool usingGain () const
 

Static Public Member Functions

static const char * errorText (int errNum)
 Returns error string.
 

Public Attributes

audioCallback callback
 User specified callback function.
 
float mGain
 
float mGainPrev
 

Protected Attributes

void * mUser
 
unsigned int mFrame
 
unsigned int mFramesPerBuffer
 
double mFramesPerSecond
 
float * mBufI
 
float * mBufO
 
float * mBufB
 
float * mBufT
 
unsigned int mNumI
 
unsigned int mNumO
 
unsigned int mNumB
 

Detailed Description

Audio input/output streaming

Definition at line 165 of file al_AudioIO.hpp.

Member Function Documentation

◆ channels()

void al::AudioIO::channels ( int  num,
bool  forOutput 
)
overridevirtual

Sets number of effective channels on input or output device depending on 'forOutput' flag. An effective channel is either a real device channel or virtual channel depending on how many channels the device supports. Passing in -1 for the number of channels opens all available channels.

Reimplemented from al::AudioIOData.

◆ init()

void al::AudioIO::init ( void(*)(AudioIOData &)  callback,
void *  userData,
int  framesPerBuf = 64,
double  framesPerSec = 44100.0,
int  outChans = 2,
int  inChans = 0 
)
Parameters
[in]framesPerBufNumber of sample frames to process per callback
[in]framesPerSecFrame rate. Unsupported values will use default rate of device.
[in]outChansNumber of output channels to open
[in]inChansNumber of input channels to open If the number of input or output channels is greater than the device supports, virtual buffers will be created.

◆ initWithDefaults()

void al::AudioIO::initWithDefaults ( void(*)(AudioIOData &)  callback,
void *  userData,
bool  use_out,
bool  use_in,
int  framesPerBuffer = 256 
)
Parameters
[in]callbackAudio processing callback (optional)
[in]userDataPointer to user data accessible within callback (optional)
[in]use_inEnable audio input
[in]use_outEnable audio output
[in]devNumID of the device to open. -1 Uses default device.
[in]framesPerBufNumber of sample frames to process per callback

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