- cleaned up
git-svn-id: http://moon:8086/svn/software/trunk/projects/JaySynth@725 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+41
-45
@@ -126,9 +126,7 @@ void LFO_Init(lfo_t *pObj, synth_float_t fs)
|
|||||||
pObj->param[LFO_PARAM2_ATTACK] = 0; // seconds
|
pObj->param[LFO_PARAM2_ATTACK] = 0; // seconds
|
||||||
|
|
||||||
pObj->sh_sample = 0;
|
pObj->sh_sample = 0;
|
||||||
pObj->out = 0;
|
pObj->smooth_out = 0;
|
||||||
pObj->sqr = 0;
|
|
||||||
pObj->tri = 0;
|
|
||||||
pObj->offset = 0.5;
|
pObj->offset = 0.5;
|
||||||
|
|
||||||
LFO_Reset(pObj, 0);
|
LFO_Reset(pObj, 0);
|
||||||
@@ -172,9 +170,7 @@ void LFO_SetFS(lfo_t *pObj, synth_float_t fs)
|
|||||||
|
|
||||||
void LFO_Reset(lfo_t *pObj, synth_float_t initial_phase)
|
void LFO_Reset(lfo_t *pObj, synth_float_t initial_phase)
|
||||||
{
|
{
|
||||||
pObj->out = 0;
|
pObj->smooth_out = 0;
|
||||||
pObj->sqr = 0;
|
|
||||||
pObj->tri = 0;
|
|
||||||
pObj->delay_x = 0;
|
pObj->delay_x = 0;
|
||||||
pObj->attack_y = 0;
|
pObj->attack_y = 0;
|
||||||
LFO_freq_update(pObj);
|
LFO_freq_update(pObj);
|
||||||
@@ -244,10 +240,10 @@ synth_float_t* LFO_ProcessDataV(lfo_t *pObj, UINT32 len)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
in = (synth_float_t)0;
|
in = (synth_float_t)0;
|
||||||
pObj->out = pObj->smooth_a*pObj->out + pObj->smooth_b*in;
|
pObj->smooth_out = pObj->smooth_a*pObj->smooth_out + pObj->smooth_b*in;
|
||||||
out = pObj->out;
|
out = pObj->smooth_out;
|
||||||
if (pObj->smooth_is_negative)
|
if (pObj->smooth_is_negative)
|
||||||
out = 2*in - pObj->out;
|
out = 2*in - pObj->smooth_out;
|
||||||
|
|
||||||
*(pOut++) = out;
|
*(pOut++) = out;
|
||||||
|
|
||||||
@@ -268,10 +264,10 @@ synth_float_t* LFO_ProcessDataV(lfo_t *pObj, UINT32 len)
|
|||||||
synth_float_t y = 2*sync_result.phase - 1.0;
|
synth_float_t y = 2*sync_result.phase - 1.0;
|
||||||
|
|
||||||
in = 0.5*y + pObj->offset;
|
in = 0.5*y + pObj->offset;
|
||||||
pObj->out = pObj->smooth_a*pObj->out + pObj->smooth_b*in;
|
pObj->smooth_out = pObj->smooth_a*pObj->smooth_out + pObj->smooth_b*in;
|
||||||
out = pObj->out;
|
out = pObj->smooth_out;
|
||||||
if (pObj->smooth_is_negative)
|
if (pObj->smooth_is_negative)
|
||||||
out = 2*in - pObj->out;
|
out = 2*in - pObj->smooth_out;
|
||||||
|
|
||||||
*(pOut++) = out*pObj->attack_y;
|
*(pOut++) = out*pObj->attack_y;
|
||||||
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
||||||
@@ -293,10 +289,10 @@ synth_float_t* LFO_ProcessDataV(lfo_t *pObj, UINT32 len)
|
|||||||
synth_float_t y = 2*sync_result.phase - 1.0;
|
synth_float_t y = 2*sync_result.phase - 1.0;
|
||||||
|
|
||||||
in = -0.5*y + pObj->offset;
|
in = -0.5*y + pObj->offset;
|
||||||
pObj->out = pObj->smooth_a*pObj->out + pObj->smooth_b*in;
|
pObj->smooth_out = pObj->smooth_a*pObj->smooth_out + pObj->smooth_b*in;
|
||||||
out = pObj->out;
|
out = pObj->smooth_out;
|
||||||
if (pObj->smooth_is_negative)
|
if (pObj->smooth_is_negative)
|
||||||
out = 2*in - pObj->out;
|
out = 2*in - pObj->smooth_out;
|
||||||
|
|
||||||
*(pOut++) = out*pObj->attack_y;
|
*(pOut++) = out*pObj->attack_y;
|
||||||
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
||||||
@@ -320,10 +316,10 @@ synth_float_t* LFO_ProcessDataV(lfo_t *pObj, UINT32 len)
|
|||||||
pObj->sh_sample = Noise_Uniform(&pObj->noise, 1, 0.5);
|
pObj->sh_sample = Noise_Uniform(&pObj->noise, 1, 0.5);
|
||||||
}
|
}
|
||||||
in = pObj->sh_sample + pObj->offset;
|
in = pObj->sh_sample + pObj->offset;
|
||||||
pObj->out = pObj->smooth_a*pObj->out + pObj->smooth_b*in;
|
pObj->smooth_out = pObj->smooth_a*pObj->smooth_out + pObj->smooth_b*in;
|
||||||
out = pObj->out;
|
out = pObj->smooth_out;
|
||||||
if (pObj->smooth_is_negative)
|
if (pObj->smooth_is_negative)
|
||||||
out = 2*in - pObj->out;
|
out = 2*in - pObj->smooth_out;
|
||||||
|
|
||||||
*(pOut++) = out*pObj->attack_y;
|
*(pOut++) = out*pObj->attack_y;
|
||||||
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
||||||
@@ -352,10 +348,10 @@ synth_float_t* LFO_ProcessDataV(lfo_t *pObj, UINT32 len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
in = pObj->sh_sample + pObj->offset;
|
in = pObj->sh_sample + pObj->offset;
|
||||||
pObj->out = pObj->smooth_a*pObj->out + pObj->smooth_b*in;
|
pObj->smooth_out = pObj->smooth_a*pObj->smooth_out + pObj->smooth_b*in;
|
||||||
out = pObj->out;
|
out = pObj->smooth_out;
|
||||||
if (pObj->smooth_is_negative)
|
if (pObj->smooth_is_negative)
|
||||||
out = 2*in - pObj->out;
|
out = 2*in - pObj->smooth_out;
|
||||||
|
|
||||||
*(pOut++) = out*pObj->attack_y;
|
*(pOut++) = out*pObj->attack_y;
|
||||||
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
||||||
@@ -377,10 +373,10 @@ synth_float_t* LFO_ProcessDataV(lfo_t *pObj, UINT32 len)
|
|||||||
synth_float_t y = sin(2*M_PI*sync_result.phase);
|
synth_float_t y = sin(2*M_PI*sync_result.phase);
|
||||||
|
|
||||||
in = 0.5*y + pObj->offset;
|
in = 0.5*y + pObj->offset;
|
||||||
pObj->out = pObj->smooth_a*pObj->out + pObj->smooth_b*in;
|
pObj->smooth_out = pObj->smooth_a*pObj->smooth_out + pObj->smooth_b*in;
|
||||||
out = pObj->out;
|
out = pObj->smooth_out;
|
||||||
if (pObj->smooth_is_negative)
|
if (pObj->smooth_is_negative)
|
||||||
out = 2*in - pObj->out;
|
out = 2*in - pObj->smooth_out;
|
||||||
|
|
||||||
*(pOut++) = out*pObj->attack_y;
|
*(pOut++) = out*pObj->attack_y;
|
||||||
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
||||||
@@ -401,10 +397,10 @@ synth_float_t* LFO_ProcessDataV(lfo_t *pObj, UINT32 len)
|
|||||||
synth_float_t y = sin(2*M_PI*sync_result.phase);
|
synth_float_t y = sin(2*M_PI*sync_result.phase);
|
||||||
|
|
||||||
in = -0.5*y + pObj->offset;
|
in = -0.5*y + pObj->offset;
|
||||||
pObj->out = pObj->smooth_a*pObj->out + pObj->smooth_b*in;
|
pObj->smooth_out = pObj->smooth_a*pObj->smooth_out + pObj->smooth_b*in;
|
||||||
out = pObj->out;
|
out = pObj->smooth_out;
|
||||||
if (pObj->smooth_is_negative)
|
if (pObj->smooth_is_negative)
|
||||||
out = 2*in - pObj->out;
|
out = 2*in - pObj->smooth_out;
|
||||||
|
|
||||||
*(pOut++) = out*pObj->attack_y;
|
*(pOut++) = out*pObj->attack_y;
|
||||||
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
||||||
@@ -425,10 +421,10 @@ synth_float_t* LFO_ProcessDataV(lfo_t *pObj, UINT32 len)
|
|||||||
synth_float_t y = cos(2*M_PI*sync_result.phase);
|
synth_float_t y = cos(2*M_PI*sync_result.phase);
|
||||||
|
|
||||||
in = 0.5*y + pObj->offset;
|
in = 0.5*y + pObj->offset;
|
||||||
pObj->out = pObj->smooth_a*pObj->out + pObj->smooth_b*in;
|
pObj->smooth_out = pObj->smooth_a*pObj->smooth_out + pObj->smooth_b*in;
|
||||||
out = pObj->out;
|
out = pObj->smooth_out;
|
||||||
if (pObj->smooth_is_negative)
|
if (pObj->smooth_is_negative)
|
||||||
out = 2*in - pObj->out;
|
out = 2*in - pObj->smooth_out;
|
||||||
|
|
||||||
*(pOut++) = out*pObj->attack_y;
|
*(pOut++) = out*pObj->attack_y;
|
||||||
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
||||||
@@ -449,10 +445,10 @@ synth_float_t* LFO_ProcessDataV(lfo_t *pObj, UINT32 len)
|
|||||||
synth_float_t y = cos(2*M_PI*sync_result.phase);
|
synth_float_t y = cos(2*M_PI*sync_result.phase);
|
||||||
|
|
||||||
in = -0.5*y + pObj->offset;
|
in = -0.5*y + pObj->offset;
|
||||||
pObj->out = pObj->smooth_a*pObj->out + pObj->smooth_b*in;
|
pObj->smooth_out = pObj->smooth_a*pObj->smooth_out + pObj->smooth_b*in;
|
||||||
out = pObj->out;
|
out = pObj->smooth_out;
|
||||||
if (pObj->smooth_is_negative)
|
if (pObj->smooth_is_negative)
|
||||||
out = 2*in - pObj->out;
|
out = 2*in - pObj->smooth_out;
|
||||||
|
|
||||||
*(pOut++) = out*pObj->attack_y;
|
*(pOut++) = out*pObj->attack_y;
|
||||||
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
||||||
@@ -474,10 +470,10 @@ synth_float_t* LFO_ProcessDataV(lfo_t *pObj, UINT32 len)
|
|||||||
synth_float_t y = 2*(synth_float_t)(sync_result.phase < 0.5) - 1.0;
|
synth_float_t y = 2*(synth_float_t)(sync_result.phase < 0.5) - 1.0;
|
||||||
|
|
||||||
in = 0.5*y + pObj->offset;
|
in = 0.5*y + pObj->offset;
|
||||||
pObj->out = pObj->smooth_a*pObj->out + pObj->smooth_b*in;
|
pObj->smooth_out = pObj->smooth_a*pObj->smooth_out + pObj->smooth_b*in;
|
||||||
out = pObj->out;
|
out = pObj->smooth_out;
|
||||||
if (pObj->smooth_is_negative)
|
if (pObj->smooth_is_negative)
|
||||||
out = 2*in - pObj->out;
|
out = 2*in - pObj->smooth_out;
|
||||||
|
|
||||||
*(pOut++) = out*pObj->attack_y;
|
*(pOut++) = out*pObj->attack_y;
|
||||||
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
||||||
@@ -499,10 +495,10 @@ synth_float_t* LFO_ProcessDataV(lfo_t *pObj, UINT32 len)
|
|||||||
synth_float_t y = 2*(synth_float_t)(sync_result.phase < 0.5) - 1.0;
|
synth_float_t y = 2*(synth_float_t)(sync_result.phase < 0.5) - 1.0;
|
||||||
|
|
||||||
in = -0.5*y + pObj->offset;
|
in = -0.5*y + pObj->offset;
|
||||||
pObj->out = pObj->smooth_a*pObj->out + pObj->smooth_b*in;
|
pObj->smooth_out = pObj->smooth_a*pObj->smooth_out + pObj->smooth_b*in;
|
||||||
out = pObj->out;
|
out = pObj->smooth_out;
|
||||||
if (pObj->smooth_is_negative)
|
if (pObj->smooth_is_negative)
|
||||||
out = 2*in - pObj->out;
|
out = 2*in - pObj->smooth_out;
|
||||||
|
|
||||||
*(pOut++) = out*pObj->attack_y;
|
*(pOut++) = out*pObj->attack_y;
|
||||||
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
||||||
@@ -528,10 +524,10 @@ synth_float_t* LFO_ProcessDataV(lfo_t *pObj, UINT32 len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
in = 0.5*y + pObj->offset;
|
in = 0.5*y + pObj->offset;
|
||||||
pObj->out = pObj->smooth_a*pObj->out + pObj->smooth_b*in;
|
pObj->smooth_out = pObj->smooth_a*pObj->smooth_out + pObj->smooth_b*in;
|
||||||
out = pObj->out;
|
out = pObj->smooth_out;
|
||||||
if (pObj->smooth_is_negative)
|
if (pObj->smooth_is_negative)
|
||||||
out = 2*in - pObj->out;
|
out = 2*in - pObj->smooth_out;
|
||||||
|
|
||||||
*(pOut++) = out*pObj->attack_y;
|
*(pOut++) = out*pObj->attack_y;
|
||||||
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
||||||
@@ -557,10 +553,10 @@ synth_float_t* LFO_ProcessDataV(lfo_t *pObj, UINT32 len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
in = -0.5*y + pObj->offset;
|
in = -0.5*y + pObj->offset;
|
||||||
pObj->out = pObj->smooth_a*pObj->out + pObj->smooth_b*in;
|
pObj->smooth_out = pObj->smooth_a*pObj->smooth_out + pObj->smooth_b*in;
|
||||||
out = pObj->out;
|
out = pObj->smooth_out;
|
||||||
if (pObj->smooth_is_negative)
|
if (pObj->smooth_is_negative)
|
||||||
out = 2*in - pObj->out;
|
out = 2*in - pObj->smooth_out;
|
||||||
|
|
||||||
*(pOut++) = out*pObj->attack_y;
|
*(pOut++) = out*pObj->attack_y;
|
||||||
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
pObj->attack_y += pObj->attack_a*(1-pObj->attack_y);
|
||||||
|
|||||||
+3
-3
@@ -83,12 +83,12 @@ typedef struct _slfo_t
|
|||||||
{
|
{
|
||||||
synth_float_t param[LFO_NUM_PARAMS];
|
synth_float_t param[LFO_NUM_PARAMS];
|
||||||
synth_float_t omega, fs;
|
synth_float_t omega, fs;
|
||||||
synth_float_t out, sh_sample, tri;
|
synth_float_t sh_sample;
|
||||||
int freq_update_req, sqr;
|
int freq_update_req;
|
||||||
synth_float_t *pOut;
|
synth_float_t *pOut;
|
||||||
UINT32 bufsize;
|
UINT32 bufsize;
|
||||||
noise_gen_t noise;
|
noise_gen_t noise;
|
||||||
synth_float_t smooth_a, smooth_b;
|
synth_float_t smooth_out, smooth_a, smooth_b;
|
||||||
UINT32 smooth_is_negative;
|
UINT32 smooth_is_negative;
|
||||||
synth_float_t delay_x, delay_dx, attack_y, attack_a;
|
synth_float_t delay_x, delay_dx, attack_y, attack_a;
|
||||||
synth_float_t offset;
|
synth_float_t offset;
|
||||||
|
|||||||
Reference in New Issue
Block a user