SynthLab SDK
SynthLab::DrumWTCore Class Reference

Wavetables that implement electronic drum samples; these samples were extracted from WAV files and converted into wavetables using RackAFX-TableMaker. More...

#include <drumwtcore.h>

Inheritance diagram for SynthLab::DrumWTCore:
SynthLab::ModuleCore

Public Member Functions

 DrumWTCore ()
 Construction: Cores follow the same construction pattern. More...
 
virtual ~DrumWTCore ()
 
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 Member Functions

double renderSample (SynthClock &clock, bool forceLoop)
 Renders one sample out of the wavetable Core Specific: More...
 

Protected Attributes

double sampleRate = 0.0
 sample rate
 
double outputAmplitude = 1.0
 amplitude in dB
 
double panLeftGain = 0.707
 left channel gain
 
double panRightGain = 0.707
 right channel gain
 
bool oneShotDone = false
 one-shot flag
 
int32_t currentWaveIndex = -1
 to minimize dictionary (map) lookup iterating
 
SynthClock oscClock
 timebase
 
IWavetableSourceselectedTableSource = nullptr
 selected based on oscillator pitch
 
DrumWTSource drumTables [MODULE_STRINGS]
 
- 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

Wavetables that implement electronic drum samples; these samples were extracted from WAV files and converted into wavetables using RackAFX-TableMaker.

This is one of the simplest wavetable oscillator cores because the samples are pitchless and there is no pitch modulation applied. Pitch modulation addition is an excellent homework chore.

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:

  • Kick_1, Kick_2, Kick_3, Snare_1, Snare_2, Snare_3, Closed_HH, Open_HH, Tom_1, Tom_2, Tom_3, Tom_4, Tom_5, Crash_1, Crash_2, Crash_3

ModKnob Strings, for fixed GUI controls by index constant

  • MOD_KNOB_A = "A"
  • MOD_KNOB_B = "B"
  • MOD_KNOB_C = "C"
  • MOD_KNOB_D = "D"

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

◆ DrumWTCore()

SynthLab::DrumWTCore::DrumWTCore ( )

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
  • in addition, this core adds its tables directly to setup the database

Core Specific:

  • tables are defined in wavetables/drumtables.h file
  • uses DrumWTSource to store pointers to the tables
  • gets table pointers from database
  • uses static
Returns
the newly constructed object

◆ ~DrumWTCore()

virtual SynthLab::DrumWTCore::~DrumWTCore ( )
inlinevirtual

Destructor is empty: all resources are smart pointers

Member Function Documentation

◆ doNoteOff()

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

  • resets the clock
  • sets one-shot flag
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::DrumWTCore::render ( CoreProcData processInfo)
overridevirtual

Renders the output of the module.

  • renders to output buffer using pointers in the CoreProcData argument
  • calls rendering sub-function
  • the simplest render function of any oscillator
Parameters
processInfothe thunk-barrier compliant data structure for passing all needed parameters
Returns
true if successful, false otherwise

Implements SynthLab::ModuleCore.

◆ renderSample()

double SynthLab::DrumWTCore::renderSample ( SynthClock clock,
bool  forceLoop 
)
protected

Renders one sample out of the wavetable Core Specific:

helper to render each sample from wavetable

  • reads drum table in one-shot fashion
Parameters
clockthe current timebase
Returns
true if successful, false otherwise

◆ reset()

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

Resets object to initialized state.

ModuleCore Overrides

  • parameters are accessed via the processInfo.moduleParameters pointer
  • wavetable database is accessed via processInfo.wavetableDatabase
  • initialize timbase
  • check table sources and add if needed
Parameters
processInfothe thunk-barrier compliant data structure for passing all needed parameters
Returns
true if successful, false otherwise

Implements SynthLab::ModuleCore.

◆ update()

bool SynthLab::DrumWTCore::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:
  • there is NO pitch modulation as these are pitchless drum samples
  • to add pitch modulation, see the ClassicWTCore object
  • 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: