SynthLab SDK
SynthLab::MorphWTCore Class Reference

Morphing Wavetable oscillator. More...

#include <morphwtcore.h>

Inheritance diagram for SynthLab::MorphWTCore:
SynthLab::ModuleCore

Public Member Functions

 MorphWTCore ()
 Construction: Cores follow the same construction pattern. More...
 
virtual ~MorphWTCore ()
 
virtual bool reset (CoreProcData &processInfo) override
 Resets object to initialized state. More...
 
virtual bool update (CoreProcData &processInfo) override
 Updates the object for the next block of audio processing. More...
 
virtual bool render (CoreProcData &processInfo) override
 Renders the output of the module. More...
 
virtual bool doNoteOn (CoreProcData &processInfo) override
 Note-on handler for the ModuleCore. More...
 
virtual bool doNoteOff (CoreProcData &processInfo) override
 Note-off handler for the ModuleCore. More...
 
double renderSample (SynthClock &clock)
 render a sample More...
 
double renderHardSyncSample (SynthClock &clock)
 render a hard-sunk sample More...
 
- Public Member Functions inherited from SynthLab::ModuleCore
 ModuleCore ()
 Constructs a ModuleCore. More...
 
virtual int32_t getState ()
 
virtual bool shutdown ()
 
virtual void setSustainOverride (bool sustain)
 
virtual void setStandAloneMode (bool b)
 
bool startGlideModulation (GlideInfo &glideInfo)
 
uint32_t getModuleType ()
 
const char * getModuleName ()
 
void * getModuleHandle ()
 
void setModuleHandle (void *handle)
 
uint32_t getModuleIndex ()
 
void setModuleIndex (uint32_t index)
 
int32_t getPreferredModuleIndex ()
 
void setPreferredModuleIndex (uint32_t index)
 
ModuleCoreDatagetModuleData ()
 provides access to the core data: More...
 

Protected Member Functions

void addMorphBankData (std::string name, SynthLabBankSet &slTableSet, uint32_t index)
 add a bank top database More...
 
void checkAddWaveBank (SynthLabBankSet &slTableSet, CoreProcData &processInfo, uint32_t waveIndex)
 Calls the querying function to check and add a new wavebank (set of wavetables) More...
 
int32_t checkAddWavetable (SynthLabTableSet &slTableSet, StaticTableSource *tableSource, CoreProcData &processInfo)
 Function that queries the datbase for the various tables based on unique table names. More...
 

Protected Attributes

double sampleRate = 0.0
 sample rate
 
double currentTableRate = 0.0
 sample rate
 
double midiPitch = 0.0
 the midi pitch
 
double outputAmplitude = 1.0
 amplitude in dB
 
double panLeftGain = 0.707
 left channel gain
 
double panRightGain = 0.707
 right channel gain
 
double hardSyncRatio = 1.0
 hard sync ratio with modulators applied
 
int32_t currentWaveIndex = -1
 to minimize dictionary (map) lookup iterating
 
int32_t currentTable0 = -1
 to minimize dictionary (map) lookup iterating
 
int32_t currentTable1 = -1
 to minimize dictionary (map) lookup iterating
 
double mixValue0 = 0.0
 
double mixValue1 = 0.0
 
SynthClock oscClock
 timebase
 
IWavetableSourceselectedTableSource [2] = { nullptr, nullptr }
 two tables to morph across
 
Synchronizer hardSyncronizer
 hard synchronizer
 
MorphBankData morphBankData [MODULE_STRINGS]
 morphing bank of wavetables
 
int32_t table0last = -1
 running index of last table_0
 
int32_t table1last = -1
 running index of last table_1
 
double morphLocation = 0.0
 fractional location to morph between table_0 and table_1
 
double lastMorphMod = -10.0
 last morph modulator
 
- Protected Attributes inherited from SynthLab::ModuleCore
uint32_t moduleType = UNDEFINED_MODULE
 type of module, LFO_MODULE, EG_MODULE, etc...
 
const char * moduleName = nullptr
 module name must be set in derived constructor
 
void * moduleHandle = nullptr
 used for dynamically loading cores from DLLs
 
uint32_t moduleIndex = 0
 index of this core
 
int32_t preferredIndex = -1
 preferred index of this DYNAMIC core
 
ModuleCoreData coreData
 core strings (16) and mod knob labels (4)
 
bool standAloneMode = false
 flag for stand-alone mode of operation outside of SynthLab
 
