SynthLab SDK
synthlabcore.h
1 #pragma once
2 
3 // *** NOTE: relative paths to SDK files ********************************************
4 // these are setup so that ModuleCore DM projects are compiled directly
5 // from the SDK itself with minimal effort
6 //
7 // You may want to adjust these to suit your particular development folder
8 // system if you only want to use parts of the SDK or plan on modifying
9 // SDK files, or need to alter the folder hierarchy for your setup.
10 //
11 // Alternatively, you may add a new "Include Path" to your compiler setup.
12 // **********************************************************************************
13 
14 #include "../../../../source/synthbase.h"
15 #include "../../../../source/synthfunctions.h"
16 
17 // -----------------------------
18 // SynthLab SDK File //
19 // for //
20 // DynamicModule //
21 // Development //
22 // ----------------------------
23 
31 // -----------------------------------------------------------------------------
32 namespace SynthLab
33 {
99  class SynthLabCore : public ModuleCore
100  {
101  public:
103  SynthLabCore(); /* C-TOR */
104 
106  virtual ~SynthLabCore() {} /* D-TOR */
107 
109  virtual bool reset(CoreProcData& processInfo) override;
110  virtual bool update(CoreProcData& processInfo) override;
111  virtual bool render(CoreProcData& processInfo) override;
112  virtual bool doNoteOn(CoreProcData& processInfo) override;
113  virtual bool doNoteOff(CoreProcData& processInfo) override;
114 
116  virtual int32_t getState() override { return enumToInt(state); }
117  virtual bool shutdown() override;
118  virtual void setSustainOverride(bool b) override;
119 
120  protected:
122  inline double setStepInc(double timeMsec, double scale = 1.0);
123 
124  // --- local variables
125  double sampleRate = 1.0;
126  double egStepInc = 0.0;
127  double attackTimeScalar = 0.0;
128  double decayTimeScalar = 0.0;
129  EGState state = EGState::kOff;
130  double envelopeOutput = 0.0;
131  bool sustainOverride = false;
132  bool releasePending = false;
133  bool resetToZero = false;
134  double incShutdown = 0.0;
135  };
136 
137 } // namespace
138 
EGState state
EG state variable.
Definition: synthlabcore.h:202
#define enumToInt(ENUM)
macro helper to cast a typed enum to an int
Definition: synthfunctions.h:251
SynthLabCore()
Construction: Cores follow the same construction pattern.
Definition: synthlabcore.cpp:29
double egStepInc
linear time stepping
Definition: synthlabcore.h:125
virtual bool shutdown() override
Shutdown handler for EG.
Definition: synthlabcore.cpp:400
virtual int32_t getState() override
Definition: synthlabcore.h:116
virtual bool doNoteOff(CoreProcData &processInfo) override
Note-off handler for the ModuleCore.
Definition: synthlabcore.cpp:135
Definition: addosccore.cpp:4
virtual bool update(CoreProcData &processInfo) override
Updates the object for the next block of audio processing.
Definition: synthlabcore.cpp:79
double sampleRate
sample rate
Definition: synthlabcore.h:108
virtual bool render(CoreProcData &processInfo) override
Renders the output of the module.
Definition: synthlabcore.cpp:98
bool sustainOverride
if true, places the EG into sustain mode
Definition: synthlabcore.h:195
bool resetToZero
notes the EG is in reset-to-zero mode
Definition: synthlabcore.h:138
EGState
Definition: synthlabparams.h:723
double decayTimeScalar
for MIDI modulations to decay time
Definition: synthlabcore.h:127
double envelopeOutput
the current envelope output sample
Definition: synthlabcore.h:176
virtual bool doNoteOn(CoreProcData &processInfo) override
Note-on handler for the ModuleCore.
Definition: synthlabcore.cpp:116
virtual bool reset(CoreProcData &processInfo) override
Resets object to initialized state.
Definition: synthlabcore.cpp:61
double setStepInc(double timeMsec, double scale=1.0)
Calculates linear step increment based on time in millisecs.
Definition: synthlabcore.cpp:486
virtual void setSustainOverride(bool b) override
Sustain pedal handler for EG.
Definition: synthlabcore.cpp:422
virtual ~SynthLabCore()
Definition: synthlabcore.h:106
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: synthlabcore.h:196
double incShutdown
shutdown linear incrementer
Definition: synthlabcore.h:199
This structure holds all of the information needed to call functions on a ModuleCore object...
Definition: synthbase.h:1071
double attackTimeScalar
for MIDI modulations to attack time
Definition: synthlabcore.h:126