Several small fixes for modulated delay offset and amplitude calculation.

master
Holger Wirtz 5 years ago
parent 4dcc68e42c
commit 4244fe6727
  1. 18
      MicroMDAEPiano.ino
  2. 2
      UI.hpp
  3. 10
      config.h
  4. 13
      effect_modulated_delay.cpp
  5. 8
      effect_modulated_delay.h

@ -248,17 +248,23 @@ void setup()
modulator.offset(0.0); modulator.offset(0.0);
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Modulated delay buffer: ")); Serial.print(F("Modulated delay buffer: "));
Serial.print(SAMPLES2TIME_MS(MOD_DELAY_SAMPLE_BUFFER), 2);
Serial.print(F(" ms / "));
Serial.print(MOD_DELAY_SAMPLE_BUFFER, DEC); Serial.print(MOD_DELAY_SAMPLE_BUFFER, DEC);
Serial.println(F(" samples")); 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(F("Max delay time: "));
Serial.print(float(ENC_CHORUS_DELAY_MAX) / 10, 2); Serial.print(float(ENC_CHORUS_DELAY_MAX) / 10, 2);
Serial.println(F(" ms")); Serial.print(F(" ms / "));
Serial.print(uint16_t(TIME_MS2SAMPLES(float(ENC_CHORUS_DELAY_MAX) / 10)), DEC);
Serial.println(F(" samples"));
Serial.print(F("Default delay time: "));
Serial.print(float(ENC_CHORUS_DELAY_DEFAULT) / 10, 2);
Serial.print(F(" ms / "));
Serial.print(uint16_t(TIME_MS2SAMPLES(float(ENC_CHORUS_DELAY_DEFAULT) / 10)), DEC);
Serial.println(F(" samples"));
#endif #endif
modchorus_r.offset(TIME_MS2SAMPLES(float(ENC_CHORUS_DELAY_DEFAULT) / 10)); modchorus_r.offset(TIME_MS2SAMPLES(float(ENC_CHORUS_DELAY_MAX) / 10));
modchorus_l.offset(TIME_MS2SAMPLES(float(ENC_CHORUS_DELAY_DEFAULT) / 10)); modchorus_l.offset(TIME_MS2SAMPLES(float(ENC_CHORUS_DELAY_MAX) / 10));
// Butterworth filter, 12 db/octave // Butterworth filter, 12 db/octave
modchorus_filter_r.setLowpass(0, 6000, 0.707); modchorus_filter_r.setLowpass(0, 6000, 0.707);
modchorus_filter_l.setLowpass(0, 6000, 0.707); modchorus_filter_l.setLowpass(0, 6000, 0.707);

@ -243,7 +243,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, "%02.1f ms", float(configuration.chorus_delay + ENC_CHORUS_DELAY_MAX) / 10); sprintf(chorus_delay_value_text1, "%02.1f ms", float(configuration.chorus_delay) / 10);
return (chorus_delay_value_text1); return (chorus_delay_value_text1);
} }

@ -59,8 +59,8 @@
#define USE_XFADE_DATA 1 #define USE_XFADE_DATA 1
/* HELPER MACROS */ /* HELPER MACROS */
#define TIME_MS2SAMPLES(x) floor(x * AUDIO_SAMPLE_RATE / 1000) #define TIME_MS2SAMPLES(x) floor(uint32_t(x) * AUDIO_SAMPLE_RATE / 1000)
#define SAMPLES2TIME_MS(x) float(x * 1000 / AUDIO_SAMPLE_RATE) #define SAMPLES2TIME_MS(x) float(uint32_t(x) * 1000 / AUDIO_SAMPLE_RATE)
// CHORUS parameters // CHORUS parameters
#define MOD_DELAY_SAMPLE_BUFFER int32_t(TIME_MS2SAMPLES(10.0)) #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 #define MOD_WAVEFORM WAVEFORM_TRIANGLE // WAVEFORM_SINE WAVEFORM_TRIANGLE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE
@ -238,9 +238,9 @@
#define ENC_CHORUS_FREQUENCY_MAX 200 #define ENC_CHORUS_FREQUENCY_MAX 200
#define ENC_CHORUS_FREQUENCY_DEFAULT 30 #define ENC_CHORUS_FREQUENCY_DEFAULT 30
// //
#define ENC_CHORUS_DELAY_MIN 0 #define ENC_CHORUS_DELAY_MIN uint8_t(SAMPLES2TIME_MS(MOD_DELAY_SAMPLE_BUFFER>>2)*10+0.5)
#define ENC_CHORUS_DELAY_MAX uint8_t(SAMPLES2TIME_MS(float(MOD_DELAY_SAMPLE_BUFFER/2)*10)) #define ENC_CHORUS_DELAY_MAX uint8_t(SAMPLES2TIME_MS(MOD_DELAY_SAMPLE_BUFFER>>2)*30+0.5)
#define ENC_CHORUS_DELAY_DEFAULT uint8_t(float(ENC_CHORUS_DELAY_MAX/2)) #define ENC_CHORUS_DELAY_DEFAULT uint8_t(SAMPLES2TIME_MS(MOD_DELAY_SAMPLE_BUFFER>>2)*20+0.5)
// //
#define ENC_CHORUS_INTENSITY_MIN 0 #define ENC_CHORUS_INTENSITY_MIN 0
#define ENC_CHORUS_INTENSITY_MAX 100 #define ENC_CHORUS_INTENSITY_MAX 100

