Added new LiquidMenu system.

master
Holger Wirtz 6 years ago
parent 9b2cd65be9
commit 27b2e96664
  1. 2
      Encoder4.h
  2. 85
      MicroMDAEPiano.ino
  3. 2248
      UI.hpp
  4. 1
      config.h
  5. 50
      fast_log.h

@ -21,7 +21,7 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
//#define ENCODER_DO_NOT_USE_INTERRUPTS
#include <Encoder.h> #include <Encoder.h>
#include "limits.h" #include "limits.h"

@ -35,10 +35,6 @@
#else #else
#include "mdaEPianoData.h" #include "mdaEPianoData.h"
#endif #endif
#include <Bounce.h>
#include "Encoder4.h"
#include <LiquidCrystal_I2C.h>
#include <LiquidMenu.h>
#include "UI.hpp" #include "UI.hpp"
#include "midi_devices.hpp" #include "midi_devices.hpp"
@ -89,12 +85,51 @@ AudioConnection patchCord13(volume_l, 0, pt8211_1, 0);
// Objects // Objects
mdaEPiano* ep; mdaEPiano* ep;
LiquidCrystal_I2C lcd(LCD_I2C_ADDRESS, LCD_CHARS, LCD_LINES);
Encoder4 enc[2] = {Encoder4(ENC_L_PIN_A, ENC_L_PIN_B), Encoder4(ENC_R_PIN_A, ENC_R_PIN_B)};
Bounce but[2] = {Bounce(BUT_L_PIN, BUT_DEBOUNCE_MS), Bounce(BUT_R_PIN, BUT_DEBOUNCE_MS)};
// Variables extern void init_menus(void);
extern int32_t encoder_value[NUM_ENCODER];
// vars fot menus
uint8_t sound = 1;
//
uint8_t decay = 0;
uint8_t release = 0;
uint8_t hardness = 0;
uint8_t treble = 0;
int8_t stereo = 0;
int8_t transpose = 0;
int8_t tune = 0;
uint8_t detune = 0;
uint8_t velocity_sense = 0;
//
uint8_t pan_trem_frequency = 0; // LFO
uint8_t pan_trem_level = 0;
uint8_t overdrive = 0;
uint8_t comp_gain = 0;
uint8_t comp_response = 0;
uint8_t comp_limit = 0;
uint8_t comp_threshold = 0;
uint8_t comp_attack = 0;
uint8_t comp_decay = 0;
uint8_t reverb_roomsize = 0;
uint8_t reverb_damping = 0;
uint8_t reverb_level = 0;
uint8_t chorus_frequency = 0; // LFO
uint8_t chorus_delay = 0;
uint8_t chorus_level = 0;
uint8_t bass_lr_level = 0;
uint8_t bass_mono_level = 0;
uint8_t eq_bass = 0;
uint8_t eq_treble = 0;
//
uint8_t loudness = 80;
uint8_t midi_channel = DEFAULT_MIDI_CHANNEL; uint8_t midi_channel = DEFAULT_MIDI_CHANNEL;
uint8_t midi_soft_thru = 1;
uint8_t max_poly = 32;
//
uint8_t master_volume = 99;
// more variables
uint32_t xrun = 0; uint32_t xrun = 0;
uint32_t overload = 0; uint32_t overload = 0;
uint32_t peak = 0; uint32_t peak = 0;
@ -109,7 +144,7 @@ bool eeprom_update_flag = false;
elapsedMillis cpu_mem_millis; elapsedMillis cpu_mem_millis;
#endif #endif
enum MDA_EP_PARAM { DECAY, RELEASE, HARDNESS, TREBLE, PAN_TREM, LFO_RATE, VELOCITY_SENSE, STEREO, MAX_POLY, TUNE, DETUNE, OVERDRIVE }; enum MDA_EP_PARAM { MDA_EP_DECAY, MDA_EP_RELEASE, MDA_EP_HARDNESS, MDA_EP_TREBLE, MDA_EP_PAN_TREM, MDA_EP_LFO_RATE, MDA_EP_VELOCITY_SENSE, MDA_EP_STEREO, MDA_EP_MAX_POLY, MDA_EP_TUNE, MDA_EP_DETUNE, MDA_EP_OVERDRIVE };
//************************************************************************************************* //*************************************************************************************************
//* SETUP FUNCTION //* SETUP FUNCTION
@ -122,21 +157,11 @@ void setup()
pinMode(BUT_L_PIN, INPUT_PULLUP); pinMode(BUT_L_PIN, INPUT_PULLUP);
pinMode(BUT_R_PIN, INPUT_PULLUP); pinMode(BUT_R_PIN, INPUT_PULLUP);
menu_init(); init_menus();
lcd.clear();
lcd.setCursor(1, 0);
lcd.print(F("MicroMDAEpiano"));
lcd.setCursor(0, 1);
lcd.print(F("(c)parasiTstudio"));
Serial.begin(SERIAL_SPEED); Serial.begin(SERIAL_SPEED);
delay(500); delay(500);
// Encoder setup
enc[0].write(INITIAL_ENC_L_VALUE);
enc[1].write(INITIAL_ENC_R_VALUE);
// Debug output // Debug output
Serial.println(F("MicroMDAEPiano based on https://sourceforge.net/projects/mda-vst")); Serial.println(F("MicroMDAEPiano based on https://sourceforge.net/projects/mda-vst"));
Serial.println(F("(c)2018/2019 H. Wirtz <wirtz@parasitstudio.de>")); Serial.println(F("(c)2018/2019 H. Wirtz <wirtz@parasitstudio.de>"));
@ -212,14 +237,14 @@ void setup()
Serial.print(audio_block_time_us); Serial.print(audio_block_time_us);
Serial.println(F("ms)")); Serial.println(F("ms)"));
ep->setParameter(DECAY, 0.5); ep->setParameter(MDA_EP_DECAY, 0.5);
ep->setParameter(RELEASE, 0.5); ep->setParameter(MDA_EP_RELEASE, 0.5);
ep->setParameter(HARDNESS, 0.7); ep->setParameter(MDA_EP_HARDNESS, 0.7);
ep->setParameter(TREBLE, 0.85); ep->setParameter(MDA_EP_TREBLE, 0.85);
ep->setParameter(DETUNE, 0.1); ep->setParameter(MDA_EP_DETUNE, 0.1);
ep->setParameter(VELOCITY_SENSE, 1.0); ep->setParameter(MDA_EP_VELOCITY_SENSE, 1.0);
ep->setParameter(STEREO, 0.7); ep->setParameter(MDA_EP_STEREO, 0.7);
ep->setParameter(OVERDRIVE, 0.3); ep->setParameter(MDA_EP_OVERDRIVE, 0.3);
freeverb_r.roomsize(0.2); freeverb_r.roomsize(0.2);
freeverb_l.roomsize(0.2); freeverb_l.roomsize(0.2);
@ -234,9 +259,6 @@ void setup()
Serial.println(F("<setup end>")); Serial.println(F("<setup end>"));
menu_system.update();
menu_system.switch_focus();
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) #if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC)
show_cpu_and_mem_usage(); show_cpu_and_mem_usage();
cpu_mem_millis = 0; cpu_mem_millis = 0;
@ -304,7 +326,6 @@ void loop()
if (control_rate > CONTROL_RATE_MS) if (control_rate > CONTROL_RATE_MS)
{ {
control_rate = 0; control_rate = 0;
handle_ui(); handle_ui();
} }
} }

