From d7159e56d299986f6743a66a548a95d46a52bb57 Mon Sep 17 00:00:00 2001 From: EvanR Date: Fri, 5 Jun 2009 19:50:15 -0400 Subject: [PATCH] Added low pass stage to additive synth. --- core.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core.c b/core.c index 66ecc64..01ebd18 100644 --- a/core.c +++ b/core.c @@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define SAMPLE_COUNT 16 #define SAMPLE_NOTE_ZERO 60 -#define ANTIPOP_LENGTH 64 +#define ANTIPOP_LENGTH 512 #define WAVEFORM_LENGTH 256 #define MAX_COMMANDS 256 @@ -70,6 +70,7 @@ struct orgux_state{ //float sample_velocity[SAMPLE_COUNT]; int sample_rate; + float lp_alpha; int command_queue[512][5]; /* sample type chan val1 val2 */ int command_count; @@ -83,6 +84,7 @@ struct orgux_state{ float wave_ptr[MAX_NOTES]; float wave_step[MAX_NOTES]; int sample_ptr[MAX_NOTES]; + float lp_y[MAX_NOTES]; int note_max; }; @@ -233,6 +235,10 @@ void orgux_process(orgux_state* S, float* lbuf, float* rbuf, int len){ float y = m*(x-x1) + y1; //float y = 0; + float y0 = S->lp_y[j]; + y = y0 + S->lp_alpha * (y - y0); + S->lp_y[j] = y; + switch(S->antipop_flag[j]){ case -1: y *= S->antipop[S->antipop_ptr[j]]; @@ -387,6 +393,8 @@ orgux_state* orgux_init(int sample_rate){ orgux_state* S = malloc(sizeof(orgux_state)); if(!S) return NULL; + float dt = 1.0/sample_rate; + /* setup oscillator states */ for(int i=0; i<16; i++){ @@ -401,6 +409,7 @@ orgux_state* orgux_init(int sample_rate){ S->antipop_flag[i] = 0; S->note_on[i] = 0; S->sample_ptr[i] = 0; + S->lp_y[i] = 0; } //for(int i=0; isample_rate = sample_rate; + S->lp_alpha = dt/(dt+(1.0/35000)); S->command_count = 0; S->note_max = 0; @@ -490,7 +500,6 @@ int N = 0; float y_l; float y_h0=0; float y_h1=0; - float dt = (1.0/sample_rate); /* notes -- 2.11.4.GIT