Added UI handling for 4pole resonant filter.

pull/4/head
Holger Wirtz 6 years ago
parent cd53e9ee1c
commit afd318b96b
  1. 42
      MicroDexed.ino
  2. 106
      UI.cpp
  3. 5
      UI.h
  4. 5
      config.h

@ -103,9 +103,8 @@ uint8_t midi_timing_counter = 0; // 24 per qarter
elapsedMillis midi_timing_timestep; elapsedMillis midi_timing_timestep;
uint16_t midi_timing_quarter = 0; uint16_t midi_timing_quarter = 0;
elapsedMillis long_button_pressed; elapsedMillis long_button_pressed;
uint8_t effect_filter_frq = ENC_FILTER_FRQ_STEPS; uint8_t effect_filter_cutoff = 0;
uint8_t effect_filter_resonance = 0; uint8_t effect_filter_resonance = 0;
uint8_t effect_filter_octave = (1.0 * ENC_FILTER_RES_STEPS / 8.0) + 0.5;
uint8_t effect_delay_time = 0; uint8_t effect_delay_time = 0;
uint8_t effect_delay_feedback = 0; uint8_t effect_delay_feedback = 0;
uint8_t effect_delay_volume = 0; uint8_t effect_delay_volume = 0;
@ -226,11 +225,9 @@ void setup()
mixer2.gain(0, 1.0 - mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // original signal mixer2.gain(0, 1.0 - mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // original signal
mixer2.gain(1, mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // delayed signal (including feedback) mixer2.gain(1, mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // delayed signal (including feedback)
mixer2.gain(2, mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // only delayed signal (without feedback) mixer2.gain(2, mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // only delayed signal (without feedback)
dexed->fx.Gain = 1.0;
// just for testing: dexed->fx.Reso = 1.0 - float(effect_filter_resonance) / ENC_FILTER_RES_STEPS;
dexed->fx.Reso = 0.5; dexed->fx.Cutoff = 1.0 - float(effect_filter_cutoff) / ENC_FILTER_CUT_STEPS;
dexed->fx.Gain = 0.5;
dexed->fx.Cutoff = 0.5;
// load default SYSEX data // load default SYSEX data
load_sysex(configuration.bank, configuration.voice); load_sysex(configuration.bank, configuration.voice);
@ -419,32 +416,15 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue)
} }
} }
break; break;
case 102: // CC 102: filter frequency
/* effect_filter_frq = map(inValue, 0, 127, 0, ENC_FILTER_FRQ_STEPS);
if (effect_filter_frq == ENC_FILTER_FRQ_STEPS)
{
// turn "off" filter
mixer1.gain(0, 0.0); // filtered signal off
mixer1.gain(3, 1.0); // original signal on
}
else
{
// turn "on" filter
mixer1.gain(0, 1.0); // filtered signal on
mixer1.gain(3, 0.0); // original signal off
}
filter1.frequency(EXP_FUNC((float)map(effect_filter_frq, 0, ENC_FILTER_FRQ_STEPS, 0, 1024) / 150.0) * 10.0 + 80.0);
handle_ui(); */
break;
case 103: // CC 103: filter resonance case 103: // CC 103: filter resonance
/* effect_filter_resonance = map(inValue, 0, 127, 0, ENC_FILTER_RES_STEPS); effect_filter_resonance = map(inValue, 0, 127, 0, ENC_FILTER_RES_STEPS);
filter1.resonance(EXP_FUNC(mapfloat(effect_filter_resonance, 0, ENC_FILTER_RES_STEPS, 0.7, 5.0)) * 0.044 + 0.61); dexed->fx.Reso = 1.0 - float(effect_filter_resonance) / ENC_FILTER_RES_STEPS;
handle_ui(); */ handle_ui();
break; break;
case 104: // CC 104: filter octave case 104: // CC 104: filter cutoff
/* effect_filter_octave = map(inValue, 0, 127, 0, ENC_FILTER_OCT_STEPS); effect_filter_cutoff = map(inValue, 0, 127, 0, ENC_FILTER_CUT_STEPS);
filter1.octaveControl(mapfloat(effect_filter_octave, 0, ENC_FILTER_OCT_STEPS, 0.0, 7.0)); dexed->fx.Cutoff = 1.0 - float(effect_filter_cutoff) / ENC_FILTER_CUT_STEPS;
handle_ui(); */ handle_ui();
break; break;
case 105: // CC 105: delay time case 105: // CC 105: delay time
effect_delay_time = map(inValue, 0, 127, 0, ENC_DELAY_TIME_STEPS); effect_delay_time = map(inValue, 0, 127, 0, ENC_DELAY_TIME_STEPS);

