Effects-UI is ready for testing.

pull/4/head
Holger Wirtz 6 years ago
parent e3bcc61194
commit 1bab42b0cc
  1. 8
      MicroDexed.ino
  2. 79
      UI.cpp
  3. 3
      UI.h
  4. 7
      config.h

@ -104,10 +104,10 @@ 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;
uint16_t effect_filter_frq=100; uint16_t effect_filter_frq=930;
uint8_t effect_filter_resonance=0; uint8_t effect_filter_resonance=(0.07*ENC_FILTER_RES_STEPS/4.3)+0.5;
uint8_t effect_filter_octave=0; uint8_t effect_filter_octave=(1.0*ENC_FILTER_RES_STEPS/8.0)+0.5;
uint16_t effect_delay_time=0; uint8_t effect_delay_time=0;
uint8_t effect_delay_feedback=0; uint8_t effect_delay_feedback=0;
bool effect_delay_sync=0; bool effect_delay_sync=0;

@ -288,31 +288,58 @@ void handle_ui(void)
case UI_MAIN_FILTER_FRQ: case UI_MAIN_FILTER_FRQ:
if (enc[i].read() <= 0) if (enc[i].read() <= 0)
enc[i].write(0); enc[i].write(0);
else if (enc[i].read() > 100) else if (enc[i].read() > ENC_FILTER_FRQ_STEPS)
enc[i].write(100); enc[i].write(ENC_FILTER_FRQ_STEPS);
effect_filter_frq = map(enc[i].read(), 0, 100, 0, 20000); effect_filter_frq = expf((float)map(enc[i].read(), 0, ENC_FILTER_FRQ_STEPS, 0, 1024) / 150.0) * 10.0 + 80.0;
filter1.frequency(effect_filter_frq); filter1.frequency(effect_filter_frq);
break; 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() > 100) else if (enc[i].read() > ENC_FILTER_RES_STEPS)
enc[i].write(100); enc[i].write(ENC_FILTER_RES_STEPS);
effect_filter_resonance = map(enc[i].read(), 0, 100, 0.7, 5.0); effect_filter_resonance = enc[i].read();
filter1.resonance(effect_filter_resonance); filter1.resonance(mapfloat(effect_filter_resonance, 0, ENC_FILTER_RES_STEPS, 0.7, 5.0));
break; break;
case UI_MAIN_FILTER_OCT: case UI_MAIN_FILTER_OCT:
if (enc[i].read() <= 0) if (enc[i].read() <= 0)
enc[i].write(0); enc[i].write(0);
else if (enc[i].read() > 9) else if (enc[i].read() > ENC_FILTER_OCT_STEPS)
enc[i].write(100); enc[i].write(ENC_FILTER_OCT_STEPS);
effect_filter_octave = map(enc[i].read(), 0, 9, 0.0, 9.0); effect_filter_octave = enc[i].read();
filter1.octaveControl(effect_filter_octave); filter1.octaveControl(mapfloat(enc[i].read(), 0, ENC_FILTER_OCT_STEPS, 0.0, 7.0));
break; break;
} }
ui_show_effects_filter(); ui_show_effects_filter();
break; break;
case UI_EFFECTS_DELAY: case UI_EFFECTS_DELAY:
switch (ui_main_state)
{
case UI_MAIN_DELAY_TIME:
if (enc[i].read() <= 0)
enc[i].write(0);
else if (enc[i].read() > ENC_DELAY_TIME_STEPS)
enc[i].write(ENC_DELAY_TIME_STEPS);
effect_delay_time = enc[i].read();;
delay1.delay(0,map(effect_delay_feedback, 0, ENC_DELAY_TIME_STEPS, 0, DELAY_MAX_TIME));
break;
case UI_MAIN_DELAY_FEEDBACK:
if (enc[i].read() <= 0)
enc[i].write(0);
else if (enc[i].read() > ENC_DELAY_FB_STEPS)
enc[i].write(ENC_DELAY_FB_STEPS);
effect_delay_feedback = enc[i].read();
mixer1.gain(1, mapfloat(effect_delay_feedback,0,99,0.0,1.0));
break;
case UI_MAIN_DELAY_SYNC:
if (enc[i].read() <= 0)
enc[i].write(0);
else if (enc[i].read() >= 1)
enc[i].write(1);
effect_delay_sync = enc[i].read();
// Nothing to do here
break;
}
ui_show_effects_delay(); ui_show_effects_delay();
break; break;
} }
@ -430,12 +457,12 @@ void ui_show_effects_filter(void)
lcd.show(0, 0, LCD_CHARS, "Filter"); lcd.show(0, 0, LCD_CHARS, "Filter");
lcd.show(0, 7, 2, "F:"); lcd.show(0, 7, 2, "F:");
lcd.show(1, 0, 4, "Res:"); lcd.show(1, 0, 4, "Res:");
lcd.show(1, 9, 4, "Oct:"); lcd.show(1, 8, 4, "Oct:");
} }
lcd.show(0, 10, 4, effect_filter_frq); lcd.show(0, 10, 3, effect_filter_frq);
lcd.show(1, 5, 3, effect_filter_resonance); lcd.show(1, 5, 2, map(effect_filter_resonance, 0, ENC_FILTER_RES_STEPS, 0, 99));
lcd.show(1, 14, 1, effect_filter_octave); lcd.show(1, 13, 2, map(effect_filter_octave, 0, ENC_FILTER_OCT_STEPS, 0, 80));
if (ui_main_state == UI_MAIN_FILTER_FRQ) if (ui_main_state == UI_MAIN_FILTER_FRQ)
{ {
@ -451,22 +478,22 @@ void ui_show_effects_filter(void)
if (ui_main_state == UI_MAIN_FILTER_RES) if (ui_main_state == UI_MAIN_FILTER_RES)
{ {
lcd.show(1, 4, 1, "["); lcd.show(1, 4, 1, "[");
lcd.show(1, 8, 1, "]"); lcd.show(1, 7, 1, "]");
} }
else else
{ {
lcd.show(1, 4, 1, " "); lcd.show(1, 4, 1, " ");
lcd.show(1, 8, 1, " "); lcd.show(1, 7, 1, " ");
} }
if (ui_main_state == UI_MAIN_FILTER_OCT) if (ui_main_state == UI_MAIN_FILTER_OCT)
{ {
lcd.show(1, 13, 1, "["); lcd.show(1, 12, 1, "[");
lcd.show(1, 15, 1, "]"); lcd.show(1, 15, 1, "]");
} }
else else
{ {
lcd.show(1, 13, 1, " "); lcd.show(1, 12, 1, " ");
lcd.show(1, 15, 1, " "); lcd.show(1, 15, 1, " ");
} }
@ -485,8 +512,8 @@ void ui_show_effects_delay(void)
lcd.show(1, 8, 5, "Sync:"); lcd.show(1, 8, 5, "Sync:");
} }
lcd.show(0, 9, 4, effect_delay_time); lcd.show(0, 9, 4, map(effect_delay_time, 0, ENC_DELAY_TIME_STEPS, 0, 1200));
lcd.show(1, 4, 3, effect_delay_feedback); lcd.show(1, 4, 2, map(effect_delay_feedback, 0, ENC_DELAY_TIME_STEPS, 0, 99));
lcd.show(1, 14, 1, effect_delay_sync); lcd.show(1, 14, 1, effect_delay_sync);
if (ui_main_state == UI_MAIN_DELAY_TIME) if (ui_main_state == UI_MAIN_DELAY_TIME)
@ -503,12 +530,12 @@ void ui_show_effects_delay(void)
if (ui_main_state == UI_MAIN_DELAY_FEEDBACK) if (ui_main_state == UI_MAIN_DELAY_FEEDBACK)
{ {
lcd.show(1, 3, 1, "["); lcd.show(1, 3, 1, "[");
lcd.show(1, 7, 1, "]"); lcd.show(1, 6, 1, "]");
} }
else else
{ {
lcd.show(1, 3, 1, " "); lcd.show(1, 3, 1, " ");
lcd.show(1, 7, 1, " "); lcd.show(1, 6, 1, " ");
} }
if (ui_main_state == UI_MAIN_DELAY_SYNC) if (ui_main_state == UI_MAIN_DELAY_SYNC)
@ -524,4 +551,10 @@ void ui_show_effects_delay(void)
ui_state = UI_EFFECTS_DELAY; ui_state = UI_EFFECTS_DELAY;
} }
float mapfloat(long x, long in_min, long in_max, long out_min, long out_max)
{
return (float)(x - in_min) * (out_max - out_min) / (float)(in_max - in_min) + out_min;
}
#endif #endif

