Using freeverbf for T_3.6 and platereverb fro T_4.x.

pull/37/head
Holger Wirtz 3 years ago
parent 6c4a11c91e
commit 7c8e516caf
  1. 57
      MicroDexed.ino
  2. 28
      UI.hpp
  3. 9
      config.h
  4. 122
      effect_platervbstereo.cpp
  5. 60
      effect_platervbstereo.h

@ -35,8 +35,11 @@
#include "effect_modulated_delay.h" #include "effect_modulated_delay.h"
#include "effect_stereo_mono.h" #include "effect_stereo_mono.h"
#include "effect_mono_stereo.h" #include "effect_mono_stereo.h"
//#include "effect_freeverbf.h" #ifdef USE_PLATEREVERB
#include "effect_platervbstereo.h" #include "effect_platervbstereo.h"
#else
#include "effect_freeverbf.h"
#endif
#include "PluginFx.h" #include "PluginFx.h"
#include "UI.hpp" #include "UI.hpp"
#include "source_microdexed.h" #include "source_microdexed.h"
@ -61,13 +64,12 @@ AudioAnalyzePeak microdexed_peak;
#if defined(USE_FX) #if defined(USE_FX)
AudioMixer4 reverb_mixer_r; AudioMixer4 reverb_mixer_r;
AudioMixer4 reverb_mixer_l; AudioMixer4 reverb_mixer_l;
//AudioEffectFreeverb freeverb_r; #ifdef USE_PLATEREVERB
//AudioEffectFreeverb freeverb_l;
//#if defined(REVERB_ANTIALIAS_FRQ)
//AudioFilterBiquad freeverb_antialias_r;
//AudioFilterBiquad freeverb_antialias_l;
//#endif
AudioEffectPlateReverb reverb; AudioEffectPlateReverb reverb;
#else
AudioEffectFreeverb freeverb_r;
AudioEffectFreeverb freeverb_l;
#endif
#endif #endif
AudioMixer4 master_mixer_r; AudioMixer4 master_mixer_r;
AudioMixer4 master_mixer_l; AudioMixer4 master_mixer_l;
@ -87,21 +89,17 @@ AudioMixer4 audio_thru_mixer_l;
// Audio chain tail // Audio chain tail
#if defined(USE_FX) #if defined(USE_FX)
//AudioConnection patchCord0(reverb_mixer_r, freeverb_r); #ifdef USE_PLATEREVERB
//AudioConnection patchCord1(reverb_mixer_l, freeverb_l);
AudioConnection patchCord0(reverb_mixer_r, 0, reverb, 0); AudioConnection patchCord0(reverb_mixer_r, 0, reverb, 0);
AudioConnection patchCord1(reverb_mixer_l, 0, reverb, 1); AudioConnection patchCord1(reverb_mixer_l, 0, reverb, 1);
AudioConnection patchCord2(reverb, 0, master_mixer_r, 3); AudioConnection patchCord2(reverb, 0, master_mixer_r, 3);
AudioConnection patchCord3(reverb, 0, master_mixer_l, 3); AudioConnection patchCord3(reverb, 0, master_mixer_l, 3);
//#if defined(REVERB_ANTIALIAS_FRQ) #else
//AudioConnection patchCord2(freeverb_r, freeverb_antialias_r); AudioConnection patchCord0(reverb_mixer_r, freeverb_r);
//AudioConnection patchCord3(freeverb_l, freeverb_antialias_l); AudioConnection patchCord1(reverb_mixer_l, freeverb_l);
//AudioConnection patchCord4(freeverb_antialias_r, 0, master_mixer_r, 3); AudioConnection patchCord2(freeverb_r, 0, master_mixer_r, 3);
//AudioConnection patchCord5(freeverb_antialias_l, 0, master_mixer_l, 3); AudioConnection patchCord3(freeverb_l, 0, master_mixer_l, 3);
//#else #endif
//AudioConnection patchCord2(freeverb_r, 0, master_mixer_r, 3);
//AudioConnection patchCord3(freeverb_l, 0, master_mixer_l, 3);
//#endif
#endif #endif
#if defined(ANTIALIAS_FRQ) #if defined(ANTIALIAS_FRQ)
AudioConnection patchCord6(master_mixer_r, antialias_r); AudioConnection patchCord6(master_mixer_r, antialias_r);
@ -409,17 +407,6 @@ void setup()
#endif #endif
#endif #endif
#if defined(USE_FX) && defined(REVERB_ANTIALIAS_FRQ)
freeverb_antialias_r.setLowpass(0, REVERB_ANTIALIAS_FRQ, 0.54);
freeverb_antialias_r.setLowpass(1, REVERB_ANTIALIAS_FRQ, 1.3);
freeverb_antialias_r.setLowpass(2, REVERB_ANTIALIAS_FRQ, 0.54);
freeverb_antialias_r.setLowpass(3, REVERB_ANTIALIAS_FRQ, 1.3);
freeverb_antialias_l.setLowpass(0, REVERB_ANTIALIAS_FRQ, 0.54);
freeverb_antialias_l.setLowpass(1, REVERB_ANTIALIAS_FRQ, 1.3);
freeverb_antialias_l.setLowpass(2, REVERB_ANTIALIAS_FRQ, 0.54);
freeverb_antialias_l.setLowpass(3, REVERB_ANTIALIAS_FRQ, 1.3);
#endif
#if defined(ANTIALIAS_FRQ) #if defined(ANTIALIAS_FRQ)
antialias_r.setLowpass(0, ANTIALIAS_FRQ, 0.54); antialias_r.setLowpass(0, ANTIALIAS_FRQ, 0.54);
antialias_r.setLowpass(1, ANTIALIAS_FRQ, 1.3); antialias_r.setLowpass(1, ANTIALIAS_FRQ, 1.3);
@ -1883,15 +1870,19 @@ void set_fx_params(void)
} }
// REVERB // REVERB
//freeverb_r.roomsize(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0)); #ifdef USE_PLATEREVERB
//freeverb_r.damping(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
//freeverb_l.roomsize(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
//freeverb_l.damping(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
reverb.size(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0)); // max reverb length reverb.size(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0)); // max reverb length
reverb.lowpass(0.3); // sets the reverb master lowpass filter reverb.lowpass(0.3); // sets the reverb master lowpass filter
reverb.lodamp(0.1); // amount of low end loss in the reverb tail reverb.lodamp(0.1); // amount of low end loss in the reverb tail
reverb.hidamp(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0)); // amount of treble loss in the reverb tail reverb.hidamp(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0)); // amount of treble loss in the reverb tail
reverb.diffusion(1.0); // 1.0 is the detault setting, lower it to create more "echoey" reverb reverb.diffusion(1.0); // 1.0 is the detault setting, lower it to create more "echoey" reverb
#else
freeverb_r.roomsize(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
freeverb_r.damping(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
freeverb_l.roomsize(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
freeverb_l.damping(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
#endif
master_mixer_r.gain(3, pseudo_log_curve(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0))); master_mixer_r.gain(3, pseudo_log_curve(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0)));
master_mixer_l.gain(3, pseudo_log_curve(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0))); master_mixer_l.gain(3, pseudo_log_curve(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0)));
#endif #endif

