Gamma  0.9.5
Generic Synthesis Library
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Accum< Stap, Ts > Class Template Reference

Fixed-point phase accumulator. More...

#include <Oscillator.h>

Inheritance diagram for Accum< Stap, Ts >:
LFO< Stap, Ts > Osc< Tv, Sipol, Stap, Ts > Sweep< Stap, Ts > TableSine< Stap, Ts >

List of all members.

Public Member Functions

 Accum (float frq=0, float phs=0)
void freq (float v)
 Set frequency.
void phase (float v)
 Set phase from [0, 1) of one period.
void phaseMax ()
 Set phase to maximum value.
void phaseAdd (float v)
 Add value to phase [0, 1)
void period (float v)
 Set period length.
void reset ()
 Reset phase accumulator.
bool done () const
 Returns true if tap is done.
float freq () const
 Get frequency.
uint32_t freqI () const
 Get fixed-point frequency.
float freqUnit () const
 Get frequency in [0, 1)
float phase () const
 Get phase in [0, 1)
uint32_t phaseI () const
 Get fixed-point phase.
uint32_t cycle ()
 Returns 0x80000000 on phase wrap, 0 otherwise.
uint32_t operator() ()
 Alias of cycle()
uint32_t nextPhase ()
 Increment phase and return pre-incremented phase.
uint32_t nextPhasePost ()
 Increment phase and return post-incremented phase.
uint32_t cycles ()
 Get 1 to 0 transitions of all accumulator bits.

Detailed Description

template<class Stap = tap::Wrap, class Ts = Synced>
class gam::Accum< Stap, Ts >

Fixed-point phase accumulator.

This is a linear phase accumulator that uses integer (fixed-point) arithmetic. The advantage of using fixed-point versus floating-point is that the phase is wrapped automatically when the integer overflows. As long as we used unsigned integers, this wrapping behavior is well-defined- all results of addition are taken modulo the maximum size of the integer.

Template Parameters:
StapRead tap strategy (tap::Clip, tap::Fold, tap::Rep, or tap::Wrap)
TsSynced type

Constructor & Destructor Documentation

Accum ( float  frq = 0,
float  phs = 0 
)
Parameters:
[in]frqFrequency
[in]phsPhase in [0, 1)

Member Function Documentation

uint32_t cycle ( )

Returns 0x80000000 on phase wrap, 0 otherwise.

The return value can be used as a bool. It's an integer because it saves a conditional check converting to a bool.


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