- LFO: use common synced phase generator

calc sin and cos using math functions


git-svn-id: http://moon:8086/svn/software/trunk/projects/JaySynth@723 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2020-08-12 06:11:29 +00:00
parent a430c135e7
commit 23260bc635
3 changed files with 68 additions and 213 deletions
+11 -15
View File
@@ -40,16 +40,8 @@ enum
LFO_NUM_PARAMS
};
typedef void (*SyncOnProcess)(void *pFuncObj);
typedef void (*SyncOnFreqUpdate)(void *pFuncObj, synth_float_t omega);
typedef synth_float_t (*SyncOnGetPhase)(void *pFuncObj);
typedef struct _ssync_t
{
void *pFuncObj;
SyncOnProcess funcSyncOnProcess;
SyncOnGetPhase funcSyncOnGetPhase;
SyncOnFreqUpdate funcSyncOnFreqUpdate;
synth_float_t phase;
synth_float_t phase_ref;
synth_float_t omega;
@@ -59,10 +51,16 @@ typedef struct _ssync_t
synth_float_t accu;
int phase_update;
int freq_update;
} sync_t;
typedef struct _ssync_result_t
{
synth_float_t phase;
int is_cycle_start;
} sync_result_t;
#if defined(__cplusplus)
extern "C" {
#endif
@@ -71,10 +69,8 @@ extern "C" {
// Exported functions
// --------------------------------------------------------------
void Sync_init(sync_t *pObj);
void Sync_set_callback(sync_t *pObj, void *pFuncObj, SyncOnProcess funcSyncOnProcess, SyncOnGetPhase funcSyncOnGetPhase, SyncOnFreqUpdate funcSyncOnFreqUpdate);
void Sync_phase_update(sync_t *pObj, synth_float_t phase_ref);
void Sync_process(sync_t *pObj);
sync_result_t Sync_process(sync_t *pObj, synth_float_t omega_base);
synth_float_t Sync_mod(synth_float_t x, synth_float_t y);
#if defined(__cplusplus)
@@ -86,8 +82,8 @@ synth_float_t Sync_mod(synth_float_t x, synth_float_t y);
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;
synth_float_t omega, fs;
synth_float_t a, b, out, sh_sample, tri;
int freq_update_req, sqr;
synth_float_t *pOut;
UINT32 bufsize;