// -------------------------------------------------------------- // -------------------------------------------------------------- #ifndef _LFO_H_ #define _LFO_H_ #include "synth_defs.h" #include "noise.h" #define LFO_SH_ALPHA 0.002 // S&H smoothing #define LFO_KE ((synth_float_t)(1-exp(-1))) // -------------------------------------------------------------- // Types // -------------------------------------------------------------- enum { LFO_WAVEFORM_SINE, LFO_WAVEFORM_COSINE, LFO_WAVEFORM_SAW, LFO_WAVEFORM_SQUARE, LFO_WAVEFORM_TRIANGLE, LFO_WAVEFORM_SH_UNI, LFO_WAVEFORM_SH_GAUSS, LFO_WAVEFORM_ONE_MINUS_SINE, LFO_WAVEFORM_ONE_MINUS_COSINE, LFO_WAVEFORM_ONE_MINUS_SAW, LFO_WAVEFORM_ONE_MINUS_SQUARE, LFO_WAVEFORM_ONE_MINUS_TRIANGLE, LFO_NUM_WAVEFORMS }; enum { LFO_PARAM2_WAVEFORM, LFO_PARAM2_FREQ, LFO_PARAM2_SMOOTH, LFO_PARAM2_DELAY, LFO_PARAM2_ATTACK, LFO_PARAM2_SYMMETRY, LFO_NUM_PARAMS }; typedef struct _slfo_t { synth_float_t param[LFO_NUM_PARAMS]; synth_float_t fs; synth_float_t a, b, y[2], x, dx, out, sh_sample, tri; int freq_update_req, sqr; synth_float_t *pOut; UINT32 bufsize; noise_gen_t noise; synth_float_t smooth_a, smooth_b; UINT32 smooth_is_negative; synth_float_t delay_x, delay_dx, attack_y, attack_a; synth_float_t gain, offset; } lfo_t; // -------------------------------------------------------------- #if defined(__cplusplus) extern "C" { #endif // -------------------------------------------------------------- // Exported functions // -------------------------------------------------------------- void LFO_Init(lfo_t *pObj, synth_float_t fs); void LFO_Free(lfo_t *pObj); void LFO_SetFS(lfo_t *pObj, synth_float_t fs); void LFO_SetBufsize(lfo_t *pObj, UINT32 bufsize); void LFO_Reset(lfo_t *pObj, synth_float_t initial_phase); void LFO_Param2Set(lfo_t *pObj, UINT32 type, synth_float_t value); synth_float_t* LFO_ProcessDataV(lfo_t *pObj, UINT32 len); #if defined(__cplusplus) } #endif // -------------------------------------------------------------- #endif // _LFO_H_