SynthLab SDK
SynthLab::SynthModule Class Referenceabstract

Abstract base class that encapsulates functionality of a module; used with the Module-Core paradigm. More...

#include <synthbase.h>

Inheritance diagram for SynthLab::SynthModule:
SynthLab::AudioDelay SynthLab::DCA SynthLab::DXEG SynthLab::EnvelopeGenerator SynthLab::FilterModule SynthLab::FMOperator SynthLab::KSOscillator SynthLab::NoiseOscillator SynthLab::Oscillator SynthLab::Oscillator SynthLab::PCMOscillator SynthLab::SynthFilter SynthLab::SynthLFO SynthLab::SynthModuleNoCores SynthLab::SynthModuleWithCores SynthLab::VAOscillator SynthLab::WaveSequencer SynthLab::WSOscillator SynthLab::WTOscillator

Public Member Functions

 SynthModule (std::shared_ptr< MidiInputData > _midiInputData)
 Constructs a SynthModule. More...
 
virtual ~SynthModule ()
 Removes cores, if any.
 
virtual bool reset (double _sampleRate)=0
 
virtual bool update ()=0
 
virtual bool render (uint32_t samplesToProcess=1)=0
 
virtual bool doNoteOn (MIDINoteEvent &noteEvent)=0
 
virtual bool doNoteOff (MIDINoteEvent &noteEvent)=0
 
virtual bool initialize (const char *_dllDirectory)
 
virtual int32_t getState ()
 
virtual bool shutdown ()
 
virtual bool startGlideModulation (GlideInfo &glideInfo)
 starts the built-in glide modulator More...
 
std::shared_ptr< ModulatorsgetModulationInput ()
 
std::shared_ptr< ModulatorsgetModulationOutput ()
 
std::shared_ptr< AudioBuffergetAudioBuffers ()
 
void setUnisonMode (double _unisonDetuneCents, double _unisonStarPhase)
 
void setFMBuffer (std::shared_ptr< AudioBuffer > pmBuffer)
 
void clearFMBuffer ()
 
virtual bool getModuleStrings (std::vector< std::string > &moduleStrings, std::string ignoreStr="")
 Gets a std::vector of Module Strings. More...
 
virtual bool getModuleStrings (uint32_t coreIndex, std::vector< std::string > &moduleStrings, std::string ignoreStr)
 Gets a std::vector of Module Strings from a particular core. More...
 
virtual bool getAllModuleStrings (std::vector< std::string > &moduleStrings, std::string ignoreStr)
 Gets a std::vector of all Module Strings concatenated from all cores in succession. More...
 
virtual bool getModKnobStrings (std::vector< std::string > &modKnobStrings)
 Gets a std::vector of Mod Knob label strings for the selected core. More...
 
virtual bool getModKnobStrings (uint32_t coreIndex, std::vector< std::string > &modKnobStrings)
 Gets a std::vector of Mod Knob label strings for a given core; if the core cannot be found returs the mod knob labels of the module itself. More...
 
virtual bool getModuleCoreStrings (std::vector< std::string > &moduleCoreStrings)
 Gets a std::vector of the names of the four cores in this module. More...
 
virtual bool addModuleCore (std::shared_ptr< ModuleCore > core)
 adds a module core to the module's set of four More...
 
virtual uint32_t getSelectedCoreIndex ()
 get the index of the selected core More...
 
virtual bool selectModuleCore (uint32_t index)
 Select a core. More...
 
virtual bool selectDefaultModuleCore ()
 Select the default core, which is always the first in the list. More...
 
virtual void packCores ()
 packs the cores into non-null ordering
 
virtual bool clearModuleCores ()
 Clears out the module core pointer list. More...
 
virtual void setStandAloneMode (bool b)
 Sets the stand-alone mode flag on all cores. More...
 

Protected Attributes

std::shared_ptr< ModulatorsmodulationInput = std::make_shared<Modulators>()
 
std::shared_ptr< ModulatorsmodulationOutput = std::make_shared<Modulators>()
 
std::shared_ptr< MidiInputDatamidiInputData = nullptr
 
std::shared_ptr< AudioBufferaudioBuffers = nullptr
 
std::unique_ptr< GlideModulatorglideModulator
 
std::shared_ptr< AudioBufferfmBuffer = nullptr
 
std::shared_ptr< ModuleCoremoduleCores [NUM_MODULE_CORES]
 
