minilogue xd SDK  v1.1-0
Public Member Functions | Public Attributes | List of all members
dsp::SimpleLFO Struct Reference

Simple LFO. More...

#include <simplelfo.hpp>

Public Member Functions

 SimpleLFO (void)
 Default constructor.
 
void cycle (void)
 Step phase one cycle forward.
 
void reset (void)
 Reset phase.
 
void setF0 (const float f0, const float fsrecip)
 Set LFO frequency. More...
 
void setW0 (const float w)
 Set LFO frequency in radians. More...
 
float sine_bi (void)
 Get value of bipolar sine wave for current phase.
 
float sine_uni (void)
 Get value of positive unipolar sine wave for current phase.
 
float sine_bi_off (const float offset)
 Get current value of bipolar sine wave for phase with offset. More...
 
float sine_uni_off (const float offset)
 Get current value of positive unipolar sine wave for phase with offset. More...
 
float triangle_bi (void)
 Get current value of bipolar triangle wave for current phase.
 
float triangle_uni (void)
 Get value of positive unipolar triangle wave for current phase.
 
float triangle_bi_off (const float offset)
 Get current value of bipolar triangle wave for phase with offset. More...
 
float triangle_uni_off (const float offset)
 Get current value of positive unipolar triangle wave for phase with offset. More...
 
float saw_bi (void)
 Get current value of bipolar saw wave for current phase.
 
float saw_uni (void)
 Get value of positive unipolar saw wave for current phase.
 
float saw_bi_off (const float offset)
 Get current value of bipolar saw wave for phase with offset. More...
 
float saw_uni_off (const float offset)
 Get current value of positive unipolar saw wave for phase with offset. More...
 
float square_bi (void)
 Get current value of bipolar square wave for current phase.
 
float square_uni (void)
 Get value of positive unipolar square wave for current phase.
 
float square_bi_off (const float offset)
 Get current value of bipolar square wave for phase with offset. More...
 
float square_uni_off (const float offset)
 Get current value of positive unipolar square wave for phase with offset. More...
 

Public Attributes

q31_t phi0
 
q31_t w0
 

Detailed Description

Simple LFO.

Definition at line 55 of file simplelfo.hpp.

Member Function Documentation

◆ saw_bi_off()

float dsp::SimpleLFO::saw_bi_off ( const float  offset)
inline

Get current value of bipolar saw wave for phase with offset.

Parameters
offsetOffset to apply to current phase, in [-1, 1]

Definition at line 231 of file simplelfo.hpp.

232  {
233  const q31_t phi = phi0 + (f32_to_q31(offset)<<1);
234  return q31_to_f32(phi);
235  }

◆ saw_uni_off()

float dsp::SimpleLFO::saw_uni_off ( const float  offset)
inline

Get current value of positive unipolar saw wave for phase with offset.

Parameters
offsetOffset to apply to current phase, in [-1, 1]

Definition at line 243 of file simplelfo.hpp.

244  {
245  q31_t phi = phi0 + (f32_to_q31(offset)<<1);
246  return 0.5f * phi + 0.5f;
247  phi >>= 1;
248  return q31_to_f32(qadd(phi,0x40000000));
249  }

◆ setF0()

void dsp::SimpleLFO::setF0 ( const float  f0,
const float  fsrecip 
)
inline

Set LFO frequency.

param f0 Frequency in Hz param fsrecip Reciprocal of sampling frequency (1/Fs)

Definition at line 101 of file simplelfo.hpp.

102  {
103  w0 = f32_to_q31(2.f * f0 * fsrecip);
104  }

◆ setW0()

void dsp::SimpleLFO::setW0 ( const float  w)
inline

Set LFO frequency in radians.

Parameters
wFrequency in radians

Definition at line 112 of file simplelfo.hpp.

113  {
114  w0 = f32_to_q31(2.f * w);
115  }

◆ sine_bi_off()

float dsp::SimpleLFO::sine_bi_off ( const float  offset)
inline

Get current value of bipolar sine wave for phase with offset.

Parameters
offsetOffset to apply to current phase, in [-1, 1]

Definition at line 145 of file simplelfo.hpp.

146  {
147  const float phi = q31_to_f32(phi0 + f32_to_q31(2*offset));
148  return 4 * phi * (si_fabsf(phi) - 1.f);
149  }

◆ sine_uni_off()

float dsp::SimpleLFO::sine_uni_off ( const float  offset)
inline

Get current value of positive unipolar sine wave for phase with offset.

Parameters
offsetOffset to apply to current phase, in [-1, 1]

Definition at line 157 of file simplelfo.hpp.

158  {
159  const float phi = q31_to_f32(phi0 + f32_to_q31(2*offset));
160  return 0.5f + 2 * phi * (si_fabsf(phi) - 1.f);
161  }

◆ square_bi_off()

float dsp::SimpleLFO::square_bi_off ( const float  offset)
inline

Get current value of bipolar square wave for phase with offset.

Parameters
offsetOffset to apply to current phase, in [-1, 1]

Definition at line 276 of file simplelfo.hpp.

277  {
278  const q31_t phi = phi0 + (f32_to_q31(offset)<<1);
279  return (phi < 0) ? -1.f : 1.f;
280  }

◆ square_uni_off()

float dsp::SimpleLFO::square_uni_off ( const float  offset)
inline

Get current value of positive unipolar square wave for phase with offset.

Parameters
offsetOffset to apply to current phase, in [-1, 1]

Definition at line 288 of file simplelfo.hpp.

289  {
290  const q31_t phi = phi0 + (f32_to_q31(offset)<<1);
291  return (phi < 0) ? 0.f : 1.f;
292  }

◆ triangle_bi_off()

float dsp::SimpleLFO::triangle_bi_off ( const float  offset)
inline

Get current value of bipolar triangle wave for phase with offset.

Parameters
offsetOffset to apply to current phase, in [-1, 1]

Definition at line 188 of file simplelfo.hpp.

189  {
190  const q31_t phi = phi0 + f32_to_q31(2*offset);
191  return q31_to_f32(qsub(q31abs(phi),0x40000000)<<1);
192  }

◆ triangle_uni_off()

float dsp::SimpleLFO::triangle_uni_off ( const float  offset)
inline

Get current value of positive unipolar triangle wave for phase with offset.

Parameters
offsetOffset to apply to current phase, in [-1, 1]

Definition at line 200 of file simplelfo.hpp.

201  {
202  const float phi = q31_to_f32(phi0 + f32_to_q31(2*offset));
203  return si_fabsf(phi);
204  }

The documentation for this struct was generated from the following file:
si_fabsf
static float si_fabsf(float x)
Absolute value.
Definition: float_math.h:284