Small fixes for chorus.

master
Holger Wirtz 6 years ago
parent f196fe60cd
commit 81de0af5b7
  1. 10
      UI.hpp
  2. 6
      config.h
  3. 17
      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 comp_decay_value_text1[] = " ";
char* get_comp_decay_value_text(void) 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); return (comp_decay_value_text1);
} }
@ -228,7 +228,7 @@ char* get_tune_value_text(void)
char chorus_frequency_value_text1[] = " "; char chorus_frequency_value_text1[] = " ";
char* get_chorus_frequency_value_text(void) 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); return (chorus_frequency_value_text1);
} }
@ -236,7 +236,7 @@ char* get_chorus_frequency_value_text(void)
char chorus_delay_value_text1[] = " "; char chorus_delay_value_text1[] = " ";
char* get_chorus_delay_value_text(void) 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); return (chorus_delay_value_text1);
} }
@ -2046,8 +2046,8 @@ void set_chorus_delay(uint8_t value)
Serial.print(F("Set CHORUS_DELAY ")); Serial.print(F("Set CHORUS_DELAY "));
Serial.println(value); Serial.println(value);
#endif #endif
modchorus_r.setDelayLength(float(value)); modchorus_r.setDelay(float(value / 10));
modchorus_l.setDelayLength(float(value)); modchorus_l.setDelay(float(value / 10));
configuration.chorus_delay = value; configuration.chorus_delay = value;
} }

@ -64,7 +64,7 @@
#define INTERPOLATION_WINDOW_SIZE 7 // use only odd numbers!!! #define INTERPOLATION_WINDOW_SIZE 7 // use only odd numbers!!!
#define INTERPOLATE QUADRATIC // LINEAR QUADRATIC COSINE CUBIC LAGRANGE #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_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 //* DEBUG OUTPUT SETTINGS
@ -237,8 +237,8 @@
#define ENC_CHORUS_FREQUENCY_DEFAULT 30 #define ENC_CHORUS_FREQUENCY_DEFAULT 30
// //
#define ENC_CHORUS_DELAY_MIN 0 #define ENC_CHORUS_DELAY_MIN 0
#define ENC_CHORUS_DELAY_MAX 20 #define ENC_CHORUS_DELAY_MAX 200
#define ENC_CHORUS_DELAY_DEFAULT 15 #define ENC_CHORUS_DELAY_DEFAULT 200
// //
#define ENC_CHORUS_INTENSITY_MIN 0 #define ENC_CHORUS_INTENSITY_MIN 0
#define ENC_CHORUS_INTENSITY_MAX 100 #define ENC_CHORUS_INTENSITY_MAX 100

@ -39,9 +39,9 @@
boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length) boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length)
{ {
#if 0 #if 0
Serial.print("AudioEffectModulatedDelay.begin(Chorus delay line length = "); Serial.print(F("AudioEffectModulatedDelay.begin(Chorus delay line length = "));
Serial.print(d_length); Serial.print(d_length);
Serial.println(")"); Serial.println(F(")");
#endif #endif
_delayline = NULL; _delayline = NULL;
@ -136,7 +136,7 @@ void AudioEffectModulatedDelay::update(void)
*bp = int(modulation_interpolate.LagrangeInterpolate() + 0.5); *bp = int(modulation_interpolate.LagrangeInterpolate() + 0.5);
#else #else
// No interpolation - should sound really bad... // 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) if (c_mod_idx < 0)
*bp = _delayline[_delay_length + c_mod_idx]; *bp = _delayline[_delay_length + c_mod_idx];
else else
@ -144,7 +144,7 @@ void AudioEffectModulatedDelay::update(void)
#endif #endif
#else #else
// No interpolation - should sound really bad... // 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) if (c_mod_idx < 0)
*bp = _delayline[_delay_length + c_mod_idx]; *bp = _delayline[_delay_length + c_mod_idx];
else else
@ -167,13 +167,8 @@ void AudioEffectModulatedDelay::update(void)
release(modulation); 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; _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); boolean begin(short *delayline, int delay_length);
virtual void update(void); virtual void update(void);
virtual void setDelayLength(float milliseconds); virtual void setDelay(float milliseconds);
virtual float getMaxDelayLength(void);
private: private:
audio_block_t *inputQueueArray[2]; audio_block_t *inputQueueArray[2];

Loading…
Cancel
Save