|
SynthLab SDK
|
Compact modulo counter with wrapping used as the timebase for all oscillators. More...
#include <synthbase.h>
Public Types | |
| enum | { MOD_COUNTER, PHASE_INC, PHASE_OFFSET, FREQUENCY_HZ, NUM_VARS } |
Public Member Functions | |
| SynthClock & | operator= (const SynthClock ¶ms) |
| Overloaded = operator for setting two clocks equal to each other by copying member values from a source. More... | |
| void | reset (double startValue=0.0) |
| Reset to initial state. More... | |
| void | initWithClock (SynthClock &clock) |
| Initialize this clock with another SynthClock. More... | |
| void | advanceClock (uint32_t renderInterval=1) |
| Advance the clock some number of tics by adding the phaseInc value. More... | |
| bool | advanceWrapClock (uint32_t renderInterval=1) |
| Advance the clock some number of tics by adding the phaseInc value and then check to see if modulo counter requires wrapping; wrap if needed. More... | |
| bool | wrapClock () |
| Wrap the modulo counter; note that this will wrap the modulo counter as many times as needed to get it back on the range of [0.0, +1.0] to support phase modulation values greater or less then +/- 1.0 which happens when the index of modulation is greater than 1.0. | |
| void | setFrequency (double _frequency_Hz, double _sampleRate) |
| Set the clock frequency, which calculates the current phase increment value. More... | |
| double | getFrequency () |
| void | addPhaseOffset (double _phaseOffset, bool wrap=true) |
| For phase modulation, this adds a phase offset and then optionally checks/wraps the counter as needed. More... | |
| void | removePhaseOffset () |
| For phase modulation, this removes a phase offset, notice that the function does not attempt to wrap the counter. More... | |
| void | addFrequencyOffset (double _freqOffset) |
| For frequency modulation, this adds a frequency offset, and recalculates the phase increment value. More... | |
| void | removeFrequencyOffset () |
| For frequency modulation, this removes a frequency offset and recalculates the phase inc. | |
| void | saveState () |
| Freeze and save the current state of the clock; for PM and FM. More... | |
| void | restoreState () |
| Restore the clock to its last saved state; for PM and FM. | |
Public Attributes | |
| double | mcounter = 0.0 |
| modulo counter [0.0, +1.0], this is the value you use | |
| double | phaseInc = 0.0 |
| phase inc = fo/fs | |
| double | phaseOffset = 0.0 |
| PM. | |
| double | freqOffset = 0.0 |
| FM. | |
| double | frequency_Hz = 0.0 |
| clock frequency | |
| double | sampleRate = 0.0 |
| double | state [NUM_VARS] = { 0.0, 0.0, 0.0, 0.0 } |
| for state save | |
Compact modulo counter with wrapping used as the timebase for all oscillators.
| void SynthLab::SynthClock::addFrequencyOffset | ( | double | _freqOffset | ) |
For frequency modulation, this adds a frequency offset, and recalculates the phase increment value.
Frequency Modulation support
| _freqOffset | the amound of frequency shift in Hz |
| void SynthLab::SynthClock::addPhaseOffset | ( | double | _phaseOffset, |
| bool | wrap = true |
||
| ) |
For phase modulation, this adds a phase offset and then optionally checks/wraps the counter as needed.
Phase Modulation support
| _phaseOffset | the amound of phase shift, normally on the range [-1.0, +1.0] but may be larger |
| wrap | set true to automatically check and wrapt the counter as a result of phase offset |
| void SynthLab::SynthClock::advanceClock | ( | uint32_t | renderInterval = 1 | ) |
Advance the clock some number of tics by adding the phaseInc value.
advancing and wrapping the clock mcounter
| renderInterval | number of tics to advance the clock |
| bool SynthLab::SynthClock::advanceWrapClock | ( | uint32_t | renderInterval = 1 | ) |
Advance the clock some number of tics by adding the phaseInc value and then check to see if modulo counter requires wrapping; wrap if needed.
| renderInterval | number of tics to advance the clock |
| void SynthLab::SynthClock::initWithClock | ( | SynthClock & | clock | ) |
Initialize this clock with another SynthClock.
| clock | source SynthClock to copy |
| SynthClock & SynthLab::SynthClock::operator= | ( | const SynthClock & | params | ) |
Overloaded = operator for setting two clocks equal to each other by copying member values from a source.
| params | source SynthClock to copy |
| void SynthLab::SynthClock::removePhaseOffset | ( | ) |
For phase modulation, this removes a phase offset, notice that the function does not attempt to wrap the counter.
| void SynthLab::SynthClock::reset | ( | double | startValue = 0.0 | ) |
Reset to initial state.
Initialization and reset
| startValue | phase offset at start time; this value is on the range [0.0, +1.0] corresponding to 0 to 360 degrees of phase shift |
| void SynthLab::SynthClock::saveState | ( | ) |
Freeze and save the current state of the clock; for PM and FM.
For both PM and FM support
| void SynthLab::SynthClock::setFrequency | ( | double | _frequency_Hz, |
| double | _sampleRate | ||
| ) |
Set the clock frequency, which calculates the current phase increment value.
get/set the clock frequency; which affects the phaseInc
| _frequency_Hz | new clock frequency, OK if this value is negative, clock will run backwards |
| _sampleRate | fs for calculating the phase inc value |