From 021dd2075ae2ccfec8a339e36572ca1a5686575d Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Wed, 22 Dec 2021 20:24:28 +0100 Subject: [PATCH] Several fixes. Newer version of plate reverb. --- MicroDexed.ino | 5 +---- config.h | 5 +++-- dexed_sd.cpp | 2 +- effect_mono_stereo.cpp | 2 +- effect_platervbstereo.cpp | 21 ++++++++++++++------- effect_platervbstereo.h | 10 +++++----- effect_stereo_panorama.cpp | 29 +++++++++++++++++++---------- effect_stereo_panorama.h | 9 +++------ 8 files changed, 47 insertions(+), 36 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index a8d614a..bcab22a 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -587,7 +587,6 @@ void setup() #if defined(USE_FX) #if defined(USE_EPIANO) // EP_CHORUS - //ep_delayline_r = new (std::nothrow) int16_t[MOD_DELAY_SAMPLE_BUFFER]; ep_delayline_r = (int16_t*)malloc(MOD_DELAY_SAMPLE_BUFFER * sizeof(int16_t)); if (ep_delayline_r != NULL) { @@ -608,7 +607,6 @@ void setup() while (1); } - //ep_delayline_l = new (std::nothrow) int16_t[MOD_DELAY_SAMPLE_BUFFER]; ep_delayline_l = (int16_t*)malloc(MOD_DELAY_SAMPLE_BUFFER * sizeof(int16_t)); if (ep_delayline_l != NULL) { @@ -644,7 +642,7 @@ void setup() ep_chorus_mixer_r.gain(1, mapfloat(EP_CHORUS_LEVEL_DEFAULT, EP_CHORUS_LEVEL_MIN, EP_CHORUS_LEVEL_MAX, 0.0, 0.5)); ep_chorus_mixer_l.gain(1, mapfloat(EP_CHORUS_LEVEL_DEFAULT, EP_CHORUS_LEVEL_MIN, EP_CHORUS_LEVEL_MAX, 0.0, 0.5)); ep_chorus_inverter.gain(-1.0); - ep_stereo_panorama.panorama(mapfloat(EP_PANORAMA_DEFAULT, EP_PANORAMA_DEFAULT, EP_PANORAMA_DEFAULT, 0.0, 1.0)); + ep_stereo_panorama.panorama(mapfloat(EP_PANORAMA_DEFAULT, EP_PANORAMA_MIN, EP_PANORAMA_MAX, -1.0, 1.0)); #endif #endif @@ -652,7 +650,6 @@ void setup() #if defined(USE_FX) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) { - //delayline[instance_id] = new (std::nothrow) int16_t[MOD_DELAY_SAMPLE_BUFFER]; delayline[instance_id] = (int16_t*)malloc(MOD_DELAY_SAMPLE_BUFFER * sizeof(int16_t)); if (delayline[instance_id] != NULL) { diff --git a/config.h b/config.h index 579aa43..ab4e264 100644 --- a/config.h +++ b/config.h @@ -725,7 +725,7 @@ #define EP_TREBLE_DEFAULT 50 #define EP_PAN_TREMOLO_MIN 0 -#define EP_PAN_TREMOLO_MAX 40 +#define EP_PAN_TREMOLO_MAX 100 #define EP_PAN_TREMOLO_DEFAULT 20 #define EP_PAN_LFO_MIN 0 @@ -930,7 +930,8 @@ enum reverb_mixer_ports { REVERB_MIX_CH_DRUMS, REVERB_MIX_CH_EPIANO }; -#if !defined(_MAPFLOAT) + +#ifndef _MAPFLOAT #define _MAPFLOAT inline float mapfloat(float val, float in_min, float in_max, float out_min, float out_max) { diff --git a/dexed_sd.cpp b/dexed_sd.cpp index e7aab60..72564cf 100644 --- a/dexed_sd.cpp +++ b/dexed_sd.cpp @@ -1000,7 +1000,7 @@ bool load_sd_epiano_json(uint8_t number) configuration.epiano.decay = data_json["decay"]; configuration.epiano.release = data_json["release"]; configuration.epiano.hardness = data_json["hardness"]; - configuration.epiano.treble = data_json["trebl"]; + configuration.epiano.treble = data_json["treble"]; configuration.epiano.pan_tremolo = data_json["pan_tremolo"]; configuration.epiano.pan_lfo = data_json["pan_lf"]; configuration.epiano.velocity_sense = data_json["velocity"]; diff --git a/effect_mono_stereo.cpp b/effect_mono_stereo.cpp index 54f6ef5..4d9d58d 100644 --- a/effect_mono_stereo.cpp +++ b/effect_mono_stereo.cpp @@ -57,7 +57,7 @@ static const audio_block_t zeroblock = { } }; -#if !defined(_MAPFLOAT) +#ifndef _MAPFLOAT #define _MAPFLOAT inline float mapfloat(float val, float in_min, float in_max, float out_min, float out_max) { diff --git a/effect_platervbstereo.cpp b/effect_platervbstereo.cpp index 32b3c1c..3617682 100644 --- a/effect_platervbstereo.cpp +++ b/effect_platervbstereo.cpp @@ -31,15 +31,13 @@ #include #include "effect_platervbstereo.h" -#include "utility/dspinst.h" -#include "synth_waveform.h" -#define INP_ALLP_COEFF (0.65f) -#define LOOP_ALLOP_COEFF (0.65f) +#define INP_ALLP_COEFF (0.65f) // default input allpass coeff +#define LOOP_ALLOP_COEFF (0.65f) // default loop allpass coeff -#define HI_LOSS_FREQ (0.3f) -#define HI_LOSS_FREQ_MAX (0.08f) -#define LO_LOSS_FREQ (0.06f) +#define HI_LOSS_FREQ (0.3f) // scaled center freq for the treble loss filter +// #define HI_LOSS_FREQ_MAX (0.08f) +#define LO_LOSS_FREQ (0.06f) // scaled center freq for the bass loss filter #define LFO_AMPL_BITS (5) // 2^LFO_AMPL_BITS will be the LFO amplitude #define LFO_AMPL ((1< 0.0) - out_f[0][n] = (pan_r / 2.0 * in_f[1][n]) + ((1.0 - pan_r) / 2.0 * in_f[0][n]); + if (pan != 0.0) + { + if (pan > 0.0) + { + out_f[0][n] = (pan / 2.0 * in_f[1][n]) + ((1.0 - pan) / 2.0 * in_f[0][n]); + out_f[1][n] = (1.0 - pan) * in_f[1][n]; + } + else + { + out_f[1][n] = (pan / 2.0 * in_f[0][n]) + ((1.0 - pan) / 2.0 * in_f[1][n]); + out_f[0][n] = (1.0 - pan) * in_f[0][n]; + } + } else - out_f[0][n] = abs(pan_r) * in_f[0][n]; - if (pan_l > 0.0) - out_f[1][n] = (pan_l / 2.0 * in_f[0][n]) + ((1.0 - pan_l) / 2.0 * in_f[1][n]); - else - out_f[1][n] = abs(pan_l) * in_f[1][n]; + { + out_f[0][n] = in_f[0][n]; + out_f[1][n] = in_f[1][n]; + } } arm_float_to_q15(out_f[0], out[0]->data, AUDIO_BLOCK_SAMPLES); diff --git a/effect_stereo_panorama.h b/effect_stereo_panorama.h index cacbbc1..c07a338 100644 --- a/effect_stereo_panorama.h +++ b/effect_stereo_panorama.h @@ -33,10 +33,9 @@ class AudioEffectStereoPanorama : public AudioStream { public: AudioEffectStereoPanorama(void): - AudioStream(1, inputQueueArray) + AudioStream(2, inputQueueArray) { - pan_l = 1.0; - pan_r = 1.0; + pan = 0.0; } virtual void update(void); @@ -47,9 +46,7 @@ class AudioEffectStereoPanorama : public AudioStream audio_block_t *out[2]; float in_f[2][AUDIO_BLOCK_SAMPLES]; float out_f[2][AUDIO_BLOCK_SAMPLES]; - float pan_l; - float pan_r; - const float _pseudo_log = 1048575 / (float)(1 << 20); + float pan; }; #endif