SynthLab SDK
exciter.h
Go to the documentation of this file.
1 #ifndef __exciter_h__
2 #define __exciter_h__
3 
4 #include "synthbase.h"
5 #include "synthfunctions.h"
6 #include "vafilters.h"
7 
8 // -----------------------------
9 // --- SynthLab SDK File --- //
10 // ----------------------------
18 // -----------------------------------------------------------------------------
19 namespace SynthLab
20 {
35  class ExciterEG
36  {
37  public:
38  ExciterEG() {}
39  virtual ~ExciterEG() {}
40 
41  public:
43  bool reset(double _sampleRate);
44  double render();
45 
47  bool startEG();
48 
50  void setParameters(double _attackTime_mSec, double _holdTime_mSec, double _releaseTime_mSec);
51 
52  protected:
53  double attackTime_mSec = -1.0;
54  double releaseTime_mSec = -1.0;
55  double holdTime_mSec = -1.0;
56 
57  // --- calculate time params
58  void calcAttackCoeff(double attackTime, double attackTimeScalar = 1.0);
59  void calcReleaseCoeff(double releaseTime, double releaseTimeScalar = 1.0);
60 
61  //--- Coefficient, offset and TCO values
62  // for each state
63  double attackCoeff = 0.0;
64  double attackOffset = 0.0;
65  double attackTCO = 0.0;
66 
67  double releaseCoeff = 0.0;
68  double releaseOffset = 0.0;
69  double releaseTCO = 0.0;
70 
71  double sampleRate = 0.0;
72  // --- the current output of the EG
73  double envelopeOutput = 0.0;
74 
75  // --- stage variable
76  EGState state = EGState::kOff;
77 
78  // --- timer for hold portion
80 
81  // --- RUN/STOP flag
82  bool noteOn = false;
83  };
84 
99  class Exciter
100  {
101  public:
102  Exciter() {}
103  virtual ~Exciter() {}
104 
105  public:
107  bool reset(double _sampleRate);
108  double render(double coupledInput = 0.0);
109  void startExciter();
110  void setParameters(double attackTime_mSec, double holdTime_mSec, double releaseTime_mSec);
111 
112  protected:
116  };
117 
118 
119 } // namespace
120 #endif /* defined(__exciter_h__) */
ExciterEG noiseEG
EG to shape the noise.
Definition: exciter.h:114
double releaseOffset
see AnalogEG
Definition: exciter.h:68
virtual ~ExciterEG()
empty destructor
Definition: exciter.h:39
Ultra compact timer object that is used for many different functionalities.
Definition: synthbase.h:195
Timer holdTimer
holding timer
Definition: exciter.h:79
double releaseCoeff
see AnalogEG
Definition: exciter.h:67
void setParameters(double _attackTime_mSec, double _holdTime_mSec, double _releaseTime_mSec)
Set attack, hold and relesase times.
Definition: exciter.cpp:55
bool reset(double _sampleRate)
Reset the exciter iternal components.
Definition: exciter.cpp:205
bool startEG()
param setter
Definition: exciter.cpp:116
bool noteOn
run/stop flag
Definition: exciter.h:82
double attackCoeff
see AnalogEG
Definition: exciter.h:63
double releaseTime_mSec
rel: is a time to decay from max output to 0.0
Definition: exciter.h:54
NoiseGenerator noiseGen
noise maker
Definition: exciter.h:113
bool reset(double _sampleRate)
< reset/render (simialar to SynthModule)
Definition: exciter.cpp:26
Special purpose EG just for the Karplus Strong exciter.
Definition: exciter.h:35
void calcAttackCoeff(double attackTime, double attackTimeScalar=1.0)
Calculate analg EG time constants.
Definition: exciter.cpp:77
double sampleRate
sample rate
Definition: exciter.h:71
Simple object that generates white, gaussian white or pink noise.
Definition: synthbase.h:495
double render(double coupledInput=0.0)
Render the exciter:
Definition: exciter.cpp:221
Definition: addosccore.cpp:4
virtual ~Exciter()
empty constructor
Definition: exciter.h:103
See also Designing Software Synthesizers in C++ 2nd Ed. by Will Pirkle.
ExciterEG()
empty constructor
Definition: exciter.h:38
double releaseTCO
see AnalogEG
Definition: exciter.h:69
EGState state
EG state variable.
Definition: exciter.h:76
double attackOffset
see AnalogEG
Definition: exciter.h:64
double attackTCO
see AnalogEG
Definition: exciter.h:65
Special purpose object for use as Karplus Strong exciter.
Definition: exciter.h:99
EGState
Definition: synthlabparams.h:723
void setParameters(double attackTime_mSec, double holdTime_mSec, double releaseTime_mSec)
Set the attack/hold/release time on the noiseEG object.
Definition: exciter.cpp:248
void startExciter()
Start the exciter:
Definition: exciter.cpp:235
DCRemovalFilter dcFilter
DC removal for short term random bias.
Definition: exciter.h:115
void calcReleaseCoeff(double releaseTime, double releaseTimeScalar=1.0)
Calculate analg EG time constants.
Definition: exciter.cpp:97
Implements a first order HPF with fc = 2.0Hz.
Definition: synthbase.h:2120
double render()
start the FSM
Definition: exciter.cpp:132
double holdTime_mSec
rel: is a time to decay from max output to 0.0
Definition: exciter.h:55
Exciter()
empty constructor
Definition: exciter.h:102
hard-coded arrays of FIR filter coefficients for the sample rate conversion objects (Interpolator and...
double attackTime_mSec
att: is a time duration
Definition: exciter.h:53
double envelopeOutput
the current envelope output sample
Definition: exciter.h:73
See also Designing Software Synthesizers in C++ 2nd Ed. by Will Pirkle.