131 void processBuffer(
const float* input,
int inputStride,
float* output,
int outputStride,
int frames);
199 virtual void processBuffer(
const float* input,
int inputStride,
float* output,
int outputStride,
int frames) {}
204 virtual void processInput(
const float* input,
int inputStride,
int frames) {}
#define PRIVATE
Attribute for private functions not intended to be called by plugins.
Definition common.hpp:32
std::vector< int > getDriverIds()
Driver * getDriver(int driverId)
void addDriver(int driverId, Driver *driver)
Registers a new audio driver.
Root namespace for the Rack API.
Definition AudioDisplay.hpp:9
Rack instance state.
Definition context.hpp:45
A single audio device of a driver API.
Definition audio.hpp:74
virtual ~Device()
Definition audio.hpp:79
virtual std::string getName()
Definition audio.hpp:81
virtual void setSampleRate(float sampleRate)
Sets the sample rate of the device, re-opening it if needed.
Definition audio.hpp:102
void onStartStream()
Called by driver code when stream starts.
virtual int getNumOutputs()
Definition audio.hpp:87
void processBuffer(const float *input, int inputStride, float *output, int outputStride, int frames)
Processes audio for each subscribed Port.
virtual std::set< int > getBlockSizes()
Returns a list of all valid (user-selectable) block sizes.
Definition audio.hpp:107
virtual void setBlockSize(int blockSize)
Sets the block size of the device, re-opening it if needed.
Definition audio.hpp:115
void onStopStream()
Called by driver code when stream stops.
virtual float getSampleRate()
Returns the current sample rate.
Definition audio.hpp:98
virtual int getNumInputs()
Definition audio.hpp:84
std::mutex processMutex
Ensures that ports do not subscribe/unsubscribe while processBuffer() is called.
Definition audio.hpp:77
std::set< Port * > subscribed
Definition audio.hpp:75
virtual std::set< float > getSampleRates()
Returns a list of all valid (user-selectable) sample rates.
Definition audio.hpp:94
virtual void subscribe(Port *port)
Adds Port to set of subscribed Ports.
virtual int getBlockSize()
Returns the current block size.
Definition audio.hpp:111
virtual void unsubscribe(Port *port)
Removes Port from set of subscribed Ports.
Wraps an audio driver API containing any number of audio devices.
Definition audio.hpp:25
virtual ~Driver()
Definition audio.hpp:26
virtual Device * subscribe(int deviceId, Port *port)
Adds the given port as a reference holder of a device and returns the it.
Definition audio.hpp:55
virtual std::string getDeviceName(int deviceId)
Returns the name of a device without obtaining it.
Definition audio.hpp:40
virtual std::string getName()
Returns the name of the driver.
Definition audio.hpp:28
virtual int getDeviceNumOutputs(int deviceId)
Returns the number of output of a device without obtaining it.
Definition audio.hpp:48
virtual std::vector< int > getDeviceIds()
Returns a list of all device IDs that can be subscribed to.
Definition audio.hpp:32
virtual void unsubscribe(int deviceId, Port *port)
Removes the give port as a reference holder of a device.
Definition audio.hpp:61
virtual int getDefaultDeviceId()
Returns the default device to use when the driver is selected, or -1 for none.
Definition audio.hpp:36
virtual int getDeviceNumInputs(int deviceId)
Returns the number of inputs of a device without obtaining it.
Definition audio.hpp:44
A handle to a Device, typically owned by modules to have shared access to a single Device.
Definition audio.hpp:147
std::string getDeviceDetail(int deviceId, int offset)
int maxOutputs
Definition audio.hpp:153
virtual void processInput(const float *input, int inputStride, int frames)
Called before processBuffer() is called for all Ports of the same device.
Definition audio.hpp:204
Context * context
Definition audio.hpp:161
std::set< float > getSampleRates()
void setSampleRate(float sampleRate)
void setDeviceId(int deviceId)
int inputOffset
The first channel index of the device to process.
Definition audio.hpp:149
virtual void processBuffer(const float *input, int inputStride, float *output, int outputStride, int frames)
Callback for processing the audio stream.
Definition audio.hpp:199
std::set< int > getBlockSizes()
std::vector< int > getDeviceIds()
void fromJson(json_t *rootJ)
virtual void onStartStream()
Definition audio.hpp:208
int outputOffset
Definition audio.hpp:150
Device * device
Definition audio.hpp:160
void setDriverId(int driverId)
virtual void processOutput(float *output, int outputStride, int frames)
Called after processBuffer() is called for all Ports of the same device.
Definition audio.hpp:207
int getDeviceNumInputs(int deviceId)
int deviceId
Definition audio.hpp:157
Driver * driver
Not owned.
Definition audio.hpp:159
int getDeviceNumOutputs(int deviceId)
void setBlockSize(int blockSize)
int getNumInputs()
Returns the number of active Port inputs, considering inputOffset and maxInputs.
std::string getDriverName()
std::string getDeviceName(int deviceId)
int maxInputs
Maximum number of channels to process.
Definition audio.hpp:152
virtual void onStopStream()
Definition audio.hpp:209
int driverId
Definition audio.hpp:156