std::shared_ptr< ModuleCoreselectedCore = nullptr
 
ModuleCoreData moduleData
 modulestrings (16) and mod knob labels (4) More...
 
double unisonDetuneCents = 0.0
 
double unisonStartPhase = 0.0
 
bool standAloneMode = false
 
CoreProcData coreProcessData
 
std::string dllDirectory
 

Detailed Description

Abstract base class that encapsulates functionality of a module; used with the Module-Core paradigm.

  • almost all Modules are generalized, and own up to four (4) module core objects that actually implement the specialized behavior
  • objects derived from SynthModule ARE NOT OBLIGED to follow the module-core paradigm, nor are they required to hold, initialize, and maintain the four cores; instead they may implemement the module functionality directly
  • the WSOScillator is an example of a SynthModule that does not use any ModuleCore objects
  • the five main abstract functions will all map to the same named functions on the ModuleCore objects, if the SynthModule chooses to use the Module-Core paradigm
  • for most objects, this is a very simple implementation that is mainly responsible for initializing and maintainig its set of four ModuleCores and these are very thin objects
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

◆ SynthModule()

SynthLab::SynthModule::SynthModule ( std::shared_ptr< MidiInputData _midiInputData)

Constructs a SynthModule.

  • creats the MIDI input data if not present, for stand-alone operation
Parameters
_midiInputDataMIDI input data interface; if nullptr, then object synthesizes its own

Member Function Documentation

◆ addModuleCore()

bool SynthLab::SynthModule::addModuleCore ( std::shared_ptr< ModuleCore core)
virtual

adds a module core to the module's set of four

  • for adding cores to a module, either statically or dynamically
Returns
true if sucessful

◆ clearModuleCores()

bool SynthLab::SynthModule::clearModuleCores ( )
virtual

Clears out the module core pointer list.

  • does not delete or destroy the core
Returns
true if sucessful

◆ getAllModuleStrings()

bool SynthLab::SynthModule::getAllModuleStrings ( std::vector< std::string > &  moduleStrings,
std::string  ignoreStr 
)
virtual

Gets a std::vector of all Module Strings concatenated from all cores in succession.

  • used to generate the waveform GUI lists for the WaveSequencer project
  • merges all core module strings together
Parameters
moduleStringsvector pf strings retured via pass-by-reference
ignoreStra string to ignore when filling the vector (e.g. "empty string")
Returns
true if strings were found, false otherwise

◆ getAudioBuffers()

std::shared_ptr<AudioBuffer> SynthLab::SynthModule::getAudioBuffers ( )
inline

access to audio buffers (I/O)

◆ getModKnobStrings() [1/2]

bool SynthLab::SynthModule::getModKnobStrings ( std::vector< std::string > &  modKnobStrings)
virtual

Gets a std::vector of Mod Knob label strings for the selected core.

  • Each Module or Core has up to 4 Mod Knob label strings strings to expose to the user
  • Used in impementations that have dynamically loadable string labels for mod knobs
Parameters
modKnobStringsvector pf strings retured via pass-by-reference
Returns
true if strings were found, false otherwise

◆ getModKnobStrings() [2/2]

bool SynthLab::SynthModule::getModKnobStrings ( uint32_t  coreIndex,
std::vector< std::string > &  modKnobStrings 
)
virtual

Gets a std::vector of Mod Knob label strings for a given core; if the core cannot be found returs the mod knob labels of the module itself.

  • Each Module or Core has up to 4 Mod Knob label strings strings to expose to the user
  • Used in impementations that have dynamically loadable string labels for mod knobs
Parameters
modKnobStringsvector pf strings retured via pass-by-reference
Returns
true if strings were found, false otherwise

◆ getModulationInput()

std::shared_ptr<Modulators> SynthLab::SynthModule::getModulationInput ( )
inline

access to modulators

◆ getModuleCoreStrings()

bool SynthLab::SynthModule::getModuleCoreStrings ( std::vector< std::string > &  moduleCoreStrings)
virtual

Gets a std::vector of the names of the four cores in this module.

  • Used in impementations that have dynamically loadable GUI controls for listing the cores
Parameters
moduleCoreStringsvector pf strings retured via pass-by-reference
Returns
true if strings were found, false otherwise

◆ getModuleStrings() [1/2]

bool SynthLab::SynthModule::getModuleStrings ( std::vector< std::string > &  moduleStrings,
std::string  ignoreStr = "" 
)
virtual