@ -25,13 +25,17 @@
#ifdef ENABLE_LCD_UI #ifdef ENABLE_LCD_UI
#ifndef _UI_HPP_ #ifndef _UI_HPP_
#define _UI_HPP_ #define _UI_HPP_
#endif
#include "config.h" #include "config.h"
#include "Disp_Plus.h" #include "Disp_Plus.h"
#include "effect_modulated_delay.h" #include "effect_modulated_delay.h"
#include "effect_stereo_mono.h" #include "effect_stereo_mono.h"
//#include "effect_freeverbf.h" #ifdef USE_PLATEREVERB
#include "effect_platervbstereo.h" #include "effect_platervbstereo.h"
#else
#include "effect_freeverbf.h"
#endif
#include "dexed.h" #include "dexed.h"
#include <LCDMenuLib2.h> #include <LCDMenuLib2.h>
@ -82,9 +86,12 @@ extern AudioAnalyzePeak microdexed_peak;
#if defined(USE_FX) #if defined(USE_FX)
extern AudioMixer4 reverb_mixer_r; extern AudioMixer4 reverb_mixer_r;
extern AudioMixer4 reverb_mixer_l; extern AudioMixer4 reverb_mixer_l;
//extern AudioEffectFreeverb freeverb_r; #ifdef USE_PLATEREVERB
//extern AudioEffectFreeverb freeverb_l;
extern AudioEffectPlateReverb reverb; extern AudioEffectPlateReverb reverb;
#else
extern AudioEffectFreeverb freeverb_r;
extern AudioEffectFreeverb freeverb_l;
#endif
#endif #endif
extern AudioMixer4 master_mixer_r; extern AudioMixer4 master_mixer_r;
extern AudioMixer4 master_mixer_l; extern AudioMixer4 master_mixer_l;
@ -912,9 +919,12 @@ void UI_func_reverb_roomsize(uint8_t param)
} }
lcd_display_bar_int("Reverb Room", configuration.fx.reverb_roomsize, 1.0, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 3, false, false, false); lcd_display_bar_int("Reverb Room", configuration.fx.reverb_roomsize, 1.0, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 3, false, false, false);
//freeverb_r.roomsize(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0)); #ifdef USE_PLATEREVERB
//freeverb_l.roomsize(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
reverb.size(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0)); reverb.size(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
#else
freeverb_r.roomsize(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
freeverb_l.roomsize(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
#endif
} }
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
@ -947,9 +957,12 @@ void UI_func_reverb_damping(uint8_t param)
lcd_display_bar_int("Reverb Damp.", configuration.fx.reverb_damping, 1.0, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 3, false, false, false); lcd_display_bar_int("Reverb Damp.", configuration.fx.reverb_damping, 1.0, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 3, false, false, false);
//freeverb_l.damping(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0)); #ifdef USE_PLATEREVERB
//freeverb_r.damping(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
reverb.hidamp(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0)); reverb.hidamp(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
#else
freeverb_l.damping(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
freeverb_r.damping(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
#endif
} }
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
@ -5832,4 +5845,3 @@ void string_trim(char *s)
} }
#endif #endif
#endif

