SynthLab SDK
pcmlegacycore.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 LegacyPCMCore : public ModuleCore
87  {
88  public:
90  LegacyPCMCore(); /* C-TOR */
91 
93  virtual ~LegacyPCMCore() {} /* 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  // --- basic 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 
void checkAddSampleSet(std::string sampleDirectory, std::string sampleName, CoreProcData &processInfo, uint32_t index)
Query the PCM database and add sample sources as needed.
Definition: pcmlegacycore.cpp:296
double outputAmplitude
amplitude in dB
Definition: pcmlegacycore.h:106
double panRightGain
right channel gain
Definition: pcmlegacycore.h:108
IPCMSampleSource * selectedSampleSource
current PCM sample
Definition: pcmlegacycore.h:118
double panLeftGain
left channel gain
Definition: pcmlegacycore.h:107
LegacyPCMCore()
Constructs Construction: Cores follow the same construction pattern.
Definition: pcmlegacycore.cpp:29
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
uint32_t currentIndex
must persist between update and render
Definition: pcmlegacycore.h:115
PCM oscillator using the same multi-samples from the 1st edition of the Synth Book.
Definition: pcmlegacycore.h:86
virtual bool render(CoreProcData &processInfo) override
Renders the output of the module.
Definition: pcmlegacycore.cpp:210
Definition: addosccore.cpp:4
virtual bool doNoteOff(CoreProcData &processInfo) override
Note-off handler for the ModuleCore.
Definition: pcmlegacycore.cpp:282
double midiPitch
the midi pitch
Definition: pcmlegacycore.h:105
virtual ~LegacyPCMCore()
Definition: pcmlegacycore.h:93
const uint32_t MODULE_STRINGS
Definition: synthconstants.h:130
virtual bool reset(CoreProcData &processInfo) override
Resets object to initialized state.
Definition: pcmlegacycore.cpp:67
double readIndex
must persist between update and render
Definition: pcmlegacycore.h:111
double phaseInc
must persist between update and render
Definition: pcmlegacycore.h:112
virtual bool doNoteOn(CoreProcData &processInfo) override
Note-on handler for the ModuleCore.
Definition: pcmlegacycore.cpp:256
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: pcmlegacycore.h:104
Abstract base class that encapsulates functionality of a module core; used with the Module-Core parad...
Definition: synthbase.h:1516
virtual bool update(CoreProcData &processInfo) override
Updates the object for the next block of audio processing.
Definition: pcmlegacycore.cpp:129
See also Designing Software Synthesizers in C++ 2nd Ed. by Will Pirkle.