VCV Rack API v2
Loading...
Searching...
No Matches
rack::audio::Device Struct Reference

A single audio device of a driver API. More...

#include <audio.hpp>

Public Member Functions

virtual ~Device ()
 
virtual std::string getName ()
 
virtual int getNumInputs ()
 
virtual int getNumOutputs ()
 
virtual std::set< float > getSampleRates ()
 Returns a list of all valid (user-selectable) sample rates.
 
virtual float getSampleRate ()
 Returns the current sample rate.
 
virtual void setSampleRate (float sampleRate)
 Sets the sample rate of the device, re-opening it if needed.
 
virtual std::set< int > getBlockSizes ()
 Returns a list of all valid (user-selectable) block sizes.
 
virtual int getBlockSize ()
 Returns the current block size.
 
virtual void setBlockSize (int blockSize)
 Sets the block size of the device, re-opening it if needed.
 
virtual void subscribe (Port *port)
 Adds Port to set of subscribed Ports.
 
virtual void unsubscribe (Port *port)
 Removes Port from set of subscribed Ports.
 
void processBuffer (const float *input, int inputStride, float *output, int outputStride, int frames)
 Processes audio for each subscribed Port.
 
void onStartStream ()
 Called by driver code when stream starts.
 
void onStopStream ()
 Called by driver code when stream stops.
 

Public Attributes

std::set< Port * > subscribed
 
std::mutex processMutex
 Ensures that ports do not subscribe/unsubscribe while processBuffer() is called.
 

Detailed Description

A single audio device of a driver API.

Modules and the UI should not interact with this API directly. Use Port instead.

Methods throw rack::Exception if the driver API has an exception.

Constructor & Destructor Documentation

◆ ~Device()

virtual rack::audio::Device::~Device ( )
inlinevirtual

Member Function Documentation

◆ getName()

virtual std::string rack::audio::Device::getName ( )
inlinevirtual

◆ getNumInputs()

virtual int rack::audio::Device::getNumInputs ( )
inlinevirtual

◆ getNumOutputs()

virtual int rack::audio::Device::getNumOutputs ( )
inlinevirtual

◆ getSampleRates()

virtual std::set< float > rack::audio::Device::getSampleRates ( )
inlinevirtual

Returns a list of all valid (user-selectable) sample rates.

The device may accept sample rates not in this list, but it must accept sample rates in the list.

◆ getSampleRate()

virtual float rack::audio::Device::getSampleRate ( )
inlinevirtual

Returns the current sample rate.

◆ setSampleRate()

virtual void rack::audio::Device::setSampleRate ( float sampleRate)
inlinevirtual

Sets the sample rate of the device, re-opening it if needed.

◆ getBlockSizes()

virtual std::set< int > rack::audio::Device::getBlockSizes ( )
inlinevirtual

Returns a list of all valid (user-selectable) block sizes.

The device may accept block sizes not in this list, but it must accept block sizes in the list.

◆ getBlockSize()

virtual int rack::audio::Device::getBlockSize ( )
inlinevirtual

Returns the current block size.

◆ setBlockSize()

virtual void rack::audio::Device::setBlockSize ( int blockSize)
inlinevirtual

Sets the block size of the device, re-opening it if needed.

◆ subscribe()

virtual void rack::audio::Device::subscribe ( Port * port)
virtual

Adds Port to set of subscribed Ports.

Called by Driver::subscribe().

◆ unsubscribe()

virtual void rack::audio::Device::unsubscribe ( Port * port)
virtual

Removes Port from set of subscribed Ports.

Called by Driver::unsubscribe().

◆ processBuffer()

void rack::audio::Device::processBuffer ( const float * input,
int inputStride,
float * output,
int outputStride,
int frames )

Processes audio for each subscribed Port.

Called by driver code. input and output must be non-overlapping. Overwrites all output, so it is unnecessary to initialize.

◆ onStartStream()

void rack::audio::Device::onStartStream ( )

Called by driver code when stream starts.

◆ onStopStream()

void rack::audio::Device::onStopStream ( )

Called by driver code when stream stops.

Member Data Documentation

◆ subscribed

std::set<Port*> rack::audio::Device::subscribed

◆ processMutex

std::mutex rack::audio::Device::processMutex

Ensures that ports do not subscribe/unsubscribe while processBuffer() is called.


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