@ -100,7 +100,7 @@
#define SHOW_CPU_LOAD_MSEC 5000 #define SHOW_CPU_LOAD_MSEC 5000
//************************************************************************************************* //*************************************************************************************************
//* DEXED AND EFECTS SETTINGS //* DEXED AND EFFECTS SETTINGS
//************************************************************************************************* //*************************************************************************************************
#define DEXED_ENGINE DEXED_ENGINE_MODERN // DEXED_ENGINE_MARKI // DEXED_ENGINE_OPL #define DEXED_ENGINE DEXED_ENGINE_MODERN // DEXED_ENGINE_MARKI // DEXED_ENGINE_OPL
@ -113,16 +113,15 @@
#define MOD_WAVEFORM WAVEFORM_TRIANGLE // WAVEFORM_SINE WAVEFORM_TRIANGLE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE #define MOD_WAVEFORM WAVEFORM_TRIANGLE // WAVEFORM_SINE WAVEFORM_TRIANGLE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE
#define MOD_FILTER_OUTPUT MOD_BUTTERWORTH_FILTER_OUTPUT // MOD_LINKWITZ_RILEY_FILTER_OUTPUT MOD_BUTTERWORTH_FILTER_OUTPUT MOD_NO_FILTER_OUTPUT #define MOD_FILTER_OUTPUT MOD_BUTTERWORTH_FILTER_OUTPUT // MOD_LINKWITZ_RILEY_FILTER_OUTPUT MOD_BUTTERWORTH_FILTER_OUTPUT MOD_NO_FILTER_OUTPUT
#define MOD_FILTER_CUTOFF_HZ 2000 #define MOD_FILTER_CUTOFF_HZ 2000
// REVERB parameters
//#define REVERB_ANTIALIAS_FRQ 7500
// ANTIALIAS frequency
//#define ANTIALIAS_FRQ 15000
// SGTL5000 // SGTL5000
#ifdef TEENSY_AUDIO_BOARD #ifdef TEENSY_AUDIO_BOARD
#define SGTL5000_AUDIO_ENHANCE 1 #define SGTL5000_AUDIO_ENHANCE 1
//#define SGTL5000_AUDIO_THRU 1 //#define SGTL5000_AUDIO_THRU 1
#define SGTL5000_HEADPHONE_VOLUME 0.8 #define SGTL5000_HEADPHONE_VOLUME 0.8
#endif #endif
#if defined(TEENSY4)
#define USE_PLATEREVERB 1
#endif
//************************************************************************************************* //*************************************************************************************************
//* AUDIO SOFTWARE SETTINGS //* AUDIO SOFTWARE SETTINGS

