SynthLab SDK
SynthLab::WaveSequencer Class Reference

WaveSequencer module. More...

#include <sequencer.h>

Inheritance diagram for SynthLab::WaveSequencer:
SynthLab::SynthModule

Public Member Functions

 WaveSequencer (std::shared_ptr< MidiInputData > _midiInputData, std::shared_ptr< WaveSequencerParameters > _parameters, uint32_t blockSize=64)
 Constructs Wave Sequencer Object. More...
 
virtual ~WaveSequencer ()
 
virtual bool reset (double _sampleRate) override
 Resets object to initialized state. More...
 
virtual bool update () override
 Updates the selected core; sets GLOBAL engine variable unisonDetuneCents that may have changed since last operation. More...
 
virtual bool render (uint32_t samplesToProcess=1) override
 Crank through one iteration of the sequencer over one block of data. More...
 
virtual bool doNoteOn (MIDINoteEvent &noteEvent) override
 Note on handler that must: More...
 
virtual bool doNoteOff (MIDINoteEvent &noteEvent) override
 Note off handler; nothing to do here. More...
 
void clearStatusArray ()
 clear out LED (flashing light) status array More...
 
uint32_t setCurrentTimingXFadeSamples ()
 Set the current cross fade time in samples.
 
void setXFadeHoldParams (uint32_t xfadeInTimeSamples)
 Set the current hold time in samples.
 
void updateLaneLoopPoints ()
 Lane loop points may have changed; this updates the start/end points.
 
- Public Member Functions inherited from SynthLab::SynthModule
 SynthModule (std::shared_ptr< MidiInputData > _midiInputData)
 Constructs a SynthModule. More...
 
virtual ~SynthModule ()
 Removes cores, if any.
 
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< WaveSequencerParametersparameters = nullptr
 
uint32_t sampleCounter = 0
 for LED timing
 
Lane timingLane
 timing lane
 
Lane waveLane
 waveform lane
 
Lane pitchLane
 pitch lane
 
Lane stepSeqLane
 step sequemcer lane
 
XHoldFader xHoldFader
 for crossfading waveforms and values
 
bool initialStep = false
 
NoiseGenerator noiseGen
 for probability
 
double sampleRate = 0.0
 sample rate
 
double samplesPerMSec = 0.0
 for step counting
 
- Protected Attributes inherited from SynthLab::SynthModule
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

WaveSequencer module.

  • is really a big modulation generation system
  • timing lane locks all lanes to its current step
  • each non-timing lane generates a modulation value of some kind
  • writes information int the module's Modulation Output array, just like all other modulators

Base Class: SynthModule

  • Overrides the five (5) common functions plus a special getParameters() method to return a shared pointer to the parameters structure.

Databases: None

GUI Parameters: WaveSequencerParameters

  • getParameters() function allows direct access to std::shared_ptr<WaveSequencerParameters>

std::shared_ptr<WaveSequencerParameters> getParameters()

  • call the getParameters() function
  • set the parameters in the WaveSequencerParameters structure with new values, typically from a GUI To apply these new parameters either:
  • (a) call the module's update() function OR
  • (b) call the render() function which in turn calls the update() method.

Ordinarily, this operation happens just prior to calling the render() function so that is the preferred method of operation to avoid multiple calls to the update() function, which is usually the most CPU intensive function of the SynthModule.

Access to Modulators

  • std::shared_ptr<Modulators> getModulationInput()
  • std::shared_ptr<Modulators> getModulationOutput()

Access to audio buffers (I/O)

Reads:

  • Modulation Input Values (modulators)

Writes:

  • Modulation Output Values (modulators)

Construction:

(1) For use within a synth project, the constructor is specialized to use shared recources for:

The owning object (SynthVoice for the SynthLab projects) must pass these valid pointers to the object at construction time. Typically the engine or voice will be the primary synthesizers of these resources. See the 2nd Edition Synth Book for more information.

(2) Standalone:

To use in standalone mode, call the constructor with the shared resoure pointers as null:

WaveSequencer(nullptr, nullptr, 64);

In standalone mode, the object creates and maintains these resources:

  • MidiInputData: this has no read access so you cannot access its data. Ordinarily, you pass this shared pointer into the object so that it has access to the current MIDI input data. The object does not write data into this resource, so it is functionally non-opeational.
  • WaveSequencerParameters: in standalone mode only, these are synthesized locally on the object, and then the owning object may obtain a shared pointer to them to read/write the parameters directly.

Render: renders modulation values into the Modulators output array:

  • kWSWaveMix_A
  • kWSWaveMix_B
  • kWSWaveIndex_A
  • kWSWaveIndex_B
  • kWSWaveAmpMod_A
  • kWSWaveAmpMod_B
  • kWSPitchMod_A
  • kWSPitchMod_B
  • kWStepSeqMod
  • kWSWaveStepNumber_A
  • kWSWaveStepNumber_B
  • NOTE: this structure returns information for LED meters or flashing lights on GUI
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

◆ WaveSequencer()

SynthLab::WaveSequencer::WaveSequencer ( std::shared_ptr< MidiInputData _midiInputData,
std::shared_ptr< WaveSequencerParameters _parameters,
uint32_t  blockSize = 64 
)

Constructs Wave Sequencer Object.

One and only specialized constructor; pointers may be null for stanalone

  • See class declaration for information on standalone operation
  • initializes the lanes and setsup for first run
Parameters
_midiInputDatashared MIDI input resource; may be nullptr
_parametersshared GUI and operational parameters; may be nullptr
blockSizethe synth block process size in frames (stereo)
Returns
the newly constructed object

◆ ~WaveSequencer()

virtual SynthLab::WaveSequencer::~WaveSequencer ( )
inlinevirtual

Destructor is empty: all resources are smart pointers

Member Function Documentation

◆ clearStatusArray()

void SynthLab::WaveSequencer::clearStatusArray ( )

clear out LED (flashing light) status array

Specialized functions

◆ doNoteOff()

bool SynthLab::WaveSequencer::doNoteOff ( MIDINoteEvent noteEvent)
overridevirtual

Note off handler; nothing to do here.

Returns
true if successful, false otherwise

Implements SynthLab::SynthModule.

◆ doNoteOn()

bool SynthLab::WaveSequencer::doNoteOn ( MIDINoteEvent noteEvent)
overridevirtual

Note on handler that must:

  • reset jump tables for each lane
  • clear modulation output slots
  • setup crossfade/holding times
  • initialize current/next steps on lanes
  • initiliaze probabilities for next steps
  • clear LED meter array
Returns
true if successful, false otherwise

Implements SynthLab::SynthModule.

◆ render()

bool SynthLab::WaveSequencer::render ( uint32_t  samplesToProcess = 1)
overridevirtual

Crank through one iteration of the sequencer over one block of data.

  • manages crossfading and holding of step values
  • populates LED status arrays for monitoring the current step in the sequence
Parameters
samplesToProcessnumber of samples in block
Returns
true if successful, false otherwise

Implements SynthLab::SynthModule.

◆ reset()

bool SynthLab::WaveSequencer::reset ( double  _sampleRate)
overridevirtual

Resets object to initialized state.

SynthModule Overrides

  • call once during initialization
  • call any time sample rate changes (after init)
  • resets step index values
Parameters
_sampleRatethe current sample rate in Hz
Returns
true if successful, false otherwise

Implements SynthLab::SynthModule.

◆ update()

bool SynthLab::WaveSequencer::update ( )
overridevirtual

Updates the selected core; sets GLOBAL engine variable unisonDetuneCents that may have changed since last operation.

Returns
true if successful, false otherwise

enum { WAVE_LANE, PITCH_LANE, STEP_SEQ_LANE, NUM_MOD_LANES };

Implements SynthLab::SynthModule.

Member Data Documentation

◆ parameters

std::shared_ptr<WaveSequencerParameters> SynthLab::WaveSequencer::parameters = nullptr
protected

for standalone operation


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