Added effect functions for controllers.

Smaller fixes.
master
Holger Wirtz 5 years ago
parent d98f68090b
commit da5ca32be0
  1. 12
      MicroMDAEPiano.ino
  2. 40
      UI.hpp
  3. 6
      config.h
  4. 17
      effect_modulated_delay.cpp
  5. 5
      effect_modulated_delay.h

@ -153,8 +153,8 @@ elapsedMillis cpu_mem_millis;
#endif
// Allocate the delay lines for left and right channels
short l_delayline[CHORUS_DELAY_LENGTH];
short r_delayline[CHORUS_DELAY_LENGTH];
short l_delayline[CHORUS_DELAY_LENGTH_BYTES];
short r_delayline[CHORUS_DELAY_LENGTH_BYTES];
//*************************************************************************************************
//* SETUP FUNCTION
@ -224,13 +224,13 @@ void setup()
Serial.print(AUDIO_BLOCK_SAMPLES);
Serial.print(F(" (Time per block="));
Serial.print(audio_block_time_us);
Serial.println(F("ms)"));
Serial.println(F("us)"));
if (!modchorus_r.begin(r_delayline, CHORUS_DELAY_LENGTH)) {
if (!modchorus_r.begin(r_delayline, CHORUS_DELAY_LENGTH_BYTES)) {
Serial.println(F("AudioEffectModulatedDelay - right channel begin failed"));
while (1);
}
if (!modchorus_l.begin(l_delayline, CHORUS_DELAY_LENGTH)) {
if (!modchorus_l.begin(l_delayline, CHORUS_DELAY_LENGTH_BYTES)) {
Serial.println(F("AudioEffectModulatedDelay - left channel begin failed"));
while (1);
}
@ -243,6 +243,8 @@ void setup()
modulator.offset(0.0);
// internal mixing of original signal(0), reverb(1) and chorus(2)
//mixer_r.gain(0, 1.0);
//mixer_l.gain(0, 1.0);
mixer_r.gain(0, 0.0);
mixer_l.gain(0, 0.0);
mixer_r.gain(1, 0.0);

@ -120,6 +120,9 @@ extern void eeprom_config_write(uint8_t value);
extern AudioControlSGTL5000 sgtl5000_1;
extern AudioEffectFreeverb freeverb_r;
extern AudioEffectFreeverb freeverb_l;
extern AudioSynthWaveform modulator;
extern AudioEffectModulatedDelay modchorus_r;
extern AudioEffectModulatedDelay modchorus_l;
extern AudioMixer4 mixer_r;
extern AudioMixer4 mixer_l;
extern AudioAmplifier volume_r;
@ -222,6 +225,22 @@ char* get_tune_value_text(void)
return (tune_value_text1);
}
char chorus_frequency_value_text1[] = " ";
char* get_chorus_frequency_value_text(void)
{
sprintf(chorus_frequency_value_text1, "%2.1f Hz", (float)configuration.chorus_frequency / 10);
return (chorus_frequency_value_text1);
}
char chorus_delay_value_text1[] = " ";
char* get_chorus_delay_value_text(void)
{
sprintf(chorus_delay_value_text1, "%2d ms", configuration.chorus_delay);
return (chorus_delay_value_text1);
}
char midi_channel_value_text1[] = " ";
char* get_midi_channel_value_text(void)
{
@ -494,7 +513,6 @@ LiquidMenu comp_gain_menu(lcd);
#define NUM_COMP_RESPONSE_MENUS 1
const char comp_response_text1[] PROGMEM = "Comp. Response";
LiquidLine comp_response_line1(1, 0, comp_response_text1);
//LiquidLine comp_response_line2(1, 1, configuration.comp_response);
LiquidLine comp_response_line2(1, 1, get_comp_response_value_text);
LiquidScreen comp_response_screen;
LiquidMenu comp_response_menu(lcd);
@ -505,7 +523,6 @@ LiquidMenu comp_response_menu(lcd);
#define NUM_COMP_LIMIT_MENUS 1
const char comp_limit_text1[] PROGMEM = "Comp. Limit";
LiquidLine comp_limit_line1(1, 0, comp_limit_text1);
//LiquidLine comp_limit_line2(1, 1, configuration.comp_limit);
LiquidLine comp_limit_line2(1, 1, get_comp_limit_value_text);
LiquidScreen comp_limit_screen;
LiquidMenu comp_limit_menu(lcd);
@ -516,7 +533,6 @@ LiquidMenu comp_limit_menu(lcd);
#define NUM_COMP_THRESHOLD_MENUS 1
const char comp_threshold_text1[] PROGMEM = "Comp. Threshold";
LiquidLine comp_threshold_line1(1, 0, comp_threshold_text1);
//LiquidLine comp_threshold_line2(1, 1, configuration.comp_threshold);
LiquidLine comp_threshold_line2(1, 1, get_comp_threshold_value_text);
LiquidScreen comp_threshold_screen;
LiquidMenu comp_threshold_menu(lcd);
@ -527,7 +543,6 @@ LiquidMenu comp_threshold_menu(lcd);
#define NUM_COMP_ATTACK_MENUS 1
const char comp_attack_text1[] PROGMEM = "Comp. Attack";
LiquidLine comp_attack_line1(1, 0, comp_attack_text1);
//LiquidLine comp_attack_line2(1, 1, configuration.comp_attack);
LiquidLine comp_attack_line2(1, 1, get_comp_attack_value_text);
LiquidScreen comp_attack_screen;
LiquidMenu comp_attack_menu(lcd);
@ -579,7 +594,7 @@ LiquidMenu reverb_level_menu(lcd);
#define NUM_CHORUS_FREQUENCY_MENUS 1
const char chorus_frequency_text1[] PROGMEM = "Chorus Freq.";
LiquidLine chorus_frequency_line1(1, 0, chorus_frequency_text1);
LiquidLine chorus_frequency_line2(1, 1, configuration.chorus_frequency);
LiquidLine chorus_frequency_line2(1, 1, get_chorus_frequency_value_text);
LiquidScreen chorus_frequency_screen;
LiquidMenu chorus_frequency_menu(lcd);
@ -589,7 +604,7 @@ LiquidMenu chorus_frequency_menu(lcd);
#define NUM_CHORUS_DELAY_MENUS 1
const char chorus_delay_text1[] PROGMEM = "Chorus Delay";
LiquidLine chorus_delay_line1(1, 0, chorus_delay_text1);
LiquidLine chorus_delay_line2(1, 1, configuration.chorus_delay);
LiquidLine chorus_delay_line2(1, 1, get_chorus_delay_value_text);
LiquidScreen chorus_delay_screen;
LiquidMenu chorus_delay_menu(lcd);
@ -2010,10 +2025,6 @@ void set_reverb_level(uint8_t value)
Serial.println(value);
#endif
float tmp = mapfloat(float(value), ENC_REVERB_LEVEL_MIN, ENC_REVERB_LEVEL_MAX, 0.0, 1.0);
//mixer_r.gain(0, 1.0 - tmp);
//mixer_l.gain(0, 1.0 - tmp);
mixer_r.gain(0, 1.0);
mixer_l.gain(0, 1.0);
mixer_r.gain(1, tmp);
mixer_l.gain(1, tmp);
configuration.reverb_level = value;
@ -2025,6 +2036,7 @@ void set_chorus_frequency(uint8_t value)
Serial.print(F("Set CHORUS_FREQUENCY "));
Serial.println(value);
#endif
modulator.frequency(float(value) / 10);
configuration.chorus_frequency = value;
}
@ -2034,6 +2046,8 @@ void set_chorus_delay(uint8_t value)
Serial.print(F("Set CHORUS_DELAY "));
Serial.println(value);
#endif
modchorus_r.setDelayLength(float(value));
modchorus_l.setDelayLength(float(value));
configuration.chorus_delay = value;
}
@ -2043,6 +2057,7 @@ void set_chorus_intensity(uint8_t value)
Serial.print(F("Set CHORUS_INTENSITY "));
Serial.println(value);
#endif
modulator.amplitude(float(value) / 100);
configuration.chorus_intensity = value;
}
@ -2052,8 +2067,9 @@ void set_chorus_level(uint8_t value)
Serial.print(F("Set CHORUS_LEVEL "));
Serial.println(value);
#endif
//float tmp = mapfloat(float(value), ENC_CHORUS_LEVEL_MIN, ENC_CHORUS_LEVEL_MAX, 0.0, 1.0);
// TDB
float tmp = mapfloat(float(value), ENC_CHORUS_LEVEL_MIN, ENC_CHORUS_LEVEL_MAX, 0.0, 1.0);
mixer_r.gain(2, tmp);
mixer_l.gain(2, tmp);
configuration.chorus_level = value;
}