@ -34,12 +34,12 @@
#include "utility/dspinst.h" #include "utility/dspinst.h"
#include "synth_waveform.h" #include "synth_waveform.h"
#define INP_ALLP_COEFF (0.65) #define INP_ALLP_COEFF (0.65f)
#define LOOP_ALLOP_COEFF (0.65) #define LOOP_ALLOP_COEFF (0.65f)
#define HI_LOSS_FREQ (0.3) #define HI_LOSS_FREQ (0.3f)
#define HI_LOSS_FREQ_MAX (0.08) #define HI_LOSS_FREQ_MAX (0.08f)
#define LO_LOSS_FREQ (0.06) #define LO_LOSS_FREQ (0.06f)
#define LFO_AMPL_BITS (5) // 2^LFO_AMPL_BITS will be the LFO amplitude #define LFO_AMPL_BITS (5) // 2^LFO_AMPL_BITS will be the LFO amplitude
#define LFO_AMPL ((1<<LFO_AMPL_BITS) + 1) // lfo amplitude #define LFO_AMPL ((1<<LFO_AMPL_BITS) + 1) // lfo amplitude
@ -47,10 +47,10 @@
#define LFO_FRAC_BITS (16 - LFO_AMPL_BITS) // fractional part used for linear interpolation #define LFO_FRAC_BITS (16 - LFO_AMPL_BITS) // fractional part used for linear interpolation
#define LFO_FRAC_MASK ((1<<LFO_FRAC_BITS)-1) // mask for the above #define LFO_FRAC_MASK ((1<<LFO_FRAC_BITS)-1) // mask for the above
#define LFO1_FREQ_HZ (1.37) // LFO1 frequency in Hz #define LFO1_FREQ_HZ (1.37f) // LFO1 frequency in Hz
#define LFO2_FREQ_HZ (1.52) // LFO2 frequency in Hz #define LFO2_FREQ_HZ (1.52f) // LFO2 frequency in Hz
#define RV_MASTER_LOWPASS_F (0.6) // master lowpass scaled frequency coeff. #define RV_MASTER_LOWPASS_F (0.6f) // master lowpass scaled frequency coeff.
extern "C" { extern "C" {
extern const int16_t AudioWaveformSine[257]; extern const int16_t AudioWaveformSine[257];
@ -71,20 +71,20 @@ float32_t DMAMEM in_allp2_bufR[520];
float32_t DMAMEM in_allp3_bufR[956]; float32_t DMAMEM in_allp3_bufR[956];
float32_t DMAMEM in_allp4_bufR[1289]; float32_t DMAMEM in_allp4_bufR[1289];
float32_t DMAMEM lp_allp1_buf[1303]; // loop allpass buffers float32_t DMAMEM lp_allp1_buf[2303]; // loop allpass buffers
float32_t DMAMEM lp_allp2_buf[905]; float32_t DMAMEM lp_allp2_buf[2905];
float32_t DMAMEM lp_allp3_buf[1175]; float32_t DMAMEM lp_allp3_buf[3175];
float32_t DMAMEM lp_allp4_buf[1398]; float32_t DMAMEM lp_allp4_buf[2398];
float32_t DMAMEM lp_dly1_buf[1423]; float32_t DMAMEM lp_dly1_buf[3423];
float32_t DMAMEM lp_dly2_buf[1589]; float32_t DMAMEM lp_dly2_buf[4589];
float32_t DMAMEM lp_dly3_buf[1365]; float32_t DMAMEM lp_dly3_buf[4365];
float32_t DMAMEM lp_dly4_buf[1698]; float32_t DMAMEM lp_dly4_buf[3698];
#endif #endif
AudioEffectPlateReverb::AudioEffectPlateReverb() : AudioStream(2, inputQueueArray) AudioEffectPlateReverb::AudioEffectPlateReverb() : AudioStream(2, inputQueueArray)
{ {
input_attn = 0.5; input_attn = 0.5f;
in_allp_k = INP_ALLP_COEFF; in_allp_k = INP_ALLP_COEFF;
memset(in_allp1_bufL, 0, sizeof(in_allp1_bufL)); memset(in_allp1_bufL, 0, sizeof(in_allp1_bufL));
@ -105,7 +105,7 @@ AudioEffectPlateReverb::AudioEffectPlateReverb() : AudioStream(2, inputQueueArra
in_allp3_idxR = 0; in_allp3_idxR = 0;
in_allp4_idxR = 0; in_allp4_idxR = 0;
in_allp_out_R = 0; in_allp_out_R = 0.0f;
memset(lp_allp1_buf, 0, sizeof(lp_allp1_buf)); memset(lp_allp1_buf, 0, sizeof(lp_allp1_buf));
memset(lp_allp2_buf, 0, sizeof(lp_allp2_buf)); memset(lp_allp2_buf, 0, sizeof(lp_allp2_buf));
@ -116,7 +116,7 @@ AudioEffectPlateReverb::AudioEffectPlateReverb() : AudioStream(2, inputQueueArra
lp_allp3_idx = 0; lp_allp3_idx = 0;
lp_allp4_idx = 0; lp_allp4_idx = 0;
loop_allp_k = LOOP_ALLOP_COEFF; loop_allp_k = LOOP_ALLOP_COEFF;
lp_allp_out = 0; lp_allp_out = 0.0f;
memset(lp_dly1_buf, 0, sizeof(lp_dly1_buf)); memset(lp_dly1_buf, 0, sizeof(lp_dly1_buf));
memset(lp_dly2_buf, 0, sizeof(lp_dly2_buf)); memset(lp_dly2_buf, 0, sizeof(lp_dly2_buf));
@ -127,25 +127,25 @@ AudioEffectPlateReverb::AudioEffectPlateReverb() : AudioStream(2, inputQueueArra
lp_dly3_idx = 0; lp_dly3_idx = 0;
lp_dly4_idx = 0; lp_dly4_idx = 0;
lp_hidamp_k = 1.0; lp_hidamp_k = 1.0f;
lp_lodamp_k = 0.0; lp_lodamp_k = 0.0f;
lp_lowpass_f = HI_LOSS_FREQ; lp_lowpass_f = HI_LOSS_FREQ;
lp_hipass_f = LO_LOSS_FREQ; lp_hipass_f = LO_LOSS_FREQ;
lpf1 = 0; lpf1 = 0.0f;
lpf2 = 0; lpf2 = 0.0f;
lpf3 = 0; lpf3 = 0.0f;
lpf4 = 0; lpf4 = 0.0f;
hpf1 = 0; hpf1 = 0.0f;
hpf2 = 0; hpf2 = 0.0f;
hpf3 = 0; hpf3 = 0.0f;
hpf4 = 0; hpf4 = 0.0f;
master_lowpass_f = RV_MASTER_LOWPASS_F; master_lowpass_f = RV_MASTER_LOWPASS_F;
master_lowpass_l = 0; master_lowpass_l = 0.0f;
master_lowpass_r = 0; master_lowpass_r = 0.0f;
lfo1_phase_acc = 0; lfo1_phase_acc = 0;
lfo1_adder = (UINT32_MAX + 1)/(AUDIO_SAMPLE_RATE_EXACT * LFO1_FREQ_HZ); lfo1_adder = (UINT32_MAX + 1)/(AUDIO_SAMPLE_RATE_EXACT * LFO1_FREQ_HZ);
@ -153,7 +153,7 @@ AudioEffectPlateReverb::AudioEffectPlateReverb() : AudioStream(2, inputQueueArra
lfo2_adder = (UINT32_MAX + 1)/(AUDIO_SAMPLE_RATE_EXACT * LFO2_FREQ_HZ); lfo2_adder = (UINT32_MAX + 1)/(AUDIO_SAMPLE_RATE_EXACT * LFO2_FREQ_HZ);
} }
#define sat16(n, rshift) signed_saturate_rshift((n), 16, (rshift)) // #define sat16(n, rshift) signed_saturate_rshift((n), 16, (rshift))
// TODO: move this to one of the data files, use in output_adat.cpp, output_tdm.cpp, etc // TODO: move this to one of the data files, use in output_adat.cpp, output_tdm.cpp, etc
static const audio_block_t zeroblock = { static const audio_block_t zeroblock = {
@ -199,6 +199,35 @@ void AudioEffectPlateReverb::update()
int32_t y0, y1; int32_t y0, y1;
int64_t y; int64_t y;
uint32_t idx; uint32_t idx;
static bool cleanup_done = false;
// handle bypass, 1st call will clean the buffers to avoid continuing the previous reverb tail
if (bypass)
{
if (!cleanup_done)
{
memset(in_allp1_bufL, 0, sizeof(in_allp1_bufL));
memset(in_allp2_bufL, 0, sizeof(in_allp2_bufL));
memset(in_allp3_bufL, 0, sizeof(in_allp3_bufL));
memset(in_allp4_bufL, 0, sizeof(in_allp4_bufL));
memset(in_allp1_bufR, 0, sizeof(in_allp1_bufR));
memset(in_allp2_bufR, 0, sizeof(in_allp2_bufR));
memset(in_allp3_bufR, 0, sizeof(in_allp3_bufR));
memset(in_allp4_bufR, 0, sizeof(in_allp4_bufR));
memset(lp_allp1_buf, 0, sizeof(lp_allp1_buf));
memset(lp_allp2_buf, 0, sizeof(lp_allp2_buf));
memset(lp_allp3_buf, 0, sizeof(lp_allp3_buf));
memset(lp_allp4_buf, 0, sizeof(lp_allp4_buf));
memset(lp_dly1_buf, 0, sizeof(lp_dly1_buf));
memset(lp_dly2_buf, 0, sizeof(lp_dly2_buf));
memset(lp_dly3_buf, 0, sizeof(lp_dly3_buf));
memset(lp_dly4_buf, 0, sizeof(lp_dly4_buf));
cleanup_done = true;
}
return;
}
cleanup_done = false;
blockL = receiveReadOnly(0); blockL = receiveReadOnly(0);
blockR = receiveReadOnly(1); blockR = receiveReadOnly(1);
@ -214,6 +243,7 @@ void AudioEffectPlateReverb::update()
if (!blockL) blockL = &zeroblock; if (!blockL) blockL = &zeroblock;
if (!blockR) blockR = &zeroblock; if (!blockR) blockR = &zeroblock;
// convert data to float32 // convert data to float32
arm_q15_to_float((q15_t *)blockL->data, input_blockL, AUDIO_BLOCK_SAMPLES); arm_q15_to_float((q15_t *)blockL->data, input_blockL, AUDIO_BLOCK_SAMPLES);
arm_q15_to_float((q15_t *)blockR->data, input_blockR, AUDIO_BLOCK_SAMPLES); arm_q15_to_float((q15_t *)blockR->data, input_blockR, AUDIO_BLOCK_SAMPLES);
@ -385,10 +415,10 @@ void AudioEffectPlateReverb::update()
if (temp16 >= sizeof(lp_dly1_buf)/sizeof(float32_t)) temp16 = 0; if (temp16 >= sizeof(lp_dly1_buf)/sizeof(float32_t)) temp16 = 0;
temp2 = lp_dly1_buf[temp16]; // sample next temp2 = lp_dly1_buf[temp16]; // sample next
input = (float32_t)(lfo1_out_cos & LFO_FRAC_MASK) / ((float32_t)LFO_FRAC_MASK); // interp. k input = (float32_t)(lfo1_out_cos & LFO_FRAC_MASK) / ((float32_t)LFO_FRAC_MASK); // interp. k
acc = (temp1*(1.0-input) + temp2*input)* 0.8; acc = (temp1*(1.0f-input) + temp2*input)* 0.8f;
#else #else
temp16 = (lp_dly1_idx + lp_dly1_offset_L) % (sizeof(lp_dly1_buf)/sizeof(float32_t)); temp16 = (lp_dly1_idx + lp_dly1_offset_L) % (sizeof(lp_dly1_buf)/sizeof(float32_t));
acc = lp_dly1_buf[temp16]* 0.8; acc = lp_dly1_buf[temp16]* 0.8f;
#endif #endif
@ -398,10 +428,10 @@ void AudioEffectPlateReverb::update()
if (temp16 >= sizeof(lp_dly2_buf)/sizeof(float32_t)) temp16 = 0; if (temp16 >= sizeof(lp_dly2_buf)/sizeof(float32_t)) temp16 = 0;
temp2 = lp_dly2_buf[temp16]; temp2 = lp_dly2_buf[temp16];
input = (float32_t)(lfo1_out_sin & LFO_FRAC_MASK) / ((float32_t)LFO_FRAC_MASK); // interp. k input = (float32_t)(lfo1_out_sin & LFO_FRAC_MASK) / ((float32_t)LFO_FRAC_MASK); // interp. k
acc += (temp1*(1.0-input) + temp2*input)* 0.7; acc += (temp1*(1.0f-input) + temp2*input)* 0.7f;
#else #else
temp16 = (lp_dly2_idx + lp_dly2_offset_L) % (sizeof(lp_dly2_buf)/sizeof(float32_t)); temp16 = (lp_dly2_idx + lp_dly2_offset_L) % (sizeof(lp_dly2_buf)/sizeof(float32_t));
acc += (temp1*(1.0-input) + temp2*input)* 0.6; acc += (temp1*(1.0f-input) + temp2*input)* 0.6f;
#endif #endif
temp16 = (lp_dly3_idx + lp_dly3_offset_L + (lfo2_out_cos>>LFO_FRAC_BITS)) % (sizeof(lp_dly3_buf)/sizeof(float32_t)); temp16 = (lp_dly3_idx + lp_dly3_offset_L + (lfo2_out_cos>>LFO_FRAC_BITS)) % (sizeof(lp_dly3_buf)/sizeof(float32_t));
@ -409,20 +439,20 @@ void AudioEffectPlateReverb::update()
if (temp16 >= sizeof(lp_dly3_buf)/sizeof(float32_t)) temp16 = 0; if (temp16 >= sizeof(lp_dly3_buf)/sizeof(float32_t)) temp16 = 0;
temp2 = lp_dly3_buf[temp16]; temp2 = lp_dly3_buf[temp16];
input = (float32_t)(lfo2_out_cos & LFO_FRAC_MASK) / ((float32_t)LFO_FRAC_MASK); // interp. k input = (float32_t)(lfo2_out_cos & LFO_FRAC_MASK) / ((float32_t)LFO_FRAC_MASK); // interp. k
acc += (temp1*(1.0-input) + temp2*input)* 0.6; acc += (temp1*(1.0f-input) + temp2*input)* 0.6f;
temp16 = (lp_dly4_idx + lp_dly4_offset_L + (lfo2_out_sin>>LFO_FRAC_BITS)) % (sizeof(lp_dly4_buf)/sizeof(float32_t)); temp16 = (lp_dly4_idx + lp_dly4_offset_L + (lfo2_out_sin>>LFO_FRAC_BITS)) % (sizeof(lp_dly4_buf)/sizeof(float32_t));
temp1 = lp_dly4_buf[temp16++]; temp1 = lp_dly4_buf[temp16++];
if (temp16 >= sizeof(lp_dly4_buf)/sizeof(float32_t)) temp16 = 0; if (temp16 >= sizeof(lp_dly4_buf)/sizeof(float32_t)) temp16 = 0;
temp2 = lp_dly4_buf[temp16]; temp2 = lp_dly4_buf[temp16];
input = (float32_t)(lfo2_out_sin & LFO_FRAC_MASK) / ((float32_t)LFO_FRAC_MASK); // interp. k input = (float32_t)(lfo2_out_sin & LFO_FRAC_MASK) / ((float32_t)LFO_FRAC_MASK); // interp. k
acc += (temp1*(1.0-input) + temp2*input)* 0.5; acc += (temp1*(1.0f-input) + temp2*input)* 0.5f;
// Master lowpass filter // Master lowpass filter
temp1 = acc - master_lowpass_l; temp1 = acc - master_lowpass_l;
master_lowpass_l += temp1 * master_lowpass_f; master_lowpass_l += temp1 * master_lowpass_f;
outblockL->data[i] =(int16_t)(master_lowpass_l * 32767.0); //sat16(output * 30, 0); outblockL->data[i] =(int16_t)(master_lowpass_l * 32767.0f); //sat16(output * 30, 0);
// Channel R // Channel R
#ifdef TAP1_MODULATED #ifdef TAP1_MODULATED
@ -432,10 +462,10 @@ void AudioEffectPlateReverb::update()
temp2 = lp_dly1_buf[temp16]; // sample next temp2 = lp_dly1_buf[temp16]; // sample next
input = (float32_t)(lfo2_out_cos & LFO_FRAC_MASK) / ((float32_t)LFO_FRAC_MASK); // interp. k input = (float32_t)(lfo2_out_cos & LFO_FRAC_MASK) / ((float32_t)LFO_FRAC_MASK); // interp. k
acc = (temp1*(1.0-input) + temp2*input)* 0.8; acc = (temp1*(1.0f-input) + temp2*input)* 0.8f;
#else #else
temp16 = (lp_dly1_idx + lp_dly1_offset_R) % (sizeof(lp_dly1_buf)/sizeof(float32_t)); temp16 = (lp_dly1_idx + lp_dly1_offset_R) % (sizeof(lp_dly1_buf)/sizeof(float32_t));
acc = lp_dly1_buf[temp16] * 0.8; acc = lp_dly1_buf[temp16] * 0.8f;
#endif #endif
#ifdef TAP2_MODULATED #ifdef TAP2_MODULATED
temp16 = (lp_dly2_idx + lp_dly2_offset_R + (lfo1_out_cos>>LFO_FRAC_BITS)) % (sizeof(lp_dly2_buf)/sizeof(float32_t)); temp16 = (lp_dly2_idx + lp_dly2_offset_R + (lfo1_out_cos>>LFO_FRAC_BITS)) % (sizeof(lp_dly2_buf)/sizeof(float32_t));
@ -443,29 +473,29 @@ void AudioEffectPlateReverb::update()
if (temp16 >= sizeof(lp_dly2_buf)/sizeof(float32_t)) temp16 = 0; if (temp16 >= sizeof(lp_dly2_buf)/sizeof(float32_t)) temp16 = 0;
temp2 = lp_dly2_buf[temp16]; temp2 = lp_dly2_buf[temp16];
input = (float32_t)(lfo1_out_cos & LFO_FRAC_MASK) / ((float32_t)LFO_FRAC_MASK); // interp. k input = (float32_t)(lfo1_out_cos & LFO_FRAC_MASK) / ((float32_t)LFO_FRAC_MASK); // interp. k
acc += (temp1*(1.0-input) + temp2*input)* 0.7; acc += (temp1*(1.0f-input) + temp2*input)* 0.7f;
#else #else
temp16 = (lp_dly2_idx + lp_dly2_offset_R) % (sizeof(lp_dly2_buf)/sizeof(float32_t)); temp16 = (lp_dly2_idx + lp_dly2_offset_R) % (sizeof(lp_dly2_buf)/sizeof(float32_t));
acc += (temp1*(1.0-input) + temp2*input)* 0.7; acc += (temp1*(1.0f-input) + temp2*input)* 0.7f;
#endif #endif
temp16 = (lp_dly3_idx + lp_dly3_offset_R + (lfo2_out_sin>>LFO_FRAC_BITS)) % (sizeof(lp_dly3_buf)/sizeof(float32_t)); temp16 = (lp_dly3_idx + lp_dly3_offset_R + (lfo2_out_sin>>LFO_FRAC_BITS)) % (sizeof(lp_dly3_buf)/sizeof(float32_t));
temp1 = lp_dly3_buf[temp16++]; temp1 = lp_dly3_buf[temp16++];
if (temp16 >= sizeof(lp_dly3_buf)/sizeof(float32_t)) temp16 = 0; if (temp16 >= sizeof(lp_dly3_buf)/sizeof(float32_t)) temp16 = 0;
temp2 = lp_dly3_buf[temp16]; temp2 = lp_dly3_buf[temp16];
input = (float32_t)(lfo2_out_sin & LFO_FRAC_MASK) / ((float32_t)LFO_FRAC_MASK); // interp. k input = (float32_t)(lfo2_out_sin & LFO_FRAC_MASK) / ((float32_t)LFO_FRAC_MASK); // interp. k
acc += (temp1*(1.0-input) + temp2*input)* 0.6; acc += (temp1*(1.0f-input) + temp2*input)* 0.6f;
temp16 = (lp_dly4_idx + lp_dly4_offset_R + (lfo1_out_sin>>LFO_FRAC_BITS)) % (sizeof(lp_dly4_buf)/sizeof(float32_t)); temp16 = (lp_dly4_idx + lp_dly4_offset_R + (lfo1_out_sin>>LFO_FRAC_BITS)) % (sizeof(lp_dly4_buf)/sizeof(float32_t));
temp1 = lp_dly4_buf[temp16++]; temp1 = lp_dly4_buf[temp16++];
if (temp16 >= sizeof(lp_dly4_buf)/sizeof(float32_t)) temp16 = 0; if (temp16 >= sizeof(lp_dly4_buf)/sizeof(float32_t)) temp16 = 0;
temp2 = lp_dly4_buf[temp16]; temp2 = lp_dly4_buf[temp16];
input = (float32_t)(lfo2_out_cos & LFO_FRAC_MASK) / ((float32_t)LFO_FRAC_MASK); // interp. k input = (float32_t)(lfo2_out_cos & LFO_FRAC_MASK) / ((float32_t)LFO_FRAC_MASK); // interp. k
acc += (temp1*(1.0-input) + temp2*input)* 0.5; acc += (temp1*(1.0f-input) + temp2*input)* 0.5f;
// Master lowpass filter // Master lowpass filter
temp1 = acc - master_lowpass_r; temp1 = acc - master_lowpass_r;
master_lowpass_r += temp1 * master_lowpass_f; master_lowpass_r += temp1 * master_lowpass_f;
outblockR->data[i] =(int16_t)(master_lowpass_r * 32767.0); outblockR->data[i] =(int16_t)(master_lowpass_r * 32767.0f);
} }
transmit(outblockL, 0); transmit(outblockL, 0);

@ -69,51 +69,55 @@ public:
void size(float n) void size(float n)
{ {
n = constrain(n, 0.0, 1.0); n = constrain(n, 0.0f, 1.0f);
n = map (n, 0.0, 1.0, 0.2, rv_time_k_max); n = map (n, 0.0f, 1.0f, 0.2f, rv_time_k_max);
float32_t attn = 0.5 * map(n, 0.0, rv_time_k_max, 0.5, 1.0); float32_t attn = 0.5f * map(n, 0.0f, rv_time_k_max, 0.5f, 1.0f);
AudioNoInterrupts(); __disable_irq();
rv_time_k = n; rv_time_k = n;
input_attn = attn; input_attn = attn;
AudioInterrupts(); __enable_irq();
} }
void hidamp(float n) void hidamp(float n)
{ {
n = constrain(n, 0.0, 1.0); n = constrain(n, 0.0f, 1.0f);
AudioNoInterrupts(); __disable_irq();
lp_hidamp_k = 1.0 - n; lp_hidamp_k = 1.0f - n;
AudioInterrupts(); __enable_irq();
} }
void lodamp(float n) void lodamp(float n)
{ {
n = constrain(n, 0.0, 1.0); n = constrain(n, 0.0f, 1.0f);
AudioNoInterrupts(); __disable_irq();
lp_lodamp_k = -n; lp_lodamp_k = -n;
rv_time_scaler = 1.0 - n * 0.12; // limit the max reverb time, otherwise it will clip rv_time_scaler = 1.0f - n * 0.12f; // limit the max reverb time, otherwise it will clip
AudioInterrupts(); __enable_irq();
} }
void lowpass(float n) void lowpass(float n)
{ {
n = constrain(n, 0.0, 1.0); n = constrain(n, 0.0f, 1.0f);
n = map(n*n*n, 0.0, 1.0, 0.05, 1.0); n = map(n*n*n, 0.0f, 1.0f, 0.05f, 1.0f);
master_lowpass_f = n; master_lowpass_f = n;
} }
void diffusion(float n) void diffusion(float n)
{ {
n = constrain(n, 0.0, 1.0); n = constrain(n, 0.0f, 1.0f);
n = map(n, 0.0, 1.0, 0.005, 0.65); n = map(n, 0.0f, 1.0f, 0.005f, 0.65f);
AudioNoInterrupts(); __disable_irq();
in_allp_k = n; in_allp_k = n;
loop_allp_k = n; loop_allp_k = n;
AudioInterrupts(); __enable_irq();
} }
float32_t get_size(void) {return rv_time_k;} float32_t get_size(void) {return rv_time_k;}
bool get_bypass(void) {return bypass;}
void set_bypass(bool state) {bypass = state;};
void tgl_bypass(void) {bypass ^=1;}
private: private:
bool bypass = false;
audio_block_t *inputQueueArray[2]; audio_block_t *inputQueueArray[2];
#ifndef REVERB_USE_DMAMEM #ifndef REVERB_USE_DMAMEM
float32_t input_blockL[AUDIO_BLOCK_SAMPLES]; float32_t input_blockL[AUDIO_BLOCK_SAMPLES];
@ -145,10 +149,10 @@ private:
uint16_t in_allp4_idxR; uint16_t in_allp4_idxR;
float32_t in_allp_out_R; // R allpass chain output float32_t in_allp_out_R; // R allpass chain output
#ifndef REVERB_USE_DMAMEM #ifndef REVERB_USE_DMAMEM
float32_t lp_allp1_buf[1303]; // loop allpass buffers float32_t lp_allp1_buf[2303]; // loop allpass buffers
float32_t lp_allp2_buf[1905]; float32_t lp_allp2_buf[2905];
float32_t lp_allp3_buf[1175]; float32_t lp_allp3_buf[3175];
float32_t lp_allp4_buf[1398]; float32_t lp_allp4_buf[2398];
#endif #endif
uint16_t lp_allp1_idx; uint16_t lp_allp1_idx;
uint16_t lp_allp2_idx; uint16_t lp_allp2_idx;
@ -157,10 +161,10 @@ private:
float32_t loop_allp_k; // loop allpass coeff (default 0.6) float32_t loop_allp_k; // loop allpass coeff (default 0.6)
float32_t lp_allp_out; float32_t lp_allp_out;
#ifndef REVERB_USE_DMAMEM #ifndef REVERB_USE_DMAMEM
float32_t lp_dly1_buf[1423]; float32_t lp_dly1_buf[3423];
float32_t lp_dly2_buf[1589]; float32_t lp_dly2_buf[4589];
float32_t lp_dly3_buf[1365]; float32_t lp_dly3_buf[4365];
float32_t lp_dly4_buf[1698]; float32_t lp_dly4_buf[3698];
#endif #endif
uint16_t lp_dly1_idx; uint16_t lp_dly1_idx;
uint16_t lp_dly2_idx; uint16_t lp_dly2_idx;
@ -197,7 +201,7 @@ private:
float32_t master_lowpass_l; float32_t master_lowpass_l;
float32_t master_lowpass_r; float32_t master_lowpass_r;
const float32_t rv_time_k_max = 0.95; const float32_t rv_time_k_max = 0.95f;
float32_t rv_time_k; // reverb time coeff float32_t rv_time_k; // reverb time coeff
float32_t rv_time_scaler; // with high lodamp settings lower the max reverb time to avoid clipping float32_t rv_time_scaler; // with high lodamp settings lower the max reverb time to avoid clipping

Loading…
Cancel
Save