SynthLab SDK
waveslicecore.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "synthbase.h"
4 #include "synthfunctions.h"
5 #include "synthlabpcmsource.h"
6 
7 // -----------------------------
8 // --- SynthLab SDK File --- //
9 // ----------------------------
17 // -----------------------------------------------------------------------------
18 namespace SynthLab
19 {
86  class WaveSliceCore : public ModuleCore
87  {
88  public:
90  WaveSliceCore(); /* C-TOR */
91 
93  virtual ~WaveSliceCore() {} /* 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 
102  protected:
103  // --- local variables
104  double sampleRate = 0.0;
105  double midiPitch = 0.0;
106  double outputAmplitude = 1.0;
107  double panLeftGain = 0.707;
108  double panRightGain = 0.707;
109 
110  // --- timebase
111  double readIndex = 0.0;
112  double phaseInc = 0.0;
113 
114  // --- unit3
115  uint32_t currentIndex = 0;
116 
117  // --- PCM sample source
119 
120  // --- PCM sources; these are used to register the samples with the database
121  // if the samples already exist, these won't be used. Notice that the update() function
122  // ONLY uses PCM sources from the database!
123  SynthLabPCMSource pcmSources[MODULE_STRINGS];
124 
125  // --- helper function
126  void checkAddSampleSet(std::string sampleDirectory, std::string sampleName, CoreProcData& processInfo, uint32_t index);
127  };
128 
129 } // namespace
130 
virtual bool doNoteOff(CoreProcData &processInfo) override
Note-off handler for the ModuleCore.
Definition: waveslicecore.cpp:277
PCM oscillator that plays wave-slices that are mapped to the C-major scale keys starting at middle C...
Definition: waveslicecore.h:86
IPCMSampleSource * selectedSampleSource
selected PCM sample
Definition: waveslicecore.h:118
virtual bool update(CoreProcData &processInfo) override
Updates the object for the next block of audio processing.
Definition: waveslicecore.cpp:121
double phaseInc
must persist from update to render
Definition: waveslicecore.h:112
void checkAddSampleSet(std::string sampleDirectory, std::string sampleName, CoreProcData &processInfo, uint32_t index)
Query the database and add a set of PCM samples if not existing already.
Definition: waveslicecore.cpp:291
double panRightGain
right channel gain
Definition: waveslicecore.h:108
WaveSliceCore()
Construction: Cores follow the same construction pattern.
Definition: waveslicecore.cpp:31
uint32_t currentIndex
must persist from update to render
Definition: waveslicecore.h:115
virtual bool reset(CoreProcData &processInfo) override
Resets object to initialized state.
Definition: waveslicecore.cpp:67
double panLeftGain
left channel gain
Definition: waveslicecore.h:107
virtual bool doNoteOn(CoreProcData &processInfo) override
Note-on handler for the ModuleCore.
Definition: waveslicecore.cpp:251
double sampleRate
sample rate
Definition: waveslicecore.h:104
Storage for a set of PCM samples that constitute a patch or instrument.
Definition: synthlabpcmsource.h:41
Interface for PCM sample sources.
Definition: synthbase.h:766
Definition: addosccore.cpp:4
const uint32_t MODULE_STRINGS
Definition: synthconstants.h:130
double readIndex
must persist from update to render
Definition: waveslicecore.h:111
virtual ~WaveSliceCore()
Definition: waveslicecore.h:93
double midiPitch
the midi pitch
Definition: waveslicecore.h:105
double outputAmplitude
amplitude in dB
Definition: waveslicecore.h:106
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
virtual bool render(CoreProcData &processInfo) override
Renders the output of the module.
Definition: waveslicecore.cpp:206
See also Designing Software Synthesizers in C++ 2nd Ed. by Will Pirkle.