Gets a std::vector of Module Strings.

functions for dealing with the module cores; SynthLab only; these may be ignored in many stand-alone implementations

  • Each Module has up to 16 module strings to expose to the user
  • Used in impementations that have dynamically loadable string controls on the GUI
Parameters
moduleStringsvector pf strings retured via pass-by-reference
ignoreStra string to ignore when filling the vector (e.g. "empty string")
Returns
true if strings were found, false otherwise

◆ getModuleStrings() [2/2]

bool SynthLab::SynthModule::getModuleStrings ( uint32_t  coreIndex,
std::vector< std::string > &  moduleStrings,
std::string  ignoreStr 
)
virtual

Gets a std::vector of Module Strings from a particular core.

  • Each Module or Core has up to 16 module strings to expose to the user
  • Used in impementations that have dynamically loadable string controls on the GUI
Parameters
coreIndexindex of core to query for its strings
moduleStringsvector pf strings retured via pass-by-reference
ignoreStra string to ignore when filling the vector (e.g. "empty string")
Returns
true if strings were found, false otherwise

◆ getSelectedCoreIndex()

uint32_t SynthLab::SynthModule::getSelectedCoreIndex ( )
virtual

get the index of the selected core

Returns
index of core

◆ getState()

virtual int32_t SynthLab::SynthModule::getState ( )
inlinevirtual

EG only

Reimplemented in SynthLab::DXEG, and SynthLab::EnvelopeGenerator.

◆ initialize()

virtual bool SynthLab::SynthModule::initialize ( const char *  _dllDirectory)
inlinevirtual

for knowing the path to the DLL itself for loading PCM samples or other resources

◆ reset()

◆ selectDefaultModuleCore()

bool SynthLab::SynthModule::selectDefaultModuleCore ( )
virtual

Select the default core, which is always the first in the list.

Returns
true if found a core to select

◆ selectModuleCore()

bool SynthLab::SynthModule::selectModuleCore ( uint32_t  index)
virtual

Select a core.

Parameters
indexindex of core to select
Returns
true if found a core to select

◆ setFMBuffer()

void SynthLab::SynthModule::setFMBuffer ( std::shared_ptr< AudioBuffer pmBuffer)
inline

for DX synths only

◆ setStandAloneMode()

void SynthLab::SynthModule::setStandAloneMode ( bool  alone)
virtual

Sets the stand-alone mode flag on all cores.

Parameters
alonetrue if stand-alone mode, false otherwise

◆ setUnisonMode()

void SynthLab::SynthModule::setUnisonMode ( double  _unisonDetuneCents,
double  _unisonStarPhase 
)
inline

— for unison mode only

◆ startGlideModulation()

bool SynthLab::SynthModule::startGlideModulation ( GlideInfo glideInfo)
virtual

starts the built-in glide modulator

for starting glide modulation on underlying objects

Returns
true if sucessful

Reimplemented in SynthLab::WSOscillator.

Member Data Documentation

◆ audioBuffers

std::shared_ptr<AudioBuffer> SynthLab::SynthModule::audioBuffers = nullptr
protected

audio buffers for pitched oscillator and filters and DCA

◆ coreProcessData

CoreProcData SynthLab::SynthModule::coreProcessData
protected

helpers for dealing with Cores

◆ fmBuffer

std::shared_ptr<AudioBuffer> SynthLab::SynthModule::fmBuffer = nullptr
protected

audio buffers for pitched oscillator and filters and DCA

◆ glideModulator

std::unique_ptr<GlideModulator> SynthLab::SynthModule::glideModulator
protected

glide modulator

◆ midiInputData

std::shared_ptr<MidiInputData> SynthLab::SynthModule::midiInputData = nullptr
protected

MIDI Data Interface

◆ modulationInput

std::shared_ptr<Modulators> SynthLab::SynthModule::modulationInput = std::make_shared<Modulators>()
protected

modulation input bus

◆ modulationOutput

std::shared_ptr<Modulators> SynthLab::SynthModule::modulationOutput = std::make_shared<Modulators>()
protected

modulation outputs bus

◆ moduleCores

std::shared_ptr<ModuleCore> SynthLab::SynthModule::moduleCores[NUM_MODULE_CORES]
protected

for core-specific stuff

◆ moduleData

ModuleCoreData SynthLab::SynthModule::moduleData
protected

modulestrings (16) and mod knob labels (4)

for modules without cores


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