SynthLab SDK
morphwtcore.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "synthbase.h"
4 #include "synthfunctions.h"
5 #include "synthlabwtsource.h"
6 
7 // -----------------------------
8 // --- SynthLab SDK File --- //
9 // ----------------------------
17 // -----------------------------------------------------------------------------
18 namespace SynthLab
19 {
86  class MorphWTCore : public ModuleCore
87  {
88  public:
90  MorphWTCore(); /* C-TOR */
91 
93  virtual ~MorphWTCore() {} /* D-TOR */
94 
96  virtual bool reset(CoreProcData& processInfo) override;
97  virtual bool update(CoreProcData& processInfo) override;
98  virtual bool render(CoreProcData& processInfo) override;
99  virtual bool doNoteOn(CoreProcData& processInfo) override;
100  virtual bool doNoteOff(CoreProcData& processInfo) override;
101 
103  double renderSample(SynthClock& clock);
104  double renderHardSyncSample(SynthClock& clock);
105 
106  protected:
107  // --- local variables
108  double sampleRate = 0.0;
109  double currentTableRate = 0.0;
110  double midiPitch = 0.0;
111  double outputAmplitude = 1.0;
112  double panLeftGain = 0.707;
113  double panRightGain = 0.707;
114  double hardSyncRatio = 1.0;
115  int32_t currentWaveIndex = -1;
116  int32_t currentTable0 = -1;
117  int32_t currentTable1 = -1;
118 
119  // --- const power summing:
120  double mixValue0 = 0.0;
121  double mixValue1 = 0.0;
122 
123  // --- timebase
125 
126  // --- table source
127  IWavetableSource* selectedTableSource[2] = { nullptr, nullptr };
128 
129  // -- hard sync helper
131 
132  // --- set of banks, one for each module string
134  void addMorphBankData(std::string name, SynthLabBankSet& slTableSet, uint32_t index);
135 
136  int32_t table0last = -1;
137  int32_t table1last = -1;
138  double morphLocation = 0.0;
139  double lastMorphMod = -10.0;
140 
141  // --- helper function
142  void checkAddWaveBank(SynthLabBankSet& slTableSet, CoreProcData& processInfo, uint32_t waveIndex);
143  int32_t checkAddWavetable(SynthLabTableSet& slTableSet, StaticTableSource* tableSource, CoreProcData& processInfo);
144  };
145 
146 } // namespace
147 
void addMorphBankData(std::string name, SynthLabBankSet &slTableSet, uint32_t index)
add a bank top database
Definition: morphwtcore.cpp:474
virtual bool render(CoreProcData &processInfo) override
Renders the output of the module.
Definition: morphwtcore.cpp:364
Compact modulo counter with wrapping used as the timebase for all oscillators.
Definition: synthbase.h:137
IWavetableSource * selectedTableSource[2]
two tables to morph across
Definition: morphwtcore.h:127
Interface for wavetable sources.
Definition: synthbase.h:609
virtual bool update(CoreProcData &processInfo) override
Updates the object for the next block of audio processing.
Definition: morphwtcore.cpp:135
double panLeftGain
left channel gain
Definition: morphwtcore.h:112
int32_t currentTable0
to minimize dictionary (map) lookup iterating
Definition: morphwtcore.h:116
MorphBankData morphBankData[MODULE_STRINGS]
morphing bank of wavetables
Definition: morphwtcore.h:133
double renderHardSyncSample(SynthClock &clock)
render a hard-sunk sample
Definition: morphwtcore.cpp:317
Morphing Wavetable oscillator.
Definition: morphwtcore.h:86
double panRightGain
right channel gain
Definition: morphwtcore.h:113
Information about a bank of wavetables that are used in the morphing wavetable core.
Definition: synthlabwtsource.h:254
virtual bool doNoteOn(CoreProcData &processInfo) override
Note-on handler for the ModuleCore.
Definition: morphwtcore.cpp:426
Definition: addosccore.cpp:4
const uint32_t MODULE_STRINGS
Definition: synthconstants.h:130
double outputAmplitude
amplitude in dB
Definition: morphwtcore.h:111
int32_t table1last
running index of last table_1
Definition: morphwtcore.h:137
double currentTableRate
sample rate
Definition: morphwtcore.h:109
Synchronizer hardSyncronizer
hard synchronizer
Definition: morphwtcore.h:130
int32_t currentTable1
to minimize dictionary (map) lookup iterating
Definition: morphwtcore.h:117
double lastMorphMod
last morph modulator
Definition: morphwtcore.h:139
double morphLocation
fractional location to morph between table_0 and table_1
Definition: morphwtcore.h:138
double hardSyncRatio
hard sync ratio with modulators applied
Definition: morphwtcore.h:114
int32_t table0last
running index of last table_0
Definition: morphwtcore.h:136
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 bool doNoteOff(CoreProcData &processInfo) override
Note-off handler for the ModuleCore.
Definition: morphwtcore.cpp:456
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
double midiPitch
the midi pitch
Definition: morphwtcore.h:110
SynthClock oscClock
timebase
Definition: morphwtcore.h:124
int32_t checkAddWavetable(SynthLabTableSet &slTableSet, StaticTableSource *tableSource, CoreProcData &processInfo)
Function that queries the datbase for the various tables based on unique table names.
Definition: morphwtcore.cpp:521
MorphWTCore()
Construction: Cores follow the same construction pattern.
Definition: morphwtcore.cpp:39
virtual bool reset(CoreProcData &processInfo) override
Resets object to initialized state.
Definition: morphwtcore.cpp:87
int32_t currentWaveIndex
to minimize dictionary (map) lookup iterating
Definition: morphwtcore.h:115
This structure defines a set of wavetables that are usually found in .h files and compiled into the s...
Definition: synthbase.h:1126
virtual ~MorphWTCore()
Definition: morphwtcore.h:93
hard-coded arrays of FIR filter coefficients for the sample rate conversion objects (Interpolator and...
This structure holds all of the information needed to call functions on a ModuleCore object...
Definition: synthbase.h:1071
double sampleRate
sample rate
Definition: morphwtcore.h:108
Abstract base class that encapsulates functionality of a module core; used with the Module-Core parad...
Definition: synthbase.h:1516
void checkAddWaveBank(SynthLabBankSet &slTableSet, CoreProcData &processInfo, uint32_t waveIndex)
Calls the querying function to check and add a new wavebank (set of wavetables)
Definition: morphwtcore.cpp:497
double renderSample(SynthClock &clock)
render a sample
Definition: morphwtcore.cpp:281
See also Designing Software Synthesizers in C++ 2nd Ed. by Will Pirkle.