From 08db6cf19ec36bb8536e3880a70f5cc349f153e3 Mon Sep 17 00:00:00 2001 From: Gordon JC Pearce Date: Thu, 22 Jun 2023 23:04:53 +0100 Subject: [PATCH] hacky declicker --- plugins/Nekobi/nekobee-src/nekobee_voice.c | 4 ++-- plugins/Nekobi/nekobee-src/nekobee_voice.h | 4 ++++ plugins/Nekobi/nekobee-src/nekobee_voice_render.c | 12 +++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/plugins/Nekobi/nekobee-src/nekobee_voice.c b/plugins/Nekobi/nekobee-src/nekobee_voice.c index e223b61..cb7b029 100644 --- a/plugins/Nekobi/nekobee-src/nekobee_voice.c +++ b/plugins/Nekobi/nekobee-src/nekobee_voice.c @@ -63,7 +63,6 @@ nekobee_voice_note_on(nekobee_synth_t *synth, nekobee_voice_t *voice, // 1.5M and 1uF voice->vca_tc = 1 / 1.5 * synth->deltat; - if (!synth->monophonic || !(_ON(voice) || _SUSTAINED(voice))) { // brand-new voice, or monophonic voice in release phase; set everything up @@ -184,7 +183,8 @@ nekobee_voice_note_off(nekobee_synth_t *synth, nekobee_voice_t *voice, { unsigned char previous_top_key; - voice->vca_tc = 1 / 0.0022 * synth->deltat; +//printf("voice->vca_tc=%f", voice->vca_tc); + voice->vca_tc = (10) * synth->deltat; /* save release velocity */ diff --git a/plugins/Nekobi/nekobee-src/nekobee_voice.h b/plugins/Nekobi/nekobee-src/nekobee_voice.h index f45abc6..21a312e 100644 --- a/plugins/Nekobi/nekobee-src/nekobee_voice.h +++ b/plugins/Nekobi/nekobee-src/nekobee_voice.h @@ -78,10 +78,14 @@ struct _nekobee_voice_t { struct blosc_t osc; float vca_eg, vcf_eg, accent_slug, delay1, delay2, delay3, delay4; float vca_tc, vcf_tc; // VCA and VCF time constants + + float vca_slug; + unsigned char vca_eg_phase, vcf_eg_phase; int osc_index; /* shared index into osc_audio */ float osc_audio[XSYNTH_NUGGET_SIZE]; float delayhp; + }; diff --git a/plugins/Nekobi/nekobee-src/nekobee_voice_render.c b/plugins/Nekobi/nekobee-src/nekobee_voice_render.c index c3665c3..6733406 100644 --- a/plugins/Nekobi/nekobee-src/nekobee_voice_render.c +++ b/plugins/Nekobi/nekobee-src/nekobee_voice_render.c @@ -120,6 +120,8 @@ void vcf(nekobee_synth_t *synth, float *out, uint32_t count) { float vcf_eg = voice->vcf_eg; float vca_eg = voice->vca_eg; + float vca_slug = voice->vca_slug; + float delayhp = voice->delayhp; // to get the correct cutoff first we need Q10's collector current @@ -194,7 +196,8 @@ void vcf(nekobee_synth_t *synth, float *out, uint32_t count) { delayhp = hp; fout = delay4-hp; } - out[i] = fout * vca_eg; + vca_slug = ((vca_eg - vca_slug)*(3000*synth->deltat))+vca_slug; + out[i] = fout * vca_slug; vcf_eg *= 1 - voice->vcf_tc; vca_eg *= 1 - voice->vca_tc; @@ -206,6 +209,7 @@ void vcf(nekobee_synth_t *synth, float *out, uint32_t count) { voice->vcf_eg = vcf_eg; voice->vca_eg = vca_eg; + voice->vca_slug = vca_slug; voice->delayhp = delayhp; } @@ -219,8 +223,14 @@ void nekobee_voice_render(nekobee_synth_t *synth, float *out, uint32_t count) { // resistor, a 1uF capacitor, and a bunch of other stuff to give a correct // DC offset and a log tailoff right at the very bottom + if (synth->voice->velocity < 90) { + printf("accent off\n"); synth->voice->vcf_tc = (1 / ((68 + 1000 * logpot[(int)synth->decay]) * 0.001)) * synth->deltat; + } else { + synth->voice->vcf_tc = 1/(68*0.001)*synth->deltat; + printf("accent on\n"); + } // printf("tc = %f deltat=%f pot=%f\n",synth->voice->vcf_tc, // synth->deltat,logpot[(int)synth->decay]);