Vuo  1.2.8
Classes | Typedefs | Functions | Variables
VuoAudio.cc File Reference

Description

VuoAudio implementation.

Classes

struct  _VuoAudio_internal
 Private data for a VuoAudio instance. More...
 

Typedefs

typedef std::map< void *, std::queue< VuoList_VuoAudioSamples > > pendingOutputType
 For each unique audio source (identified by void *), a queue of buffers to output. More...
 
typedef std::map< void *, std::map< VuoInteger, VuoReal > > lastOutputSampleType
 For each unique audio source (identified by void *), the last sample value that was output on each channel. More...
 
typedef struct _VuoAudio_internalVuoAudio_internal
 Private data for a VuoAudio instance. More...
 

Functions

static void __attribute__ ((constructor)) VuoAudio_init()
 Ensure we're listening for the system's device notifications. More...
 
VuoList_VuoAudioInputDevice VuoAudio_getInputDevices (void)
 Returns a list of the available audio input devices. More...
 
VuoList_VuoAudioOutputDevice VuoAudio_getOutputDevices (void)
 Returns a list of the available audio output devices. More...
 
int VuoAudio_receivedEvent (void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, double streamTime, RtAudioStreamStatus status, void *userData)
 RtAudio calls this function when a new sample buffer is ready or needed. More...
 
VuoAudioIn VuoAudioIn_getShared (VuoAudioInputDevice aid)
 Returns the reference-counted object for the specified audio input device. More...
 
VuoAudioOut VuoAudioOut_getShared (VuoAudioOutputDevice aod)
 Returns the reference-counted object for the specified audio output device. More...
 
void VuoAudioIn_addTrigger (VuoAudioIn ai, VuoOutputTrigger(receivedChannels, VuoList_VuoAudioSamples))
 Sets up the audio input device to call the trigger functions when it receives an event. More...
 
void VuoAudioOut_addTrigger (VuoAudioOut ao, VuoOutputTrigger(requestedChannels, VuoReal))
 Sets up the audio output device to call the trigger functions when it receives an event. More...
 
void VuoAudioIn_removeTrigger (VuoAudioIn ai, VuoOutputTrigger(receivedChannels, VuoList_VuoAudioSamples))
 Stops the audio input device from calling trigger functions when it receives an event. More...
 
void VuoAudioOut_removeTrigger (VuoAudioOut ao, VuoOutputTrigger(requestedChannels, VuoReal))
 Stops the audio output device from calling trigger functions when it receives an event. More...
 
void VuoAudioOut_sendChannels (VuoAudioOut ao, VuoList_VuoAudioSamples channels, void *id)
 Enqueues channels for eventual playback. More...
 
 VUOKEYEDPOOL (unsigned int, VuoAudio_internal)
 
static void VuoAudio_destroy (VuoAudio_internal ai)
 
VuoAudio_internal VuoAudio_make (unsigned int deviceId)
 
 VUOKEYEDPOOL_DEFINE (unsigned int, VuoAudio_internal, VuoAudio_make)
 

Variables

const VuoInteger VuoAudio_queueSize = 8
 The number of buffers that must be enqueued before starting playback. More...
 

Class Documentation

◆ _VuoAudio_internal

