LMMS
Loading...
Searching...
No Matches
dsp::fixed_point< T, FracBits > Class Template Reference

#include <fixed_point.h>

Public Member Functions

 fixed_point ()
 default constructor, does not initialize the value, just like - say - float doesn't
template<class U, int FracBits2>
 fixed_point (const fixed_point< U, FracBits2 > &v)
 copy constructor from any other fixed_point value
 fixed_point (double v)
void set (T value)
get () const
 operator double () const
fixed_pointoperator= (double v)
template<class U, int FracBits2>
fixed_pointoperator= (const fixed_point< U, FracBits2 > &v)
template<class U, int FracBits2>
fixed_pointoperator+= (const fixed_point< U, FracBits2 > &v)
template<class U, int FracBits2>
fixed_pointoperator-= (const fixed_point< U, FracBits2 > &v)
template<class U, int FracBits2>
fixed_point operator+ (const fixed_point< U, FracBits2 > &v) const
template<class U, int FracBits2>
fixed_point operator- (const fixed_point< U, FracBits2 > &v) const
template<class U, int FracBits2>
fixed_point operator* (const fixed_point< U, FracBits2 > &v) const
 multiply two fixed point values, using long long int to store the temporary multiplication result
template<class U, int FracBits2, class BigType>
fixed_pointoperator*= (const fixed_point< U, FracBits2 > &v)
 multiply two fixed point values, using BigType (usually 64-bit int) to store the temporary multiplication result
fixed_point operator+ (int v) const
fixed_point operator- (int v) const
fixed_point operator* (int v) const
fixed_pointoperator+= (int v)
fixed_pointoperator-= (int v)
fixed_pointoperator*= (int v)
ipart () const
 return integer part
unsigned int uipart () const
 return integer part as unsigned int
unsigned int ui64part () const
 return integer part as unsigned int
fpart () const
 return fractional part as 0..(2^FracBits-1)
template<int Bits>
fpart () const
 return fractional part as 0..(2^Bits-1)
double fpart_as_double () const
 return fractional part as 0..1
template<class U, int UseBits, class MulType>
U lerp_by_fract_int (U v1, U v2) const
template<class U, int UseBits>
U lerp_table_lookup_int (U *data) const
template<class U, int UseBits>
U lerp_table_lookup_int_shift (U *data, unsigned int shift)
template<class U>
U lerp_table_lookup_float (U *data) const
template<class U>
U lerp_table_lookup_float_mask (U *data, unsigned int mask) const
template<class U, int UseBits, class MulType>
U lerp_ptr_lookup_int (U *data) const
template<class U>
U lerp_ptr_lookup_float (U *data) const

Static Public Member Functions

static fixed_point from_base (const T &v)
 Makes an instance from a representation value (ie. same type of value as is used for internal storage and get/set).
static T one ()
template<class U, int FracBits2>
static T rebase (const fixed_point< U, FracBits2 > &v)

Private Types

enum  { IntBits = (sizeof(T)*8) - FracBits }

Private Attributes

value

Member Enumeration Documentation

◆ anonymous enum

template<class T, int FracBits>
anonymous enum
private
Enumerator
IntBits 

Constructor & Destructor Documentation

◆ fixed_point() [1/3]

template<class T, int FracBits>
dsp::fixed_point< T, FracBits >::fixed_point ( )
inline

default constructor, does not initialize the value, just like - say - float doesn't

◆ fixed_point() [2/3]

template<class T, int FracBits>
template<class U, int FracBits2>
dsp::fixed_point< T, FracBits >::fixed_point ( const fixed_point< U, FracBits2 > & v)
inline

copy constructor from any other fixed_point value

◆ fixed_point() [3/3]

template<class T, int FracBits>
dsp::fixed_point< T, FracBits >::fixed_point ( double v)
inlineexplicit

Member Function Documentation

◆ fpart() [1/2]

template<class T, int FracBits>
template<int Bits>
T dsp::fixed_point< T, FracBits >::fpart ( ) const
inline

return fractional part as 0..(2^Bits-1)

◆ fpart() [2/2]

template<class T, int FracBits>
T dsp::fixed_point< T, FracBits >::fpart ( ) const
inline

return fractional part as 0..(2^FracBits-1)

◆ fpart_as_double()

template<class T, int FracBits>
double dsp::fixed_point< T, FracBits >::fpart_as_double ( ) const
inline

return fractional part as 0..1

◆ from_base()

template<class T, int FracBits>
fixed_point dsp::fixed_point< T, FracBits >::from_base ( const T & v)
inlinestatic

Makes an instance from a representation value (ie. same type of value as is used for internal storage and get/set).

◆ get()

template<class T, int FracBits>
T dsp::fixed_point< T, FracBits >::get ( ) const
inline

◆ ipart()

template<class T, int FracBits>
T dsp::fixed_point< T, FracBits >::ipart ( ) const
inline

return integer part

◆ lerp_by_fract_int()

template<class T, int FracBits>
template<class U, int UseBits, class MulType>
U dsp::fixed_point< T, FracBits >::lerp_by_fract_int ( U v1,
U v2 ) const
inline

use fractional part (either whole or given number of most significant bits) for interpolating between two values note that it uses integer arithmetic only, and isn't suitable for floating point or fixed point U!

Parameters
UseBitscan be used when there's a risk of exceeding range of U because max(fpart)*max(v1 or v2) > range of U