2248
UI.hpp

File diff suppressed because it is too large Load Diff

@ -112,6 +112,7 @@
//************************************************************************************************* //*************************************************************************************************
#define CONTROL_RATE_MS 100 #define CONTROL_RATE_MS 100
#define BACK_TO_MAIN_MS 500
// MIDI // MIDI
#ifdef MIDI_DEVICE_USB #ifdef MIDI_DEVICE_USB

@ -1,50 +0,0 @@
/* ----------------------------------------------------------------------
* https://community.arm.com/tools/f/discussions/4292/cmsis-dsp-new-functionality-proposal/22621#22621
* Fast approximation to the log2() function. It uses a two step
* process. First, it decomposes the floating-point number into
* a fractional component F and an exponent E. The fraction component
* is used in a polynomial approximation and then the exponent added
* to the result. A 3rd order polynomial is used and the result
* when computing db20() is accurate to 7.984884e-003 dB.
** ------------------------------------------------------------------- */
float log2f_approx_coeff[4] = {1.23149591368684f, -4.11852516267426f, 6.02197014179219f, -3.13396450166353f};
float log2f_approx(float X)
{
float *C = &log2f_approx_coeff[0];
float Y;
float F;
int E;
// This is the approximation to log2()
F = frexpf(fabsf(X), &E);
// Y = C[0]*F*F*F + C[1]*F*F + C[2]*F + C[3] + E;
Y = *C++;
Y *= F;
Y += (*C++);
Y *= F;
Y += (*C++);
Y *= F;
Y += (*C++);
Y += E;
return(Y);
}
// https://codingforspeed.com/using-faster-exponential-approximation/
inline float expf_approx(float x) {
x = 1.0f + x / 1024;
x *= x; x *= x; x *= x; x *= x;
x *= x; x *= x; x *= x; x *= x;
x *= x; x *= x;
return x;
}
inline float unitToDb(float unit) {
return 6.02f * log2f_approx(unit);
}
inline float dbToUnit(float db) {
return expf_approx(db * 2.302585092994046f * 0.05f);
}
Loading…
Cancel
Save