:)
Loading...
Searching...
No Matches
RustyAudioLibAPI Class Reference

Top-Level API to interact with RustyAudioLibrary (RustyAudioLib.hpp). More...

#include <RustyAudioLib.hpp>

Public Member Functions

 RustyAudioLibAPI ()
 RustyAudioLibAPI constructor.
 
 ~RustyAudioLibAPI ()
 RustyAudioLibAPI destructor.
 
void init ()
 Initialisation function for RustyAudioLib.
 
void cliCallback (std::vector< std::string > inputParsed)
 Callback from CLI.
 
void printProcessors ()
 Prints instantiated processors.
 
void printModulators ()
 Prints instantiated modulators.
 
void setParam (std::string unit, std::string param, std::string value)
 Set Parameters inside units at run time.
 
void addProcessorToSignalChain (RustyProcessor *processor)
 Adds RustyProcessors to signal chain.
 
RustyProcessor * createGainUnit (std::string name, float gain)
 Creation function for RustyGain.
 
RustyProcessor * createOverdriveUnit (std::string name, float drive)
 Creation function for RustyOverdrive.
 
RustyProcessor * createFilterUnit (std::string name, RustyFilterType type, float frequency, float q)
 Creation function for RustyFilter.
 
RustyProcessor * createCompressorUnit (std::string name, float threshold, float knee, float ratio, float attack, float release, float makeupGain)
 Creation function for RustyCompressor.
 
void setModulator (std::string parameter, RustyProcessor *processor, RustyModulator *modulator)
 Adds RustyModulator to RustyProcessor.
 
RustyModulator * createLFO (std::string name, float frequency, float min, float max)
 Creation function for RustyLFO.
 
void setIO (std::string inputString, AudioType inputType, int inputIx, std::string outputString, AudioType outputType, int outputIx)
 Defines IO devices for RustyAudioEngine to connect to.
 

Private Member Functions

void initCLI ()
 Initialise CLI and CLI thread.
 

Private Attributes

std::map< std::string, std::unique_ptr< RustyProcessor > > _processors
 Map of all instantiated RustyProcessor units.
 
std::map< std::string, std::unique_ptr< RustyModulator > > _modulators
 Map of all instantiated RustyModulator units.
 
RustyAudioEngine engine
 RustyAudioEngine instance saved here.
 
RustyCLI cli
 RustyCLI instance saved here.
 
std::thread cliThread
 Dedicated thread to run RustyCLI on.
 
SettingsIO settings
 RustyAudioLib IO settings.
 

Detailed Description

Top-Level API to interact with RustyAudioLibrary (RustyAudioLib.hpp).

RustyAudioLibAPI follows a factory style top level implementation. Meaning instead of interacting with the library directly, instead there are creation functions. Creation functions will create instances of RustyAudioLibrary units. Creation functions will then return a pointer to the created unit allowing for further manipulation at runtime or within the user's main() code.

Must call init() function to open audio stream and start CLI. Call it at the end of main().

Audio-related heavy lifting is handled by RustyAudioEngine. CLI handled by RustyCLI.

See also
RustyAudioEngine
RustyCLI

Definition at line 47 of file RustyAudioLib.hpp.

Constructor & Destructor Documentation

◆ RustyAudioLibAPI()

RustyAudioLibAPI::RustyAudioLibAPI ( )
inline

RustyAudioLibAPI constructor.

Constructor creates relevant objects. No interaction from user needed.

Definition at line 56 of file RustyAudioLib.hpp.

◆ ~RustyAudioLibAPI()

RustyAudioLibAPI::~RustyAudioLibAPI ( )
inline

RustyAudioLibAPI destructor.

Joins CLI thread before initialising shutdown. No interaction from user needed.

Definition at line 67 of file RustyAudioLib.hpp.

Member Function Documentation

◆ init()

void RustyAudioLibAPI::init ( )
inline

Initialisation function for RustyAudioLib.

RustyAudioLib initialise function calls the relevant functions inside RustyCLI and RustyAudioEngine to start them running.

For the RustyAudioEngine it starts the stream, opening it to the chosen output/input.

For RustyCLI it begins the loop needed to check the console for inputs.

RustyAudioEngine and RustyCLI also run on separate threads, this functions helps instantiate that.

Ensure this function is called at the END of your main.

See also
initCLI()