std::unique_ptr< GlideModulatorglideModulator
 built-in glide modulator for oscillators
 

Detailed Description

Morphing Wavetable oscillator.

  • demonstrates morphing between two IWavetableSources
  • demonstrates use of MorphBankData to store a bank of wavetable oscillator waveforms
  • morphs across a range of up to 16 waveforms, each of which is a set of high-resolution wavetables
  • allows hard-sync of wavetables during morph (!!)

Base Class: ModuleCore

  • Overrides the five (5) common functions plus a special getParameters() method to return a shared pointer to the parameters structure.
  • NOTE: These functions have identical names as the SynthModules that own them, however the arguments are different. ModuleCores use the CoreProcData structure for passing arguments into the cores because they are thunk-barrier compliant.
  • This means that the owning SynthModule must prepare this structure and populate it prior to function calls. The large majority of this preparation is done in the SynthModule constructor and is one-time in nature.

GUI Parameters: WTOscParameters

  • GUI parameters are delivered into the core via the thunk-barrier compliant CoreProcData argument that is passed into each function identically
  • processInfo.moduleParameters contains a void* version of the GUI parameter structure pointer
  • the Core function casts the GUI parameter pointer prior to usage

Access to Modulators is done via the thunk-barrier compliant CoreProcData argument

  • processInfo.modulationInputs
  • processInfo.modulationOutputs

Access to audio buffers (I/O/FM) is done via the thunk-barrier compliant CoreProcData argument

  • processInfo.inputBuffers
  • processInfo.outputBuffers
  • processInfo.fmBuffers

Construction: Cores follow the same construction pattern

  • set the Module type and name parameters
  • expose the 16 module strings
  • expose the 4 mod knob label strings
  • intialize any internal variables

Standalone Mode:

  • These objects are designed to be internal members of the outer SynthModule that owns them. They may be used in standalone mode without modification, and you will use the CoreProcData structure to pass information into the functions.

Module Strings, zero-indexed for your GUI Control:

  • PrimalWaves, DigiDoo1, DigiDoo2, DigiDoo3, SawDemon, SquareDuty,S quareComb, SquareRing, SineMorph, Dentist

ModKnob Strings, for fixed GUI controls by index constant

  • MOD_KNOB_A = "A"
  • MOD_KNOB_B = "HSync"
  • MOD_KNOB_C = "MorphStart"
  • MOD_KNOB_D = "MorphMod"

Render:

  • renders into the output buffer using pointers in the CoreProcData argument to the render function
  • renders one block of audio per render cycle
  • renders in mono that is copied to the right channel as dual-mono stereo
Author
Will Pirkle http://www.willpirkle.com
Remarks
This object is included and described in further detail in Designing Software Synthesizer Plugins in C++ 2nd Ed. by Will Pirkle
Version
Revision : 1.0
Date
Date : 2021 / 04 / 26

Constructor & Destructor Documentation

◆ MorphWTCore()

SynthLab::MorphWTCore::MorphWTCore ( )

Construction: Cores follow the same construction pattern.

simple default constructor

  • set the Module type and name parameters
  • expose the 16 module strings
  • expose the 4 mod knob label strings
  • intialize any internal variables

Core Specific:

  • uses MorphBankData structures to hold information about these STATIC structures
Returns
the newly constructed object

◆ ~MorphWTCore()

virtual SynthLab::MorphWTCore::~MorphWTCore ( )
inlinevirtual

Destructor is empty: all resources are smart pointers

Member Function Documentation

◆ addMorphBankData()

void SynthLab::MorphWTCore::addMorphBankData ( std::string  name,
SynthLabBankSet slBankSet,
uint32_t  index 
)
protected

add a bank top database

Adds a set of tables to the morph bank data structures, storing names of the tables.

Core Specific:

  • nothing to do
Parameters
namename of wavetable
slTableSetset of tables tp be added
processInfois the thunk-barrier compliant data structure for passing all needed parameters
indexindex in MorphBankData structure
Returns
true if successful, false otherwise

◆ checkAddWaveBank()

void SynthLab::MorphWTCore::checkAddWaveBank ( SynthLabBankSet slBankSet,
CoreProcData processInfo,
uint32_t  waveIndex 
)
protected

Calls the querying function to check and add a new wavebank (set of wavetables)

Parameters
slTableSetset of tables tp be added
processInfois the thunk-barrier compliant data structure for passing all needed parameters
Returns
true if successful, false otherwise

