SynthLab SDK
SynthLab::Synchronizer Class Reference

This is a very specialized object that performs the hard-sync operation using two SynthClocks. More...

#include <synthbase.h>

Public Member Functions

bool reset (double _sampleRate, double startPhase, int32_t xfadeSamples=16)
 Specialized reset function that: More...
 
bool setHardSyncFrequency (double hardSyncFrequency)
 Sets the new reset oscillator frequency in Hz. More...
 
SynthClockgetHardSyncClock ()
 
SynthClockgetCrossFadeClock ()
 
void startHardSync (SynthClock oscClock)
 Starts the hard sync operation as a result of being reset, using the main oscillator's SynthClock to get the number of sub-samples to offset the clock with (see synth book). The crossfader object is then started. More...
 
double doHardSyncXFade (double inA, double inB)
 Perform the crossfade on the two oscillator signals to smear over the discontinuity. More...
 
bool isProcessing ()
 
void addPhaseOffset (double offset)
 Add a phase offset to the reset clock; for supporting phase modulation. More...
 
void removePhaseOffset ()
 Remove existing a phase offset to the reset clock; for supporting phase modulation.
 

Protected Attributes

SynthClock hardSyncClock
 clock for reset oscillator
 
SynthClock crossFadeClock
 crossfading timer
 
XFader hardSyncFader
 crossfader for smearing discontinuity
 
double hardSyncFrequency = 440.0
 reset oscillator rate
 
double sampleRate = 44100.0
 fs
 

Detailed Description

This is a very specialized object that performs the hard-sync operation using two SynthClocks.

  • designed for use with an oscillator that is using a SynthClock for the timebase and running at a rate that is HIGHER than the MIDI pitch, called the "main oscillator" in the synth book
  • contains two SynthClocks: one is used as the "reset oscillator" in the synth book
  • the other is used as a timer for smearing over the discontinuity
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

◆ addPhaseOffset()

void SynthLab::Synchronizer::addPhaseOffset ( double  offset)

Add a phase offset to the reset clock; for supporting phase modulation.

for hard syncing with phase modulation

Parameters
offsetphase offset value

◆ doHardSyncXFade()

double SynthLab::Synchronizer::doHardSyncXFade ( double  inA,
double  inB 
)

Perform the crossfade on the two oscillator signals to smear over the discontinuity.

Parameters
inAinput A for crossfade - will be the output of the currently running oscillator
inBinput B for crossfade - will be the output of a shadow oscillator that has been reset

◆ reset()

bool SynthLab::Synchronizer::reset ( double  _sampleRate,
double  startPhase,
int32_t  xfadeSamples = 16 
)

Specialized reset function that:

initialization

  • resets the reset-oscillator
  • resets the crossfader
  • sets the crossfade time in samples - usually just a few (4-10) samples during smear-over
Parameters
_sampleRatefs
startPhasethe starting phase of the reset oscillator; used when the main oscillator is phase shifted at the note-on time
xfadeSamplescrossfade time for discontinuity

◆ setHardSyncFrequency()

bool SynthLab::Synchronizer::setHardSyncFrequency ( double  hardSyncFrequency)

Sets the new reset oscillator frequency in Hz.

hard sync functions

Parameters
hardSyncFrequencyfrequency in Hz of the reset oscillator

◆ startHardSync()

void SynthLab::Synchronizer::startHardSync ( SynthClock  oscClock)

Starts the hard sync operation as a result of being reset, using the main oscillator's SynthClock to get the number of sub-samples to offset the clock with (see synth book). The crossfader object is then started.

Parameters
oscClockmain oscillator's SynthClock

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