Small fixes for chorus.

master
Holger Wirtz 5 years ago
parent f196fe60cd
commit 81de0af5b7
  1. 12
      UI.hpp
  2. 6
      config.h
  3. 35
      effect_modulated_delay.cpp
  4. 3
      effect_modulated_delay.h

@ -212,7 +212,7 @@ char* get_comp_attack_value_text(void)
char comp_decay_value_text1[] = " ";
char* get_comp_decay_value_text(void)
{
sprintf(comp_decay_value_text1, "%0.1f dB/s", (float)configuration.comp_decay / 10);
sprintf(comp_decay_value_text1, "%0.1f dB/s", float(configuration.comp_decay) / 10);
return (comp_decay_value_text1);
}
@ -228,15 +228,15 @@ char* get_tune_value_text(void)
char chorus_frequency_value_text1[] = " ";
char* get_chorus_frequency_value_text(void)
{
sprintf(chorus_frequency_value_text1, "%2.1f Hz", (float)configuration.chorus_frequency / 10);
sprintf(chorus_frequency_value_text1, "%2.1f Hz", float(configuration.chorus_frequency) / 10);
return (chorus_frequency_value_text1);
}
char chorus_delay_value_text1[] = " ";
char chorus_delay_value_text1[] = " ";
char* get_chorus_delay_value_text(void)
{
sprintf(chorus_delay_value_text1, "%2d ms", configuration.chorus_delay);
sprintf(chorus_delay_value_text1, "%2.1f ms", float(configuration.chorus_delay) / 10);
return (chorus_delay_value_text1);
}
@ -2046,8 +2046,8 @@ void set_chorus_delay(uint8_t value)
Serial.print(F("Set CHORUS_DELAY "));
Serial.println(value);
#endif
modchorus_r.setDelayLength(float(value));
modchorus_l.setDelayLength(float(value));
modchorus_r.setDelay(float(value / 10));
modchorus_l.setDelay(float(value / 10));
configuration.chorus_delay = value;
}

@ -64,7 +64,7 @@
#define INTERPOLATION_WINDOW_SIZE 7 // use only odd numbers!!!
#define INTERPOLATE QUADRATIC // LINEAR QUADRATIC COSINE CUBIC LAGRANGE
#define CHORUS_WAVEFORM WAVEFORM_SINE // WAVEFORM_SINE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE WAVEFORM_SQUARE WAVEFORM_TRIANGLE
#define CHORUS_DELAY_LENGTH_SAMPLES (16*AUDIO_BLOCK_SAMPLES)
#define CHORUS_DELAY_LENGTH_SAMPLES (14*AUDIO_BLOCK_SAMPLES) // one AUDIO_BLOCK_SAMPLES = 2.902ms; you need doubled length, e.g. delay point is 20ms, so you need up to 40ms delay!
//*************************************************************************************************
//* DEBUG OUTPUT SETTINGS
@ -237,8 +237,8 @@
#define ENC_CHORUS_FREQUENCY_DEFAULT 30
//
#define ENC_CHORUS_DELAY_MIN 0
#define ENC_CHORUS_DELAY_MAX 20
#define ENC_CHORUS_DELAY_DEFAULT 15
#define ENC_CHORUS_DELAY_MAX 200
#define ENC_CHORUS_DELAY_DEFAULT 200
//
#define ENC_CHORUS_INTENSITY_MIN 0
#define ENC_CHORUS_INTENSITY_MAX 100

@ -39,29 +39,29 @@
boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length)
{
#if 0
Serial.print("AudioEffectModulatedDelay.begin(Chorus delay line length = ");
Serial.print(F("AudioEffectModulatedDelay.begin(Chorus delay line length = "));
Serial.print(d_length);
Serial.println(")");
Serial.println(F(")");
#endif
_delayline = NULL;
_delay_length = 0;
_circ_idx = 0;
_delayline = NULL;
_delay_length = 0;
_circ_idx = 0;
if (delayline == NULL) {
return (false);
return (false);
}
if (d_length < 10) {
return (false);
return (false);
}
_delayline = delayline;
_delay_length = _max_delay_length = d_length;
_delay_length_half = _delay_length / 2;
_delay_length = _max_delay_length = d_length;
_delay_length_half = _delay_length / 2;
memset(_delayline, 0, sizeof(int16_t)*_delay_length);
memset(_delayline, 0, sizeof(int16_t)*_delay_length);
return (true);
return (true);
}
void AudioEffectModulatedDelay::update(void)
@ -136,7 +136,7 @@ void AudioEffectModulatedDelay::update(void)
*bp = int(modulation_interpolate.LagrangeInterpolate() + 0.5);
#else
// No interpolation - should sound really bad...
int16_t c_mod_idx = int(mod_idx + 0.5) + _circ_idx;
int16_t c_mod_idx = (int(mod_idx + 0.5) + _circ_idx) % _delay_length;
if (c_mod_idx < 0)
*bp = _delayline[_delay_length + c_mod_idx];
else
@ -144,7 +144,7 @@ void AudioEffectModulatedDelay::update(void)
#endif
#else
// No interpolation - should sound really bad...
int16_t c_mod_idx = int(mod_idx + 0.5) + _circ_idx;
int16_t c_mod_idx = (int(mod_idx + 0.5) + _circ_idx) % _delay_length;
if (c_mod_idx < 0)
*bp = _delayline[_delay_length + c_mod_idx];
else
@ -167,13 +167,8 @@ void AudioEffectModulatedDelay::update(void)
release(modulation);
}
void AudioEffectModulatedDelay::setDelayLength(float milliseconds)
void AudioEffectModulatedDelay::setDelay(float milliseconds)
{
_delay_length = min(AUDIO_SAMPLE_RATE / milliseconds, _max_delay_length);
_delay_length = min(AUDIO_SAMPLE_RATE * milliseconds / 500, _max_delay_length);
_delay_length_half = _delay_length / 2;
}
float AudioEffectModulatedDelay::getMaxDelayLength(void)
{
return (AUDIO_SAMPLE_RATE / _max_delay_length);
}

@ -46,8 +46,7 @@ class AudioEffectModulatedDelay :
boolean begin(short *delayline, int delay_length);
virtual void update(void);
virtual void setDelayLength(float milliseconds);
virtual float getMaxDelayLength(void);
virtual void setDelay(float milliseconds);
private:
audio_block_t *inputQueueArray[2];

Loading…
Cancel
Save