Fixed Bank/Voice menu.

Fixed volume display and calculation.
pull/3/head
Holger Wirtz 5 years ago
parent 1d4c19e49c
commit f700967724
  1. 40
      MicroDexed.ino
  2. 124
      UI.hpp
  3. 5
      config.h

@ -821,7 +821,8 @@ void set_volume(float v, float p)
configuration.vol = v; configuration.vol = v;
configuration.pan = p; configuration.pan = p;
#ifdef DEBUG /*
#ifdef DEBUG
Serial.print(F("Setting volume: VOL=")); Serial.print(F("Setting volume: VOL="));
Serial.print(v, DEC); Serial.print(v, DEC);
Serial.print(F("[")); Serial.print(F("["));
@ -833,13 +834,43 @@ void set_volume(float v, float p)
Serial.print(pow(configuration.vol * sinf(configuration.pan * PI / 2), VOLUME_CURVE), 3); Serial.print(pow(configuration.vol * sinf(configuration.pan * PI / 2), VOLUME_CURVE), 3);
Serial.print(F("/")); Serial.print(F("/"));
Serial.println(pow(configuration.vol * cosf( configuration.pan * PI / 2), VOLUME_CURVE), 3); Serial.println(pow(configuration.vol * cosf( configuration.pan * PI / 2), VOLUME_CURVE), 3);
#endif #endif
dexed->fx.Gain = v; dexed->fx.Gain = v;
// http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html // http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html
volume_r.gain(sinf(p * PI / 2)); volume_r.gain(sinf(p * PI / 2));
volume_l.gain(cosf(p * PI / 2)); volume_l.gain(cosf(p * PI / 2));
*/
dexed->fx.Gain = v;
uint16_t tmp = v * 1023.0 + 0.5;
float tmp2 = configuration.pan;
float tmp3 = (float)(tmp * (tmp + 2)) / (float)(1 << 20);
#ifdef SHOW_DEBUG
Serial.print(F("Setting volume: VOL="));
Serial.print(value, DEC);
Serial.print(F("["));
Serial.print(tmp3, 3);
Serial.print(F("] PAN="));
Serial.print(configuration.pan, DEC);
Serial.print(F("["));
Serial.print(tmp2, 3);
Serial.print(F("] "));
Serial.print(tmp3 * sinf(tmp2 * PI / 2), 3);
Serial.print(F("/"));
Serial.println(tmp3 * cosf(tmp2 * PI / 2), 3);
#endif
// float v = (float)(a * (a + 2))/(float)(1 << 20); // (pseudo-) logarithmic curve for volume control
// http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html
volume_r.gain(tmp3 * sinf(tmp2 * PI / 2));
volume_l.gain(tmp3 * cosf(tmp2 * PI / 2));
/* if (configuration.mono == 2)
volume_l.gain(0.0);
else if (configuration.mono == 3)
volume_r.gain(0.0); */
} }
// https://www.dr-lex.be/info-stuff/volumecontrols.html#table1 // https://www.dr-lex.be/info-stuff/volumecontrols.html#table1
@ -883,6 +914,11 @@ void initial_values_from_eeprom(void)
#ifdef DEBUG #ifdef DEBUG
Serial.println(); Serial.println();
#endif #endif
if (configuration.vol > 1.0)
configuration.vol = 1.0;
else if (configuration.vol < 0.0)
configuration.vol = 0.0;
} }
void eeprom_write(void) void eeprom_write(void)

124
UI.hpp

