SynthLab SDK
drumwtcore.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 {
88  class DrumWTCore : public ModuleCore
89  {
90  public:
92  DrumWTCore(); /* C-TOR */
93 
95  virtual ~DrumWTCore() {} /* D-TOR */
96 
98  virtual bool reset(CoreProcData& processInfo) override;
99  virtual bool update(CoreProcData& processInfo) override;
100  virtual bool render(CoreProcData& processInfo) override;
101  virtual bool doNoteOn(CoreProcData& processInfo) override;
102  virtual bool doNoteOff(CoreProcData& processInfo) override;
103 
104  protected:
106  double renderSample(SynthClock& clock, bool forceLoop);
107 
108  // --- basic variables
109  double sampleRate = 0.0;
110  double outputAmplitude = 1.0;
111  double panLeftGain = 0.707;
112  double panRightGain = 0.707;
113  bool oneShotDone = false;
114  int32_t currentWaveIndex = -1;
115 
116  // --- timebase
118 
119  // --- table source
121 
122  // --- wavetable sources; these are used to register the tables with the database
123  // if the tables already exist, these won't be used. Notice that the update() function
124  // ONLY uses wavetable sources from the database!
125  //
126  // NOTE: this is an old-fashioned mapping where each drum is it's own patch
127  // See the comments in pcmsample.cpp for mapping each drum to a different key
128  // search for: // --- here, I am mapping them to the C-major scale white keys, starting at middle C
129  DrumWTSource drumTables[MODULE_STRINGS];
130  };
131 
132 } // namespace
133 
int32_t currentWaveIndex
to minimize dictionary (map) lookup iterating
Definition: drumwtcore.h:114
IWavetableSource * selectedTableSource
selected based on oscillator pitch
Definition: drumwtcore.h:120
double outputAmplitude
amplitude in dB
Definition: drumwtcore.h:110
Wavetables that implement electronic drum samples; these samples were extracted from WAV files and co...
Definition: drumwtcore.h:88
Compact modulo counter with wrapping used as the timebase for all oscillators.
Definition: synthbase.h:137
double renderSample(SynthClock &clock, bool forceLoop)
Renders one sample out of the wavetable Core Specific:
Definition: drumwtcore.cpp:176
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 reset(CoreProcData &processInfo) override
Resets object to initialized state.
Definition: drumwtcore.cpp:88
SynthClock oscClock
timebase
Definition: drumwtcore.h:117
Definition: addosccore.cpp:4
virtual ~DrumWTCore()
Definition: drumwtcore.h:95
virtual bool update(CoreProcData &processInfo) override
Updates the object for the next block of audio processing.
Definition: drumwtcore.cpp:132
const uint32_t MODULE_STRINGS
Definition: synthconstants.h:130
double panLeftGain
left channel gain
Definition: drumwtcore.h:111
virtual bool doNoteOff(CoreProcData &processInfo) override
Note-off handler for the ModuleCore.
Definition: drumwtcore.cpp:264
bool oneShotDone
one-shot flag
Definition: drumwtcore.h:113
DrumWTCore()
Construction: Cores follow the same construction pattern.
Definition: drumwtcore.cpp:34
virtual bool render(CoreProcData &processInfo) override
Renders the output of the module.
Definition: drumwtcore.cpp:201
virtual bool doNoteOn(CoreProcData &processInfo) override
Note-on handler for the ModuleCore.
Definition: drumwtcore.cpp:239
double panRightGain
right channel gain
Definition: drumwtcore.h:112
double sampleRate
sample rate
Definition: drumwtcore.h:109
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
Abstract base class that encapsulates functionality of a module core; used with the Module-Core parad...
Definition: synthbase.h:1516
See also Designing Software Synthesizers in C++ 2nd Ed. by Will Pirkle.