SynthLab SDK
linearegcore.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "synthbase.h"
4 
5 // -----------------------------
6 // --- SynthLab SDK File --- //
7 // ----------------------------
15 // -----------------------------------------------------------------------------
16 namespace SynthLab
17 {
83  class LinearEGCore : public ModuleCore
84  {
85  public:
87  LinearEGCore(); /* C-TOR */
88 
90  virtual ~LinearEGCore() {} /* D-TOR */
91 
93  virtual bool reset(CoreProcData& processInfo) override;
94  virtual bool update(CoreProcData& processInfo) override;
95  virtual bool render(CoreProcData& processInfo) override;
96  virtual bool doNoteOn(CoreProcData& processInfo) override;
97  virtual bool doNoteOff(CoreProcData& processInfo) override;
98 
100  virtual int32_t getState() override { return enumToInt(state); }
101  virtual bool shutdown() override;
102  virtual void setSustainOverride(bool b) override;
103 
104  protected:
106  inline double setStepInc(double timeMsec, double scale = 1.0);
107 
108  // --- local variables
109  double sampleRate = 1.0;
110  double egStepInc = 0.0;
111  double attackTimeScalar = 0.0;
112  double decayTimeScalar = 0.0;
113  EGState state = EGState::kOff;
114  double envelopeOutput = 0.0;
115  bool sustainOverride = false;
116  bool releasePending = false;
117  bool resetToZero = false;
118  double incShutdown = 0.0;
119  };
120 
121 } // namespace
122 
#define enumToInt(ENUM)
macro helper to cast a typed enum to an int
Definition: synthfunctions.h:251
virtual bool render(CoreProcData &processInfo) override
Renders the output of the module.
Definition: linearegcore.cpp:123
double envelopeOutput
current output
Definition: linearegcore.h:114
double setStepInc(double timeMsec, double scale=1.0)
Calculates linear step increment based on time in millisecs.
Definition: linearegcore.cpp:370
double egStepInc
current stepping inc
Definition: linearegcore.h:110
virtual bool update(CoreProcData &processInfo) override
Updates the object for the next block of audio processing.
Definition: linearegcore.cpp:94
double incShutdown
shutdown linear incrementer
Definition: linearegcore.h:118
Simplest EG of all, using linear segments - the place to start to build your own EG from scratch...
Definition: linearegcore.h:83
Definition: addosccore.cpp:4
virtual bool doNoteOn(CoreProcData &processInfo) override
Note-on handler for the ModuleCore.
Definition: linearegcore.cpp:235
EGState
Definition: synthlabparams.h:723
EGState state
FSM state variable.
Definition: linearegcore.h:113
virtual void setSustainOverride(bool b) override
Sustain pedal handler for EG.
Definition: linearegcore.cpp:349
virtual ~LinearEGCore()
Definition: linearegcore.h:90
virtual bool shutdown() override
Shutdown handler for EG.
Definition: linearegcore.cpp:327
double decayTimeScalar
for MIDI modulation
Definition: linearegcore.h:112
virtual bool doNoteOff(CoreProcData &processInfo) override
Note-off handler for the ModuleCore.
Definition: linearegcore.cpp:296
LinearEGCore()
Construction: Cores follow the same construction pattern.
Definition: linearegcore.cpp:30
virtual int32_t getState() override
Definition: linearegcore.h:100
bool resetToZero
notes the EG is in reset-to-zero mode
Definition: linearegcore.h:117
This structure holds all of the information needed to call functions on a ModuleCore object...
Definition: synthbase.h:1071
double attackTimeScalar
for MIDI modulation
Definition: linearegcore.h:111
double sampleRate
fs
Definition: linearegcore.h:109
Abstract base class that encapsulates functionality of a module core; used with the Module-Core parad...
Definition: synthbase.h:1516
bool releasePending
a flag set when a note off event occurs while the sustain pedal is held, telling the EG to go to the ...
Definition: linearegcore.h:116
See also Designing Software Synthesizers in C++ 2nd Ed. by Will Pirkle.
virtual bool reset(CoreProcData &processInfo) override
Resets object to initialized state.
Definition: linearegcore.cpp:66
bool sustainOverride
if true, places the EG into sustain mode
Definition: linearegcore.h:115