Removed SoftenValue, because it was not working without problems and it is

not needed anymore.
pull/15/head^2
Holger Wirtz 5 years ago
parent 308335d2b0
commit 71764bc9f8
  1. 64
      MicroDexed.ino
  2. 143
      SoftenValue.hpp
  3. 25
      UI.hpp
  4. 2
      config.h

@ -36,7 +36,6 @@
#include "effect_modulated_delay.h" #include "effect_modulated_delay.h"
#include "effect_stereo_mono.h" #include "effect_stereo_mono.h"
#include "PluginFx.h" #include "PluginFx.h"
#include "SoftenValue.hpp"
#include "UI.hpp" #include "UI.hpp"
#include "source_microdexed.h" #include "source_microdexed.h"
@ -155,9 +154,6 @@ 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;
SoftenValue <uint8_t> soften_volume;
SoftenValue <uint8_t> soften_filter_res[NUM_DEXED];
SoftenValue <uint8_t> soften_filter_cut[NUM_DEXED];
//elapsedMicros fill_audio_buffer; //elapsedMicros fill_audio_buffer;
elapsedMillis control_rate; elapsedMillis control_rate;
uint8_t active_voices = 0; uint8_t active_voices = 0;
@ -416,8 +412,6 @@ void setup()
// Filter // Filter
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
soften_filter_res[instance_id].init(configuration.dexed[instance_id].filter_resonance);
soften_filter_cut[instance_id].init(configuration.dexed[instance_id].filter_cutoff);
MicroDexed[instance_id]->fx.Gain = mapfloat(configuration.dexed[instance_id].loudness, LOUDNESS_MIN, LOUDNESS_MAX, 0.0, 1.0); MicroDexed[instance_id]->fx.Gain = mapfloat(configuration.dexed[instance_id].loudness, LOUDNESS_MIN, LOUDNESS_MAX, 0.0, 1.0);
MicroDexed[instance_id]->fx.Reso = mapfloat(configuration.dexed[instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 1.0, 0.0); MicroDexed[instance_id]->fx.Reso = mapfloat(configuration.dexed[instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 1.0, 0.0);
MicroDexed[instance_id]->fx.Cutoff = mapfloat(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0); MicroDexed[instance_id]->fx.Cutoff = mapfloat(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0);
@ -426,7 +420,6 @@ void setup()
// set initial volume and pan (read from EEPROM) // set initial volume and pan (read from EEPROM)
set_volume(configuration.vol, configuration.pan, configuration.mono); set_volume(configuration.vol, configuration.pan, configuration.mono);
soften_volume.init(configuration.vol);
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) #if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC)
// Initialize processor and memory measurements // Initialize processor and memory measurements
@ -525,57 +518,9 @@ void loop()
} }
// check for value changes and unused voices // check for value changes and unused voices
soften_volume.tick();
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
active_voices = MicroDexed[instance_id]->getNumNotesPlaying(); active_voices = MicroDexed[instance_id]->getNumNotesPlaying();
soften_filter_res[instance_id].tick();
soften_filter_cut[instance_id].tick();
if (soften_filter_res[instance_id].running())
{
// soften filter resonance value
configuration.dexed[instance_id].filter_resonance=soften_filter_res[instance_id].value();
MicroDexed[instance_id]->fx.Reso = mapfloat(configuration.dexed[instance_id].filter_resonance, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0);
#ifdef DEBUG
Serial.print(F("Filter-Resonance: "));
Serial.print(MicroDexed[instance_id]->fx.Reso, 5);
Serial.print(F(" Filter-Resonance step: "));
Serial.print(soften_filter_res[instance_id].steps());
Serial.print(F(" Filter-Resonance diff: "));
Serial.println(soften_filter_res[instance_id].diff(), 5);
#endif
}
// soften filter cutoff value
if (soften_filter_cut[instance_id].running())
{
configuration.dexed[instance_id].filter_cutoff=soften_filter_cut[instance_id].value();
MicroDexed[instance_id]->fx.Cutoff = mapfloat(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0);
#ifdef DEBUG
Serial.print(F("Filter-Cutoff: "));
Serial.print(MicroDexed[instance_id]->fx.Cutoff, 5);
Serial.print(F(" Filter-Cutoff step: "));
Serial.print(soften_filter_cut[instance_id].steps());
Serial.print(F(" Filter-Cutoff diff: "));
Serial.println(soften_filter_cut[instance_id].diff(), 5);
#endif
}
}
if (soften_volume.running())
{
set_volume(soften_volume.value(), configuration.pan, configuration.mono);
#ifdef DEBUG
Serial.print(F("Volume: "));
Serial.print(configuration.vol, DEC);
Serial.print(F(" step: "));
Serial.print(soften_volume.steps());
Serial.print(F(" diff: "));
Serial.println(soften_volume.diff(), 5);
#endif
} }
} }
@ -655,7 +600,7 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue)
break; break;
case 7: // Volume case 7: // Volume
configuration.vol = map(inValue, 0, 0x7f, VOLUME_MIN, VOLUME_MAX); configuration.vol = map(inValue, 0, 0x7f, VOLUME_MIN, VOLUME_MAX);
soften_volume.update(configuration.vol, SOFTEN_VALUE_CHANGE_STEPS); set_volume(configuration.vol, configuration.pan, configuration.mono);
break; break;
case 10: // Pan case 10: // Pan
configuration.pan = map(inValue, 0, 0x7f, PANORAMA_MIN, PANORAMA_MAX); configuration.pan = map(inValue, 0, 0x7f, PANORAMA_MIN, PANORAMA_MAX);
@ -680,13 +625,11 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue)
break; break;
case 103: // CC 103: filter resonance case 103: // CC 103: filter resonance
configuration.dexed[instance_id].filter_resonance = map(inValue, 0, 0x7f, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX); configuration.dexed[instance_id].filter_resonance = map(inValue, 0, 0x7f, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX);
//MicroDexed[instance_id]->fx.Reso = (100 - configuration.dexed[instance_id].filter_resonance) / 100.0; MicroDexed[instance_id]->fx.Reso = mapfloat(configuration.dexed[instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 1.0, 0.0);
soften_filter_res[instance_id].update(configuration.dexed[instance_id].filter_resonance, SOFTEN_VALUE_CHANGE_STEPS);
break; break;
case 104: // CC 104: filter cutoff case 104: // CC 104: filter cutoff
configuration.dexed[instance_id].filter_cutoff = map(inValue, 0, 0x7f, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX); configuration.dexed[instance_id].filter_cutoff = map(inValue, 0, 0x7f, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX);
//MicroDexed[instance_id]->fx.Cutoff = (100 - configuration.dexed[instance_id].filter_cutoff) / 100.0; MicroDexed[instance_id]->fx.Cutoff = mapfloat(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0);
soften_filter_cut[instance_id].update(configuration.dexed[instance_id].filter_cutoff, SOFTEN_VALUE_CHANGE_STEPS);
break; break;
case 105: // CC 105: delay time case 105: // CC 105: delay time
configuration.delay_time = map(inValue, 0, 0x7f, DELAY_TIME_MIN, DELAY_TIME_MAX); configuration.delay_time = map(inValue, 0, 0x7f, DELAY_TIME_MIN, DELAY_TIME_MAX);
@ -717,6 +660,7 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue)
MicroDexed[instance_id]->setMonoMode(false); MicroDexed[instance_id]->setMonoMode(false);
break; break;
} }
eeprom_write();
} }
} }
} }

