Implemented soft volume changing.

Changed volume displaying towards a simpler display algorithm.
Small fixes.
pull/4/head
Holger Wirtz 5 years ago
parent 7b0a83cef8
commit c046111e40
  1. 21
      MicroDexed.ino
  2. 40
      UI.cpp
  3. 1
      UI.h
  4. 11
      config.h

@ -72,8 +72,8 @@ AudioConnection patchCord10(volume_l, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1;
#elif defined(TGA_AUDIO_BOARD)
AudioOutputI2S i2s1;
AudioConnection patchCord9(volume_r, 0, i2s1, 1);
AudioConnection patchCord10(volume_l, 0, i2s1, 0);
AudioConnection patchCord9(volume_r, 0, i2s1, 0);
AudioConnection patchCord10(volume_l, 0, i2s1, 1);
AudioControlWM8731master wm8731_1;
#else
AudioOutputPT8211 pt8211_1;
@ -111,6 +111,7 @@ elapsedMillis cpu_mem_millis;
#endif
config_t configuration = {0xffff, 0, 0, VOLUME, 0.5f, DEFAULT_MIDI_CHANNEL};
bool eeprom_update_flag = false;
value_change_t soften_volume = {0.0, 0};
void setup()
{
@ -323,6 +324,22 @@ void loop()
// Shutdown unused voices
active_voices = dexed->getNumNotesPlaying();
// check for value changes
if (soften_volume.steps > 0)
{
// soften volume value
soften_volume.steps--;
set_volume(configuration.vol + soften_volume.diff, configuration.pan);
#ifdef DEBUG
Serial.print(F("Volume: "));
Serial.print(configuration.vol, 5);
Serial.print(F(" Volume step: "));
Serial.print(soften_volume.steps);
Serial.print(F(" Volume diff: "));
Serial.println(soften_volume.diff, 5);
#endif
}
}
#ifdef I2C_DISPLAY

@ -203,6 +203,7 @@ void handle_ui(void)
switch (i)
{
case 0: // left encoder moved
float tmp;
switch (ui_state)
{
case UI_MAIN:
@ -211,7 +212,18 @@ void handle_ui(void)
enc[i].write(0);
else if (enc[i].read() >= ENC_VOL_STEPS)
enc[i].write(ENC_VOL_STEPS);
set_volume(float(map(enc[i].read(), 0, ENC_VOL_STEPS, 0, 100)) / 100, configuration.pan);
//set_volume(float(map(enc[i].read(), 0, ENC_VOL_STEPS, 0, 100)) / 100, configuration.pan);
tmp = (float(map(enc[i].read(), 0, ENC_VOL_STEPS, 0, 100)) / 100) - configuration.vol;
soften_volume.diff = tmp / SOFTEN_VALUE_CHANGE_STEPS;
soften_volume.steps = SOFTEN_VALUE_CHANGE_STEPS;
#ifdef DEBUG
Serial.print(F("Setting soften volume from: "));
Serial.print(configuration.vol, 5);
Serial.print(F(" Volume step: "));
Serial.print(soften_volume.steps);
Serial.print(F(" Volume diff: "));
Serial.println(soften_volume.diff, 5);
#endif
eeprom_write();
ui_show_volume();
break;
@ -416,28 +428,30 @@ void ui_show_main(void)
void ui_show_volume(void)
{
uint8_t pos;
static uint8_t old_pos;
ui_back_to_main = 0;
// erase old marker and show new marker
pos = map(configuration.vol * 100, 0, 100, 0, LCD_CHARS);
if (ui_state != UI_VOLUME)
{
lcd.clear();
lcd.show(0, 0, LCD_CHARS, "Volume");
lcd.show(1, pos, 1, "*");
old_pos = pos;
}
// show value
lcd.show(0, LCD_CHARS - 3, 3, configuration.vol * 100);
if (configuration.vol == 0.0)
lcd.show(1, 0, LCD_CHARS , " ");
else
if (pos != old_pos)
{
if (configuration.vol < (float(LCD_CHARS) / 100))
lcd.show(1, 0, LCD_CHARS, "*");
else
{
for (uint8_t i = 0; i < map(configuration.vol * 100, 0, 100, 0, LCD_CHARS); i++)
lcd.show(1, i, 1, "*");
for (uint8_t i = map(configuration.vol * 100, 0, 100, 0, LCD_CHARS); i < LCD_CHARS; i++)
lcd.show(1, i, 1, " ");
}
lcd.show(1, pos, 1, "*");
lcd.show(1, old_pos, 1, " ");
old_pos=pos;
}
ui_state = UI_VOLUME;

@ -56,6 +56,7 @@ extern bool effect_delay_sync;
extern AudioEffectDelay delay1;
extern AudioMixer4 mixer1;
extern AudioMixer4 mixer2;
extern value_change_t soften_volume;
void handle_ui(void);
void ui_show_main(void);

@ -46,7 +46,7 @@
// AUDIO
// If nothing is defined PT8211 is used as audio output device!
#define TEENSY_AUDIO_BOARD 1
//#define TGA_AUDIO_BOARD
//#define TGA_AUDIO_BOARD
//*************************************************************************************************
//* MIDI SETTINGS
@ -89,11 +89,12 @@
#define REDUCE_LOUDNESS 1
#endif
#define SAMPLE_RATE 44100
#define SOFTEN_VALUE_CHANGE_STEPS 10
//*************************************************************************************************
//* UI AND DATA-STORE SETTINGS
//*************************************************************************************************
#define CONTROL_RATE_MS 200
#define CONTROL_RATE_MS 100
#define TIMER_UI_HANDLING_MS 100
//*************************************************************************************************
@ -192,4 +193,10 @@ struct config_t {
float pan;
uint8_t midi_channel;
};
// struct for smoothing value changes
struct value_change_t {
float diff;
uint16_t steps;
};
#endif // CONFIG_H_INCLUDED

Loading…
Cancel
Save