Rewrite of delay offset for modulated-delay.

dev
Holger Wirtz 5 years ago
parent df29c71f8e
commit 686a861621
  1. 25
      MicroMDAEPiano.ino
  2. 21
      UI.hpp
  3. 14
      config.h
  4. 3
      effect_modulated_delay.h

@ -166,8 +166,8 @@ elapsedMillis debug_audio_timer;
#endif
// Allocate the delay lines for left and right channels
short l_delayline[CHORUS_DELAY_LENGTH_SAMPLES];
short r_delayline[CHORUS_DELAY_LENGTH_SAMPLES];
short l_delayline[MOD_DELAY_SAMPLE_BUFFER];
short r_delayline[MOD_DELAY_SAMPLE_BUFFER];
enum { VOL_MAIN, VOL_REVERB, VOL_CHORUS };
//*************************************************************************************************
@ -232,22 +232,33 @@ void setup()
Serial.print(audio_block_time_us);
Serial.println(F("us)"));
if (!modchorus_r.begin(r_delayline, CHORUS_DELAY_LENGTH_SAMPLES)) {
if (!modchorus_r.begin(r_delayline, MOD_DELAY_SAMPLE_BUFFER)) {
Serial.println(F("AudioEffectModulatedDelay - right channel begin failed"));
while (1);
}
if (!modchorus_l.begin(l_delayline, CHORUS_DELAY_LENGTH_SAMPLES)) {
if (!modchorus_l.begin(l_delayline, MOD_DELAY_SAMPLE_BUFFER)) {
Serial.println(F("AudioEffectModulatedDelay - left channel begin failed"));
while (1);
}
// chorus modulation fixed
modulator.begin(WAVEFORM_MOD);
modulator.begin(MOD_WAVEFORM);
modulator.phase(0);
modulator.amplitude(0.0);
modulator.offset(0.0);
modchorus_r.offset(0);
modchorus_l.offset(0);
#ifdef DEBUG
Serial.print(F("Modulated delay buffer: "));
Serial.print(MOD_DELAY_SAMPLE_BUFFER, DEC);
Serial.println(F(" samples"));
Serial.print(F("Default delay time: "));
Serial.print(float(ENC_CHORUS_DELAY_DEFAULT) / 10, 2);
Serial.println(" ms");
Serial.print(F("Max delay time: "));
Serial.print(float(ENC_CHORUS_DELAY_MAX) / 10, 2);
Serial.println(F(" ms"));
#endif
modchorus_r.offset(TIME_MS2SAMPLES(float(ENC_CHORUS_DELAY_DEFAULT) / 10));
modchorus_l.offset(TIME_MS2SAMPLES(float(ENC_CHORUS_DELAY_DEFAULT) / 10));
// 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, "%03d%%", configuration.chorus_delay);
sprintf(chorus_delay_value_text1, "%02.1f ms", float(configuration.chorus_delay + ENC_CHORUS_DELAY_MAX) / 10);
return (chorus_delay_value_text1);
}
@ -2228,10 +2228,15 @@ void set_chorus_delay(uint8_t value)
value = ENC_CHORUS_DELAY_MAX;
#ifdef SHOW_DEBUG
Serial.print(F("Set CHORUS_DELAY "));
Serial.println(value);
#endif
modchorus_r.offset(value);
modchorus_l.offset(value);
Serial.print(value);
Serial.print(F("/"));
Serial.print(float(value) / 10);
Serial.print(F("/"));
Serial.print(uint16_t(TIME_MS2SAMPLES(float(value) / 10)));
Serial.println();
#endif
modchorus_r.offset(TIME_MS2SAMPLES(float(value) / 10));
modchorus_l.offset(TIME_MS2SAMPLES(float(value) / 10));
configuration.chorus_delay = value;
}
@ -2256,8 +2261,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;

@ -57,9 +57,13 @@
#define SAMPLE_RATE AUDIO_SAMPLE_RATE
#define REDUCE_LOUDNESS 0
#define USE_XFADE_DATA 1
/* HELPER MACROS */
#define TIME_MS2SAMPLES(x) floor(x * AUDIO_SAMPLE_RATE / 1000)
#define SAMPLES2TIME_MS(x) float(x * 1000 / AUDIO_SAMPLE_RATE)
// CHORUS parameters
#define CHORUS_DELAY_LENGTH_SAMPLES (16*AUDIO_BLOCK_SAMPLES) // one AUDIO_BLOCK_SAMPLES = 2.902ms
#define WAVEFORM_MOD WAVEFORM_TRIANGLE // WAVEFORM_SINE WAVEFORM_TRIANGLE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE
#define MOD_DELAY_SAMPLE_BUFFER int32_t(TIME_MS2SAMPLES(10.0))
#define MOD_WAVEFORM WAVEFORM_TRIANGLE // WAVEFORM_SINE WAVEFORM_TRIANGLE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE
//*************************************************************************************************
//* DEBUG OUTPUT SETTINGS
@ -137,7 +141,7 @@
//* DO NO CHANGE ANYTHING BEYOND IF YOU DON'T KNOW WHAT YOU ARE DOING !!!
//*************************************************************************************************
#define MICRO_MDAEPIANO_VERSION "0.9.8"
#define MICRO_MDAEPIANO_VERSION "0.9.9"
#define MAX_SOUNDS min(99,int((4096-EEPROM_CONFIGURATIONS)/sizeof(config_t)))
@ -235,8 +239,8 @@
#define ENC_CHORUS_FREQUENCY_DEFAULT 30
//
#define ENC_CHORUS_DELAY_MIN 0
#define ENC_CHORUS_DELAY_MAX 100
#define ENC_CHORUS_DELAY_DEFAULT 70
#define ENC_CHORUS_DELAY_MAX uint8_t(SAMPLES2TIME_MS(float(MOD_DELAY_SAMPLE_BUFFER/2)*10))
#define ENC_CHORUS_DELAY_DEFAULT uint8_t(float(ENC_CHORUS_DELAY_MAX/2))
//
#define ENC_CHORUS_INTENSITY_MIN 0
#define ENC_CHORUS_INTENSITY_MAX 100

@ -34,6 +34,9 @@
// 140219 - correct storage class (not static)
// 190527 - added modulation input handling (Aug 2019 by Holger Wirtz)
#define TIME_MS2SAMPLES(x) floor(x * AUDIO_SAMPLE_RATE / 1000)
#define SAMPLES2TIME_MS(x) float(x * 1000 / AUDIO_SAMPLE_RATE)
class AudioEffectModulatedDelay :
public AudioStream
{

Loading…
Cancel
Save