◆ checkAddWavetable()

int32_t SynthLab::MorphWTCore::checkAddWavetable ( SynthLabTableSet slTableSet,
StaticTableSource tableSource,
CoreProcData processInfo 
)
protected

Function that queries the datbase for the various tables based on unique table names.

  • this is a set-wise version of the same function found on the non-morphing cores
Parameters
slTableSetset of tables tp be added
processInfois the thunk-barrier compliant data structure for passing all needed parameters
Returns
index of table in database if successful, -1 otherwise

◆ doNoteOff()

bool SynthLab::MorphWTCore::doNoteOff ( CoreProcData processInfo)
overridevirtual

Note-off handler for the ModuleCore.

  • parameters are accessed via the processInfo.moduleParameters pointer
  • MIDI note information is accessed via processInfo.noteEvent

Core Specific:

  • nothing to do
Parameters
processInfois the thunk-barrier compliant data structure for passing all needed parameters
Returns
true if successful, false otherwise

Implements SynthLab::ModuleCore.

◆ doNoteOn()

bool SynthLab::MorphWTCore::doNoteOn ( CoreProcData processInfo)
overridevirtual

Note-on handler for the ModuleCore.

  • parameters are accessed via the processInfo.moduleParameters pointer
  • MIDI note information is accessed via processInfo.noteEvent

Core Specific:

  • saves MIDI pitch for modulation calculation in update() function
  • resets table index values to -1 indicating a new note event
Parameters
processInfois the thunk-barrier compliant data structure for passing all needed parameters
Returns
true if successful, false otherwise

Implements SynthLab::ModuleCore.

◆ render()

bool SynthLab::MorphWTCore::render ( CoreProcData processInfo)
overridevirtual

Renders the output of the module.

  • renders to output buffer using pointers in the CoreProcData argument
  • supports FM via the pmBuffer if avaialble; if pmBuffer is NULL then there is no FM Core Specific:
  • call rendering sub-function
  • apply and remove phase offsets for phase modulation (FM)
  • renders one block of audio per render cycle
  • renders in mono that is copied to the right channel as dual-mono stereo
Parameters
processInfothe thunk-barrier compliant data structure for passing all needed parameters
Returns
true if successful, false otherwise

Implements SynthLab::ModuleCore.

◆ renderHardSyncSample()

double SynthLab::MorphWTCore::renderHardSyncSample ( SynthClock clock)

render a hard-sunk sample

Renders one hard-synced sample from the wavetable Core Specific:

  • calls renderSample() for the main and reset oscillators as needed
  • detects new reset signal and restarts synchronizer
Parameters
clockthe current timebase
Returns
true if successful, false otherwise

◆ renderSample()

double SynthLab::MorphWTCore::renderSample ( SynthClock clock)

render a sample

Renders one sample out of the wavetable Core Specific:

Render helper functions

  • note the check to see if we are at the end of the tables (morph = 1)
  • uses constant power morphing; you can try the others too: square law and linear
Parameters
clockthe current timebase
Returns
true if successful, false otherwise

◆ reset()

bool SynthLab::MorphWTCore::reset ( CoreProcData processInfo)
overridevirtual

Resets object to initialized state.

ModuleCore Overrides

  • parameters are accessed via the processInfo.moduleParameters pointer
  • initialize timbase and hard synchronizer
  • check and add wavetable banks to the database
  • a bank is a set of wavetable sources
Parameters
processInfothe thunk-barrier compliant data structure for passing all needed parameters
Returns
true if successful, false otherwise

Implements SynthLab::ModuleCore.

◆ update()

bool SynthLab::MorphWTCore::update ( CoreProcData processInfo)
overridevirtual

Updates the object for the next block of audio processing.

  • parameters are accessed via the processInfo.moduleParameters pointer
  • modulator inputs are accessied via processInfo.modulationInputs
  • mod knob values are accessed via parameters->modKnobValue[] Core Specific:
  • calculates the pitch modulation value from GUI controls, input modulator kBipolarMod, and MIDI pitch bend
  • selects a pair of wavetables based on modulated frequency AND morphing location across bank
  • sets up hard-sync (this oscillator's unique modulation)
  • calculates final gain and pan values
Parameters
processInfothe thunk-barrier compliant data structure for passing all needed parameters
Returns
true if successful, false otherwise

Implements SynthLab::ModuleCore.


The documentation for this class was generated from the following files: