Vuo  1.2.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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.
 
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.
 
typedef struct _VuoAudio_internalVuoAudio_internal
 Private data for a VuoAudio instance.
 

Functions

static void __attribute__ ((constructor)) VuoAudio_init()
 Ensure we're listening for the system's device notifications.
 
VuoList_VuoAudioInputDevice VuoAudio_getInputDevices (void)
 Returns a list of the available audio input devices.
 
VuoList_VuoAudioOutputDevice VuoAudio_getOutputDevices (void)
 Returns a list of the available audio output devices.
 
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.
 
VuoAudioIn VuoAudioIn_getShared (VuoAudioInputDevice aid)
 Returns the reference-counted object for the specified audio input device.
 
VuoAudioOut VuoAudioOut_getShared (VuoAudioOutputDevice aod)
 Returns the reference-counted object for the specified audio output device.
 
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.
 
void VuoAudioOut_addTrigger (VuoAudioOut ao, VuoOutputTrigger(requestedChannels, VuoReal))
 Sets up the audio output device to call the trigger functions when it receives an event.
 
void VuoAudioIn_removeTrigger (VuoAudioIn ai, VuoOutputTrigger(receivedChannels, VuoList_VuoAudioSamples))
 Stops the audio input device from calling trigger functions when it receives an event.
 
void VuoAudioOut_removeTrigger (VuoAudioOut ao, VuoOutputTrigger(requestedChannels, VuoReal))
 Stops the audio output device from calling trigger functions when it receives an event.
 
void VuoAudioOut_sendChannels (VuoAudioOut ao, VuoList_VuoAudioSamples channels, void *id)
 Enqueues channels for eventual playback.
 
 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.
 

Class Documentation

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

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.

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

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

Private data for a VuoAudio instance.

Function Documentation

static void __attribute__ ( (constructor)  )
static
static void VuoAudio_destroy ( VuoAudio_internal  ai)
static
VuoList_VuoAudioInputDevice VuoAudio_getInputDevices ( void  )

Returns a list of the available audio input devices.

VuoList_VuoAudioOutputDevice VuoAudio_getOutputDevices ( void  )

Returns a list of the available audio output devices.

VuoAudio_internal VuoAudio_make ( unsigned int  deviceId)
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?
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 VuoAudioIn_getShared ( VuoAudioInputDevice  aid)

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

Todo:
https://b33p.net/kosada/node/4724
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.

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 VuoAudioOut_getShared ( VuoAudioOutputDevice  aod)

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

Todo:
https://b33p.net/kosada/node/4724
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.

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 ( unsigned  int,
VuoAudio_internal   
)
VUOKEYEDPOOL_DEFINE ( unsigned  int,
VuoAudio_internal  ,
VuoAudio_make   
)

Variable Documentation

const VuoInteger VuoAudio_queueSize = 8

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