From 60bbe39472db0e243b8094f72b979abeb26513d2 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Thu, 16 May 2019 12:52:56 +0200 Subject: [PATCH] Save the current state. Added default configuration an some additions for changing values via menus. --- .swp | Bin 0 -> 12288 bytes MicroMDAEPiano.ino | 99 +++++----- UI.hpp | 473 ++++++++++++++++++++++++++++----------------- config.h | 191 +++++++++++++++++- mdaEPiano.cpp | 4 +- 5 files changed, 531 insertions(+), 236 deletions(-) create mode 100644 .swp diff --git a/.swp b/.swp new file mode 100644 index 0000000000000000000000000000000000000000..fccdd8bfabfaab6a09cc8489426fbf0240e26c68 GIT binary patch literal 12288 zcmeI%Jxjwt7{KwT;^I`%FK|s4r6pWyUj!$iAP$aozqZC6jcutHgf2z>)=s@P$)H1V z>I?iIxIA3$?a2=^g!J|Ea3RbUIrmFoXaC2Ox0P zyJnoteOn(inNumber, inVelocity); + ep->noteOn(inNumber + configuration.transpose, inVelocity); } } @@ -345,7 +338,7 @@ void handleNoteOff(byte inChannel, byte inNumber, byte inVelocity) { if (checkMidiChannel(inChannel)) { - ep->noteOn(inNumber, 0); + ep->noteOn(inNumber + configuration.transpose, 0); } } @@ -440,17 +433,17 @@ void handleRealTimeSystem(void) bool checkMidiChannel(byte inChannel) { // check for MIDI channel - if (midi_channel == MIDI_CHANNEL_OMNI) + if (configuration.midi_channel == MIDI_CHANNEL_OMNI) { return (true); } - else if (inChannel != midi_channel) + else if (inChannel != configuration.midi_channel) { #ifdef DEBUG Serial.print(F("Ignoring MIDI data on channel ")); Serial.print(inChannel); Serial.print(F("(listening on ")); - Serial.print(midi_channel); + Serial.print(configuration.midi_channel); Serial.println(F(")")); #endif return (false); @@ -460,21 +453,21 @@ bool checkMidiChannel(byte inChannel) void set_volume(float v, float p) { - configuration.vol = v; + configuration.loudness = v; configuration.pan = p; #ifdef DEBUG Serial.print(F("Setting volume: VOL=")); Serial.print(v, DEC); Serial.print(F("[")); - Serial.print(configuration.vol, DEC); + Serial.print(configuration.loudness, DEC); Serial.print(F("] PAN=")); Serial.print(F("[")); Serial.print(configuration.pan, DEC); Serial.print(F("] ")); - Serial.print(pow(configuration.vol * sinf(configuration.pan * PI / 2), VOLUME_CURVE), 3); + Serial.print(pow(configuration.loudness * sinf(configuration.pan * PI / 2), VOLUME_CURVE), 3); Serial.print(F("/")); - Serial.println(pow(configuration.vol * cosf( configuration.pan * PI / 2), VOLUME_CURVE), 3); + Serial.println(pow(configuration.loudness * cosf( configuration.pan * PI / 2), VOLUME_CURVE), 3); #endif // http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html diff --git a/UI.hpp b/UI.hpp index c60eb10..24451b0 100644 --- a/UI.hpp +++ b/UI.hpp @@ -34,43 +34,10 @@ LiquidCrystal_I2C lcd(LCD_I2C_ADDRESS, LCD_CHARS, LCD_LINES); Encoder4 enc[NUM_ENCODER] = {Encoder4(ENC_L_PIN_A, ENC_L_PIN_B), Encoder4(ENC_R_PIN_A, ENC_R_PIN_B)}; int32_t encoder_value[NUM_ENCODER]; Bounce but[NUM_ENCODER] = {Bounce(BUT_L_PIN, BUT_DEBOUNCE_MS), Bounce(BUT_R_PIN, BUT_DEBOUNCE_MS)}; -LiquidScreen* old_screen; -elapsedMillis back_to_main;; - -extern uint8_t sound; -extern uint8_t decay; -extern uint8_t release; -extern uint8_t hardness; -extern uint8_t treble; -extern int8_t stereo; -extern int8_t transpose; -extern int8_t tune; -extern uint8_t detune; -extern uint8_t velocity_sense; -extern uint8_t pan_trem_frequency; -extern uint8_t pan_trem_level; -extern uint8_t overdrive; -extern uint8_t comp_gain; -extern uint8_t comp_response; -extern uint8_t comp_limit; -extern uint8_t comp_threshold; -extern uint8_t comp_attack; -extern uint8_t comp_decay; -extern uint8_t reverb_roomsize; -extern uint8_t reverb_damping; -extern uint8_t reverb_level; -extern uint8_t chorus_frequency; -extern uint8_t chorus_delay; -extern uint8_t chorus_level; -extern uint8_t bass_lr_level; -extern uint8_t bass_mono_level; -extern uint8_t eq_bass; -extern uint8_t eq_treble; -extern uint8_t loudness; -extern uint8_t midi_channel; -extern uint8_t midi_soft_thru; -extern uint8_t max_poly; -extern uint8_t master_volume; +elapsedMillis back_to_main; + +uint8_t master_volume = ENC_MASTER_VOLUME_DEFAULT; +int8_t pan = ENC_MASTER_PAN_DEFAULT; #define NUM_MENUS 41 @@ -125,6 +92,9 @@ int8_t menu_position[NUM_MENUS]; #define LEFT_ENCODER 0 #define RIGHT_ENCODER 1 +extern mdaEPiano* ep; +extern void set_volume(float v, float p); + /****************************************** MAIN MENU ******************************************/ @@ -150,7 +120,7 @@ LiquidMenu main_menu(lcd); #define NUM_LOAD_SOUNDS_MENUS 1 const char load_sound_text1[] PROGMEM = "Load Sound"; LiquidLine load_sound_line1(1, 0, load_sound_text1); -LiquidLine load_sound_line2(1, 1, sound); +LiquidLine load_sound_line2(1, 1, configuration.sound); LiquidScreen load_sound_screen; LiquidMenu load_sound_menu(lcd); @@ -185,7 +155,7 @@ LiquidMenu edit_sound_menu(lcd); #define NUM_DECAY_MENUS 1 const char decay_text1[] PROGMEM = "Decay"; LiquidLine decay_line1(1, 0, decay_text1); -LiquidLine decay_line2(1, 1, decay); +LiquidLine decay_line2(1, 1, configuration.decay); LiquidScreen decay_screen; LiquidMenu decay_menu(lcd); @@ -195,7 +165,7 @@ LiquidMenu decay_menu(lcd); #define NUM_RELEASE_MENUS 1 const char release_text1[] PROGMEM = "Release"; LiquidLine release_line1(1, 0, release_text1); -LiquidLine release_line2(1, 1, release); +LiquidLine release_line2(1, 1, configuration.release); LiquidScreen release_screen; LiquidMenu release_menu(lcd); @@ -205,7 +175,7 @@ LiquidMenu release_menu(lcd); #define NUM_HARDNESS_MENUS 1 const char hardness_text1[] PROGMEM = "Hardness"; LiquidLine hardness_line1(1, 0, hardness_text1); -LiquidLine hardness_line2(1, 1, hardness); +LiquidLine hardness_line2(1, 1, configuration.hardness); LiquidScreen hardness_screen; LiquidMenu hardness_menu(lcd); @@ -215,7 +185,7 @@ LiquidMenu hardness_menu(lcd); #define NUM_TREBLE_MENUS 1 const char treble_text1[] PROGMEM = "Treble"; LiquidLine treble_line1(1, 0, treble_text1); -LiquidLine treble_line2(1, 1, treble); +LiquidLine treble_line2(1, 1, configuration.treble); LiquidScreen treble_screen; LiquidMenu treble_menu(lcd); @@ -225,7 +195,7 @@ LiquidMenu treble_menu(lcd); #define NUM_TREBLE_MENUS 1 const char stereo_text1[] PROGMEM = "Stereo"; LiquidLine stereo_line1(1, 0, stereo_text1); -LiquidLine stereo_line2(1, 1, stereo); +LiquidLine stereo_line2(1, 1, configuration.stereo); LiquidScreen stereo_screen; LiquidMenu stereo_menu(lcd); @@ -235,7 +205,7 @@ LiquidMenu stereo_menu(lcd); #define NUM_TRANSPOSE_MENUS 1 const char transpose_text1[] PROGMEM = "Transpose"; LiquidLine transpose_line1(1, 0, transpose_text1); -LiquidLine transpose_line2(1, 1, transpose); +LiquidLine transpose_line2(1, 1, configuration.transpose); LiquidScreen transpose_screen; LiquidMenu transpose_menu(lcd); @@ -245,7 +215,7 @@ LiquidMenu transpose_menu(lcd); #define NUM_TUNE_MENUS 1 const char tune_text1[] PROGMEM = "Tune"; LiquidLine tune_line1(1, 0, tune_text1); -LiquidLine tune_line2(1, 1, tune); +LiquidLine tune_line2(1, 1, configuration.tune); LiquidScreen tune_screen; LiquidMenu tune_menu(lcd); @@ -255,7 +225,7 @@ LiquidMenu tune_menu(lcd); #define NUM_DETUNE_MENUS 1 const char detune_text1[] PROGMEM = "Detune"; LiquidLine detune_line1(1, 0, detune_text1); -LiquidLine detune_line2(1, 1, detune); +LiquidLine detune_line2(1, 1, configuration.detune); LiquidScreen detune_screen; LiquidMenu detune_menu(lcd); @@ -265,7 +235,7 @@ LiquidMenu detune_menu(lcd); #define NUM_VELOCITY_MENUS 1 const char velocity_sense_text1[] PROGMEM = "Velocity Sense"; LiquidLine velocity_sense_line1(1, 0, velocity_sense_text1); -LiquidLine velocity_sense_line2(1, 1, velocity_sense); +LiquidLine velocity_sense_line2(1, 1, configuration.velocity_sense); LiquidScreen velocity_sense_screen; LiquidMenu velocity_sense_menu(lcd); @@ -320,7 +290,7 @@ LiquidMenu effects_menu(lcd); #define NUM_PAN_TREM_FRQUENCY_MENUS 1 const char pan_trem_frequency_text1[] PROGMEM = "PAN/Trem Freq."; LiquidLine pan_trem_frequency_line1(1, 0, pan_trem_frequency_text1); -LiquidLine pan_trem_frequency_line2(1, 1, pan_trem_frequency); +LiquidLine pan_trem_frequency_line2(1, 1, configuration.pan_trem_frequency); LiquidScreen pan_trem_frequency_screen; LiquidMenu pan_trem_frequency_menu(lcd); @@ -330,7 +300,7 @@ LiquidMenu pan_trem_frequency_menu(lcd); #define NUM_PAN_TREM_LEVEL_MENUS 1 const char pan_trem_level_text1[] PROGMEM = "Pan/Trem Level"; LiquidLine pan_trem_level_line1(1, 0, pan_trem_level_text1); -LiquidLine pan_trem_level_line2(1, 1, pan_trem_level); +LiquidLine pan_trem_level_line2(1, 1, configuration.pan_trem_level); LiquidScreen pan_trem_level_screen; LiquidMenu pan_trem_level_menu(lcd); @@ -340,7 +310,7 @@ LiquidMenu pan_trem_level_menu(lcd); #define NUM_OVERDRIVE_MENUS 1 const char overdrive_text1[] PROGMEM = "Overdrive"; LiquidLine overdrive_line1(1, 0, overdrive_text1); -LiquidLine overdrive_line2(1, 1, overdrive); +LiquidLine overdrive_line2(1, 1, configuration.overdrive); LiquidScreen overdrive_screen; LiquidMenu overdrive_menu(lcd); @@ -350,7 +320,7 @@ LiquidMenu overdrive_menu(lcd); #define NUM_COMP_GAIN_MENUS 1 const char comp_gain_text1[] PROGMEM = "Comp. Gain"; LiquidLine comp_gain_line1(1, 0, comp_gain_text1); -LiquidLine comp_gain_line2(1, 1, comp_gain); +LiquidLine comp_gain_line2(1, 1, configuration.comp_gain); LiquidScreen comp_gain_screen; LiquidMenu comp_gain_menu(lcd); @@ -360,7 +330,7 @@ LiquidMenu comp_gain_menu(lcd); #define NUM_COMP_RESPONSE_MENUS 1 const char comp_response_text1[] PROGMEM = "Comp. Response"; LiquidLine comp_response_line1(1, 0, comp_response_text1); -LiquidLine comp_response_line2(1, 1, comp_response); +LiquidLine comp_response_line2(1, 1, configuration.comp_response); LiquidScreen comp_response_screen; LiquidMenu comp_response_menu(lcd); @@ -370,7 +340,7 @@ LiquidMenu comp_response_menu(lcd); #define NUM_COMP_LIMIT_MENUS 1 const char comp_limit_text1[] PROGMEM = "Comp. Limit"; LiquidLine comp_limit_line1(1, 0, comp_limit_text1); -LiquidLine comp_limit_line2(1, 1, comp_limit); +LiquidLine comp_limit_line2(1, 1, configuration.comp_limit); LiquidScreen comp_limit_screen; LiquidMenu comp_limit_menu(lcd); @@ -380,7 +350,7 @@ LiquidMenu comp_limit_menu(lcd); #define NUM_COMP_THRESHOLD_MENUS 1 const char comp_threshold_text1[] PROGMEM = "Comp. Threshold"; LiquidLine comp_threshold_line1(1, 0, comp_threshold_text1); -LiquidLine comp_threshold_line2(1, 1, comp_threshold); +LiquidLine comp_threshold_line2(1, 1, configuration.comp_threshold); LiquidScreen comp_threshold_screen; LiquidMenu comp_threshold_menu(lcd); @@ -390,7 +360,7 @@ LiquidMenu comp_threshold_menu(lcd); #define NUM_COMP_ATTACK_MENUS 1 const char comp_attack_text1[] PROGMEM = "Comp. Attack"; LiquidLine comp_attack_line1(1, 0, comp_attack_text1); -LiquidLine comp_attack_line2(1, 1, comp_attack); +LiquidLine comp_attack_line2(1, 1, configuration.comp_attack); LiquidScreen comp_attack_screen; LiquidMenu comp_attack_menu(lcd); @@ -400,7 +370,7 @@ LiquidMenu comp_attack_menu(lcd); #define NUM_COMP_DECAY_MENUS 1 const char comp_decay_text1[] PROGMEM = "Comp. Decay"; LiquidLine comp_decay_line1(1, 0, comp_decay_text1); -LiquidLine comp_decay_line2(1, 1, comp_decay); +LiquidLine comp_decay_line2(1, 1, configuration.comp_decay); LiquidScreen comp_decay_screen; LiquidMenu comp_decay_menu(lcd); @@ -410,7 +380,7 @@ LiquidMenu comp_decay_menu(lcd); #define NUM_REVERB_ROOMSIZE_MENUS 1 const char reverb_roomsize_text1[] PROGMEM = "Reverb Roomsize"; LiquidLine reverb_roomsize_line1(1, 0, reverb_roomsize_text1); -LiquidLine reverb_roomsize_line2(1, 1, reverb_roomsize); +LiquidLine reverb_roomsize_line2(1, 1, configuration.reverb_roomsize); LiquidScreen reverb_roomsize_screen; LiquidMenu reverb_roomsize_menu(lcd); @@ -420,7 +390,7 @@ LiquidMenu reverb_roomsize_menu(lcd); #define NUM_REVERB_DAMPING_MENUS 1 const char reverb_damping_text1[] PROGMEM = "Reverb Damping"; LiquidLine reverb_damping_line1(1, 0, reverb_damping_text1); -LiquidLine reverb_damping_line2(1, 1, reverb_damping); +LiquidLine reverb_damping_line2(1, 1, configuration.reverb_damping); LiquidScreen reverb_damping_screen; LiquidMenu reverb_damping_menu(lcd); @@ -430,7 +400,7 @@ LiquidMenu reverb_damping_menu(lcd); #define NUM_REVERB_LEVEL_MENUS 1 const char reverb_level_text1[] PROGMEM = "Reverb Level"; LiquidLine reverb_level_line1(1, 0, reverb_level_text1); -LiquidLine reverb_level_line2(1, 1, reverb_level); +LiquidLine reverb_level_line2(1, 1, configuration.reverb_level); LiquidScreen reverb_level_screen; LiquidMenu reverb_level_menu(lcd); @@ -440,7 +410,7 @@ LiquidMenu reverb_level_menu(lcd); #define NUM_CHORUS_FREQUENCY_MENUS 1 const char chorus_frequency_text1[] PROGMEM = "Chorus Frequency"; LiquidLine chorus_frequency_line1(1, 0, chorus_frequency_text1); -LiquidLine chorus_frequency_line2(1, 1, chorus_frequency); +LiquidLine chorus_frequency_line2(1, 1, configuration.chorus_frequency); LiquidScreen chorus_frequency_screen; LiquidMenu chorus_frequency_menu(lcd); @@ -450,7 +420,7 @@ LiquidMenu chorus_frequency_menu(lcd); #define NUM_CHORUS_DELAY_MENUS 1 const char chorus_delay_text1[] PROGMEM = "Chorus Delay"; LiquidLine chorus_delay_line1(1, 0, chorus_delay_text1); -LiquidLine chorus_delay_line2(1, 1, chorus_delay); +LiquidLine chorus_delay_line2(1, 1, configuration.chorus_delay); LiquidScreen chorus_delay_screen; LiquidMenu chorus_delay_menu(lcd); @@ -460,7 +430,7 @@ LiquidMenu chorus_delay_menu(lcd); #define NUM_CHORUS_LEVEL_MENUS 1 const char chorus_level_text1[] PROGMEM = "Chorus Level"; LiquidLine chorus_level_line1(1, 0, chorus_level_text1); -LiquidLine chorus_level_line2(1, 1, chorus_level); +LiquidLine chorus_level_line2(1, 1, configuration.chorus_level); LiquidScreen chorus_level_screen; LiquidMenu chorus_level_menu(lcd); @@ -470,7 +440,7 @@ LiquidMenu chorus_level_menu(lcd); #define NUM_BASS_LR_LEVEL_MENUS 1 const char bass_lr_level_text1[] PROGMEM = "Bass L/R Level"; LiquidLine bass_lr_level_line1(1, 0, bass_lr_level_text1); -LiquidLine bass_lr_level_line2(1, 1, bass_lr_level); +LiquidLine bass_lr_level_line2(1, 1, configuration.bass_lr_level); LiquidScreen bass_lr_level_screen; LiquidMenu bass_lr_level_menu(lcd); @@ -480,7 +450,7 @@ LiquidMenu bass_lr_level_menu(lcd); #define NUM_BASS_MONO_LEVEL_MENUS 1 const char bass_mono_level_text1[] PROGMEM = "Bass mono Level"; LiquidLine bass_mono_level_line1(1, 0, bass_mono_level_text1); -LiquidLine bass_mono_level_line2(1, 1, bass_mono_level); +LiquidLine bass_mono_level_line2(1, 1, configuration.bass_mono_level); LiquidScreen bass_mono_level_screen; LiquidMenu bass_mono_level_menu(lcd); @@ -490,7 +460,7 @@ LiquidMenu bass_mono_level_menu(lcd); #define NUM_EQ_BASS_MENUS 1 const char eq_bass_text1[] PROGMEM = "EQ Bass"; LiquidLine eq_bass_line1(1, 0, eq_bass_text1); -LiquidLine eq_bass_line2(1, 1, eq_bass); +LiquidLine eq_bass_line2(1, 1, configuration.eq_bass); LiquidScreen eq_bass_screen; LiquidMenu eq_bass_menu(lcd); @@ -500,7 +470,7 @@ LiquidMenu eq_bass_menu(lcd); #define NUM_EQ_TREBLE_MENUS 1 const char eq_treble_text1[] PROGMEM = "EQ Treble"; LiquidLine eq_treble_line1(1, 0, eq_treble_text1); -LiquidLine eq_treble_line2(1, 1, eq_treble); +LiquidLine eq_treble_line2(1, 1, configuration.eq_treble); LiquidScreen eq_treble_screen; LiquidMenu eq_treble_menu(lcd); @@ -510,7 +480,7 @@ LiquidMenu eq_treble_menu(lcd); #define NUM_SAVE_SOUNDS_MENUS 1 const char save_sound_text1[] PROGMEM = "Save Sound"; LiquidLine save_sound_line1(1, 0, save_sound_text1); -LiquidLine save_sound_line2(1, 1, sound); +LiquidLine save_sound_line2(1, 1, configuration.sound); LiquidScreen save_sound_screen; LiquidMenu save_sound_menu(lcd); @@ -535,7 +505,7 @@ LiquidMenu system_menu(lcd); #define NUM_LOUDNESS_MENUS 1 const char loudness_text1[] PROGMEM = "Loudness"; LiquidLine loudness_line1(1, 0, loudness_text1); -LiquidLine loudness_line2(1, 1, loudness); +LiquidLine loudness_line2(1, 1, configuration.loudness); LiquidScreen loudness_screen; LiquidMenu loudness_menu(lcd); @@ -545,7 +515,7 @@ LiquidMenu loudness_menu(lcd); #define NUM_MIDI_CHANNEL_MENUS 1 const char midi_channel_text1[] PROGMEM = "MIDI CHannel"; LiquidLine midi_channel_line1(1, 0, midi_channel_text1); -LiquidLine midi_channel_line2(1, 1, midi_channel); +LiquidLine midi_channel_line2(1, 1, configuration.midi_channel); LiquidScreen midi_channel_screen; LiquidMenu midi_channel_menu(lcd); @@ -555,7 +525,7 @@ LiquidMenu midi_channel_menu(lcd); #define NUM_MIDI_SOFT_THRU_MENUS 1 const char midi_soft_thru_text1[] PROGMEM = "MIDI Soft Thru"; LiquidLine midi_soft_thru_line1(1, 0, midi_soft_thru_text1); -LiquidLine midi_soft_thru_line2(1, 1, midi_soft_thru); +LiquidLine midi_soft_thru_line2(1, 1, configuration.midi_soft_thru); LiquidScreen midi_soft_thru_screen; LiquidMenu midi_soft_thru_menu(lcd); @@ -565,7 +535,7 @@ LiquidMenu midi_soft_thru_menu(lcd); #define NUM_MAX_POLY_MENUS 1 const char max_poly_text1[] PROGMEM = "Max. Polyphony"; LiquidLine max_poly_line1(1, 0, max_poly_text1); -LiquidLine max_poly_line2(1, 1, max_poly); +LiquidLine max_poly_line2(1, 1, configuration.max_poly); LiquidScreen max_poly_screen; LiquidMenu max_poly_menu(lcd); @@ -603,8 +573,8 @@ void callback_load_sound_function() { #endif menu_system.change_menu(load_sound_menu); menu_position[MAIN] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = sound; - enc[RIGHT_ENCODER].write(sound, 1, 99); + encoder_value[RIGHT_ENCODER] = configuration.sound; + enc[RIGHT_ENCODER].write(configuration.sound, 1, 99); menu_system.update(); } @@ -641,8 +611,8 @@ void callback_decay_function() #endif menu_system.change_menu(decay_menu); menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = decay; - enc[RIGHT_ENCODER].write(decay, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.decay; + enc[RIGHT_ENCODER].write(configuration.decay, ENC_DECAY_MIN, ENC_DECAY_MAX); menu_system.update(); } @@ -653,8 +623,8 @@ void callback_release_function() #endif menu_system.change_menu(release_menu); menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = release; - enc[RIGHT_ENCODER].write(release, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.release; + enc[RIGHT_ENCODER].write(configuration.release, ENC_RELEASE_MIN, ENC_RELEASE_MAX); menu_system.update(); } @@ -665,8 +635,8 @@ void callback_hardness_function() #endif menu_system.change_menu(hardness_menu); menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = hardness; - enc[RIGHT_ENCODER].write(hardness, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.hardness; + enc[RIGHT_ENCODER].write(configuration.hardness, ENC_HARDNESS_MIN, ENC_HARDNESS_MAX); menu_system.update(); } @@ -677,8 +647,8 @@ void callback_treble_function() #endif menu_system.change_menu(treble_menu); menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = treble; - enc[RIGHT_ENCODER].write(treble, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.treble; + enc[RIGHT_ENCODER].write(configuration.treble, ENC_TREBLE_MIN, ENC_TREBLE_MAX); menu_system.update(); } @@ -689,8 +659,8 @@ void callback_stereo_function() #endif menu_system.change_menu(stereo_menu); menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = stereo; - enc[RIGHT_ENCODER].write(stereo, -10, 10); + encoder_value[RIGHT_ENCODER] = configuration.stereo; + enc[RIGHT_ENCODER].write(configuration.stereo, ENC_STEREO_MIN, ENC_STEREO_MAX); menu_system.update(); } @@ -701,8 +671,8 @@ void callback_transpose_function() #endif menu_system.change_menu(transpose_menu); menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = transpose; - enc[RIGHT_ENCODER].write(transpose, -36, 36); + encoder_value[RIGHT_ENCODER] = configuration.transpose; + enc[RIGHT_ENCODER].write(configuration.transpose, ENC_TRANSPOSE_MIN, ENC_TRANSPOSE_MAX); menu_system.update(); } @@ -713,8 +683,8 @@ void callback_tune_function() #endif menu_system.change_menu(tune_menu); menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = tune; - enc[RIGHT_ENCODER].write(tune, -50, 50); + encoder_value[RIGHT_ENCODER] = configuration.tune; + enc[RIGHT_ENCODER].write(configuration.tune, ENC_TUNE_MIN, ENC_TUNE_MAX); menu_system.update(); } @@ -725,8 +695,8 @@ void callback_detune_function() #endif menu_system.change_menu(detune_menu); menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = detune; - enc[RIGHT_ENCODER].write(detune, 0, 50); + encoder_value[RIGHT_ENCODER] = configuration.detune; + enc[RIGHT_ENCODER].write(configuration.detune, ENC_DETUNE_MIN, ENC_DETUNE_MAX); menu_system.update(); } @@ -737,8 +707,8 @@ void callback_velocity_sense_function() #endif menu_system.change_menu(velocity_sense_menu); menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = velocity_sense; - enc[RIGHT_ENCODER].write(velocity_sense, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.velocity_sense; + enc[RIGHT_ENCODER].write(configuration.velocity_sense, ENC_VELOCITY_SENSE_MIN, ENC_VELOCITY_SENSE_MAX); menu_system.update(); } @@ -775,8 +745,8 @@ void callback_pan_trem_frequency_function() #endif menu_system.change_menu(pan_trem_frequency_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = pan_trem_frequency; - enc[RIGHT_ENCODER].write(pan_trem_frequency, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.pan_trem_frequency; + enc[RIGHT_ENCODER].write(configuration.pan_trem_frequency, 0, 99); menu_system.update(); } @@ -787,8 +757,8 @@ void callback_pan_trem_level_function() #endif menu_system.change_menu(pan_trem_level_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = pan_trem_level; - enc[RIGHT_ENCODER].write(pan_trem_level, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.pan_trem_level; + enc[RIGHT_ENCODER].write(configuration.pan_trem_level, 0, 99); menu_system.update(); } @@ -799,8 +769,8 @@ void callback_overdrive_function() #endif menu_system.change_menu(overdrive_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = overdrive; - enc[RIGHT_ENCODER].write(overdrive, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.overdrive; + enc[RIGHT_ENCODER].write(configuration.overdrive, 0, 99); menu_system.update(); } @@ -811,8 +781,8 @@ void callback_comp_gain_function() #endif menu_system.change_menu(comp_gain_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = comp_gain; - enc[RIGHT_ENCODER].write(comp_gain, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.comp_gain; + enc[RIGHT_ENCODER].write(configuration.comp_gain, 0, 99); menu_system.update(); } @@ -823,8 +793,8 @@ void callback_comp_response_function() #endif menu_system.change_menu(comp_response_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = comp_response; - enc[RIGHT_ENCODER].write(comp_response, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.comp_response; + enc[RIGHT_ENCODER].write(configuration.comp_response, 0, 99); menu_system.update(); } @@ -835,8 +805,8 @@ void callback_comp_limit_function() #endif menu_system.change_menu(comp_limit_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = comp_limit; - enc[RIGHT_ENCODER].write(comp_limit, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.comp_limit; + enc[RIGHT_ENCODER].write(configuration.comp_limit, 0, 99); menu_system.update(); } @@ -847,8 +817,8 @@ void callback_comp_threshold_function() #endif menu_system.change_menu(comp_threshold_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = comp_threshold; - enc[RIGHT_ENCODER].write(comp_threshold, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.comp_threshold; + enc[RIGHT_ENCODER].write(configuration.comp_threshold, 0, 99); menu_system.update(); } @@ -859,8 +829,8 @@ void callback_comp_attack_function() #endif menu_system.change_menu(comp_attack_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = comp_attack; - enc[RIGHT_ENCODER].write(comp_attack, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.comp_attack; + enc[RIGHT_ENCODER].write(configuration.comp_attack, 0, 99); menu_system.update(); } @@ -871,8 +841,8 @@ void callback_comp_decay_function() #endif menu_system.change_menu(comp_decay_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = comp_decay; - enc[RIGHT_ENCODER].write(comp_decay, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.comp_decay; + enc[RIGHT_ENCODER].write(configuration.comp_decay, 0, 99); menu_system.update(); } @@ -883,8 +853,8 @@ void callback_reverb_roomsize_function() #endif menu_system.change_menu(reverb_roomsize_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = reverb_roomsize; - enc[RIGHT_ENCODER].write(reverb_roomsize, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.reverb_roomsize; + enc[RIGHT_ENCODER].write(configuration.reverb_roomsize, 0, 99); menu_system.update(); } @@ -895,8 +865,8 @@ void callback_reverb_damping_function() #endif menu_system.change_menu(reverb_damping_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = reverb_damping; - enc[RIGHT_ENCODER].write(reverb_damping, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.reverb_damping; + enc[RIGHT_ENCODER].write(configuration.reverb_damping, 0, 99); menu_system.update(); } @@ -907,8 +877,8 @@ void callback_reverb_level_function() #endif menu_system.change_menu(reverb_level_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = reverb_level; - enc[RIGHT_ENCODER].write(reverb_level, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.reverb_level; + enc[RIGHT_ENCODER].write(configuration.reverb_level, 0, 99); menu_system.update(); } @@ -919,8 +889,8 @@ void callback_chorus_frequency_function() #endif menu_system.change_menu(chorus_frequency_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = chorus_frequency; - enc[RIGHT_ENCODER].write(chorus_frequency, 0, 20); + encoder_value[RIGHT_ENCODER] = configuration.chorus_frequency; + enc[RIGHT_ENCODER].write(configuration.chorus_frequency, 0, 20); menu_system.update(); } @@ -931,8 +901,8 @@ void callback_chorus_delay_function() #endif menu_system.change_menu(chorus_delay_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = chorus_delay; - enc[RIGHT_ENCODER].write(chorus_delay, 0, 20); + encoder_value[RIGHT_ENCODER] = configuration.chorus_delay; + enc[RIGHT_ENCODER].write(configuration.chorus_delay, 0, 20); menu_system.update(); } @@ -943,8 +913,8 @@ void callback_chorus_level_function() #endif menu_system.change_menu(chorus_level_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = chorus_level; - enc[RIGHT_ENCODER].write(chorus_level, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.chorus_level; + enc[RIGHT_ENCODER].write(configuration.chorus_level, 0, 99); menu_system.update(); } @@ -955,8 +925,8 @@ void callback_bass_lr_level_function() #endif menu_system.change_menu(bass_lr_level_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = bass_lr_level; - enc[RIGHT_ENCODER].write(bass_lr_level, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.bass_lr_level; + enc[RIGHT_ENCODER].write(configuration.bass_lr_level, 0, 99); menu_system.update(); } @@ -967,8 +937,8 @@ void callback_bass_mono_level_function() #endif menu_system.change_menu(bass_mono_level_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = bass_mono_level; - enc[RIGHT_ENCODER].write(bass_mono_level, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.bass_mono_level; + enc[RIGHT_ENCODER].write(configuration.bass_mono_level, 0, 99); menu_system.update(); } @@ -979,8 +949,8 @@ void callback_eq_bass_function() #endif menu_system.change_menu(eq_bass_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = eq_bass; - enc[RIGHT_ENCODER].write(eq_bass, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.eq_bass; + enc[RIGHT_ENCODER].write(configuration.eq_bass, 0, 99); menu_system.update(); } @@ -991,8 +961,8 @@ void callback_eq_treble_function() #endif menu_system.change_menu(eq_treble_menu); menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = eq_treble; - enc[RIGHT_ENCODER].write(eq_treble, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.eq_treble; + enc[RIGHT_ENCODER].write(configuration.eq_treble, 0, 99); menu_system.update(); } @@ -1005,8 +975,8 @@ void callback_save_sound_function() { #endif menu_system.change_menu(save_sound_menu); menu_position[MAIN] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = sound; - enc[RIGHT_ENCODER].write(sound, 1, 99); + encoder_value[RIGHT_ENCODER] = configuration.sound; + enc[RIGHT_ENCODER].write(configuration.sound, 1, 99); menu_system.update(); } @@ -1043,8 +1013,8 @@ void callback_loudness_function() #endif menu_system.change_menu(loudness_menu); menu_position[SYSTEM] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = loudness; - enc[RIGHT_ENCODER].write(loudness, 0, 99); + encoder_value[RIGHT_ENCODER] = configuration.loudness; + enc[RIGHT_ENCODER].write(configuration.loudness, 0, 99); menu_system.update(); } @@ -1055,8 +1025,8 @@ void callback_midi_channel_function() #endif menu_system.change_menu(midi_channel_menu); menu_position[SYSTEM] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = midi_channel; - enc[RIGHT_ENCODER].write(midi_channel, 0, 16); + encoder_value[RIGHT_ENCODER] = configuration.midi_channel; + enc[RIGHT_ENCODER].write(configuration.midi_channel, 0, 16); menu_system.update(); } @@ -1067,8 +1037,8 @@ void callback_midi_soft_thru_function() #endif menu_system.change_menu(midi_soft_thru_menu); menu_position[SYSTEM] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = midi_soft_thru; - enc[RIGHT_ENCODER].write(midi_soft_thru, 0, 1); + encoder_value[RIGHT_ENCODER] = configuration.midi_soft_thru; + enc[RIGHT_ENCODER].write(configuration.midi_soft_thru, 0, 1); menu_system.update(); } @@ -1079,8 +1049,8 @@ void callback_max_poly_function() #endif menu_system.change_menu(max_poly_menu); menu_position[SYSTEM] = encoder_value[RIGHT_ENCODER]; - encoder_value[RIGHT_ENCODER] = max_poly; - enc[RIGHT_ENCODER].write(max_poly, 1, 32); + encoder_value[RIGHT_ENCODER] =configuration. max_poly; + enc[RIGHT_ENCODER].write(configuration.max_poly, 1, 32); menu_system.update(); } @@ -1101,6 +1071,12 @@ void callback_info_function() HELPER FUCTIONS ******************************************/ +float mapfloat(float val, float in_min, float in_max, float out_min, float out_max) +// e.g. mapfloat(float(effect_delay_feedback), 0, ENC_DELAY_FB_STEPS, 0.0, 1.0) +{ + return (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; +} + void encoder_switch_focus(uint8_t encoder_last, uint8_t encoder_value) { uint8_t i; @@ -1512,6 +1488,137 @@ void init_menus(void) encoder_value[RIGHT_ENCODER] = 0; } +void load_sound(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Load sound ")); + Serial.println(value); +#endif + ; +} + +void save_sound(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Save sound ")); + Serial.println(value); +#endif + ; +} + +void set_decay(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set DECAY ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_DECAY_MIN, ENC_DECAY_MAX, 0.0, 1.0); + ep->setParameter(MDA_EP_DECAY, tmp); +} + +void set_release(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set RELEASE ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_RELEASE_MIN, ENC_RELEASE_MAX, 0.0, 1.0); + ep->setParameter(MDA_EP_RELEASE, tmp); +} + +void set_hardness(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set HARDNESS ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_HARDNESS_MIN, ENC_HARDNESS_MAX, 0.0, 1.0); + ep->setParameter(MDA_EP_HARDNESS, tmp); +} + +void set_treble(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set TREBLE ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_TREBLE_MIN, ENC_TREBLE_MAX, 0.0, 1.0); + ep->setParameter(MDA_EP_TREBLE, tmp); +} + +void set_stereo(int8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set STEREO ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_STEREO_MIN, ENC_STEREO_MAX, 0.0, 1.0); + ep->setParameter(MDA_EP_STEREO, tmp); +} + +// transpose + +void set_tune(int8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set TUNE ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_TUNE_MIN, ENC_TUNE_MAX, 0.0, 1.0); + ep->setParameter(MDA_EP_TUNE, tmp); +} + +void set_detune(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set DETUNE ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_DETUNE_MIN, ENC_DETUNE_MAX, 0.0, 1.0); + ep->setParameter(MDA_EP_DETUNE, tmp); +} + +void set_velocity_sense(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set VELOCITY_SENSE ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_VELOCITY_SENSE_MIN, ENC_VELOCITY_SENSE_MAX, 0.0, 1.0); + ep->setParameter(MDA_EP_DETUNE, tmp); +} + +void set_pan_trem_frequency(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set PAN_TREM_FREQENCY ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_PAN_TREM_FREQUENCY_MIN, ENC_PAN_TREM_FREQUENCY_MAX, 0.0, 1.0); + ep->setParameter(MDA_EP_LFO_RATE, tmp); +} + +void set_pan_trem_level(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set PAN_TREM_LEVEL ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_PAN_TREM_LEVEL_MIN, ENC_PAN_TREM_LEVEL_MAX, 0.0, 1.0); + ep->setParameter(MDA_EP_PAN_TREM, tmp); +} + +void set_overdrive(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set OVERDRIVE ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_OVERDRIVE_MIN, ENC_OVERDRIVE_MAX, 0.0, 1.0); + ep->setParameter(MDA_EP_OVERDRIVE, tmp); +} + +//********************************************************************************************+ void handle_ui(void) { uint8_t i; @@ -1542,7 +1649,8 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - sound = encoder_tmp; + configuration.sound = encoder_tmp; + load_sound(configuration.sound); menu_system.update(); } } @@ -1551,7 +1659,8 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - decay = encoder_tmp; + configuration.decay = encoder_tmp; + set_decay(configuration.decay); menu_system.update(); } } @@ -1560,7 +1669,8 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - release = encoder_tmp; + configuration.release = encoder_tmp; + set_release(configuration.release); menu_system.update(); } } @@ -1569,7 +1679,8 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - hardness = encoder_tmp; + configuration.hardness = encoder_tmp; + set_hardness(configuration.hardness); menu_system.update(); } } @@ -1578,7 +1689,8 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - treble = encoder_tmp; + configuration.treble = encoder_tmp; + set_treble(configuration.treble); menu_system.update(); } } @@ -1587,7 +1699,8 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - stereo = encoder_tmp; + configuration.stereo = encoder_tmp; + set_stereo(configuration.stereo); menu_system.update(); } } @@ -1596,7 +1709,8 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - transpose = encoder_tmp; + configuration.transpose = encoder_tmp; + // Nothing to do... will be added in handleNoteOn() menu_system.update(); } } @@ -1605,7 +1719,8 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - tune = encoder_tmp; + configuration.tune = encoder_tmp; + set_tune(configuration.tune); menu_system.update(); } } @@ -1614,7 +1729,8 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - detune = encoder_tmp; + configuration.detune = encoder_tmp; + set_detune(configuration.detune); menu_system.update(); } } @@ -1623,7 +1739,8 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - velocity_sense = encoder_tmp; + configuration.velocity_sense = encoder_tmp; + set_velocity_sense(configuration.velocity_sense); menu_system.update(); } } @@ -1632,7 +1749,8 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - pan_trem_frequency = encoder_tmp; + configuration.pan_trem_frequency = encoder_tmp; + set_pan_trem_frequency(configuration.pan_trem_frequency); menu_system.update(); } } @@ -1641,7 +1759,8 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - pan_trem_level = encoder_tmp; + configuration.pan_trem_level = encoder_tmp; + set_pan_trem_level(configuration.pan_trem_level); menu_system.update(); } } @@ -1650,7 +1769,8 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - overdrive = encoder_tmp; + configuration.overdrive = encoder_tmp; + set_overdrive(configuration.overdrive); menu_system.update(); } } @@ -1659,7 +1779,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - comp_gain = encoder_tmp; + configuration.comp_gain = encoder_tmp; menu_system.update(); } } @@ -1668,7 +1788,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - comp_response = encoder_tmp; + configuration.comp_response = encoder_tmp; menu_system.update(); } } @@ -1677,7 +1797,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - comp_limit = encoder_tmp; + configuration.comp_limit = encoder_tmp; menu_system.update(); } } @@ -1686,7 +1806,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - comp_threshold = encoder_tmp; + configuration.comp_threshold = encoder_tmp; menu_system.update(); } } @@ -1695,7 +1815,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - comp_attack = encoder_tmp; + configuration.comp_attack = encoder_tmp; menu_system.update(); } } @@ -1704,7 +1824,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - comp_decay = encoder_tmp; + configuration.comp_decay = encoder_tmp; menu_system.update(); } } @@ -1713,7 +1833,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - reverb_roomsize = encoder_tmp; + configuration.reverb_roomsize = encoder_tmp; menu_system.update(); } } @@ -1722,7 +1842,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - reverb_damping = encoder_tmp; + configuration.reverb_damping = encoder_tmp; menu_system.update(); } } @@ -1731,7 +1851,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - reverb_level = encoder_tmp; + configuration.reverb_level = encoder_tmp; menu_system.update(); } } @@ -1740,7 +1860,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - chorus_frequency = encoder_tmp; + configuration.chorus_frequency = encoder_tmp; menu_system.update(); } } @@ -1749,7 +1869,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - chorus_delay = encoder_tmp; + configuration.chorus_delay = encoder_tmp; menu_system.update(); } } @@ -1758,7 +1878,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - chorus_level = encoder_tmp; + configuration.chorus_level = encoder_tmp; menu_system.update(); } } @@ -1767,7 +1887,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - bass_lr_level = encoder_tmp; + configuration.bass_lr_level = encoder_tmp; menu_system.update(); } } @@ -1776,7 +1896,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - bass_mono_level = encoder_tmp; + configuration.bass_mono_level = encoder_tmp; menu_system.update(); } } @@ -1785,7 +1905,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - eq_bass = encoder_tmp; + configuration.eq_bass = encoder_tmp; menu_system.update(); } } @@ -1794,7 +1914,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - eq_treble = encoder_tmp; + configuration.eq_treble = encoder_tmp; menu_system.update(); } } @@ -1803,7 +1923,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - sound = encoder_tmp; + configuration.sound = encoder_tmp; menu_system.update(); } } @@ -1812,7 +1932,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - loudness = encoder_tmp; + configuration.loudness = encoder_tmp; menu_system.update(); } } @@ -1821,7 +1941,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - midi_channel = encoder_tmp; + configuration.midi_channel = encoder_tmp; menu_system.update(); } } @@ -1830,7 +1950,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - midi_soft_thru = encoder_tmp; + configuration.midi_soft_thru = encoder_tmp; menu_system.update(); } } @@ -1839,7 +1959,7 @@ void handle_ui(void) if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - max_poly = encoder_tmp; + configuration.max_poly = encoder_tmp; menu_system.update(); } } @@ -1881,7 +2001,7 @@ void handle_ui(void) // load sound #ifdef DEBUG Serial.print("Load sound "); - Serial.println(sound); + Serial.println(configuration.sound); #endif ; // TODO } @@ -1890,7 +2010,7 @@ void handle_ui(void) // save sound #ifdef DEBUG Serial.print("Save sound "); - Serial.println(sound); + Serial.println(configuration.sound); #endif ; // TODO } @@ -1953,7 +2073,8 @@ void handle_ui(void) if (encoder_tmp != encoder_value[LEFT_ENCODER]) { master_volume = encoder_tmp; - old_screen = menu_system.get_currentScreen(); + float tmp = mapfloat(float(master_volume), ENC_MASTER_VOLUME_MIN, ENC_MASTER_VOLUME_MAX, 0.0, 1.0); + set_volume(tmp, 0.5); #ifdef DEBUG Serial.print(F("master_volume: ")); Serial.println(master_volume); diff --git a/config.h b/config.h index e214640..fafe67f 100644 --- a/config.h +++ b/config.h @@ -3,7 +3,7 @@ MicroMDAEPiano is a port of the MDA-EPiano sound engine (https://sourceforge.net/projects/mda-vst/) for the Teensy-3.5/3.6 with audio shield. - + (c)2019 H. Wirtz This program is free software; you can redistribute it and/or modify @@ -112,7 +112,158 @@ //************************************************************************************************* #define CONTROL_RATE_MS 100 -#define BACK_TO_MAIN_MS 500 +#define BACK_TO_MAIN_MS 800 + +// Encoder min/max values +#define ENC_DECAY_MIN 0 +#define ENC_DECAY_MAX 99 +#define ENC_DECAY_DEFAULT 49 +// +#define ENC_RELEASE_MIN 0 +#define ENC_RELEASE_MAX 99 +#define ENC_RELEASE_DEFAULT 49 +// +#define ENC_HARDNESS_MIN 0 +#define ENC_HARDNESS_MAX 99 +#define ENC_HARDNESS_DEFAULT 49 +// +#define ENC_TREBLE_MIN 0 +#define ENC_TREBLE_MAX 99 +#define ENC_TREBLE_DEFAULT 49 +// +#define ENC_STEREO_MIN 0 +#define ENC_STEREO_MAX 99 +#define ENC_STEREO_DEFAULT 64 +// +#define ENC_TRANSPOSE_MIN -24 +#define ENC_TRANSPOSE_MAX 24 +#define ENC_TRANSPOSE_DEFAULT 0 +// +#define ENC_TUNE_MIN 0 +#define ENC_TUNE_MAX 99 +#define ENC_TUNE_DEFAULT 49 +// +#define ENC_DETUNE_MIN 0 +#define ENC_DETUNE_MAX 99 +#define ENC_DETUNE_DEFAULT 14 +// +#define ENC_VELOCITY_SENSE_MIN 0 +#define ENC_VELOCITY_SENSE_MAX 99 +#define ENC_VELOCITY_SENSE_DEFAULT 24 +// +#define ENC_PAN_TREM_FREQUENCY_MIN 0 +#define ENC_PAN_TREM_FREQUENCY_MAX 99 +#define ENC_PAN_TREM_FREQUENCY_DEFAULT 50 +// +#define ENC_PAN_TREM_LEVEL_MIN 0 +#define ENC_PAN_TREM_LEVEL_MAX 99 +#define ENC_PAN_TREM_LEVEL_DEFAULT 50 +// +#define ENC_OVERDRIVE_MIN 0 +#define ENC_OVERDRIVE_MAX 99 +#define ENC_OVERDRIVE_DEFAULT 50 +// +#define ENC_COMP_GAIN_MIN 0 +#define ENC_COMP_GAIN_MAX 99 +#define ENC_COMP_GAIN_DEFAULT 50 +// +#define ENC_COMP_RESPONSE_MIN 0 +#define ENC_COMP_RESPONSE_MAX 99 +#define ENC_COMP_RESPONSE_DEFAULT 50 +// +#define ENC_COMP_LIMIT_MIN 0 +#define ENC_COMP_LIMIT_MAX 99 +#define ENC_COMP_LIMIT_DEFAULT 50 +// +#define ENC_COMP_THRESHOLD_MIN 0 +#define ENC_COMP_THRESHOLD_MAX 99 +#define ENC_COMP_THRESHOLD_DEFAULT 50 +// +#define ENC_COMP_ATTACK_MIN 0 +#define ENC_COMP_ATTACK_MAX 99 +#define ENC_COMP_ATTACK_DEFAULT 50 +// +#define ENC_COMP_DECAY_MIN 0 +#define ENC_COMP_DECAY_MAX 99 +#define ENC_COMP_DECAY_DEFAULT 50 +// +#define ENC_REVERB_ROOMSIZE_MIN 0 +#define ENC_REVERB_ROOMSIZE_MAX 99 +#define ENC_REVERB_ROOMSIZE_DEFAULT 50 +// +#define ENC_REVERB_DAMPING_MIN 0 +#define ENC_REVERB_DAMPING_MAX 99 +#define ENC_REVERB_DAMPING_DEFAULT 50 +// +#define ENC_REVERB_LEVEL_MIN 0 +#define ENC_REVERB_LEVEL_MAX 99 +#define ENC_REVERB_LEVEL_DEFAULT 50 +// +#define ENC_CHORUS_FREQUENCY_MIN 0 +#define ENC_CHORUS_FREQUENCY_MAX 20 +#define ENC_CHORUS_FREQUENCY_DEFAULT 3 +// +#define ENC_CHORUS_DELAY_MIN 0 +#define ENC_CHORUS_DELAY_MAX 20 +#define ENC_CHORUS_DELAY_DEFAULT 15 +// +#define ENC_CHORUS_LEVEL_MIN 0 +#define ENC_CHORUS_LEVEL_MAX 99 +#define ENC_CHORUS_LEVEL_DEFAULT 50 +// +#define ENC_BASS_LR_LEVEL_MIN 0 +#define ENC_BASS_LR_LEVEL_MAX 99 +#define ENC_BASS_LR_LEVEL_DEFAULT 50 +// +#define ENC_BASS_MONO_LEVEL_MIN 0 +#define ENC_BASS_MONO_LEVEL_MAX 99 +#define ENC_BASS_MONO_LEVEL_DEFAULT 50 +// +#define ENC_EQ_BASS_MIN 0 +#define ENC_EQ_BASS_MAX 99 +#define ENC_EQ_BASS_DEFAULT 50 +// +#define ENC_EQ_TREBLE_MIN 0 +#define ENC_EQ_TREBLE_MAX 99 +#define ENC_EQ_TREBLE_DEFAULT 50 +// +#define ENC_LOUDNESS_MIN 0 +#define ENC_LOUDNESS_MAX 99 +#define ENC_LOUDNESS_DEFAULT 80 +// +#define ENC_MIDI_CHANNEL_MIN 0 +#define ENC_MIDI_CHANNEL_MAX 16 +#define ENC_MIDI_CHANNEL_DEFAULT DEFAULT_MIDI_CHANNEL +// +#define ENC_MIDI_SOFT_THRU_MIN 0 +#define ENC_MIDI_SOFT_THRU_MAX 1 +#define ENC_MIDI_SOFT_THRU_DEFAULT 1 +// +#define ENC_MAX_POLY_MIN 1 +#define ENC_MAX_POLY_MAX 32 +#define ENC_MAX_POLY_DEFAULT 32 +// +#define ENC_MASTER_VOLUME_MIN 0 +#define ENC_MASTER_VOLUME_MAX 99 +#define ENC_MASTER_VOLUME_DEFAULT 80 +// +#define ENC_MASTER_PAN_MIN -20 +#define ENC_MASTER_PAN_MAX 20 +#define ENC_MASTER_PAN_DEFAULT 0 + +// MDAEPiano parameter mapping +#define MDA_EP_DECAY 0 +#define MDA_EP_RELEASE 1 +#define MDA_EP_HARDNESS 2 +#define MDA_EP_TREBLE 3 +#define MDA_EP_PAN_TREM 4 +#define MDA_EP_LFO_RATE 5 +#define MDA_EP_VELOCITY_SENSE 6 +#define MDA_EP_STEREO 7 +#define MDA_EP_MAX_POLY 8 +#define MDA_EP_TUNE 9 +#define MDA_EP_DETUNE 10 +#define MDA_EP_OVERDRIVE 11 // MIDI #ifdef MIDI_DEVICE_USB @@ -136,10 +287,40 @@ // struct for holding the current configuration struct config_t { uint32_t checksum; - uint8_t voice; - float vol; - float pan; + uint8_t sound; + uint8_t decay; + uint8_t release; + uint8_t hardness; + uint8_t treble; + int8_t stereo; + int8_t transpose; + int8_t tune; + uint8_t detune; + uint8_t velocity_sense; + uint8_t pan_trem_frequency; + uint8_t pan_trem_level; + uint8_t overdrive; + uint8_t comp_gain; + uint8_t comp_response; + uint8_t comp_limit; + uint8_t comp_threshold; + uint8_t comp_attack; + uint8_t comp_decay; + uint8_t reverb_roomsize; + uint8_t reverb_damping; + uint8_t reverb_level; + uint8_t chorus_frequency; + uint8_t chorus_delay; + uint8_t chorus_level; + uint8_t bass_lr_level; + uint8_t bass_mono_level; + uint8_t eq_bass; + uint8_t eq_treble; + uint8_t loudness; uint8_t midi_channel; + uint8_t midi_soft_thru; + uint8_t max_poly; + int8_t pan; }; #endif diff --git a/mdaEPiano.cpp b/mdaEPiano.cpp index 3aad90f..019ec42 100644 --- a/mdaEPiano.cpp +++ b/mdaEPiano.cpp @@ -240,8 +240,8 @@ void mdaEPiano::process(int16_t* outputs_r, int16_t* outputs_l) l = 1.0; else if (l < -1.0) l = -1.0; - outputs_l[frame] = static_cast(l * configuration.vol * 0x7fff) >> REDUCE_LOUDNESS; - outputs_r[frame] = static_cast(r * configuration.vol * 0x7fff) >> REDUCE_LOUDNESS; + outputs_l[frame] = static_cast(l * configuration.loudness * 0x7fff) >> REDUCE_LOUDNESS; + outputs_r[frame] = static_cast(r * configuration.loudness * 0x7fff) >> REDUCE_LOUDNESS; } if (fabs(tl) < 1.0e-10) tl = 0.0f; //anti-denormal