From a3ab60fb40f92776d2977572c46b3d27bd004e4f Mon Sep 17 00:00:00 2001 From: Markus Schmidt Date: Wed, 12 Feb 2014 15:46:30 +0100 Subject: [PATCH] Vocoder: improve performance of detector LEDs --- src/calf/modules_filter.h | 2 +- src/giface.cpp | 2 +- src/modules_filter.cpp | 23 ++++++++++++++++------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/calf/modules_filter.h b/src/calf/modules_filter.h index fb4a779..ca06fd2 100644 --- a/src/calf/modules_filter.h +++ b/src/calf/modules_filter.h @@ -356,7 +356,7 @@ public: double env_mods[2][32]; vumeters meters; analyzer _analyzer; - double attack, release, fcoeff; + double attack, release, fcoeff, log2_; vocoder_audio_module(); void activate(); void deactivate(); diff --git a/src/giface.cpp b/src/giface.cpp index f81674f..093b245 100644 --- a/src/giface.cpp +++ b/src/giface.cpp @@ -362,7 +362,7 @@ void calf_plugins::set_channel_dash(cairo_iface *context, int channel) void calf_plugins::draw_cairo_label(cairo_iface *context, const char *label, float x, float y, int pos, float margin, float align) { - //context->draw_label(label, x, y, pos, margin, align); + context->draw_label(label, x, y, pos, margin, align); } //////////////////////////////////////////////////////////////////////// diff --git a/src/modules_filter.cpp b/src/modules_filter.cpp index 0e4d356..4aba8be 100644 --- a/src/modules_filter.cpp +++ b/src/modules_filter.cpp @@ -872,6 +872,7 @@ vocoder_audio_module::vocoder_audio_module() order = 0; order_old = -1; fcoeff = log10(20.f); + log2_ = log(2); memset(env_mods, 0, 32 * 2 * sizeof(double)); } @@ -936,6 +937,7 @@ uint32_t vocoder_audio_module::process(uint32_t offset, uint32_t numsamples, uin bool bypass = *params[param_bypass] > 0.f; int solo = get_solo(); numsamples += offset; + float led[32] = {0}; if(bypass) { // everything bypassed while(offset < numsamples) { @@ -1007,18 +1009,17 @@ uint32_t vocoder_audio_module::process(uint32_t offset, uint32_t numsamples, uin // add to outputs with proc level pL += cL_ * *params[param_proc]; pR += cR_ * *params[param_proc]; - - // LED - float val = std::max(0.0, 1 + log(((env_mods[0][i] + env_mods[1][i]) / 2) * order * 4) / log(2) / 10); - *params[param_level0 + i * band_params] = *params[param_detectors] > 0.5 ? val : 0; } + // LED + if (*params[param_detectors] > 0.5) + if (env_mods[0][i] + env_mods[1][i] > led[i]) + led[i] = env_mods[0][i] + env_mods[1][i]; + // advance envelopes env_mods[0][i] = (fabs(mL_) > env_mods[0][i] ? attack : release) * (env_mods[0][i] - fabs(mL_)) + fabs(mL_); env_mods[1][i] = (fabs(mR_) > env_mods[1][i] ? attack : release) * (env_mods[1][i] - fabs(mR_)) + fabs(mR_); } - for (int i = bands; i < 32; i ++) { - *params[param_level0 + i * band_params] = 0; - } + outL = pL; outR = pR; @@ -1074,6 +1075,14 @@ uint32_t vocoder_audio_module::process(uint32_t offset, uint32_t numsamples, uin } } } + + // LED + for (int i = 0; i < 32; i++) { + float val = 0; + if (*params[param_detectors] > 0.5) + val = std::max(0.0, 1 + log((led[i] / 2) * order) / log2_ / 10); + *params[param_level0 + i * band_params] = val; + } meters.fall(orig_numsamples); return outputs_mask; } -- 2.11.4.GIT