From bb6879eac2b91d41679e6e1e638e6cf4e3e15e3a Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Thu, 1 Nov 2018 09:55:30 +0100 Subject: [PATCH] FIxes. --- config.h | 2 +- mdaEPiano.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/config.h b/config.h index 35c9b0a..00b4dce 100644 --- a/config.h +++ b/config.h @@ -36,7 +36,7 @@ #define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI #define AUDIO_MEM 300 #define SAMPLE_RATE 44100 -#define REDUCE_LOUDNESS 0 +#define REDUCE_LOUDNESS 1 #if !defined(__MK66FX1M0__) // check for Teensy-3.6 #define NVOCIES 11 // No? diff --git a/mdaEPiano.cpp b/mdaEPiano.cpp index 69f1312..d76f5d9 100644 --- a/mdaEPiano.cpp +++ b/mdaEPiano.cpp @@ -352,8 +352,10 @@ void mdaEPiano::process(int16_t *outputs_r, int16_t *outputs_l) V->pos -= V->loop; i = waves[V->pos] + ((V->frac * (waves[V->pos + 1] - waves[V->pos])) >> 16); x = V->env * static_cast(i) / 32768.0f; + V->env = V->env * V->dec; //envelope - if (x > 0.0f) { + if (x > 0.0f) + { x -= od * x * x; //overdrive if (x < -V->env) x = -V->env; } @@ -373,8 +375,8 @@ void mdaEPiano::process(int16_t *outputs_r, int16_t *outputs_l) l += l * lmod * lfo1; r += r * rmod * lfo1; //worth making all these local variables? - outputs_l[frame] = static_cast(l) >> REDUCE_LOUDNESS; - outputs_r[frame] = static_cast(r) >> REDUCE_LOUDNESS; + outputs_l[frame] = static_cast(l * 0x7fff) >> REDUCE_LOUDNESS; + outputs_r[frame] = static_cast(r * 0x7fff) >> REDUCE_LOUDNESS; } if (fabs(tl) < 1.0e-10) tl = 0.0f; //anti-denormal