Several small fixes for modulated delay offset and amplitude calculation.

dev
Holger Wirtz 5 years ago
parent 686a861621
commit 812dff60aa
  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);
#ifdef DEBUG
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.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"));
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
modchorus_r.offset(TIME_MS2SAMPLES(float(ENC_CHORUS_DELAY_DEFAULT) / 10));
modchorus_l.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_MAX) / 10));
// Butterworth filter, 12 db/octave
modchorus_filter_r.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* 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);
}

@ -59,8 +59,8 @@
#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)
#define TIME_MS2SAMPLES(x) floor(uint32_t(x) * AUDIO_SAMPLE_RATE / 1000)
#define SAMPLES2TIME_MS(x) float(uint32_t(x) * 1000 / AUDIO_SAMPLE_RATE)
// CHORUS parameters
#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
@ -238,9 +238,9 @@
#define ENC_CHORUS_FREQUENCY_MAX 200
#define ENC_CHORUS_FREQUENCY_DEFAULT 30
//
#define ENC_CHORUS_DELAY_MIN 0
#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_DELAY_MIN uint8_t(SAMPLES2TIME_MS(MOD_DELAY_SAMPLE_BUFFER>>2)*10+0.5)
#define ENC_CHORUS_DELAY_MAX uint8_t(SAMPLES2TIME_MS(MOD_DELAY_SAMPLE_BUFFER>>2)*30+0.5)
#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_MAX 100

@ -29,8 +29,6 @@
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
@ -39,7 +37,7 @@ extern config_t configuration;
// 140219 - correct storage class (not static)
// 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
Serial.print(F("AudioEffectModulatedDelay.begin(modulated-delay line length = "));
@ -66,13 +64,18 @@ boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length)
return (true);
}
void AudioEffectModulatedDelay::offset(uint8_t offset_value) // in %
void AudioEffectModulatedDelay::offset(uint16_t offset_value) // in %
{
if (offset_value > 100)
offset_value = 100;
_delay_offset = floor(offset_value / 200.0 * _delay_length);
}
uint16_t AudioEffectModulatedDelay::get_delay_length(void)
{
return (_delay_length);
}
void AudioEffectModulatedDelay::update(void)
{
audio_block_t *block;
@ -106,7 +109,7 @@ void AudioEffectModulatedDelay::update(void)
_delayline[_cb_index] = *bp;
// 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
// calculate modulation index into circular buffer

@ -34,9 +34,6 @@
// 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
{
@ -45,9 +42,10 @@ class AudioEffectModulatedDelay :
AudioStream(2, inputQueueArray)
{ }
boolean begin(short *delayline, int delay_length);
boolean begin(short *delayline, uint16_t delay_length);
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:
void set_modulator_filter_coeffs(void);

Loading…
Cancel
Save