106
UI.cpp

@ -84,8 +84,8 @@ void handle_ui(void)
switch (ui_state) switch (ui_state)
{ {
case UI_MAIN: case UI_MAIN:
ui_main_state = UI_MAIN_FILTER_FRQ; ui_main_state = UI_MAIN_FILTER_RES;
enc[i].write(effect_filter_frq); enc[i].write(effect_filter_resonance);
enc_val[i] = enc[i].read(); enc_val[i] = enc[i].read();
ui_show_effects_filter(); ui_show_effects_filter();
break; break;
@ -155,21 +155,15 @@ void handle_ui(void)
case UI_EFFECTS_DELAY: case UI_EFFECTS_DELAY:
switch (ui_main_state) switch (ui_main_state)
{ {
case UI_MAIN_FILTER_FRQ:
ui_main_state = UI_MAIN_FILTER_RES;
enc[i].write(effect_filter_resonance);
enc_val[i] = enc[i].read();
ui_show_effects_filter();
break;
case UI_MAIN_FILTER_RES: case UI_MAIN_FILTER_RES:
ui_main_state = UI_MAIN_FILTER_OCT; ui_main_state = UI_MAIN_FILTER_CUT;
enc[i].write(effect_filter_octave); enc[i].write(effect_filter_cutoff);
enc_val[i] = enc[i].read(); enc_val[i] = enc[i].read();
ui_show_effects_filter(); ui_show_effects_filter();
break; break;
case UI_MAIN_FILTER_OCT: case UI_MAIN_FILTER_CUT:
ui_main_state = UI_MAIN_FILTER_FRQ; ui_main_state = UI_MAIN_FILTER_RES;
enc[i].write(effect_filter_frq); enc[i].write(effect_filter_resonance);
enc_val[i] = enc[i].read(); enc_val[i] = enc[i].read();
ui_show_effects_filter(); ui_show_effects_filter();
break; break;
@ -291,61 +285,29 @@ void handle_ui(void)
case UI_EFFECTS_FILTER: case UI_EFFECTS_FILTER:
switch (ui_main_state) switch (ui_main_state)
{ {
case UI_MAIN_FILTER_FRQ:
if (enc[i].read() <= 0)
enc[i].write(0);
else if (enc[i].read() > ENC_FILTER_FRQ_STEPS)
enc[i].write(ENC_FILTER_FRQ_STEPS);
effect_filter_frq = enc[i].read();
/*
if (effect_filter_frq == ENC_FILTER_FRQ_STEPS)
{
// turn "off" filter
mixer1.gain(0, 0.0); // filtered signal off
mixer1.gain(3, 1.0); // original signal on
}
else
{
// turn "on" filter
mixer1.gain(0, 1.0); // filtered signal on
mixer1.gain(3, 0.0); // original signal off
}
filter1.frequency(EXP_FUNC((float)map(effect_filter_frq, 0, ENC_FILTER_FRQ_STEPS, 0, 1024) / 150.0) * 10.0 + 80.0);
#ifdef DEBUG
Serial.print(F("Setting filter frequency to: "));
Serial.println(EXP_FUNC((float)map(effect_filter_frq, 0, ENC_FILTER_FRQ_STEPS, 0, 1024) / 150.0) * 10.0 + 80.0, DEC);
#endif
*/
break;
case UI_MAIN_FILTER_RES: case UI_MAIN_FILTER_RES:
if (enc[i].read() <= 0) if (enc[i].read() <= 0)
enc[i].write(0); enc[i].write(0);
else if (enc[i].read() > ENC_FILTER_RES_STEPS) else if (enc[i].read() > ENC_FILTER_RES_STEPS)
enc[i].write(ENC_FILTER_RES_STEPS); enc[i].write(ENC_FILTER_RES_STEPS);
effect_filter_resonance = enc[i].read(); effect_filter_resonance = enc[i].read();
/* dexed->fx.Reso = 1.0 - float(effect_filter_resonance) / ENC_FILTER_RES_STEPS;
//filter1.resonance(mapfloat(effect_filter_resonance, 0, ENC_FILTER_RES_STEPS, 0.7, 5.0)); #ifdef DEBUG
filter1.resonance(EXP_FUNC(mapfloat(effect_filter_resonance, 0, ENC_FILTER_RES_STEPS, 0.7, 5.0)) * 0.044 + 0.61); Serial.print(F("Setting filter resonance to: "));
Serial.println(1.0 - float(effect_filter_resonance) / ENC_FILTER_RES_STEPS, 5);
#ifdef DEBUG #endif
Serial.print(F("Setting filter resonance to: "));
Serial.println(EXP_FUNC(mapfloat(effect_filter_resonance, 0, ENC_FILTER_RES_STEPS, 0.7, 5.0)) * 0.044 + 0.61, 2);
#endif
*/
break; break;
case UI_MAIN_FILTER_OCT: case UI_MAIN_FILTER_CUT:
if (enc[i].read() <= 0) if (enc[i].read() <= 0)
enc[i].write(0); enc[i].write(0);
else if (enc[i].read() > ENC_FILTER_OCT_STEPS) else if (enc[i].read() > ENC_FILTER_CUT_STEPS)
enc[i].write(ENC_FILTER_OCT_STEPS); enc[i].write(ENC_FILTER_CUT_STEPS);
effect_filter_octave = enc[i].read(); effect_filter_cutoff = enc[i].read();
/* dexed->fx.Cutoff = 1.0 - float(effect_filter_cutoff) / ENC_FILTER_CUT_STEPS;
filter1.octaveControl(mapfloat(effect_filter_octave, 0, ENC_FILTER_OCT_STEPS, 0.0, 7.0)); #ifdef DEBUG
#ifdef DEBUG Serial.print(F("Setting filter cutoff to: "));
Serial.print(F("Setting filter octave control to: ")); Serial.println(1.0 - float(effect_filter_cutoff) / ENC_FILTER_CUT_STEPS, 5);
Serial.println(mapfloat(effect_filter_octave, 0, ENC_FILTER_OCT_STEPS, 0.0, 7.0), 2); #endif
#endif
*/
break; break;
} }
ui_show_effects_filter(); ui_show_effects_filter();
@ -509,32 +471,12 @@ void ui_show_effects_filter(void)
{ {
lcd.clear(); lcd.clear();
lcd.show(0, 0, LCD_CHARS, "Filter"); lcd.show(0, 0, LCD_CHARS, "Filter");
lcd.show(0, 7, 2, "F:");
lcd.show(1, 0, 4, "Res:"); lcd.show(1, 0, 4, "Res:");
lcd.show(1, 8, 4, "Oct:"); lcd.show(1, 8, 4, "Cut:");
} }
if (effect_filter_frq == ENC_FILTER_FRQ_STEPS)
{
lcd.show(0, 10, 4, "OFF ");
}
else
{
lcd.show(0, 10, 4, uint16_t(EXP_FUNC((float)map(effect_filter_frq, 0, ENC_FILTER_FRQ_STEPS, 0, 1024) / 150.0) * 10.0 + 80.5));
}
lcd.show(1, 5, 2, map(effect_filter_resonance, 0, ENC_FILTER_RES_STEPS, 0, 99)); lcd.show(1, 5, 2, map(effect_filter_resonance, 0, ENC_FILTER_RES_STEPS, 0, 99));
lcd.show(1, 13, 2, map(effect_filter_octave, 0, ENC_FILTER_OCT_STEPS, 0, 80)); lcd.show(1, 13, 2, map(effect_filter_cutoff, 0, ENC_FILTER_CUT_STEPS, 0, 99));
if (ui_main_state == UI_MAIN_FILTER_FRQ)
{
lcd.show(0, 9, 1, "[");
lcd.show(0, 14, 1, "]");
}
else
{
lcd.show(0, 9, 1, " ");
lcd.show(0, 14, 1, " ");
}
if (ui_main_state == UI_MAIN_FILTER_RES) if (ui_main_state == UI_MAIN_FILTER_RES)
{ {
@ -547,7 +489,7 @@ void ui_show_effects_filter(void)
lcd.show(1, 7, 1, " "); lcd.show(1, 7, 1, " ");
} }
if (ui_main_state == UI_MAIN_FILTER_OCT) if (ui_main_state == UI_MAIN_FILTER_CUT)
{ {
lcd.show(1, 12, 1, "["); lcd.show(1, 12, 1, "[");
lcd.show(1, 15, 1, "]"); lcd.show(1, 15, 1, "]");

@ -47,9 +47,8 @@ extern void eeprom_write(void);
extern void set_volume(float v, float pan); extern void set_volume(float v, float pan);
extern elapsedMillis autostore; extern elapsedMillis autostore;
extern elapsedMillis long_button_pressed; extern elapsedMillis long_button_pressed;
extern uint8_t effect_filter_frq; extern uint8_t effect_filter_cutoff;
extern uint8_t effect_filter_resonance; extern uint8_t effect_filter_resonance;
extern uint8_t effect_filter_octave;
extern uint8_t effect_delay_time; extern uint8_t effect_delay_time;
extern uint8_t effect_delay_feedback; extern uint8_t effect_delay_feedback;
extern uint8_t effect_delay_volume; extern uint8_t effect_delay_volume;
@ -67,7 +66,7 @@ void ui_show_effects_delay(void);
float mapfloat(float val, float in_min, float in_max, float out_min, float out_max); float mapfloat(float val, float in_min, float in_max, float out_min, float out_max);
enum ui_states {UI_MAIN, UI_VOLUME, UI_MIDICHANNEL, UI_EFFECTS_FILTER, UI_EFFECTS_DELAY}; enum ui_states {UI_MAIN, UI_VOLUME, UI_MIDICHANNEL, UI_EFFECTS_FILTER, UI_EFFECTS_DELAY};
enum ui_main_states {UI_MAIN_BANK, UI_MAIN_VOICE, UI_MAIN_BANK_SELECTED, UI_MAIN_VOICE_SELECTED, UI_MAIN_FILTER_FRQ, UI_MAIN_FILTER_RES, UI_MAIN_FILTER_OCT, UI_MAIN_DELAY_TIME, UI_MAIN_DELAY_FEEDBACK, UI_MAIN_DELAY_VOLUME}; enum ui_main_states {UI_MAIN_BANK, UI_MAIN_VOICE, UI_MAIN_BANK_SELECTED, UI_MAIN_VOICE_SELECTED, UI_MAIN_FILTER_RES, UI_MAIN_FILTER_CUT, UI_MAIN_DELAY_TIME, UI_MAIN_DELAY_FEEDBACK, UI_MAIN_DELAY_VOLUME};
class MyEncoder : public Encoder class MyEncoder : public Encoder
{ {

@ -120,9 +120,8 @@
// Encoder with button // Encoder with button
#define ENC_VOL_STEPS 43 #define ENC_VOL_STEPS 43
#define ENC_FILTER_FRQ_STEPS 50 #define ENC_FILTER_RES_STEPS 100
#define ENC_FILTER_RES_STEPS 35 #define ENC_FILTER_CUT_STEPS 100
#define ENC_FILTER_OCT_STEPS 27
#define ENC_DELAY_TIME_STEPS 50 #define ENC_DELAY_TIME_STEPS 50
#define ENC_DELAY_FB_STEPS 35 #define ENC_DELAY_FB_STEPS 35
#define ENC_DELAY_VOLUME_STEPS 50 #define ENC_DELAY_VOLUME_STEPS 50

Loading…
Cancel
Save