@ -64,7 +64,7 @@
#define INTERPOLATION_WINDOW_SIZE 7 // use only odd numbers!!!
#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_DELAY_LENGTH (16*AUDIO_BLOCK_SAMPLES)
#define CHORUS_DELAY_LENGTH_BYTES (16*AUDIO_BLOCK_SAMPLES)
//*************************************************************************************************
//* DEBUG OUTPUT SETTINGS
@ -233,8 +233,8 @@
#define ENC_REVERB_LEVEL_DEFAULT 15
//
#define ENC_CHORUS_FREQUENCY_MIN 0
#define ENC_CHORUS_FREQUENCY_MAX 20
#define ENC_CHORUS_FREQUENCY_DEFAULT 3
#define ENC_CHORUS_FREQUENCY_MAX 200
#define ENC_CHORUS_FREQUENCY_DEFAULT 30
//
#define ENC_CHORUS_DELAY_MIN 0
#define ENC_CHORUS_DELAY_MAX 20

@ -22,6 +22,7 @@
*/
#include <Arduino.h>
#include <Audio.h>
#include "limits.h"
#include "effect_modulated_delay.h"
#include "interpolation.h"
@ -55,15 +56,14 @@ boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length)
}
_delayline = delayline;
_delay_length = d_length;
_delay_length_half = d_length / 2;
_delay_length = _max_delay_length = d_length;
_delay_length_half = _delay_length / 2;
memset(_delayline, 0, sizeof(int16_t)*_delay_length);
return (true);
}
//int last_idx = 0;
void AudioEffectModulatedDelay::update(void)
{
audio_block_t *block;
@ -166,3 +166,14 @@ void AudioEffectModulatedDelay::update(void)
if (modulation)
release(modulation);
}
void AudioEffectModulatedDelay::setDelayLength(float milliseconds)
{
_delay_length = min(AUDIO_SAMPLE_RATE / milliseconds, _max_delay_length);
_delay_length_half = _delay_length / 2;
}
float AudioEffectModulatedDelay::getMaxDelayLength(void)
{
return (AUDIO_SAMPLE_RATE / _max_delay_length);
}

@ -46,12 +46,15 @@ class AudioEffectModulatedDelay :
boolean begin(short *delayline, int delay_length);
virtual void update(void);
virtual void setDelayLength(float milliseconds);
virtual float getMaxDelayLength(void);
private:
audio_block_t *inputQueueArray[2];
int16_t *_delayline;
int16_t _circ_idx;
uint16_t _max_delay_length;
uint16_t _delay_length;
uint16_t _delay_length_half;
};

Loading…
Cancel
Save