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/primalwaves/primalwaves.h"
18 #include "../../../../wavetables/digdoo1/digdoo1.h"
19 #include "../../../../wavetables/digdoo2/digdoo2.h"
20 #include "../../../../wavetables/digdoo3/digdoo3.h"
21 #include "../../../../wavetables/sawdemon/sawdemon.h"
22 #include "../../../../wavetables/sqrduty/sqrduty.h"
23 #include "../../../../wavetables/squarecomb/sqrcomb.h"
24 #include "../../../../wavetables/squareing/sqring.h"
25 #include "../../../../wavetables/sinemorph/sinemorph.h"
26 #include "../../../../wavetables/dentist/dentist.h"
27 
28 // -----------------------------
29 // SynthLab SDK File //
30 // for //
31 // DynamicModule //
32 // Development //
33 // ----------------------------
34 
42 // -----------------------------------------------------------------------------
43 namespace SynthLab
44 {
111  class SynthLabCore : public ModuleCore
112  {
113  public:
115  SynthLabCore(); /* C-TOR */
116 
118  virtual ~SynthLabCore() {} /* D-TOR */
119 
121  virtual bool reset(CoreProcData& processInfo) override;
122  virtual bool update(CoreProcData& processInfo) override;
123  virtual bool render(CoreProcData& processInfo) override;
124  virtual bool doNoteOn(CoreProcData& processInfo) override;
125  virtual bool doNoteOff(CoreProcData& processInfo) override;
126 
128  double renderSample(SynthClock& clock);
129  double renderHardSyncSample(SynthClock& clock);
130 
131  protected:
132  // --- local variables
133  double sampleRate = 0.0;
134  double currentTableRate = 0.0;
135  double midiPitch = 0.0;
136  double outputAmplitude = 1.0;
137  double panLeftGain = 0.707;
138  double panRightGain = 0.707;
139  double hardSyncRatio = 1.0;
140  int32_t currentWaveIndex = -1;
141  int32_t currentTable0 = -1;
142  int32_t currentTable1 = -1;
143 
144  // --- const power summing:
145  double mixValue0 = 0.0;
146  double mixValue1 = 0.0;
147 
148  // --- timebase
150 
151  // --- table source
152  IWavetableSource* selectedTableSource[2] = { nullptr, nullptr };
153 
154  // -- hard sync helper
156 
157  // --- set of banks, one for each module string
159  void addMorphBankData(std::string name, SynthLabBankSet& slTableSet, uint32_t index);
160 
161  int32_t table0last = -1;
162  int32_t table1last = -1;
163  double morphLocation = 0.0;
164  double lastMorphMod = -10.0;
165 
166  // --- helper function
167  void checkAddWaveBank(SynthLabBankSet& slTableSet, CoreProcData& processInfo, uint32_t waveIndex);
168  int32_t checkAddWavetable(SynthLabTableSet& slTableSet, StaticTableSource* tableSource, CoreProcData& processInfo);
169  };
170 
171 } // namespace
172 
173 
MorphBankData morphBankData[MODULE_STRINGS]
morphing bank of wavetables
Definition: synthlabcore.h:158
void checkAddWaveBank(SynthLabBankSet &slTableSet, CoreProcData &processInfo, uint32_t waveIndex)
Calls the querying function to check and add a new wavebank (set of wavetables)
Definition: synthlabcore.cpp:483
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
int32_t currentTable1
to minimize dictionary (map) lookup iterating
Definition: synthlabcore.h:142
void addMorphBankData(std::string name, SynthLabBankSet &slTableSet, uint32_t index)
add a bank top database
Definition: synthlabcore.cpp:461
double currentTableRate
sample rate
Definition: synthlabcore.h:128
virtual bool doNoteOff(CoreProcData &processInfo) override
Note-off handler for the ModuleCore.
Definition: synthlabcore.cpp:135
Information about a bank of wavetables that are used in the morphing wavetable core.
Definition: synthlabwtsource.h:254
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
double hardSyncRatio
for hard sync
Definition: synthlabcore.h:133
double lastMorphMod
last morph modulator
Definition: synthlabcore.h:164
virtual bool render(CoreProcData &processInfo) override
Renders the output of the module.
Definition: synthlabcore.cpp:98
int32_t table0last
running index of last table_0
Definition: synthlabcore.h:161
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
double midiPitch
midi note pitch
Definition: synthlabcore.h:123
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
double renderHardSyncSample(SynthClock &clock, double shape=0.5)
Renders one hard-synced sample from the wavetable Core Specific:
Definition: synthlabcore.cpp:262
Storage for one static table source; a static table is pre-compiled into the synth, or (optionally) read from a file. The "source" stores a set of these tables to maximize frequency content while prohibiting aliasing.
Definition: synthlabwtsource.h:39
virtual ~SynthLabCore()
Definition: synthlabcore.h:118
double morphLocation
fractional location to morph between table_0 and table_1
Definition: synthlabcore.h:163
This super-structure holds a set of SynthLabTableSet called a "bank" and used in the morphing wavetab...
Definition: synthbase.h:1173
This is a very specialized object that performs the hard-sync operation using two SynthClocks...
Definition: synthbase.h:365
void checkAddWavetable(SynthLabTableSet &slTableSet, CoreProcData &processInfo, uint32_t waveIndex)
helper function to check database for wavetable and add it if the table does not exist ...
Definition: synthlabcore.cpp:419
This structure defines a set of wavetables that are usually found in .h files and compiled into the s...
Definition: synthbase.h:1126
This structure holds all of the information needed to call functions on a ModuleCore object...
Definition: synthbase.h:1071
int32_t table1last
running index of last table_1
Definition: synthlabcore.h:162
IWavetableSource * selectedTableSource
selected table
Definition: synthlabcore.h:137
int32_t currentTable0
to minimize dictionary (map) lookup iterating
Definition: synthlabcore.h:141
Synchronizer hardSyncronizer
hard sync helper
Definition: synthlabcore.h:140
double renderSample(SynthClock &clock, double shape=0.5)
Renders one sample out of the wavetable Core Specific:
Definition: synthlabcore.cpp:236