20 #include "mozzi_fixmath.h" 21 #include <util/atomic.h> 23 #define PHASOR_MAX_VALUE_UL 4294967295UL 32 template <
unsigned int UPDATE_RATE>
36 unsigned long current_value;
37 volatile unsigned long step_size;
53 ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
55 current_value += step_size;
64 void set(
unsigned long value)
78 step_size = ((((
unsigned long)((PHASOR_MAX_VALUE_UL>>8)+1))/(UPDATE_RATE))*frequency)<<8;
91 step_size = (
unsigned long)(((
float)PHASOR_MAX_VALUE_UL/UPDATE_RATE)*frequency);
108 return ((((
unsigned long)((PHASOR_MAX_VALUE_UL>>8)+1))/(UPDATE_RATE))*frequency)<<8;
118 ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
120 step_size = stepsize;
unsigned long phaseIncFromFreq(int frequency)
phaseIncFromFreq() and setPhaseInc() are for saving processor time when sliding between frequencies...
void setFreq(int frequency)
Set the Phasor frequency with an unsigned int.
void setFreq(float frequency)
Set the Phasor frequency with a float.
void setPhaseInc(unsigned long stepsize)
Set a specific phase increment.
unsigned long next()
Increments one step along the phase.
Phasor repeatedly generates a high resolution ramp at a variable frequency.