@ -1,143 +0,0 @@
/*
MicroDexed
MicroDexed is a port of the Dexed sound engine
(https://github.com/asb2m10/dexed) for the Teensy-3.5/3.6 with audio shield.
Dexed ist heavily based on https://github.com/google/music-synthesizer-for-android
(c)2018 H. Wirtz <wirtz@parasitstudio.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef SOFTEN_VALUE_H_INCLUDED
#define SOFTEN_VALUE_H_INCLUDED 1
template <class T>
class SoftenValue
{
public:
void init(T value)
{
_from = value;
_to = value;
_steps = 0;
_diff = 0.0;
}
void update(T to, uint16_t steps)
{
_to = to;
_steps = steps;
_calculate();
}
void update_to(T to)
{
_to = to;
_calculate();
}
void update_steps(uint16_t steps)
{
_steps = steps;
_calculate();
}
void tick(void)
{
if (_steps > 0)
{
_from -= _diff;
_steps--;
#ifdef DEBUG
Serial.print(F("Steps: "));
Serial.print(_steps, DEC);
Serial.print(F(" Diff="));
Serial.println(_diff, 5);
#endif
}
}
bool running(void)
{
if (_steps > 0)
return (true);
else
return (false);
}
uint16_t steps(void)
{
return (_steps);
}
T diff(void)
{
return (_diff);
}
T value(void)
{
if (_steps == 0)
return (_to);
if (_diff < 0.0)
{
if (_from < _to)
_from = _to;
}
else
{ if (_from > _to)
_from = _to;
}
if (std::is_same<T, float>::value)
return (_from);
else
return (round(_from));
}
protected:
float _from;
float _to;
uint16_t _steps;
float _diff;
void _calculate(void)
{
if (_from == _to || _steps <= 0)
{
_steps = 0;
_diff = 0.0;
}
else
_diff = (_from - _to) / _steps;
#ifdef DEBUG
Serial.print(F("Update SoftenValue: from="));
Serial.print(_from, 5);
Serial.print(F(" to="));
Serial.print(_to, 5);
Serial.print(F(" diff="));
Serial.print(_diff, 5);
Serial.print(F(" steps="));
Serial.println(_steps, DEC);
#endif
}
};
#endif

@ -28,11 +28,12 @@
#include "config.h" #include "config.h"
#include "Disp_Plus.h" #include "Disp_Plus.h"
#include "SoftenValue.hpp"
#include "effect_modulated_delay.h" #include "effect_modulated_delay.h"
#include "effect_stereo_mono.h" #include "effect_stereo_mono.h"
#include "dexed.h" #include "dexed.h"
#define ENCODER_USE_INTERRUPTS
#include <LCDMenuLib2.h> #include <LCDMenuLib2.h>
#include <Encoder.h> #include <Encoder.h>
@ -59,9 +60,6 @@ extern bool load_sysex(uint8_t b, uint8_t v);
#ifdef DISPLAY_LCD_SPI #ifdef DISPLAY_LCD_SPI
extern void change_disp_sd(bool d); extern void change_disp_sd(bool d);
#endif #endif
extern SoftenValue <uint8_t> soften_volume;
extern SoftenValue <uint8_t> soften_filter_res[NUM_DEXED];
extern SoftenValue <uint8_t> soften_filter_cut[NUM_DEXED];
extern AudioEffectDelay delay1; extern AudioEffectDelay delay1;
#ifdef USE_REVERB #ifdef USE_REVERB
extern AudioEffectFreeverbStereo freeverbs1; extern AudioEffectFreeverbStereo freeverbs1;
@ -708,10 +706,9 @@ void encoder_left_up(void)
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("Volume +")); Serial.println(F("Volume +"));
#endif #endif
if (configuration.vol < VOLUME_MAX) configuration.vol = constrain(configuration.vol + VOLUME_ENC_STEPS, VOLUME_MIN, VOLUME_MAX);
soften_volume.update(soften_volume.value() + (VOLUME_MAX - VOLUME_MIN) / VOLUME_ENC_STEPS, SOFTEN_VALUE_CHANGE_STEPS); eeprom_write();
else set_volume(configuration.vol, configuration.pan, configuration.mono);
configuration.vol = VOLUME_MAX;
UI_func_volume(0); UI_func_volume(0);
} }
@ -721,11 +718,9 @@ void encoder_left_down(void)
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("Volume -")); Serial.println(F("Volume -"));
#endif #endif
int8_t tmp = soften_volume.value() - (VOLUME_MAX - VOLUME_MIN) / VOLUME_ENC_STEPS; configuration.vol = constrain(configuration.vol - VOLUME_ENC_STEPS, VOLUME_MIN, VOLUME_MAX);
if (tmp > VOLUME_MIN) eeprom_write();
soften_volume.update(tmp, SOFTEN_VALUE_CHANGE_STEPS); set_volume(configuration.vol, configuration.pan, configuration.mono);
else
configuration.vol = VOLUME_MIN;
UI_func_volume(0); UI_func_volume(0);
} }
@ -1456,7 +1451,7 @@ void UI_func_filter_cutoff(uint8_t param)
} }
} }
soften_filter_cut[instance_id].update(constrain(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX), SOFTEN_VALUE_CHANGE_STEPS); MicroDexed[instance_id]->fx.Cutoff = mapfloat(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0);
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
lcd_display_int(configuration.dexed[instance_id].filter_cutoff, 3, true, true, false); lcd_display_int(configuration.dexed[instance_id].filter_cutoff, 3, true, true, false);
@ -1504,7 +1499,7 @@ void UI_func_filter_resonance(uint8_t param)
} }
} }
soften_filter_res[instance_id].update(constrain(configuration.dexed[instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX), SOFTEN_VALUE_CHANGE_STEPS); MicroDexed[instance_id]->fx.Reso = mapfloat(configuration.dexed[instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 1.0, 0.0);
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
lcd_display_int(configuration.dexed[instance_id].filter_resonance, 3, true, true, false); lcd_display_int(configuration.dexed[instance_id].filter_resonance, 3, true, true, false);

@ -272,7 +272,7 @@ enum { DEXED, REVERB, DELAY, CHORUS };
#define VOLUME_MIN 0 #define VOLUME_MIN 0
#define VOLUME_MAX 100 #define VOLUME_MAX 100
#define VOLUME_DEFAULT 80 #define VOLUME_DEFAULT 80
#define VOLUME_ENC_STEPS 20 #define VOLUME_ENC_STEPS 5
#define PANORAMA_MIN -20 #define PANORAMA_MIN -20
#define PANORAMA_MAX 20 #define PANORAMA_MAX 20

Loading…
Cancel
Save