diff --git a/MicroDexed.ino b/MicroDexed.ino index c7aae81..3e906af 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -36,7 +36,6 @@ #include "effect_modulated_delay.h" #include "effect_stereo_mono.h" #include "PluginFx.h" -#include "SoftenValue.hpp" #include "UI.hpp" #include "source_microdexed.h" @@ -65,8 +64,8 @@ AudioConnection patchCord2(chorus_mixer, 0, modchorus, 0); AudioConnection patchCord3(delay_mixer, 0, delay_fb_mixer, 0); AudioConnection patchCord4(delay_fb_mixer, delay1); AudioConnection patchCord5(delay1, 0, delay_fb_mixer, 1); -AudioConnection patchCord6(delay_mixer, 0, master_mixer_r, 2); -AudioConnection patchCord7(delay_mixer, 0, master_mixer_l, 2); +AudioConnection patchCord6(delay1, 0, master_mixer_r, 2); +AudioConnection patchCord7(delay1, 0, master_mixer_l, 2); AudioConnection patchCord8(master_mixer_r, volume_r); AudioConnection patchCord9(master_mixer_l, volume_l); AudioConnection patchCord10(volume_r, 0, stereomono1, 0); @@ -155,9 +154,6 @@ uint8_t midi_timing_counter = 0; // 24 per qarter elapsedMillis midi_timing_timestep; uint16_t midi_timing_quarter = 0; elapsedMillis long_button_pressed; -SoftenValue soften_volume; -SoftenValue soften_filter_res[NUM_DEXED]; -SoftenValue soften_filter_cut[NUM_DEXED]; //elapsedMicros fill_audio_buffer; elapsedMillis control_rate; uint8_t active_voices = 0; @@ -360,7 +356,7 @@ void setup() #ifdef USE_REVERB // INIT REVERB for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) - reverb_mixer.gain(instance_id, 0.0); + reverb_mixer.gain(instance_id, mapfloat(configuration.dexed[instance_id].reverb_send, REVERB_SEND_MIN, REVERB_SEND_MAX, 0.0, 1.0)); master_mixer_r.gain(REVERB, 1.0); master_mixer_l.gain(REVERB, 1.0); freeverbs1.roomsize(mapfloat(configuration.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0)); @@ -369,10 +365,10 @@ void setup() // INIT DELAY for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) - delay_mixer.gain(instance_id, 0.0); + delay_mixer.gain(instance_id, mapfloat(configuration.dexed[instance_id].delay_send, DELAY_SEND_MIN, DELAY_SEND_MAX, 0.0, 1.0)); master_mixer_r.gain(DELAY, 1.0); master_mixer_l.gain(DELAY, 1.0); - delay1.delay(0, mapfloat(configuration.delay_time, DELAY_TIME_MIN, DELAY_TIME_MAX, 0.0, float(DELAY_TIME_MAX))); + delay1.delay(0, mapfloat(configuration.delay_time * 10, DELAY_TIME_MIN, DELAY_TIME_MAX, 0.0, float(DELAY_TIME_MAX))); // delay_fb_mixer is the feedback-adding mixer //delay_fb_mixer.gain(0, 1.0 - (mapfloat(configuration.delay_feedback, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 0.0, 1.0))); // original signal delay_fb_mixer.gain(0, 1.0); // original signal @@ -380,7 +376,7 @@ void setup() // INIT CHORUS for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) - chorus_mixer.gain(instance_id, 0.0); + chorus_mixer.gain(instance_id, mapfloat(configuration.dexed[instance_id].chorus_send, CHORUS_SEND_MIN, CHORUS_SEND_MAX, 0.0, 1.0)); master_mixer_r.gain(CHORUS, 1.0); master_mixer_l.gain(CHORUS, 1.0); switch (configuration.chorus_waveform) @@ -395,6 +391,7 @@ void setup() modulator.begin(WAVEFORM_TRIANGLE); } modulator.phase(0); + modulator.frequency(configuration.chorus_frequency / 10.0); modulator.amplitude(mapfloat(configuration.chorus_depth, CHORUS_DEPTH_MIN, CHORUS_DEPTH_MAX, 0.0, 1.0)); modulator.offset(0.0); #if MOD_FILTER_OUTPUT == MOD_BUTTERWORTH_FILTER_OUTPUT @@ -411,19 +408,18 @@ void setup() modchorus_inverter.gain(-1.0); // stereo mode else modchorus_inverter.gain(1.0); // mono mode + + // Filter 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.Reso = mapfloat(FILTER_RESONANCE_MAX - configuration.dexed[instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 1.0, 0.0); - MicroDexed[instance_id]->fx.Cutoff = mapfloat(FILTER_CUTOFF_MAX - configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_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]->doRefreshVoice(); } // set initial volume and pan (read from EEPROM) set_volume(configuration.vol, configuration.pan, configuration.mono); - soften_volume.init(configuration.vol); #if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) // Initialize processor and memory measurements @@ -522,55 +518,9 @@ void loop() } // check for value changes and unused voices - soften_volume.tick(); - - for (uint8_t i = 0; i < NUM_DEXED; i++) - { - active_voices = MicroDexed[i]->getNumNotesPlaying(); - - soften_filter_res[i].tick(); - soften_filter_cut[i].tick(); - - if (soften_filter_res[i].running()) - { - // soften filter resonance value - MicroDexed[i]->fx.Reso = (FILTER_RESONANCE_MAX - soften_filter_res[i].value()) / 100.0; - -#ifdef DEBUG - Serial.print(F("Filter-Resonance: ")); - Serial.print(MicroDexed[i]->fx.Reso, 5); - Serial.print(F(" Filter-Resonance step: ")); - Serial.print(soften_filter_res[i].steps()); - Serial.print(F(" Filter-Resonance diff: ")); - Serial.println(soften_filter_res[i].diff(), 5); -#endif - } - // soften filter cutoff value - if (soften_filter_cut[i].running()) - { - MicroDexed[i]->fx.Cutoff = (FILTER_CUTOFF_MAX - soften_filter_cut[i].value()) / 100.0; -#ifdef DEBUG - Serial.print(F("Filter-Cutoff: ")); - Serial.print(MicroDexed[i]->fx.Cutoff, 5); - Serial.print(F(" Filter-Cutoff step: ")); - Serial.print(soften_filter_cut[i].steps()); - Serial.print(F(" Filter-Cutoff diff: ")); - Serial.println(soften_filter_cut[i].diff(), 5); -#endif - } - } - if (soften_volume.running()) + for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) { - 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 + active_voices = MicroDexed[instance_id]->getNumNotesPlaying(); } } @@ -650,7 +600,7 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue) break; case 7: // Volume 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; case 10: // Pan configuration.pan = map(inValue, 0, 0x7f, PANORAMA_MIN, PANORAMA_MAX); @@ -675,13 +625,11 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue) break; case 103: // CC 103: filter resonance 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; - soften_filter_res[instance_id].update(soften_filter_res[instance_id].value() + (FILTER_RESONANCE_MAX - FILTER_RESONANCE_MIN) / FILTER_RESONANCE_ENC_STEPS, 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); break; case 104: // CC 104: filter cutoff 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; - soften_filter_cut[instance_id].update(soften_filter_cut[instance_id].value() + (FILTER_CUTOFF_MAX - FILTER_CUTOFF_MIN) / FILTER_CUTOFF_ENC_STEPS, 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); break; case 105: // CC 105: delay time configuration.delay_time = map(inValue, 0, 0x7f, DELAY_TIME_MIN, DELAY_TIME_MAX); @@ -712,6 +660,7 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue) MicroDexed[instance_id]->setMonoMode(false); break; } + eeprom_write(); } } } @@ -1160,45 +1109,6 @@ void initial_values_from_eeprom(bool init) else { EEPROM.get(EEPROM_START_ADDRESS, configuration); - /* - configuration.instances %= INSTANCES_MAX; - configuration.instance_mode %= INSTANCE_MODE_MAX; - configuration.instance_splitpoint %= INSTANCE_SPLITPOINT_MAX; - configuration.vol %= VOLUME_MAX; - configuration.mono %= MONO_MAX; - configuration.reverb_roomsize %= REVERB_ROOMSIZE_MAX; - configuration.reverb_damping %= REVERB_DAMPING_MAX; - configuration.chorus_frequency %= CHORUS_FREQUENCY_MAX; - configuration.chorus_waveform %= CHORUS_WAVEFORM_MAX; - configuration.chorus_depth %= CHORUS_DEPTH_MAX; - configuration.delay_time %= DELAY_TIME_MAX; - configuration.delay_feedback %= DELAY_FEEDBACK_MAX; - for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) - { - configuration.dexed[instance_id].midi_channel %= MIDI_CHANNEL_MAX; - configuration.dexed[instance_id].bank %= MAX_BANKS; - configuration.dexed[instance_id].voice %= MAX_VOICES; - configuration.dexed[instance_id].pan %= PANORAMA_MAX; - configuration.dexed[instance_id].reverb_send %= REVERB_SEND_MAX; - configuration.dexed[instance_id].chorus_send %= CHORUS_SEND_MAX; - configuration.dexed[instance_id].delay_send %= DELAY_SEND_MAX; - configuration.dexed[instance_id].filter_cutoff %= FILTER_CUTOFF_MAX; - configuration.dexed[instance_id].filter_resonance %= FILTER_RESONANCE_MAX; - configuration.dexed[instance_id].loudness %= LOUDNESS_MAX; - configuration.dexed[instance_id].polyphony %= POLYPHONY_MAX; - configuration.dexed[instance_id].engine %= ENGINE_MAX; - configuration.dexed[instance_id].monopoly %= MONOPOLY_MAX; - configuration.dexed[instance_id].pb_range %= PB_RANGE_MAX; - configuration.dexed[instance_id].pb_step %= PB_STEP_MAX; - configuration.dexed[instance_id].mw_range %= MW_RANGE_MAX; - configuration.dexed[instance_id].mw_assign %= MW_ASSIGN_MAX; - configuration.dexed[instance_id].fc_range %= FC_RANGE_MAX; - configuration.dexed[instance_id].fc_assign %= FC_ASSIGN_MAX; - configuration.dexed[instance_id].bc_range %= BC_RANGE_MAX; - configuration.dexed[instance_id].bc_assign %= BC_ASSIGN_MAX; - configuration.dexed[instance_id].at_range %= AT_RANGE_MAX; - configuration.dexed[instance_id].at_assign %= AT_ASSIGN_MAX; - configuration.dexed[instance_id].op_enabled %= 0x3f; */ for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) { @@ -1210,16 +1120,61 @@ void initial_values_from_eeprom(bool init) MicroDexed[instance_id]->setOPs(configuration.dexed[instance_id].op_enabled); MicroDexed[instance_id]->doRefreshVoice(); } - Serial.println(F("OK, loaded!")); } + Serial.println(F("OK, loaded!")); } + check_configuration(); + #ifdef DEBUG show_configuration(); #endif if (configuration.vol > 100) - configuration.vol = 100; + configuration.vol = 100; // just to be sure ;-) +} + +void check_configuration(void) +{ + configuration.instances = constrain(configuration.instances, INSTANCES_MIN, INSTANCES_MAX); + configuration.instance_mode = constrain(configuration.instance_mode, INSTANCE_MODE_MIN, INSTANCE_MODE_MAX); + configuration.instance_splitpoint = constrain(configuration.instance_splitpoint, INSTANCE_SPLITPOINT_MAX, INSTANCE_SPLITPOINT_MAX); + configuration.vol = constrain(configuration.vol, VOLUME_MIN, VOLUME_MAX); + configuration.pan = constrain(configuration.pan, PANORAMA_MIN, PANORAMA_MAX); + configuration.mono = constrain(configuration.mono, MONO_MIN, MONO_MAX); + configuration.reverb_roomsize = constrain(configuration.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX); + configuration.reverb_damping = constrain(configuration.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX); + configuration.chorus_frequency = constrain(configuration.chorus_frequency, CHORUS_FREQUENCY_MIN, CHORUS_FREQUENCY_MAX); + configuration.chorus_waveform = constrain(configuration.chorus_waveform, CHORUS_WAVEFORM_MIN, CHORUS_WAVEFORM_MAX); + configuration.chorus_depth = constrain(configuration.chorus_depth, CHORUS_DEPTH_MIN, CHORUS_DEPTH_MAX); + configuration.delay_time = constrain(configuration.delay_time, DELAY_TIME_MIN, DELAY_TIME_MAX); + configuration.delay_feedback = constrain(configuration.delay_feedback, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX); + for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) + { + configuration.dexed[instance_id].midi_channel = constrain(configuration.dexed[instance_id].midi_channel, MIDI_CHANNEL_MIN, MIDI_CHANNEL_MAX); + configuration.dexed[instance_id].bank = constrain(configuration.dexed[instance_id].bank, 0, MAX_BANKS); + configuration.dexed[instance_id].voice = constrain(configuration.dexed[instance_id].voice, 0, MAX_VOICES); + configuration.dexed[instance_id].reverb_send = constrain(configuration.dexed[instance_id].reverb_send, REVERB_SEND_MIN, REVERB_SEND_MAX); + configuration.dexed[instance_id].chorus_send = constrain(configuration.dexed[instance_id].chorus_send, CHORUS_SEND_MIN, CHORUS_SEND_MAX); + configuration.dexed[instance_id].delay_send = constrain(configuration.dexed[instance_id].delay_send, DELAY_SEND_MIN, DELAY_SEND_MAX); + configuration.dexed[instance_id].filter_cutoff = constrain(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX); + configuration.dexed[instance_id].filter_resonance = constrain(configuration.dexed[instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX); + configuration.dexed[instance_id].loudness = constrain(configuration.dexed[instance_id].loudness, LOUDNESS_MIN, LOUDNESS_MAX); + configuration.dexed[instance_id].polyphony = constrain(configuration.dexed[instance_id].polyphony, POLYPHONY_MIN, POLYPHONY_MAX); + configuration.dexed[instance_id].engine = constrain(configuration.dexed[instance_id].engine, ENGINE_MIN, ENGINE_MAX); + configuration.dexed[instance_id].monopoly = constrain(configuration.dexed[instance_id].monopoly, MONOPOLY_MIN, MONOPOLY_MAX); + configuration.dexed[instance_id].pb_range = constrain(configuration.dexed[instance_id].pb_range, PB_RANGE_MIN, PB_RANGE_MAX); + configuration.dexed[instance_id].pb_step = constrain(configuration.dexed[instance_id].pb_step, PB_STEP_MIN, PB_STEP_MAX); + configuration.dexed[instance_id].mw_range = constrain(configuration.dexed[instance_id].mw_range, MW_RANGE_MIN, MW_RANGE_MAX); + configuration.dexed[instance_id].mw_assign = constrain(configuration.dexed[instance_id].mw_assign, MW_ASSIGN_MIN, MW_ASSIGN_MAX); + configuration.dexed[instance_id].fc_range = constrain(configuration.dexed[instance_id].fc_range, FC_RANGE_MIN, FC_RANGE_MAX); + configuration.dexed[instance_id].fc_assign = constrain(configuration.dexed[instance_id].fc_assign, FC_ASSIGN_MIN, FC_ASSIGN_MAX); + configuration.dexed[instance_id].bc_range = constrain(configuration.dexed[instance_id].bc_range, BC_RANGE_MIN, BC_RANGE_MAX); + configuration.dexed[instance_id].bc_assign = constrain(configuration.dexed[instance_id].bc_assign, BC_ASSIGN_MIN, BC_ASSIGN_MAX); + configuration.dexed[instance_id].at_range = constrain(configuration.dexed[instance_id].at_range, AT_RANGE_MIN, AT_RANGE_MAX); + configuration.dexed[instance_id].at_assign = constrain(configuration.dexed[instance_id].at_assign, AT_ASSIGN_MIN, AT_ASSIGN_MAX); + configuration.dexed[instance_id].op_enabled = constrain(configuration.dexed[instance_id].op_enabled, OP_ENABLED_MIN, OP_ENABLED_MAX); + } } void init_configuration(void) diff --git a/SoftenValue.hpp b/SoftenValue.hpp deleted file mode 100644 index 7749c5e..0000000 --- a/SoftenValue.hpp +++ /dev/null @@ -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 - - 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 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::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 diff --git a/UI.hpp b/UI.hpp index 1e604ba..a3d23fc 100644 --- a/UI.hpp +++ b/UI.hpp @@ -28,11 +28,12 @@ #include "config.h" #include "Disp_Plus.h" -#include "SoftenValue.hpp" #include "effect_modulated_delay.h" #include "effect_stereo_mono.h" #include "dexed.h" +#define ENCODER_USE_INTERRUPTS + #include #include @@ -59,9 +60,6 @@ extern bool load_sysex(uint8_t b, uint8_t v); #ifdef DISPLAY_LCD_SPI extern void change_disp_sd(bool d); #endif -extern SoftenValue soften_volume; -extern SoftenValue soften_filter_res[NUM_DEXED]; -extern SoftenValue soften_filter_cut[NUM_DEXED]; extern AudioEffectDelay delay1; #ifdef USE_REVERB extern AudioEffectFreeverbStereo freeverbs1; @@ -708,10 +706,9 @@ void encoder_left_up(void) #ifdef DEBUG Serial.println(F("Volume +")); #endif - if (configuration.vol < VOLUME_MAX) - soften_volume.update(soften_volume.value() + (VOLUME_MAX - VOLUME_MIN) / VOLUME_ENC_STEPS, SOFTEN_VALUE_CHANGE_STEPS); - else - configuration.vol = VOLUME_MAX; + configuration.vol = constrain(configuration.vol + VOLUME_ENC_STEPS, VOLUME_MIN, VOLUME_MAX); + eeprom_write(); + set_volume(configuration.vol, configuration.pan, configuration.mono); UI_func_volume(0); } @@ -721,11 +718,9 @@ void encoder_left_down(void) #ifdef DEBUG Serial.println(F("Volume -")); #endif - 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 - configuration.vol = VOLUME_MIN; + configuration.vol = constrain(configuration.vol - VOLUME_ENC_STEPS, VOLUME_MIN, VOLUME_MAX); + eeprom_write(); + set_volume(configuration.vol, configuration.pan, configuration.mono); UI_func_volume(0); } @@ -1456,15 +1451,10 @@ void UI_func_filter_cutoff(uint8_t param) } } + 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_display_int(configuration.dexed[instance_id].filter_cutoff, 3, true, true, false); - Serial.print(LCDML.FUNC_getID(), DEC); - Serial.print(instance_id, DEC); - Serial.print(" value: "); - Serial.println(configuration.dexed[instance_id].filter_cutoff / 100.0, 3); - - //MicroDexed[instance_id]->fx.Cutoff = (100 - configuration.dexed[instance_id].filter_cutoff) / 100.0; - soften_filter_cut[instance_id].update(soften_filter_cut[instance_id].value() + (FILTER_CUTOFF_MAX - FILTER_CUTOFF_MIN) / FILTER_CUTOFF_ENC_STEPS, SOFTEN_VALUE_CHANGE_STEPS); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -1509,11 +1499,10 @@ void UI_func_filter_resonance(uint8_t param) } } + 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_display_int(configuration.dexed[instance_id].filter_resonance, 3, true, true, false); - - //MicroDexed[instance_id]->fx.Reso = (100 - configuration.dexed[instance_id].filter_resonance) / 100.0; - soften_filter_res[instance_id].update(soften_filter_res[instance_id].value() + (FILTER_RESONANCE_MAX - FILTER_RESONANCE_MIN) / FILTER_RESONANCE_ENC_STEPS, SOFTEN_VALUE_CHANGE_STEPS); } if (LCDML.FUNC_close()) // ****** STABLE END ********* diff --git a/config.h b/config.h index 6c5d357..d308777 100644 --- a/config.h +++ b/config.h @@ -81,7 +81,7 @@ // CHORUS parameters #define MOD_DELAY_SAMPLE_BUFFER int32_t(TIME_MS2SAMPLES(20.0)) // 20.0 ms delay buffer. #define MOD_WAVEFORM WAVEFORM_TRIANGLE // WAVEFORM_SINE WAVEFORM_TRIANGLE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE -#define MOD_FILTER_OUTPUT MOD_LINKWITZ_RILEY_FILTER_OUTPUT // MOD_LINKWITZ_RILEY_FILTER_OUTPUT MOD_BUTTERWORTH_FILTER_OUTPUT MOD_NO_FILTER_OUTPUT +#define MOD_FILTER_OUTPUT MOD_NO_FILTER_OUTPUT // MOD_LINKWITZ_RILEY_FILTER_OUTPUT MOD_BUTTERWORTH_FILTER_OUTPUT MOD_NO_FILTER_OUTPUT #define MOD_FILTER_CUTOFF_HZ 3000 #define USE_REVERB 1 @@ -228,9 +228,9 @@ enum { DEXED, REVERB, DELAY, CHORUS }; // Teensy-3.6 settings #define MIDI_DEVICE_USB_HOST 1 #if defined(USE_REVERB) -#define MAX_NOTES 12 +#define MAX_NOTES 11 #else -#define MAX_NOTES 16 +#define MAX_NOTES 14 #endif #endif @@ -272,7 +272,7 @@ enum { DEXED, REVERB, DELAY, CHORUS }; #define VOLUME_MIN 0 #define VOLUME_MAX 100 #define VOLUME_DEFAULT 80 -#define VOLUME_ENC_STEPS 20 +#define VOLUME_ENC_STEPS 5 #define PANORAMA_MIN -20 #define PANORAMA_MAX 20 @@ -324,13 +324,11 @@ enum { DEXED, REVERB, DELAY, CHORUS }; #define FILTER_CUTOFF_MIN 0 #define FILTER_CUTOFF_MAX 100 -#define FILTER_CUTOFF_DEFAULT 100 -#define FILTER_CUTOFF_ENC_STEPS 1 +#define FILTER_CUTOFF_DEFAULT 0 #define FILTER_RESONANCE_MIN 0 #define FILTER_RESONANCE_MAX 100 -#define FILTER_RESONANCE_DEFAULT 100 -#define FILTER_RESONANCE_ENC_STEPS 1 +#define FILTER_RESONANCE_DEFAULT 0 #define LOUDNESS_MIN 0 #define LOUDNESS_MAX 100