@ -55,7 +55,7 @@ extern elapsedMillis long_button_pressed;
extern uint16_t effect_filter_frq; extern uint16_t effect_filter_frq;
extern uint8_t effect_filter_resonance; extern uint8_t effect_filter_resonance;
extern uint8_t effect_filter_octave; extern uint8_t effect_filter_octave;
extern uint16_t effect_delay_time; extern uint8_t effect_delay_time;
extern uint8_t effect_delay_feedback; extern uint8_t effect_delay_feedback;
extern bool effect_delay_sync; extern bool effect_delay_sync;
extern AudioFilterStateVariable filter1; extern AudioFilterStateVariable filter1;
@ -68,6 +68,7 @@ void ui_show_volume(void);
void ui_show_midichannel(void); void ui_show_midichannel(void);
void ui_show_effects_filter(void); void ui_show_effects_filter(void);
void ui_show_effects_delay(void); void ui_show_effects_delay(void);
float mapfloat(long x, long in_min, long in_max, long out_min, long 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, UI_MAIN_DELAY_SYNC}; 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, UI_MAIN_DELAY_SYNC};

@ -60,6 +60,8 @@
#endif #endif
// EFFECTS // EFFECTS
#define FILTER_MAX_FREQ 1000
#define DELAY_MAX_TIME 1200
// Master key handling (comment for disabling) // Master key handling (comment for disabling)
//#define MASTER_KEY_MIDI MIDI_C7 //#define MASTER_KEY_MIDI MIDI_C7
@ -103,6 +105,11 @@
// 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 35
#define ENC_FILTER_OCT_STEPS 27
#define ENC_DELAY_TIME_STEPS 50
#define ENC_DELAY_FB_STEPS 35
#define TIMER_UI_HANDLING_MS 100 #define TIMER_UI_HANDLING_MS 100
#define NUM_ENCODER 2 #define NUM_ENCODER 2
#define ENC_L_PIN_A 3 #define ENC_L_PIN_A 3

Loading…
Cancel
Save