Audio input/output streaming. More...
#include <AudioIO.h>
Public Member Functions | |
AudioIO (int framesPerBuf=64, double framesPerSec=44100.0, void(*callback)(AudioIOData &)=0, void *userData=0, int outChans=2, int inChans=0) | |
bool | clipOut () const |
Returns clipOut setting. | |
double | cpu () const |
Returns current CPU usage of audio thread. | |
bool | supportsFPS (double fps) const |
Return true if fps supported, otherwise false. | |
bool | zeroNANs () const |
Returns whether to zero NANs in output buffer going to DAC. | |
void | operator() () |
Call callback manually. | |
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 | channels (int num, bool forOutput) |
Sets number of effective channels on input or output device depending on 'forOutput' flag. | |
void | channelsIn (int n) |
Set number of input channels. | |
void | channelsOut (int n) |
Set number of output channels. | |
void | channelsBus (int num) |
Set number of bus channels. | |
void | clipOut (bool v) |
Set whether to clip output between -1 and 1. | |
void | deviceIn (const AudioDevice &v) |
Set input device. | |
void | deviceOut (const AudioDevice &v) |
Set output device. | |
void | framesPerSecond (double v) |
Set number of frames per second. | |
void | framesPerBuffer (int n) |
Set number of frames per processing buffer. | |
void | zeroNANs (bool v) |
Set whether to zero NANs in output buffer going to DAC. | |
void | print () |
Prints info about current i/o devices to stdout. | |
bool | operator() () const |
Iterate frame counter, returning true while more frames. | |
int | frame () const |
Get current frame number. | |
void | frame (int v) |
Set frame count for next iteration. | |
float & | bus (int chan) const |
Get bus sample at current frame iteration on specified channel. | |
float & | bus (int chan, int frame) const |
Get bus sample at specified channel and frame. | |
float * | busBuffer (int chan=0) const |
Get non-interleaved bus buffer on specified channel. | |
const float & | in (int chan) const |
Get input sample at current frame iteration on specified channel. | |
const float & | in (int chan, int frame) const |
Get input sample at specified channel and frame. | |
const float * | inBuffer (int chan=0) const |
Get non-interleaved input buffer on specified channel. | |
float & | out (int chan) const |
Get output sample at current frame iteration on specified channel. | |
float & | out (int chan, int frame) const |
Get output sample at specified channel and frame. | |
float * | outBuffer (int chan=0) const |
Get non-interleaved output buffer on specified channel. | |
void | sum (float v, int chan) const |
Add value to current output sample on specified channel. | |
void | sum (float v, int ch1, int ch2) const |
Add value to current output sample on specified channels. | |
float & | temp (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. | |
int | channelsIn () const |
Get effective number of input channels. | |
int | channelsOut () const |
Get effective number of output channels. | |
int | channelsBus () const |
Get number of allocated bus channels. | |
int | channelsInDevice () const |
Get number of channels opened on input device. | |
int | channelsOutDevice () const |
Get number of channels opened on output device. | |
int | framesPerBuffer () const |
Get frames/buffer of audio I/O stream. | |
double | framesPerSecond () const |
Get frames/second of audio I/O streams. | |
double | secondsPerBuffer () const |
Get seconds/buffer of audio I/O stream. | |
double | time () const |
Get current stream time in seconds. | |
double | time (int frame) const |
Get current stream time in seconds of frame. | |
void | zeroBus () |
Zeros all the bus buffers. | |
void | zeroOut () |
Zeros all the internal output buffers. | |
Public Attributes | |
audioCallback | callback |
User specified callback function. |
Audio input/output streaming.
This is a wrapper around the PortAudio v1.9 library.
AudioIO | ( | int | framesPerBuf = 64 , |
double | framesPerSec = 44100.0 , |
||
void(*)(AudioIOData &) | callback = 0 , |
||
void * | userData = 0 , |
||
int | outChans = 2 , |
||
int | inChans = 0 |
||
) |
Creates AudioIO using default I/O devices.
[in] | framesPerBuf | Number of sample frames to process per callback |
[in] | framesPerSec | Frame rate. Unsupported values will use default rate of device. |
[in] | callback | Audio processing callback |
[in] | userData | Pointer to user data accessible within callback |
[in] | outChans | Number of output channels to open |
[in] | inChans | Number of input channels to open If the number of input or output channels is greater than the device supports, virtual buffers will be created. |
void channels | ( | int | num, |
bool | forOutput | ||
) |
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.