Definition at line 93 of file RustyAudioLib.hpp.

◆ cliCallback()

void RustyAudioLibAPI::cliCallback ( std::vector< std::string >  inputParsed)
inline

Callback from CLI.

Function is called from RustyCLI when users input commands that need to interact with information only available in the RustyAudioLibAPI.

Parameters
inputParsedParsed user CLI commands.
See also
RustyCLI::commandHandler()

Definition at line 109 of file RustyAudioLib.hpp.

◆ printProcessors()

void RustyAudioLibAPI::printProcessors ( )
inline

Prints instantiated processors.

Function is normally called by the CLI when user is interacting with RustyAudioTool at runtime.

# CLI call
[-p, --processors]

This function will print to console all RustyProcessors that have been created. This will include RustyProcessors that have not been added to the processing chain in RustyAudioEngine.

See also
RustyCLI::commandHandler()

Definition at line 147 of file RustyAudioLib.hpp.

◆ printModulators()

void RustyAudioLibAPI::printModulators ( )
inline

Prints instantiated modulators.

Function is normally called by the CLI when user is interacting with RustyAudioTool at runtime.

# CLI call
[-m, --modulators]

This function will print to console all RustyModulators that have been created. This will include RustyModulators that have not been added to any RustyProcessors.

See also
RustyCLI::commandHandler()

Definition at line 176 of file RustyAudioLib.hpp.

◆ setParam()

void RustyAudioLibAPI::setParam ( std::string  unit,
std::string  param,
std::string  value 
)
inline

Set Parameters inside units at run time.

Function is normally called by the CLI when user is interacting with RustyAudioTool at runtime.

# CLI call
[-param], [MODULATOR/PROCESSOR NAME], [PARAM NAME], [NEW VALUE]

This function allows users to update parameters of units at runtime. This function is called via callback by RustyCLI::commandHandler();

Parameters
processorName given to unit when created.
paramName of parameter to change.
valueNew value for parameter.
Exceptions
BAD_UNIT_NAMEIf given processor name doesn't match an existing unit.
See also
RustyCLI::commandHandler()

Definition at line 212 of file RustyAudioLib.hpp.

◆ addProcessorToSignalChain()

void RustyAudioLibAPI::addProcessorToSignalChain ( RustyProcessor *  processor)
inline

Adds RustyProcessors to signal chain.

This function will place the passed in processing unit into the signal chain, allowing the processor to affect the audio. You can add as many units as you want to the signal chain but bare in mind they will be used in the sequence you added them in. First in first used.

Parameters
processorA pointer to an instantiated RustyProcessor unit.
See also
RustyEngine::addProcessor()

Definition at line 243 of file RustyAudioLib.hpp.

◆ createGainUnit()

RustyProcessor * RustyAudioLibAPI::createGainUnit ( std::string  name,
float  gain 
)
inline

Creation function for RustyGain.

This function creates an instance of a RustyGain and stores it inside a map of instantiated processors.

Parameters
nameName given to the created RustyProcessor.
driveFloat of gain multiplier.
Returns
Pointer to created unit.

Definition at line 259 of file RustyAudioLib.hpp.

◆ createOverdriveUnit()

RustyProcessor * RustyAudioLibAPI::createOverdriveUnit ( std::string  name,
float  drive 
)
inline

Creation function for RustyOverdrive.

This function creates an instance of a RustyOverdrive and stores it inside a map of instantiated processors.

Parameters
nameName given to the created RustyProcessor.
driveFloat of distortion multiplier.
Returns
Pointer to created unit.

Definition at line 278 of file RustyAudioLib.hpp.

◆ createFilterUnit()

RustyProcessor * RustyAudioLibAPI::createFilterUnit ( std::string  name,
RustyFilterType  type,
float  frequency,
float  q 
)
inline

Creation function for RustyFilter.

This function creates an instance of a RustyFilter and stores it inside a map of instantiated processors.

Parameters
nameName given to the created RustyProcessor.
typeSelects filter mode from RustyFilterType.
frequencyCutoff frequency of filter - Runtime adjustable.
qQ of filter - Runtime adjustable.
Returns
Pointer to created unit.

Definition at line 299 of file RustyAudioLib.hpp.

◆ createCompressorUnit()

RustyProcessor * RustyAudioLibAPI::createCompressorUnit ( std::string  name,
float  threshold,
float  knee,
float  ratio,
float  attack,
float  release,
float  makeupGain 
)
inline

