ofxPDSP
pdsp::GainComputer Class Reference

Calculate gain reduction value. Needs an input converted from linear to dB values. More...

#include <GainComputer.h>

Inheritance diagram for pdsp::GainComputer:
pdsp::Unit pdsp::Preparable pdsp::Patchable

Public Member Functions

Patchableset (float threshold, float ratio, float knee=0.0f)
 sets the threshold, ratio and optionally knee default values and returns this unit ready to be patched. More...
 
float meter_reduction () const
 returns the first value of the last processed buffer, it rappresent the gain reduction in db. This method is thread-safe.
 
Patchablein_signal ()
 Sets "signal" as selected input and returns this Unit ready to be patched. This is the default input. This input is the signal to process.
 
Patchablein_threshold ()
 Sets "threshold" as selected input and returns this Unit ready to be patched. This is the threshold of the gain reduction.
 
Patchablein_ratio ()
 Sets "ratio" as selected input and returns this Unit ready to be patched. This is the ratio of gain reduction. If the input value is greater than 40 the gain reduction operate as a limiter.
 
Patchablein_knee ()
 Sets "knee" as selected input and returns this Unit ready to be patched. This is the knee of the gain reduction.
 
Patchableout_signal ()
 Sets "signal" as selected output and returns this Unit ready to be patched. This is the default output. This is the gain reduction in dB to apply to the signal.
 
- Public Member Functions inherited from pdsp::Unit
 Unit (const Unit &other)
 
Unitoperator= (const Unit &other)
 
 Unit (Unit &&other)
 
Unitoperator= (Unit &&other)
 
virtual void setOversampleLevel (int newOversampleLevel)
 sets the unit oversample level More...
 
int getOversampleLevel () const
 returns the Unit oversample level
 
- Public Member Functions inherited from pdsp::Patchable
void resetInputToDefault ()
 resets the selected input to the default.
 
void resetOutputToDefault ()
 resets the selected output to the default.
 
Patchablein (const char *tag)
 sets the selected input to the one tagged with "tag", if tag is a valid string, and returns this Patchable ready to be patched. More...
 
Patchableout (const char *tag)
 sets the selected output to the one tagged with "tag", if tag is a valid string, and returns this Patchable ready to be patched. More...
 
void disconnectIn ()
 disconnects all the outputs connected to the selected input, then resets the selected input to the default.
 
void disconnectOut ()
 disconnects all the inputs connected to the selected output, then resets the selected output to the default.
 
void disconnectAll ()
 disconnects all the inputs and outputs to their connected outputs and inputs. Also resets the selected input and output to the default.
 
InputNodegetSelectedInput ()
 returns the selected input, you can patch a Patchable or OutputNode to it with the >> operator.
 
OutputNodegetSelectedOutput ()
 returns the selected output, you can patch it to another Patchable or InputNode with the >> operator.
 
std::vector< std::string > getInputsList ()
 returns a vector of the valid input tags
 
std::vector< std::string > getOutputsList ()
 returns a vector of the valid input tags
 

Additional Inherited Members

- Static Public Member Functions inherited from pdsp::Preparable
static double getGlobalSampleRate ()
 
- Protected Member Functions inherited from pdsp::Unit
void prepareToPlay (int expectedBufferSize, double sampleRate) override
 you have to use this method only in the constructor, inside if(dynamicConstruction){ } More...
 
const float * processInput (InputNode &node, int &stateNow)
 process the given input, gives you a pointer to the processed buffer as result and its state More...
 
float processAndGetSingleValue (InputNode &input, int pos)
 process the given input, gives you a pointer to the processed buffer as result and its state More...
 
float * getOutputBufferToFill (OutputNode &node)
 gets a pointer to the output buffer for rendering audio to it, and sets the OutputNode state to AudioRate More...
 
void setControlRateOutput (OutputNode &node, float scalarValue)
 sets the OutputNode buffer to "Changed" and its first value to scalarValue More...
 
void setOutputToZero (OutputNode &node)
 sets the OutputNode buffer to "Changed" and its first value to 0.0f More...
 
void updateOutputNodes ()
 call this method in the Unit constructor after adding all the Outputs, this is mandatory for the inner working of the patching framework.
 
- Protected Member Functions inherited from pdsp::Patchable
void addOutput (const char *tag, OutputNode &output)
 method to add outputs when constructing a Unit More...
 
void addInput (const char *tag, InputNode &input)
 method to add inputs when constructing a Unit More...
 
void addModuleOutput (const char *tag, Patchable &unit)
 method to add outputs when constructing a module More...
 
void addModuleInput (const char *tag, Patchable &unit)
 method to add outputs when constructing a module More...
 

Detailed Description

Calculate gain reduction value. Needs an input converted from linear to dB values.

This unit takes an input of values converted in db values (you can use LinToDB for this) and calculate the gain reduction to apply (in dB) with a given threshold, ratio and knee. For an example of a full compressor chain see the Compressor1 code. Threshold, ratio and knee are updated at control rate speed, so there is no reason to patch audio rate units to those inputs.

Member Function Documentation

◆ set()

pdsp::Patchable & pdsp::GainComputer::set ( float  threshold,
float  ratio,
float  knee = 0.0f 
)

sets the threshold, ratio and optionally knee default values and returns this unit ready to be patched.

Parameters
[in]thresholdthreshold befor compress the audio signal
[in]ratioratio of compression. If the value is greater than 40 then the units behave as a limiter.
[in]kneeknee of gain reduction in dB. If not given this argument is 0.0f

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