SynthLab SDK
mellotroncore.h
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 {
85  class MellotronCore : public ModuleCore
86  {
87  public:
89  MellotronCore(); /* C-TOR */
90 
92  virtual ~MellotronCore() {} /* D-TOR */
93 
95  virtual bool reset(CoreProcData& processInfo) override;
96  virtual bool update(CoreProcData& processInfo) override;
97  virtual bool render(CoreProcData& processInfo) override;
98  virtual bool doNoteOn(CoreProcData& processInfo) override;
99  virtual bool doNoteOff(CoreProcData& processInfo) override;
100 
101  protected:
102  // --- basic variables
103  double sampleRate = 0.0;
104  double midiPitch = 0.0;
105  double outputAmplitude = 1.0;
106  double panLeftGain = 0.707;
107  double panRightGain = 0.707;
108 
109  // --- timebase
110  double readIndex = 0.0;
111  double phaseInc = 0.0;
112 
113  // --- unit3
114  uint32_t currentIndex = 0;
115 
116  // --- PCM sample source
118 
119  // --- PCM sources; these are used to register the samples with the database
120  // if the samples already exist, these won't be used. Notice that the update() function
121  // ONLY uses PCM sources from the database!
122  SynthLabPCMSource pcmSources[MODULE_STRINGS];
123 
124  // --- helper function
125  void checkAddSampleSet(std::string sampleDirectory, std::string sampleName, CoreProcData& processInfo, uint32_t index);
126  };
127 
128 } // namespace
129 
virtual ~MellotronCore()
Definition: mellotroncore.h:92
virtual bool doNoteOn(CoreProcData &processInfo) override
Note-on handler for the ModuleCore.
Definition: mellotroncore.cpp:250
double panLeftGain
left channel gain
Definition: mellotroncore.h:106
double sampleRate
sample rate
Definition: mellotroncore.h:103
uint32_t currentIndex
index of sample; does not change often
Definition: mellotroncore.h:114
virtual bool doNoteOff(CoreProcData &processInfo) override
Note-off handler for the ModuleCore.
Definition: mellotroncore.cpp:276
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
virtual bool update(CoreProcData &processInfo) override
Updates the object for the next block of audio processing.
Definition: mellotroncore.cpp:128
double outputAmplitude
amplitude in dB
Definition: mellotroncore.h:105
PCM oscillator using Mellotron(R) samples freely available.
Definition: mellotroncore.h:85
const uint32_t MODULE_STRINGS
Definition: synthconstants.h:130
MellotronCore()
Construction: Cores follow the same construction pattern.
Definition: mellotroncore.cpp:29
void checkAddSampleSet(std::string sampleDirectory, std::string sampleName, CoreProcData &processInfo, uint32_t index)
query and add a sample set to the database
Definition: mellotroncore.cpp:290
virtual bool reset(CoreProcData &processInfo) override
Resets object to initialized state.
Definition: mellotroncore.cpp:67
double readIndex
need to persist from update to render
Definition: mellotroncore.h:110
double panRightGain
right channel gain
Definition: mellotroncore.h:107
virtual bool render(CoreProcData &processInfo) override
Renders the output of the module.
Definition: mellotroncore.cpp:206
IPCMSampleSource * selectedSampleSource
PCM sourse database object.
Definition: mellotroncore.h:117
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 midiPitch
the midi pitch
Definition: mellotroncore.h:104
Abstract base class that encapsulates functionality of a module core; used with the Module-Core parad...
Definition: synthbase.h:1516
double phaseInc
need to persist from update to render
Definition: mellotroncore.h:111
See also Designing Software Synthesizers in C++ 2nd Ed. by Will Pirkle.