Creation function for RustyCompressor.

This function creates an instance of a RustyCompressor and stores it inside a map of instantiated processors.

Parameters
nameName given to the created RustyProcessor.
thresholdFloat of threshold in dB.
kneeFloat of knee curve in dB.
ratioFloat of compression ratio.
attackFloat of attack speed in Ms.
releaseFloat of release speed in ms.
makeupGainFloat of gain makeup in dB.
Returns
Pointer to created unit.

Definition at line 323 of file RustyAudioLib.hpp.

◆ setModulator()

void RustyAudioLibAPI::setModulator ( std::string  parameter,
RustyProcessor *  processor,
RustyModulator *  modulator 
)
inline

Adds RustyModulator to RustyProcessor.

This function allows you to add a RustyModulator unit to a RustyProcessor unit. You define the parameter you wish to manipulate and then the RustyModulator will affect the parameter at the rate defined during it's creation.

Parameters
parameterName of the RustyProcessor parameter to modulate .
processorPointer to RustyProcessor to affect.
modulatorPointer to RustyModulator that will be used to affect parameter.

Definition at line 343 of file RustyAudioLib.hpp.

◆ createLFO()

RustyModulator * RustyAudioLibAPI::createLFO ( std::string  name,
float  frequency,
float  min,
float  max 
)
inline

Creation function for RustyLFO.

This function creates an instance of a RustyLFO and stores it inside a map of instantiated modulators.

Parameters
nameName given to the created RustyModulator.
frequencyFrequency of LFO in Hz.
minMinimum value to be oscillated between.
maxMaximum value to be oscillated between.
Returns
Pointer to created unit.

Definition at line 361 of file RustyAudioLib.hpp.

◆ setIO()

void RustyAudioLibAPI::setIO ( std::string  inputString,
AudioType  inputType,
int  inputIx,
std::string  outputString,
AudioType  outputType,
int  outputIx 
)
inline

Defines IO devices for RustyAudioEngine to connect to.

This function creates an objects of RustyCommonTypes::SettingsIO. This keeps all of the users selected IO in one neat place then passes it down to RustyAudioEngine so it can open streams to the appropriate devices.

lib.setIO(<SOME_INPUT_DEVICE>, <MONO_OR_STEREO>, <SOME_CHANNEL_INDEX>, <SOME_OUTPUT_DEVICE>, <MONO_OR_STEREO>, <SOME_CHANNEL_INDEX>);
Parameters
inputStringString of input device name.
inputTypeAudioType of input (MONO or STEREO).
inputIxInt of used channel index(s) within device (Channel 1 = index 0).
outputStringString of output device name.
outputTypeAudioType of output (MONO or STEREO).
outputIxInt of used channel index(s) within device (Channel 1 = index 0).

Definition at line 387 of file RustyAudioLib.hpp.

◆ initCLI()

void RustyAudioLibAPI::initCLI ( )
inlineprivate

Initialise CLI and CLI thread.

A simple initialisation function to start the CLI loop and start the CLI separate thread.

See also
init()

Definition at line 416 of file RustyAudioLib.hpp.

Member Data Documentation

◆ _processors

std::map<std::string, std::unique_ptr<RustyProcessor> > RustyAudioLibAPI::_processors
private

Map of all instantiated RustyProcessor units.

Definition at line 400 of file RustyAudioLib.hpp.

◆ _modulators

std::map<std::string, std::unique_ptr<RustyModulator> > RustyAudioLibAPI::_modulators
private

Map of all instantiated RustyModulator units.

Definition at line 401 of file RustyAudioLib.hpp.

◆ engine

RustyAudioEngine RustyAudioLibAPI::engine
private

RustyAudioEngine instance saved here.

Definition at line 403 of file RustyAudioLib.hpp.

◆ cli

RustyCLI RustyAudioLibAPI::cli
private

RustyCLI instance saved here.

Definition at line 404 of file RustyAudioLib.hpp.

◆ cliThread

std::thread RustyAudioLibAPI::cliThread
private

Dedicated thread to run RustyCLI on.

Definition at line 405 of file RustyAudioLib.hpp.

◆ settings

SettingsIO RustyAudioLibAPI::settings
private

RustyAudioLib IO settings.

Definition at line 406 of file RustyAudioLib.hpp.


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