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 #include "../../../../source/synthlabwtsource.h"
17 #include "../../../../wavetables/static_tables/drumtables.h"
18 
19 // -----------------------------
20 // SynthLab SDK File //
21 // for //
22 // DynamicModule //
23 // Development //
24 // ----------------------------
32 // -----------------------------------------------------------------------------
33 namespace SynthLab
34 {
103  class SynthLabCore : public ModuleCore
104  {
105  public:
107  SynthLabCore(); /* C-TOR */
108 
110  virtual ~SynthLabCore() {} /* D-TOR */
111 
113  virtual bool reset(CoreProcData& processInfo) override;
114  virtual bool update(CoreProcData& processInfo) override;
115  virtual bool render(CoreProcData& processInfo) override;
116  virtual bool doNoteOn(CoreProcData& processInfo) override;
117  virtual bool doNoteOff(CoreProcData& processInfo) override;
118 
119  protected:
121  double renderSample(SynthClock& clock, bool forceLoop);
122 
123  // --- basic variables
124  double sampleRate = 0.0;
125  double outputAmplitude = 1.0;
126  double panLeftGain = 0.707;
127  double panRightGain = 0.707;
128  bool oneShotDone = false;
129  int32_t currentWaveIndex = -1;
130 
131  // --- timebase
133 
134  // --- table source
136 
137  // --- wavetable sources; these are used to register the tables with the database
138  // if the tables already exist, these won't be used. Notice that the update() function
139  // ONLY uses wavetable sources from the database!
140  //
141  // NOTE: this is an old-fashioned mapping where each drum is it's own patch
142  // See the comments in pcmsample.cpp for mapping each drum to a different key
143  // search for: // --- here, I am mapping them to the C-major scale white keys, starting at middle C
144  DrumWTSource drumTables[MODULE_STRINGS];
145  };
146 
147 } // namespace
148 
149 
SynthLabCore()
Construction: Cores follow the same construction pattern.
Definition: synthlabcore.cpp:29
Compact modulo counter with wrapping used as the timebase for all oscillators.
Definition: synthbase.h:137
double panRightGain
right channel gain
Definition: synthlabcore.h:130
Interface for wavetable sources.
Definition: synthbase.h:609
Storage for one static table source, specifically for drums which are pitchless and one-shot...
Definition: synthlabwtsource.h:151
virtual bool doNoteOff(CoreProcData &processInfo) override
Note-off handler for the ModuleCore.
Definition: synthlabcore.cpp:135
Definition: addosccore.cpp:4
SynthClock oscClock
the oscillator timebase
Definition: synthlabcore.h:134
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
bool oneShotDone
one-shot flag
Definition: synthlabcore.h:128
virtual bool render(CoreProcData &processInfo) override
Renders the output of the module.
Definition: synthlabcore.cpp:98
const uint32_t MODULE_STRINGS
Definition: synthconstants.h:130
virtual bool doNoteOn(CoreProcData &processInfo) override
Note-on handler for the ModuleCore.
Definition: synthlabcore.cpp:116
double outputAmplitude
amplitude in dB
Definition: synthlabcore.h:128
virtual bool reset(CoreProcData &processInfo) override
Resets object to initialized state.
Definition: synthlabcore.cpp:61
double panLeftGain
left channel gain
Definition: synthlabcore.h:129
int32_t currentWaveIndex
to minimize dictionary (map) lookup iterating
Definition: synthlabcore.h:131
virtual ~SynthLabCore()
Definition: synthlabcore.h:110
This structure holds all of the information needed to call functions on a ModuleCore object...
Definition: synthbase.h:1071
IWavetableSource * selectedTableSource
selected table
Definition: synthlabcore.h:137
double renderSample(SynthClock &clock, double shape=0.5)
Renders one sample out of the wavetable Core Specific:
Definition: synthlabcore.cpp:236