◆ lerp_ptr_lookup_float()

template<class T, int FracBits>
template<class U>
U dsp::fixed_point< T, FracBits >::lerp_ptr_lookup_float ( U * data) const
inline

◆ lerp_ptr_lookup_int()

template<class T, int FracBits>
template<class U, int UseBits, class MulType>
U dsp::fixed_point< T, FracBits >::lerp_ptr_lookup_int ( U * data) const
inline

◆ lerp_table_lookup_float()

template<class T, int FracBits>
template<class U>
U dsp::fixed_point< T, FracBits >::lerp_table_lookup_float ( U * data) const
inline

◆ lerp_table_lookup_float_mask()

template<class T, int FracBits>
template<class U>
U dsp::fixed_point< T, FracBits >::lerp_table_lookup_float_mask ( U * data,
unsigned int mask ) const
inline

◆ lerp_table_lookup_int()

template<class T, int FracBits>
template<class U, int UseBits>
U dsp::fixed_point< T, FracBits >::lerp_table_lookup_int ( U * data) const
inline

◆ lerp_table_lookup_int_shift()

template<class T, int FracBits>
template<class U, int UseBits>
U dsp::fixed_point< T, FracBits >::lerp_table_lookup_int_shift ( U * data,
unsigned int shift )
inline

Untested... I've started it to get a sin/cos readout for rotaryorgan, but decided to use table-less solution instead Do not assume it works, because it most probably doesn't

◆ one()

template<class T, int FracBits>
T dsp::fixed_point< T, FracBits >::one ( )
inlinestatic

◆ operator double()

template<class T, int FracBits>
dsp::fixed_point< T, FracBits >::operator double ( ) const
inline

◆ operator*() [1/2]

template<class T, int FracBits>
template<class U, int FracBits2>
fixed_point dsp::fixed_point< T, FracBits >::operator* ( const fixed_point< U, FracBits2 > & v) const
inline

multiply two fixed point values, using long long int to store the temporary multiplication result

◆ operator*() [2/2]

template<class T, int FracBits>
fixed_point dsp::fixed_point< T, FracBits >::operator* ( int v) const
inline

◆ operator*=() [1/2]

template<class T, int FracBits>
template<class U, int FracBits2, class BigType>
fixed_point & dsp::fixed_point< T, FracBits >::operator*= ( const fixed_point< U, FracBits2 > & v)
inline

multiply two fixed point values, using BigType (usually 64-bit int) to store the temporary multiplication result

◆ operator*=() [2/2]

template<class T, int FracBits>
fixed_point & dsp::fixed_point< T, FracBits >::operator*= ( int v)
inline

◆ operator+() [1/2]

template<class T, int FracBits>
template<class U, int FracBits2>
fixed_point dsp::fixed_point< T, FracBits >::operator+ ( const fixed_point< U, FracBits2 > & v) const
inline

◆ operator+() [2/2]

template<class T, int FracBits>
fixed_point dsp::fixed_point< T, FracBits >::operator+ ( int v) const
inline

◆ operator+=() [1/2]

template<class T, int FracBits>
template<class U, int FracBits2>
fixed_point & dsp::fixed_point< T, FracBits >::operator+= ( const fixed_point< U, FracBits2 > & v)
inline

◆ operator+=() [2/2]

template<class T, int FracBits>
fixed_point & dsp::fixed_point< T, FracBits >::operator+= ( int v)
inline

◆ operator-() [1/2]

template<class T, int FracBits>
template<class U, int FracBits2>
fixed_point dsp::fixed_point< T, FracBits >::operator- ( const fixed_point< U, FracBits2 > & v) const
inline

◆ operator-() [2/2]

template<class T, int FracBits>
fixed_point dsp::fixed_point< T, FracBits >::operator- ( int v) const
inline

◆ operator-=() [1/2]

template<class T, int FracBits>
template<class U, int FracBits2>
fixed_point & dsp::fixed_point< T, FracBits >::operator-= ( const fixed_point< U, FracBits2 > & v)
inline

◆ operator-=() [2/2]

template<class T, int FracBits>
fixed_point & dsp::fixed_point< T, FracBits >::operator-= ( int v)
inline

◆ operator=() [1/2]

template<class T, int FracBits>
template<class U, int FracBits2>
fixed_point & dsp::fixed_point< T, FracBits >::operator= ( const fixed_point< U, FracBits2 > & v)
inline

◆ operator=() [2/2]

template<class T, int FracBits>
fixed_point & dsp::fixed_point< T, FracBits >::operator= ( double v)
inline

◆ rebase()

template<class T, int FracBits>
template<class U, int FracBits2>
T dsp::fixed_point< T, FracBits >::rebase ( const fixed_point< U, FracBits2 > & v)
inlinestatic

◆ set()

template<class T, int FracBits>
void dsp::fixed_point< T, FracBits >::set ( T value)
inline

◆ ui64part()

template<class T, int FracBits>
unsigned int dsp::fixed_point< T, FracBits >::ui64part ( ) const
inline

return integer part as unsigned int

◆ uipart()

template<class T, int FracBits>
unsigned int dsp::fixed_point< T, FracBits >::uipart ( ) const
inline

return integer part as unsigned int

Member Data Documentation

◆ value

template<class T, int FracBits>
T dsp::fixed_point< T, FracBits >::value
private

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