Fixes for stereo-panning.

Fixes for dynamic memory allocation of the delaylines for chorus effects.
pull/112/head
Holger Wirtz 3 years ago
parent 8aaf3b92d4
commit 109462f0b0
  1. 23
      MicroDexed.ino
  2. 6
      UI.hpp
  3. 26
      effect_stereo_panorama.cpp

@ -407,10 +407,10 @@ int perform_release_mod[NUM_DEXED] = { 0 };
#endif #endif
#if defined(USE_FX) #if defined(USE_FX)
// Allocate the delay lines for chorus // Allocate the delay lines for chorus
int16_t delayline[NUM_DEXED][MOD_DELAY_SAMPLE_BUFFER]; int16_t* delayline[NUM_DEXED];
#ifdef USE_EPIANO #ifdef USE_EPIANO
int16_t ep_delayline_r[MOD_DELAY_SAMPLE_BUFFER]; int16_t* ep_delayline_r;
int16_t ep_delayline_l[MOD_DELAY_SAMPLE_BUFFER]; int16_t* ep_delayline_l;
#endif #endif
#endif #endif
@ -589,7 +589,8 @@ void setup()
#if defined(USE_FX) #if defined(USE_FX)
#if defined(USE_EPIANO) #if defined(USE_EPIANO)
// EP_CHORUS // EP_CHORUS
memset(ep_delayline_r, 0, sizeof(ep_delayline_r)); ep_delayline_l = new int16_t[MOD_DELAY_SAMPLE_BUFFER];
memset(ep_delayline_r, 0, MOD_DELAY_SAMPLE_BUFFER * sizeof(int16_t));
if (!ep_modchorus_r.begin(ep_delayline_r, MOD_DELAY_SAMPLE_BUFFER)) if (!ep_modchorus_r.begin(ep_delayline_r, MOD_DELAY_SAMPLE_BUFFER))
{ {
#ifdef DEBUG #ifdef DEBUG
@ -597,7 +598,8 @@ void setup()
#endif #endif
while (1); while (1);
} }
memset(ep_delayline_l, 0, sizeof(ep_delayline_l)); ep_delayline_r = new int16_t[MOD_DELAY_SAMPLE_BUFFER];
memset(ep_delayline_l, 0, MOD_DELAY_SAMPLE_BUFFER * sizeof(int16_t));
if (!ep_modchorus_l.begin(ep_delayline_l, MOD_DELAY_SAMPLE_BUFFER)) if (!ep_modchorus_l.begin(ep_delayline_l, MOD_DELAY_SAMPLE_BUFFER))
{ {
#ifdef DEBUG #ifdef DEBUG
@ -628,8 +630,9 @@ void setup()
// Setup effects // Setup effects
#if defined(USE_FX) #if defined(USE_FX)
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
memset(delayline[instance_id], 0, sizeof(delayline[instance_id])); delayline[instance_id] = new int16_t[MOD_DELAY_SAMPLE_BUFFER];
memset(delayline[instance_id], 0, MOD_DELAY_SAMPLE_BUFFER * sizeof(int16_t));
if (!modchorus[instance_id]->begin(delayline[instance_id], MOD_DELAY_SAMPLE_BUFFER)) { if (!modchorus[instance_id]->begin(delayline[instance_id], MOD_DELAY_SAMPLE_BUFFER)) {
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("AudioEffectModulatedDelay - begin failed [")); Serial.print(F("AudioEffectModulatedDelay - begin failed ["));
@ -653,7 +656,7 @@ void setup()
sd_card = check_sd_cards(); sd_card = check_sd_cards();
if (sd_card < 1) if (sd_card < 1)
{ {
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("SD card not accessable.")); Serial.println(F("SD card not accessable."));
#endif #endif
@ -691,7 +694,7 @@ void setup()
// Load voices // Load voices
#ifdef DEBUG #ifdef DEBUG
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
Serial.print(F("Dexed instance ")); Serial.print(F("Dexed instance "));
Serial.print(instance_id); Serial.print(instance_id);
Serial.println(F(":")); Serial.println(F(":"));
@ -717,7 +720,7 @@ void setup()
// Init master_mixer // Init master_mixer
#if NUM_DEXED > 1 #if NUM_DEXED > 1
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
master_mixer_r.gain(instance_id, VOL_MAX_FLOAT); master_mixer_r.gain(instance_id, VOL_MAX_FLOAT);
master_mixer_l.gain(instance_id, VOL_MAX_FLOAT); master_mixer_l.gain(instance_id, VOL_MAX_FLOAT);
} }

@ -3065,7 +3065,7 @@ void UI_func_epiano_chorus_frequency(uint8_t param)
if (LCDML.FUNC_loop()) // ****** LOOP ********* if (LCDML.FUNC_loop()) // ****** LOOP *********
{ {
if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()))
{ {
if (LCDML.BT_checkDown()) if (LCDML.BT_checkDown())
configuration.fx.ep_chorus_frequency = constrain(configuration.fx.ep_chorus_frequency + ENCODER[ENC_R].speed(), EP_CHORUS_FREQUENCY_MIN, EP_CHORUS_FREQUENCY_MAX); configuration.fx.ep_chorus_frequency = constrain(configuration.fx.ep_chorus_frequency + ENCODER[ENC_R].speed(), EP_CHORUS_FREQUENCY_MIN, EP_CHORUS_FREQUENCY_MAX);
@ -3145,7 +3145,7 @@ void UI_func_epiano_chorus_depth(uint8_t param)
if (LCDML.FUNC_loop()) // ****** LOOP ********* if (LCDML.FUNC_loop()) // ****** LOOP *********
{ {
if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()))
{ {
if (LCDML.BT_checkDown()) if (LCDML.BT_checkDown())
configuration.fx.ep_chorus_depth = constrain(configuration.fx.ep_chorus_depth + ENCODER[ENC_R].speed(), EP_CHORUS_DEPTH_MIN, EP_CHORUS_DEPTH_MAX); configuration.fx.ep_chorus_depth = constrain(configuration.fx.ep_chorus_depth + ENCODER[ENC_R].speed(), EP_CHORUS_DEPTH_MIN, EP_CHORUS_DEPTH_MAX);
@ -3178,7 +3178,7 @@ void UI_func_epiano_chorus_level(uint8_t param)
if (LCDML.FUNC_loop()) // ****** LOOP ********* if (LCDML.FUNC_loop()) // ****** LOOP *********
{ {
if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()))
{ {
if (LCDML.BT_checkDown()) if (LCDML.BT_checkDown())
{ {

@ -68,18 +68,8 @@ inline float mapfloat(float val, float in_min, float in_max, float out_min, floa
void AudioEffectStereoPanorama::panorama(float p) void AudioEffectStereoPanorama::panorama(float p)
{ {
if (p == 0.5) pan_r = mapfloat(p, 0.0, 1.0, -1.0, 1.0);
pan_l = pan_r = 1.0; pan_l = pan_r * -1.0;
else if (p > 0.5)
{
pan_r = 0.5 - abs(0.5 - p);
pan_l = 1.0 - pan_r;
}
else
{
pan_l = 0.5 - abs(0.5 - p);
pan_r = 1.0 - p;
}
} }
void AudioEffectStereoPanorama::update(void) void AudioEffectStereoPanorama::update(void)
@ -105,10 +95,14 @@ void AudioEffectStereoPanorama::update(void)
for (uint16_t n = 0; n < AUDIO_BLOCK_SAMPLES; n++) for (uint16_t n = 0; n < AUDIO_BLOCK_SAMPLES; n++)
{ {
out_f[0][n] = in_f[0][n] * pan_r; if (pan_r > 0.0)
out_f[0][n] += in_f[1][n] * pan_l; out_f[0][n] = (pan_r / 2.0 * in_f[1][n]) + ((1.0 - pan_r) / 2.0 * in_f[0][n]);
out_f[1][n] = in_f[1][n] * pan_r; else
out_f[1][n] += in_f[0][n] * pan_l; 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];
} }
arm_float_to_q15(out_f[0], out[0]->data, AUDIO_BLOCK_SAMPLES); arm_float_to_q15(out_f[0], out[0]->data, AUDIO_BLOCK_SAMPLES);

Loading…
Cancel
Save