SynthLab SDK
addosccore.h
1 #pragma once
2 
3 #include "synthbase.h"
4 #include "synthfunctions.h"
5 
6 namespace SynthLab
7 {
82  class AddOscCore : public ModuleCore
83  {
84  public:
85  // --- constructor/destructor
86  AddOscCore(); /* C-TOR */
87  virtual ~AddOscCore(){} /* D-TOR */
88 
89  virtual bool reset(CoreProcData& processInfo) override;
90  virtual bool update(CoreProcData& processInfo) override;
91  virtual bool render(CoreProcData& processInfo) override;
92  virtual bool doNoteOn(CoreProcData& processInfo) override;
93  virtual bool doNoteOff(CoreProcData& processInfo) override;
94 
95  protected:
96  double sampleRate = 1.0;
97  double midiPitch = 0.0;
98 
99  // --- timebase
100  SynthClock oscClock;
101 
102  enum { ChebyT2, ChebyT3, ChebyT4, ChebyT5 };
103  // --- NOT the most efficient implementation!!!!!
104  inline double doChebyWaveshaper(double xn, uint32_t order)
105  {
106  double xSquared = xn*xn;
107  double xCubed = xn*xSquared;
108  double x4th = xn*xCubed;
109  double x5th = xn*x4th;
110 
111  if (order == ChebyT2)
112  return (2.0 * xSquared) - 1.0;
113  else if (order == ChebyT3)
114  return (4.0 * xCubed) - (3.0 * xn);
115  else if (order == ChebyT4)
116  return (8.0 * x4th) - (8.0 * xSquared) + 1.0;
117  else if (order == ChebyT5)
118  return (16.0 * x5th) - (20.0 * xCubed) + (5.0 * xn);
119 
120  return xn; // not found
121  }
122 
123 
124  };
125 
126 
127 
128 } // namespace
129 
virtual bool reset(CoreProcData &processInfo) override
Resets object to initialized state.
Definition: addosccore.cpp:52
Compact modulo counter with wrapping used as the timebase for all oscillators.
Definition: synthbase.h:137
AddOscCore()
Construction: Cores follow the same construction pattern.
Definition: addosccore.cpp:19
virtual bool render(CoreProcData &processInfo) override
Renders the output of the module.
Definition: addosccore.cpp:137
Definition: addosccore.cpp:4
virtual bool update(CoreProcData &processInfo) override
Updates the object for the next block of audio processing.
Definition: addosccore.cpp:77
This is the "blank" core template for compiling your own Cores as dynamic modules.
Definition: addosccore.h:82
virtual bool doNoteOff(CoreProcData &processInfo) override
Note-off handler for the ModuleCore.
Definition: addosccore.cpp:221
virtual bool doNoteOn(CoreProcData &processInfo) override
Note-on handler for the ModuleCore.
Definition: addosccore.cpp:199
double midiPitch
the midi pitch
Definition: addosccore.h:97
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.