Merge remote-tracking branch 'upstream/dev' into dev

pull/7/head
Dirk Niggemann 5 years ago
commit 2ad093cd64
  1. 21
      MicroDexed.ino
  2. 19
      SoftenValue.hpp
  3. 10
      UI.hpp

@ -363,8 +363,8 @@ void setup()
for (uint8_t i = 0; i < NUM_DEXED; i++)
{
soften_filter_res[i].init(1.0, 0.0, 1.0);
soften_filter_cut[i].init(1.0, 0.0, 1.0);
soften_filter_res[i].init(1.0);
soften_filter_cut[i].init(1.0);
MicroDexed[i]->fx.Gain = 1.0;
MicroDexed[i]->fx.Reso = 1.0;
MicroDexed[i]->fx.Cutoff = 1.0;
@ -372,7 +372,7 @@ void setup()
// set initial volume and pan (read from EEPROM)
set_volume(configuration.vol, configuration.pan, configuration.mono);
soften_volume.init(configuration.vol, VOLUME_MIN, VOLUME_MAX);
soften_volume.init(configuration.vol);
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC)
// Initialize processor and memory measurements
@ -996,10 +996,6 @@ void set_volume(uint8_t v, int8_t p, uint8_t m)
float tmp2 = mapfloat(configuration.pan, PANORAMA_MIN, PANORAMA_MAX, 0.0, 1.0);
float tmp3 = (float)(tmp * (tmp + 2)) / (float)(1 << 20);
// 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
#ifdef DEBUG
Serial.print(F("Setting volume: VOL="));
Serial.print(v, DEC);
@ -1015,26 +1011,25 @@ void set_volume(uint8_t v, int8_t p, uint8_t m)
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));
switch (m)
{
case 0:
volume_r.gain(tmp3 * sinf(tmp2 * PI / 2));
volume_l.gain(tmp3 * cosf(tmp2 * PI / 2));
stereomono1.stereo(true);
break;
case 1:
volume_r.gain(tmp3 * sinf(tmp2 * PI / 2));
volume_l.gain(tmp3 * cosf(tmp2 * PI / 2));
stereomono1.stereo(false);
break;
case 2:
volume_r.gain(tmp3 * sinf(tmp2 * PI / 2));
volume_l.gain(0.0);
stereomono1.stereo(false);
break;
case 3:
volume_r.gain(0.0);
volume_l.gain(tmp3 * cosf(tmp2 * PI / 2));
stereomono1.stereo(false);
break;
}

@ -30,14 +30,12 @@ template <class T>
class SoftenValue
{
public:
void init(T value, T minimum, T maximum)
void init(T value)
{
_from = value;
_to = value;
_steps = 0;
_diff = 0.0;
_min = minimum;
_max = maximum;
}
void update(T to, uint16_t steps)
@ -97,10 +95,15 @@ class SoftenValue
if (_steps == 0)
return (_to);
if (_from < _min)
_from = _min;
else if (_from > _max)
_from = _max;
if (_diff < 0.0)
{
if (_from < _to)
_from = _to;
}
else
{ if (_from > _to)
_from = _to;
}
if (std::is_same<T, float>::value)
return (_from);
@ -113,8 +116,6 @@ class SoftenValue
float _to;
uint16_t _steps;
float _diff;
T _min;
T _max;
void _calculate(void)
{

@ -563,7 +563,7 @@ void encoder_left_up(void)
if (configuration.vol < VOLUME_MAX)
soften_volume.update(soften_volume.value() + (VOLUME_MAX - VOLUME_MIN) / VOLUME_ENC_STEPS, SOFTEN_VALUE_CHANGE_STEPS);
else
soften_volume.update(VOLUME_MAX, SOFTEN_VALUE_CHANGE_STEPS);
configuration.vol = VOLUME_MAX;
eeprom_write();
UI_func_volume(0);
}
@ -573,10 +573,11 @@ void encoder_left_down(void)
#ifdef DEBUG
Serial.println(F("Volume -"));
#endif
if (configuration.vol > VOLUME_MIN)
soften_volume.update(soften_volume.value() - (VOLUME_MAX - VOLUME_MIN) / VOLUME_ENC_STEPS, SOFTEN_VALUE_CHANGE_STEPS);
int8_t tmp = soften_volume.value() - (VOLUME_MAX - VOLUME_MIN) / VOLUME_ENC_STEPS;
if (tmp > VOLUME_MIN)
soften_volume.update(tmp, SOFTEN_VALUE_CHANGE_STEPS);
else
soften_volume.update(VOLUME_MIN, SOFTEN_VALUE_CHANGE_STEPS);
configuration.vol = VOLUME_MIN;
eeprom_write();
UI_func_volume(0);
}
@ -1713,6 +1714,7 @@ void UI_func_volume(uint8_t param)
else
lcd.print(F(" "));
}
set_volume(configuration.vol, configuration.pan, configuration.mono);
lcd.show(1, 0, 1, "[");
lcd.show(1, 15, 1, "]");
}

Loading…
Cancel
Save