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

Lookup table sine oscillator. More...

#include <Oscillator.h>

Inheritance diagram for TableSine< Stap, Ts >:
Accum< Stap, Ts >

List of all members.

Public Member Functions

 TableSine (float frq=440, float phase=0)
float operator() (float freqOffset=0)
 Return next linearly-interpolated sample.
float nextN (float freqOffset=0)
 Return next non-interpolated sample.
float nextL (float freqOffset=0)
 Return next linearly-interpolated sample.
void freq (float v)
 Set frequency.
float freq () const
 Get frequency.
void phase (float v)
 Set phase from [0, 1) of one period.
float phase () const
 Get phase in [0, 1)
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.
uint32_t freqI () const
 Get fixed-point frequency.
float freqUnit () const
 Get frequency 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.

Static Public Member Functions

static void resize (uint32_t bits)
 Resize global sine table.

Detailed Description

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

Lookup table sine oscillator.

This oscillator looks up values in a table containing the sine function in [0, pi/2]. Doing a non-interpolating table lookup is very fast and stable compared to other methods. The downsides are that the waveform is generally not as spectrally pure and additional memory needs to be allocated to store the lookup table (although it's relatively small and only allocated once).


Constructor & Destructor Documentation

TableSine ( float  frq = 440,
float  phase = 0 
)
Parameters:
[in]frqFrequency
[in]phasePhase in [0, 1)

Member Function Documentation

uint32_t cycle ( ) [inherited]

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.

void resize ( uint32_t  bits) [static]

Resize global sine table.

Parameters:
[in]bitsset effective table size to be 2^bits

This sets the effective table size with only one quarter the amount of memory actually being allocated. For example, if bits=10, the effective table size is 2^10 = 1024, but the amount of allocated memory is only 1024/4 = 256. This call is not thread safe.


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