ofxPDSP
Formula.h
1 
2 // Formula.h
3 // ofxPDSP
4 // Nicola Pisanti, MIT License, 2016
5 
6 
7 #ifndef PDSP_CORE_FORMULA_H_INCLUDED
8 #define PDSP_CORE_FORMULA_H_INCLUDED
9 
10 #include "BasicNodes.h"
11 
12 namespace pdsp{
13 
20 class Formula : public Unit{
21 
22 public:
23  Formula();
24 
28  float meter_input() const;
29 
33  float meter_output() const;
34 
38  Patchable& set(float value);
39 
45  void enableBoundaries( float low, float high);
46 
50  void disableBoundaries();
51 
52 protected:
53 
58  virtual float formula(const float & x) noexcept = 0;
59 
66  virtual void formulaAudioRate(float* & output, const float* & input, const int & bufferSize) noexcept;
67 
68 private:
69 
70  float lastProcessedValue;
71  void process (int bufferSize) noexcept override;
72 
73  void prepareUnit( int expectedBufferSize, double sampleRate ) override;
74  void releaseResources () override;
75 
76  OutputNode output;
77  InputNode input;
78 
79  std::atomic<float> inputMeter;
80  std::atomic<float> outputMeter;
81 
82 };
83 
84 }//END NAMESPACE
85 
86 
87 
88 
89 
90 
91 #endif // FORMULA_H_INCLUDED
void disableBoundaries()
disables the clamping of input values
Definition: Formula.cpp:25
virtual void formulaAudioRate(float *&output, const float *&input, const int &bufferSize) noexcept
function to be overloaded with your own math function or dsp code.
Definition: Formula.cpp:41
virtual float formula(const float &x) noexcept=0
function to be overloaded with your own math function or dsp code.
float meter_input() const
returns the value of the input buffer, updated at control rate. This method is thread safe...
Definition: Formula.cpp:29
Abstract class for implementing Units.
Definition: BasicNodes.h:223
Abstract class for implementing Units and Modules.
Definition: BasicNodes.h:82
float meter_output() const
returns the value of the output buffer, updated at control rate. This method is thread safe...
Definition: Formula.cpp:33
Input of a Unit, process all the connected Outputs and sum them. Has an internal variable state...
Definition: BasicNodes.h:536
Thread-safe value control with smoothing.
Definition: SequencerBridge.h:11
Output of a Unit, contains a buffer of rendered floats and has a variable state flag.
Definition: BasicNodes.h:354
void enableBoundaries(float low, float high)
sets some boundaries to which the values of the input will be clamped
Definition: Formula.cpp:21
An abstract unit with one input and one output and no other controls, for simple processing.
Definition: Formula.h:20