@ -29,8 +29,6 @@
extern config_t configuration; extern config_t configuration;
#define MODULATION_MAX_FACTOR 0.5 // Not sure to put this into a var?
/******************************************************************/ /******************************************************************/
// Based on; A u d i o E f f e c t D e l a y // Based on; A u d i o E f f e c t D e l a y
@ -39,7 +37,7 @@ extern config_t configuration;
// 140219 - correct storage class (not static) // 140219 - correct storage class (not static)
// 190527 - added modulation input (by Holger Wirtz) // 190527 - added modulation input (by Holger Wirtz)
boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length) boolean AudioEffectModulatedDelay::begin(short *delayline, uint16_t d_length)
{ {
#if 0 #if 0
Serial.print(F("AudioEffectModulatedDelay.begin(modulated-delay line length = ")); Serial.print(F("AudioEffectModulatedDelay.begin(modulated-delay line length = "));
@ -66,13 +64,18 @@ boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length)
return (true); return (true);
} }
void AudioEffectModulatedDelay::offset(uint8_t offset_value) // in % void AudioEffectModulatedDelay::offset(uint16_t offset_value) // in %
{ {
if (offset_value > 100) if (offset_value > 100)
offset_value = 100; offset_value = 100;
_delay_offset = floor(offset_value / 200.0 * _delay_length); _delay_offset = floor(offset_value / 200.0 * _delay_length);
} }
uint16_t AudioEffectModulatedDelay::get_delay_length(void)
{
return (_delay_length);
}
void AudioEffectModulatedDelay::update(void) void AudioEffectModulatedDelay::update(void)
{ {
audio_block_t *block; audio_block_t *block;
@ -106,7 +109,7 @@ void AudioEffectModulatedDelay::update(void)
_delayline[_cb_index] = *bp; _delayline[_cb_index] = *bp;
// calculate the modulation-index as a floating point number for interpolation // calculate the modulation-index as a floating point number for interpolation
mod_index = *mp * MODULATION_MAX_FACTOR * _delay_length; mod_index = *mp * (_delay_length >> 2);
mod_fraction = modff(mod_index, &mod_number); // split float of mod_index into integer (= mod_number) and fraction part mod_fraction = modff(mod_index, &mod_number); // split float of mod_index into integer (= mod_number) and fraction part
// calculate modulation index into circular buffer // calculate modulation index into circular buffer

@ -34,9 +34,6 @@
// 140219 - correct storage class (not static) // 140219 - correct storage class (not static)
// 190527 - added modulation input handling (Aug 2019 by Holger Wirtz) // 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 : class AudioEffectModulatedDelay :
public AudioStream public AudioStream
{ {
@ -45,9 +42,10 @@ class AudioEffectModulatedDelay :
AudioStream(2, inputQueueArray) AudioStream(2, inputQueueArray)
{ } { }
boolean begin(short *delayline, int delay_length); boolean begin(short *delayline, uint16_t delay_length);
virtual void update(void); virtual void update(void);
virtual void offset(uint8_t offset_value); virtual void offset(uint16_t offset_value);
virtual uint16_t get_delay_length(void);
private: private:
void set_modulator_filter_coeffs(void); void set_modulator_filter_coeffs(void);

Loading…
Cancel
Save