SynthLab SDK
SynthLab::AddOscCore Class Reference

This is the "blank" core template for compiling your own Cores as dynamic modules. More...

#include <addosccore.h>

Inheritance diagram for SynthLab::AddOscCore:
SynthLab::ModuleCore

Public Member Functions

 AddOscCore ()
 Construction: Cores follow the same construction pattern. More...
 
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...
 
- 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 Types

enum  { ChebyT2, ChebyT3, ChebyT4, ChebyT5 }
 

Protected Member Functions

double doChebyWaveshaper (double xn, uint32_t order)
 

Protected Attributes

double sampleRate = 1.0
 
double midiPitch = 0.0
 the midi pitch
 
SynthClock oscClock
 
- 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

This is the "blank" core template for compiling your own Cores as dynamic modules.

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: Depends on the type of Core you are implementing

  • 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.

Render:

  • Oscillators and Filters:
  1. processes all audio samples in block
  2. processes from input buffer to output buffer using pointers in the CoreProcData argument
  • EGs
  1. renders into the modulation output array that is passed into the function via the CoreProcData structure and populates the arrays with index values of:
  2. kEGNormalOutput normal EG output value
  3. kEGBiasedOutput biased EG (sustain level subtracted out)
  • LFOs 1.renders into the modulation output array that is passed into the function via the CoreProcData structure and populates the arrays with index values of:
  1. kLFONormalOutput normal LFO output value
  2. kLFOInvertedOutput 180 degrees out of phase with normal output
  3. kUnipolarFromMax unipolar version of the waveform that sits at +1 when the output amplitude is at 0, and descends from +1 downward as the output amplitude is increases; used for tremolo
  4. kUnipolarFromMin unipolar version of the waveform that sits at 0 when the output amplitude is at 0, and ascends from 0 upward as the output amplitude is increases; the ordinary unipolar version
  • Filters
  1. renders into the output buffer using pointers in the CoreProcData argument to the render function
  2. processes one block of audio input into one block of audio output per render cycle
  3. processes 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

◆ AddOscCore()

SynthLab::AddOscCore::AddOscCore ( )

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

Core Specific:

  • depends on your core type
Returns
the newly constructed object

Member Function Documentation

◆ doNoteOff()

bool SynthLab::AddOscCore::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:

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::AddOscCore::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:

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::AddOscCore::render ( CoreProcData processInfo)
overridevirtual

Renders the output of the module.

  • write modulator output with: processInfo.modulationOutputs->setModValue( )

Core Specific:

  • see class declaration (comments and Doxygen docs) about where to write output values
  • see template below
Parameters
processInfothe thunk-barrier compliant data structure for passing all needed parameters
Returns
true if successful, false otherwise

Implements SynthLab::ModuleCore.

◆ reset()

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

Resets object to initialized state.

  • parameters are accessed via the processInfo.moduleParameters pointer
  • resets and initializes clocks and timers
  • sets initial state variables
Parameters
processInfothe thunk-barrier compliant data structure for passing all needed parameters
Returns
true if successful, false otherwise

Implements SynthLab::ModuleCore.

◆ update()

bool SynthLab::AddOscCore::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[]
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: