Exchanged delay offset calculation from time to bytes (or better percent).

dev
Holger Wirtz 5 years ago
parent 7e24df7a46
commit df29c71f8e
  1. 4
      MicroMDAEPiano.ino
  2. 12
      UI.hpp
  3. 4
      config.h
  4. 17
      effect_modulated_delay.cpp
  5. 2
      effect_modulated_delay.h

@ -246,8 +246,8 @@ void setup()
modulator.phase(0);
modulator.amplitude(0.0);
modulator.offset(0.0);
modchorus_r.offset(15.0);
modchorus_l.offset(15.0);
modchorus_r.offset(0);
modchorus_l.offset(0);
// Butterworth filter, 12 db/octave
modchorus_filter_r.setLowpass(0, 6000, 0.707);
modchorus_filter_l.setLowpass(0, 6000, 0.707);

@ -240,10 +240,10 @@ char* get_chorus_frequency_value_text(void)
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, "%2.1f ms", float(configuration.chorus_delay) / 10);
sprintf(chorus_delay_value_text1, "%03d%%", configuration.chorus_delay);
return (chorus_delay_value_text1);
}
@ -2230,8 +2230,8 @@ void set_chorus_delay(uint8_t value)
Serial.print(F("Set CHORUS_DELAY "));
Serial.println(value);
#endif
modchorus_r.offset(float(value) / 10);
modchorus_l.offset(float(value) / 10);
modchorus_r.offset(value);
modchorus_l.offset(value);
configuration.chorus_delay = value;
}
@ -2256,8 +2256,8 @@ void set_chorus_feedback(uint8_t value)
Serial.println(value);
#endif
float tmp = mapfloat(float(value), ENC_CHORUS_FEEDBACK_MIN, ENC_CHORUS_FEEDBACK_MAX, 0.0, 0.5);
modchorus_fbk_mixer_r.gain(0, 1.0 - tmp);
modchorus_fbk_mixer_l.gain(0, 1.0 - tmp);
//modchorus_fbk_mixer_r.gain(0, 1.0 - tmp);
//modchorus_fbk_mixer_l.gain(0, 1.0 - tmp);
modchorus_fbk_mixer_r.gain(1, tmp);
modchorus_fbk_mixer_l.gain(1, tmp);
configuration.chorus_feedback = value;

@ -235,8 +235,8 @@
#define ENC_CHORUS_FREQUENCY_DEFAULT 30
//
#define ENC_CHORUS_DELAY_MIN 0
#define ENC_CHORUS_DELAY_MAX 200
#define ENC_CHORUS_DELAY_DEFAULT 200
#define ENC_CHORUS_DELAY_MAX 100
#define ENC_CHORUS_DELAY_DEFAULT 70
//
#define ENC_CHORUS_INTENSITY_MIN 0
#define ENC_CHORUS_INTENSITY_MAX 100

@ -49,7 +49,7 @@ boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length)
_delayline = NULL;
_delay_length = 0;
_delay_offset = 0.0;
_delay_offset = 0;
_cb_index = 0;
if (delayline == NULL) {
@ -66,18 +66,11 @@ boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length)
return (true);
}
float AudioEffectModulatedDelay::offset(float offset_value) // in ms
void AudioEffectModulatedDelay::offset(uint8_t offset_value) // in %
{
uint16_t offset_frames = floor((offset_value / 1000) * AUDIO_SAMPLE_RATE);
if (offset_frames > round(_delay_length * (1 - (MODULATION_MAX_FACTOR / 2))))
_delay_offset = floor(_delay_length * (1 - (MODULATION_MAX_FACTOR / 2)));
else if (offset_frames <= round(_delay_length * (MODULATION_MAX_FACTOR / 2)))
_delay_offset = floor(_delay_length * (MODULATION_MAX_FACTOR) / 2);
else
_delay_offset = offset_frames;
return (floor(offset_frames / AUDIO_SAMPLE_RATE * 1000));
if (offset_value > 100)
offset_value = 100;
_delay_offset = floor(offset_value / 200.0 * _delay_length);
}
void AudioEffectModulatedDelay::update(void)

@ -44,7 +44,7 @@ class AudioEffectModulatedDelay :
boolean begin(short *delayline, int delay_length);
virtual void update(void);
virtual float offset(float offset_value);
virtual void offset(uint8_t offset_value);
private:
void set_modulator_filter_coeffs(void);

Loading…
Cancel
Save