@ -38,12 +38,18 @@
#define _LCDML_DISP_cfg_scrollbar 1 // enable a scrollbar #define _LCDML_DISP_cfg_scrollbar 1 // enable a scrollbar
extern config_t configuration; extern config_t configuration;
void set_volume(float v, float p); //void set_volume(float v, float p);
extern char bank_names[MAX_BANKS][BANK_NAME_LEN]; extern char bank_names[MAX_BANKS][BANK_NAME_LEN];
extern char bank_name[BANK_NAME_LEN]; extern char bank_name[BANK_NAME_LEN];
extern char voice_name[VOICE_NAME_LEN]; extern char voice_name[VOICE_NAME_LEN];
extern char voice_names[MAX_VOICES][VOICE_NAME_LEN]; extern char voice_names[MAX_VOICES][VOICE_NAME_LEN];
extern void strip_extension(char* s, char *target); extern void strip_extension(char* s, char *target);
extern void eeprom_write(void);
extern bool get_voice_names_from_bank(uint8_t b);
extern bool load_sysex(uint8_t b, uint8_t v);
extern value_change_t soften_volume;
extern value_change_t soften_filter_res;
extern value_change_t soften_filter_cut;
/*********************************************************************** /***********************************************************************
GLOBAL GLOBAL
@ -62,7 +68,9 @@ const uint8_t scroll_bar[5][8] = {
enum { ENC_R, ENC_L }; enum { ENC_R, ENC_L };
enum { MENU_START, MENU_VOICE, MENU_EDIT, MENU_VOLUME }; enum { MENU_START, MENU_VOICE, MENU_EDIT, MENU_VOLUME };
enum {MENU_VOICE_BANK, MENU_VOICE_SOUND};
uint8_t menu_state = MENU_START; uint8_t menu_state = MENU_START;
uint8_t menu_voice = MENU_VOICE_SOUND;
void lcdml_menu_display(void); void lcdml_menu_display(void);
void lcdml_voice_menu_display(void); void lcdml_voice_menu_display(void);
@ -184,8 +192,34 @@ void lcdml_menu_control(void)
case MENU_VOICE: case MENU_VOICE:
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("State: MENU_VOICE, Encoder left down")); Serial.println(F("State: MENU_VOICE, Encoder left down"));
break;
#endif #endif
switch (menu_voice)
{
case MENU_VOICE_BANK:
if (configuration.bank < MAX_BANKS)
{
configuration.bank++;
load_sysex(configuration.bank, configuration.voice);
get_voice_names_from_bank(configuration.bank);
}
break;
case MENU_VOICE_SOUND:
if (configuration.voice < 31)
configuration.voice++;
else
{
if (configuration.bank < MAX_BANKS)
{
configuration.bank++;
configuration.voice = 0;
load_sysex(configuration.bank, configuration.voice);
get_voice_names_from_bank(configuration.bank);
}
}
eeprom_write();
}
UI_func_voice_selection(0);
break;
} }
} }
ENCODER[ENC_R].write(g_LCDML_CONTROL_Encoder_position[ENC_R] + 4); ENCODER[ENC_R].write(g_LCDML_CONTROL_Encoder_position[ENC_R] + 4);
@ -211,8 +245,34 @@ void lcdml_menu_control(void)
case MENU_VOICE: case MENU_VOICE:
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("State: MENU_VOICE, Encoder left up")); Serial.println(F("State: MENU_VOICE, Encoder left up"));
break;
#endif #endif
switch (menu_voice)
{
case MENU_VOICE_BANK:
if (configuration.bank > 0)
{
configuration.bank--;
load_sysex(configuration.bank, configuration.voice);
get_voice_names_from_bank(configuration.bank);
}
break;
case MENU_VOICE_SOUND:
if (configuration.voice > 0)
configuration.voice--;
else
{
if (configuration.bank > 0)
{
configuration.bank--;
configuration.voice = 31;
load_sysex(configuration.bank, configuration.voice);
get_voice_names_from_bank(configuration.bank);
}
}
eeprom_write();
}
UI_func_voice_selection(0);
break;
} }
} }
ENCODER[ENC_R].write(g_LCDML_CONTROL_Encoder_position[ENC_R] - 4); ENCODER[ENC_R].write(g_LCDML_CONTROL_Encoder_position[ENC_R] - 4);
@ -258,6 +318,11 @@ void lcdml_menu_control(void)
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("State: MENU_VOICE, button short press")); Serial.println(F("State: MENU_VOICE, button short press"));
#endif #endif
if (menu_voice == MENU_VOICE_BANK)
menu_voice = MENU_VOICE_SOUND;
else
menu_voice = MENU_VOICE_BANK;
UI_func_voice_selection(0);
} }
} }
} }
@ -279,11 +344,14 @@ void lcdml_menu_control(void)
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("Volume +")); Serial.println(F("Volume +"));
#endif #endif
if (configuration.vol < 1.0) if (configuration.vol < 0.95)
{ {
set_volume(configuration.vol + 0.05, configuration.pan); //set_volume(configuration.vol + 0.05, configuration.pan);
UI_func_volume(0); soften_volume.diff = 0.05 / SOFTEN_VALUE_CHANGE_STEPS;
soften_volume.steps = SOFTEN_VALUE_CHANGE_STEPS;
eeprom_write();
} }
UI_func_volume(0);
} }
ENCODER[ENC_L].write(g_LCDML_CONTROL_Encoder_position[ENC_L] + 4); ENCODER[ENC_L].write(g_LCDML_CONTROL_Encoder_position[ENC_L] + 4);
} }
@ -301,11 +369,14 @@ void lcdml_menu_control(void)
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("Volume -")); Serial.println(F("Volume -"));
#endif #endif
if (configuration.vol > 0.0) if (configuration.vol > 0.05)
{ {
set_volume(configuration.vol - 0.05, configuration.pan); //set_volume(configuration.vol - 0.05, configuration.pan);
UI_func_volume(0); soften_volume.diff = -0.05 / SOFTEN_VALUE_CHANGE_STEPS;
soften_volume.steps = SOFTEN_VALUE_CHANGE_STEPS;
eeprom_write();
} }
UI_func_volume(0);
} }
ENCODER[ENC_L].write(g_LCDML_CONTROL_Encoder_position[ENC_L] - 4); ENCODER[ENC_L].write(g_LCDML_CONTROL_Encoder_position[ENC_L] - 4);
} }
@ -619,23 +690,34 @@ void UI_func_voice_selection(uint8_t param)
menu_state = MENU_VOICE; menu_state = MENU_VOICE;
// update LCD content
LCDML.DISP_clear();
lcd.show(0, 0, 2, configuration.bank);
lcd.show(0, 2, 1, " ");
strip_extension(bank_names[configuration.bank], bank_name); strip_extension(bank_names[configuration.bank], bank_name);
lcd.show(0, 2, 1, " "); //LCDML.DISP_clear();
lcd.show(0, 3, 8, bank_name);
lcd.show(0, 11, 1, " ");
// display bank and voice number
lcd.show(0, 0, 2, configuration.bank);
lcd.show(1, 0, 2, configuration.voice + 1); lcd.show(1, 0, 2, configuration.voice + 1);
lcd.show(1, 2, 1, " ");
lcd.show(1, 2, 1, "["); // display names
lcd.show(1, 3, 10, voice_names[configuration.voice]); lcd.show(0, 4, 10, bank_name);
lcd.show(1, 14, 1, "]"); lcd.show(1, 4, 10, voice_names[configuration.voice]);
// display selections
switch (menu_voice)
{
case MENU_VOICE_BANK:
lcd.show(0, 2, 2, " [");
lcd.show(0, 14, 2, "] ");
lcd.show(1, 2, 2, " ");
lcd.show(1, 14, 2, " ");
break;
case MENU_VOICE_SOUND:
lcd.show(0, 2, 2, " ");
lcd.show(0, 14, 2, " ");
lcd.show(1, 2, 2, " [");
lcd.show(1, 14, 2, "] ");
break;
}
} }
void UI_func_volume(uint8_t param) void UI_func_volume(uint8_t param)

@ -38,7 +38,7 @@
// $ aplaymidi -p 20:0 <MIDI-File> # e.g. test.mid // $ aplaymidi -p 20:0 <MIDI-File> # e.g. test.mid
// $ arecord -f cd -Dhw:1,0 /tmp/bla.wav // $ arecord -f cd -Dhw:1,0 /tmp/bla.wav
#define VERSION "0.9.6" #define VERSION "0.9.7"
//************************************************************************************************* //*************************************************************************************************
//* DEVICE SETTINGS //* DEVICE SETTINGS
@ -96,7 +96,7 @@
#define REDUCE_LOUDNESS 1 #define REDUCE_LOUDNESS 1
#endif #endif
#define SAMPLE_RATE 44100 #define SAMPLE_RATE 44100
#define SOFTEN_VALUE_CHANGE_STEPS 20 #define SOFTEN_VALUE_CHANGE_STEPS 5
//************************************************************************************************* //*************************************************************************************************
//* UI //* UI
@ -138,6 +138,7 @@
#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
#define ENC_VOLUME_STEPS 20
#define NUM_ENCODER 2 #define NUM_ENCODER 2
#define ENC_L_PIN_A 3 #define ENC_L_PIN_A 3
#define ENC_L_PIN_B 2 #define ENC_L_PIN_B 2

Loading…
Cancel
Save