struct _VuoAudio_internal
Class Members
VuoAudioInputDevice inputDevice The device's id must be nonnegative, and channelCount must be set.
VuoTriggerSet< VuoList_VuoAudioSamples > inputTriggers Trigger methods to call when an audio buffer is received.
lastOutputSampleType lastOutputSample The last sample value sent on each channel (to smoothly move back to 0 DC when there's a dropout). Not present means no buffer was sent to the channel during the last frame.
VuoAudioOutputDevice outputDevice The device's id must be nonnegative, and channelCount must be set.
VuoTriggerSet< VuoReal > outputTriggers Trigger methods to call when an audio buffer is needed.
pendingOutputType pendingOutput Sample buffers waiting to be output.
dispatch_queue_t pendingOutputQueue Serializes access to the following set of buffers.
VuoReal priorStreamTime The time at which the prior VuoAudio_receivedEvent() happened, to track stream overflows.
RtAudio * rta RtAudio's device pointer.

Typedef Documentation

◆ lastOutputSampleType

typedef std::map<void *, std::map<VuoInteger, VuoReal> > lastOutputSampleType

For each unique audio source (identified by void *), the last sample value that was output on each channel.

◆ pendingOutputType

typedef std::map<void *, std::queue<VuoList_VuoAudioSamples> > pendingOutputType

For each unique audio source (identified by void *), a queue of buffers to output.

◆ VuoAudio_internal

Private data for a VuoAudio instance.

Function Documentation

◆ __attribute__()

static void __attribute__ ( (constructor)  )
static

◆ VuoAudio_destroy()

static void VuoAudio_destroy ( VuoAudio_internal  ai)
static

◆ VuoAudio_getInputDevices()

VuoList_VuoAudioInputDevice VuoAudio_getInputDevices ( void  )

Returns a list of the available audio input devices.

◆ VuoAudio_getOutputDevices()

VuoList_VuoAudioOutputDevice VuoAudio_getOutputDevices ( void  )

Returns a list of the available audio output devices.

◆ VuoAudio_make()

VuoAudio_internal VuoAudio_make ( unsigned int  deviceId)

◆ VuoAudio_receivedEvent()

int VuoAudio_receivedEvent ( void *  outputBuffer,
void *  inputBuffer,
unsigned int  nBufferFrames,
double  streamTime,
RtAudioStreamStatus  status,
void *  userData 
)

RtAudio calls this function when a new sample buffer is ready or needed.

Todo:
handle differing sample rates
Todo:
Should we clamp here (or after all buffers for this channel have been summed), or does CoreAudio handle that for us?

◆ VuoAudioIn_addTrigger()

void VuoAudioIn_addTrigger ( VuoAudioIn  ai,
VuoOutputTrigger(receivedChannels, VuoList_VuoAudioSamples  
)

Sets up the audio input device to call the trigger functions when it receives an event.

This function may be called from any thread.

◆ VuoAudioIn_getShared()

VuoAudioIn VuoAudioIn_getShared ( VuoAudioInputDevice  aid)

Returns the reference-counted object for the specified audio input device.

Todo:
https://b33p.net/kosada/node/4724

◆ VuoAudioIn_removeTrigger()

void VuoAudioIn_removeTrigger ( VuoAudioIn  ai,
VuoOutputTrigger(receivedChannels, VuoList_VuoAudioSamples  
)

Stops the audio input device from calling trigger functions when it receives an event.

This function may be called from any thread.

◆ VuoAudioOut_addTrigger()

void VuoAudioOut_addTrigger ( VuoAudioOut  ao,
VuoOutputTrigger(requestedChannels, VuoReal  
)

Sets up the audio output device to call the trigger functions when it receives an event.

This function may be called from any thread.

◆ VuoAudioOut_getShared()

VuoAudioOut VuoAudioOut_getShared ( VuoAudioOutputDevice  aod)

Returns the reference-counted object for the specified audio output device.

Todo:
https://b33p.net/kosada/node/4724

◆ VuoAudioOut_removeTrigger()

void VuoAudioOut_removeTrigger ( VuoAudioOut  ao,
VuoOutputTrigger(requestedChannels, VuoReal  
)

Stops the audio output device from calling trigger functions when it receives an event.

This function may be called from any thread.

◆ VuoAudioOut_sendChannels()

void VuoAudioOut_sendChannels ( VuoAudioOut  ao,
VuoList_VuoAudioSamples  channels,
void *  id 
)

Enqueues channels for eventual playback.

id should be a unique identifier for the audio stream (e.g., a pointer to the node's instance data).

When multiple sources are simultaneously sending to the same audio device, each is buffered independently — each unique id gets its own queue, and at output time a single buffer from each source's queue is mixed to form the final output stream.

◆ VUOKEYEDPOOL()

VUOKEYEDPOOL ( unsigned  int,
VuoAudio_internal   
)

◆ VUOKEYEDPOOL_DEFINE()

VUOKEYEDPOOL_DEFINE ( unsigned  int,
VuoAudio_internal  ,
VuoAudio_make   
)

Variable Documentation

◆ VuoAudio_queueSize

const VuoInteger VuoAudio_queueSize = 8

The number of buffers that must be enqueued before starting playback.