SynthLab SDK
wsoscillator.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "synthbase.h"
4 #include "synthfunctions.h"
5 #include "wtoscillator.h"
6 
7 // -----------------------------
8 // --- SynthLab SDK File --- //
9 // ----------------------------
17 // -----------------------------------------------------------------------------
18 namespace SynthLab
19 {
109  class WSOscillator : public SynthModule
110  {
111  public:
113  WSOscillator(std::shared_ptr<MidiInputData> _midiInputData,
114  std::shared_ptr<WSOscParameters> _parameters,
115  std::shared_ptr<WavetableDatabase> _waveTableDatabase,
116  uint32_t blockSize = 64);
117 
119  virtual ~WSOscillator() {}/* D-TOR */
120 
122  virtual bool reset(double _sampleRate) override;
123  virtual bool update() override;
124  virtual bool render(uint32_t samplesToProcess = 1) override;
125  virtual bool doNoteOn(MIDINoteEvent& noteEvent) override;
126  virtual bool doNoteOff(MIDINoteEvent& noteEvent) override;
127  virtual bool startGlideModulation(GlideInfo& glideInfo) override;
128 
130  void makeWaveStringMap();
131  void mixOscBuffers(std::shared_ptr<AudioBuffer> oscBuffers, uint32_t samplesInBlock, double scaling);
132 
134  bool oscIsFree(uint32_t oscIndex, uint32_t waveAIndex, uint32_t waveBIndex);
135  bool oscHasWaveIndex(uint32_t oscIndex, uint32_t waveIndex);
136  void setNewOscWaveA(uint32_t oscIndex, uint32_t waveAIndex, double oscAMixCoeff);
137  void setNewOscWaveB(uint32_t oscIndex, uint32_t waveBIndex, double oscBMixCoeff);
138 
140  std::shared_ptr<Modulators> getWSOscModulationInput(uint32_t oscIndex);
141  std::shared_ptr<WTOscillator> getWTOscillator(uint32_t index);
142 
145 
146  protected:
147  // --- parameters
148  std::shared_ptr<WSOscParameters> parameters = nullptr;
149 
150  // --- four WT Oscillators
151  std::shared_ptr<WTOscillator> waveSeqOsc[NUM_WS_OSCILLATORS] = { nullptr, nullptr, nullptr, nullptr };
152  std::shared_ptr<WTOscParameters> waveSeqParams[NUM_WS_OSCILLATORS] = { nullptr, nullptr, nullptr, nullptr };
153 
154  // --- stores the active pair of osc indexes
155  uint32_t activeOsc[2] = { 0, 1 };
156  int32_t currSoloWave = -1; // -1 = nothing is being soloed
157 
158  // --- mising coefficients for the oscillators
159  double oscMixCoeff[NUM_WS_OSCILLATORS] = { 0.0, 0.0, 0.0, 0.0 };
160 
161  // --- initializer for one-time setup
162  bool initRoundRobin = true;
163 
164  // --- for connecting waveform strings to the oscillator cores that implement them
165  std::vector<WaveStringData> waveStringFinder;
166  };
167 
168 
169 }
bool oscIsFree(uint32_t oscIndex, uint32_t waveAIndex, uint32_t waveBIndex)
Finds out if oscillator has the same core and waveform index as the selection.
Definition: wsoscillator.cpp:335
void setNewOscWaveA(uint32_t oscIndex, uint32_t waveAIndex, double oscAMixCoeff)
Change oscillator&#39;s waveform to Wave A.
Definition: wsoscillator.cpp:374
virtual bool startGlideModulation(GlideInfo &glideInfo) override
Calls the startGlideModulation handler for the first two oscillators; these will always be the first ...
Definition: wsoscillator.cpp:266
uint32_t activeOsc[2]
active pair
Definition: wsoscillator.h:155
virtual bool doNoteOn(MIDINoteEvent &noteEvent) override
Calls the note-on handler for all cores on all four internal oscillators so that they will be running...
Definition: wsoscillator.cpp:227
virtual bool reset(double _sampleRate) override
Resets object to initialized state.
Definition: wsoscillator.cpp:71
virtual bool render(uint32_t samplesToProcess=1) override
Renders audio from the selected core.
Definition: wsoscillator.cpp:204
void makeWaveStringMap()
Creates a mapping that links the waveform names to their underlying cores and oscillators.
Definition: wsoscillator.cpp:279
Definition: addosccore.cpp:4
Definition: synthstructures.h:235
This is an aggregate of 4 wavetable oscillators being controlled with the single object that appears ...
Definition: wsoscillator.h:109
virtual ~WSOscillator()
Definition: wsoscillator.h:119
virtual bool update() override
Updates the the two active oscillators.
Definition: wsoscillator.cpp:129
virtual bool doNoteOff(MIDINoteEvent &noteEvent) override
Calls the note-off handler on four internal oscillators.
Definition: wsoscillator.cpp:251
Abstract base class that encapsulates functionality of a module; used with the Module-Core paradigm...
Definition: synthbase.h:1600
void mixOscBuffers(std::shared_ptr< AudioBuffer > oscBuffers, uint32_t samplesInBlock, double scaling)
Helper function to mix oscillator buffers together during render() phase into the audio buffers on th...
Definition: wsoscillator.cpp:311
See also Designing Software Synthesizers in C++ 2nd Ed. by Will Pirkle.
void updateActiveOscillators()
Updates the two active oscillators during the update() phase.
Definition: wsoscillator.cpp:96
void setNewOscWaveB(uint32_t oscIndex, uint32_t waveBIndex, double oscBMixCoeff)
Change oscillator&#39;s waveform to Wave B.
Definition: wsoscillator.cpp:397
WSOscillator(std::shared_ptr< MidiInputData > _midiInputData, std::shared_ptr< WSOscParameters > _parameters, std::shared_ptr< WavetableDatabase > _waveTableDatabase, uint32_t blockSize=64)
Constructs Wave Sequencing Oscillator module.
Definition: wsoscillator.cpp:31
bool oscHasWaveIndex(uint32_t oscIndex, uint32_t waveIndex)
Finds out if oscillator has the same waveform index as the selection.
Definition: wsoscillator.cpp:356
hard-coded arrays of FIR filter coefficients for the sample rate conversion objects (Interpolator and...
std::shared_ptr< WTOscillator > getWTOscillator(uint32_t index)
Provides direct access to internal oscillator objects.
Definition: wsoscillator.cpp:428
std::shared_ptr< Modulators > getWSOscModulationInput(uint32_t oscIndex)
Gets the modulation input array pointer from one of the internal oscillators.
Definition: wsoscillator.cpp:417
const uint32_t NUM_WS_OSCILLATORS
Definition: synthconstants.h:100
Information about a MIDI note event (note on or note off).
Definition: synthstructures.h:212
See also Designing Software Synthesizers in C++ 2nd Ed. by Will Pirkle.