SynthLab SDK
SynthLab::RampModulator Class Reference

This is a tiny modulator object that produces an output that ramps up or down linearly between two values over a specified time in milliseconds. More...

#include <synthbase.h>

Public Member Functions

bool startModulator (double startValue, double endValue, double modTime_mSec, double sampleRate)
 Setup the timers and start the ramp modulator running. The modulator produces an output on the range of [startValue, endValue] over a specified duration in mSec. More...
 
bool setModTime (double modTime_mSec, double sampleRate)
 Change the modulation time; this is optional. More...
 
double getNextModulationValue (uint32_t advanceClock=1)
 Get the current output of the modulator; this is called repeatedly over the ramp modulation time. More...
 
void advanceClock (uint32_t ticks=1)
 Nudge the clock on the modulator; this is used for block processing where the modulator output outputs one value per audio block. This is called repeatedly to get the modulator clock "caught up" to where it needs to be for the next block of audio to process. More...
 
bool isActive ()
 checks to see if the modulator is running, or completed
 

Protected Attributes

bool timerActive = false
 state of modulator, running (true) or expired (false)
 
double timerInc = 0.0
 timer incrementer value
 
double countUpTimer = 0.0
 current timer value; this always counts UP regardless of the polarity of the modulation (up or down)
 
double modRange = 1.0
 range of modulation output
 
double modStart = 0.0
 ramp mod start value
 
double modEnd = 1.0
 ramp mod end value
 

Detailed Description

This is a tiny modulator object that produces an output that ramps up or down linearly between two values over a specified time in milliseconds.

  • used for LFO fade-in time
  • can be used to fade-in or fade-out any kind of value, from audio samples to modulation values to modulation times
  • the timer always counts UP regardless of the direction of the ramp
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

Member Function Documentation

◆ advanceClock()

void SynthLab::RampModulator::advanceClock ( uint32_t  ticks = 1)

Nudge the clock on the modulator; this is used for block processing where the modulator output outputs one value per audio block. This is called repeatedly to get the modulator clock "caught up" to where it needs to be for the next block of audio to process.

manually advance the clock

Parameters
ticksnumber of tics to advance the clock for the next value

◆ getNextModulationValue()

double SynthLab::RampModulator::getNextModulationValue ( uint32_t  advanceClock = 1)

Get the current output of the modulator; this is called repeatedly over the ramp modulation time.

get the next modulation value - this is the main output function; auto advances the clock

  • check the modulator to see when it is done, then stop calling this function
Parameters
advanceClocknumber of tics to advance the clock for the next value

◆ setModTime()

bool SynthLab::RampModulator::setModTime ( double  modTime_mSec,
double  sampleRate 
)

Change the modulation time; this is optional.

the mod time may be changed while running, normally not used but permitted

Parameters
modTime_mSectime for the ramp-up or ramp-down across the values
sampleRatefs for calculating timer increment

◆ startModulator()

bool SynthLab::RampModulator::startModulator ( double  startValue,
double  endValue,
double  modTime_mSec,
double  sampleRate 
)

Setup the timers and start the ramp modulator running. The modulator produces an output on the range of [startValue, endValue] over a specified duration in mSec.

the main function that sets up and start the modulator

Parameters
startValuestarting modulator value
endValueending modulator value
modTime_mSectime for the ramp-up or ramp-down across the values
sampleRatefs for calculating timer increment

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