You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3227 lines
106 KiB

  1. /*
  2. MicroMDAEPiano
  3. MicroMDAEPiano is a port of the MDA-EPiano sound engine
  4. (https://sourceforge.net/projects/mda-vst/) for the Teensy-3.5/3.6 with audio shield.
  5. (c)2019 H. Wirtz <wirtz@parasitstudio.de>
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software Foundation,
  16. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. /* Don't forget to change parameters in ../libraries/LiquidMenu/src/LiquidMenu_config.h
  19. /// Configures the number of available variables per line.
  20. const uint8_t MAX_VARIABLES = 5; ///< @note Default: 5
  21. /// Configures the number of available functions per line.
  22. const uint8_t MAX_FUNCTIONS = 42; ///< @note Default: 8
  23. /// Configures the number of available lines per screen.
  24. const uint8_t MAX_LINES = 20; ///< @note Default: 12
  25. /// Configures the number of available screens per menu.
  26. const uint8_t MAX_SCREENS = 2; ///< @note Default: 14
  27. /// Configures the number of available menus per menus system.
  28. const uint8_t MAX_MENUS = 45; ///< @note Default: 8
  29. */
  30. #ifndef UI_HPP_INCLUDED
  31. #define UI_HPP_INCLUDED
  32. #include <LiquidCrystal_I2C.h>
  33. #include <LiquidMenu.h>
  34. #define BOUNCE_WITH_PROMPT_DETECTION
  35. #include <Bounce.h>
  36. #include "Encoder4.h"
  37. #include "config.h"
  38. LiquidCrystal_I2C lcd(LCD_I2C_ADDRESS, LCD_CHARS, LCD_LINES);
  39. Encoder4 enc[NUM_ENCODER] = {Encoder4(ENC_L_PIN_A, ENC_L_PIN_B), Encoder4(ENC_R_PIN_A, ENC_R_PIN_B)};
  40. int32_t encoder_value[NUM_ENCODER];
  41. Bounce but[NUM_ENCODER] = {Bounce(BUT_L_PIN, BUT_DEBOUNCE_MS), Bounce(BUT_R_PIN, BUT_DEBOUNCE_MS)};
  42. elapsedMillis back_to_main;
  43. #define NUM_MENUS 44
  44. #define MAIN 0
  45. /*************************************/
  46. #define LOAD_SOUND 1
  47. #define EDIT_SOUND 2
  48. #define EFFECTS 3
  49. #define SAVE_SOUND 4
  50. #define SYSTEM 5
  51. #define INFO 6
  52. /*************************************/
  53. #define DECAY 7
  54. #define RELEASE 8
  55. #define HARDNESS 9
  56. #define TREBLE 10
  57. #define STEREO_LEVEL 11
  58. #define TRANSPOSE 12
  59. #define TUNE 13
  60. #define DETUNE 14
  61. #define VELOCITY_SENSE 15
  62. /*************************************/
  63. #define PAN_TREM_FREQUENCY 16
  64. #define PAN_TREM_LEVEL 17
  65. #define OVERDRIVE 18
  66. #define COMP_GAIN 19
  67. #define COMP_RESPONSE 20
  68. #define COMP_LIMIT 21
  69. #define COMP_THRESHOLD 22
  70. #define COMP_ATTACK 23
  71. #define COMP_DECAY 24
  72. #define REV_ROOMSIZE 25
  73. #define REV_DAMPING 26
  74. #define REV_LEVEL 27
  75. #define CHORUS_FREQ 28
  76. #define CHORUS_INTENSITY 29
  77. #define CHORUS_WAVEFORM 30
  78. #define CHORUS_LEVEL 31
  79. #define BASS_LR_LEVEL 32
  80. #define BASS_MONO_LEVEL 33
  81. #define EQ_BASS 34
  82. #define EQ_TREBLE 35
  83. /*************************************/
  84. #define LOUDNESS 36
  85. #define MIDI_CHANNEL 37
  86. #define MIDI_SOFT_THRU 38
  87. #define MAX_POLY 39
  88. #define MONO 40
  89. #define PANORAMA 41
  90. /*************************************/
  91. #define STORE_QUESTION 42
  92. /*************************************/
  93. #define MASTER_VOLUME 43
  94. /*************************************/
  95. int8_t menu_position[NUM_MENUS];
  96. bool yes_no = false;
  97. #define LEFT_ENCODER 0
  98. #define RIGHT_ENCODER 1
  99. extern void set_master_volume(uint8_t value);
  100. extern void config_from_eeprom(void);
  101. extern void eeprom_config_write(uint8_t value);
  102. extern AudioControlSGTL5000 sgtl5000_1;
  103. extern AudioEffectFreeverb freeverb_r;
  104. extern AudioEffectFreeverb freeverb_l;
  105. extern AudioSynthWaveform modulator;
  106. extern AudioEffectModulatedDelay modchorus_r;
  107. extern AudioEffectModulatedDelay modchorus_l;
  108. extern AudioMixer4 mixer_r;
  109. extern AudioMixer4 mixer_l;
  110. extern AudioAmplifier volume_r;
  111. extern AudioAmplifier volume_l;
  112. extern AudioAmplifier inverter;
  113. extern mdaEPiano* ep;
  114. extern config_t configuration;
  115. extern uint8_t sound;
  116. extern uint8_t master_volume;
  117. extern int8_t pan;
  118. /******************************************
  119. TEXT GETTER FUCTIONS
  120. ******************************************/
  121. char comp_gain_value_text1[] = " 0 dB";
  122. char comp_gain_value_text2[] = "+ 6 dB";
  123. char comp_gain_value_text3[] = "+12 dB";
  124. char* get_comp_gain_value_text(void)
  125. {
  126. switch (configuration.comp_gain)
  127. {
  128. case 0:
  129. return (comp_gain_value_text1);
  130. break;
  131. case 1:
  132. return (comp_gain_value_text2);
  133. break;
  134. case 2:
  135. return (comp_gain_value_text3);
  136. break;
  137. }
  138. return ('\0');
  139. }
  140. char comp_response_value_text1[] = " 0 ms";
  141. char comp_response_value_text2[] = " 25 ms";
  142. char comp_response_value_text3[] = " 50 ms";
  143. char comp_response_value_text4[] = "100 ms";
  144. char* get_comp_response_value_text(void)
  145. {
  146. switch (configuration.comp_response)
  147. {
  148. case 0:
  149. return (comp_response_value_text1);
  150. break;
  151. case 1:
  152. return (comp_response_value_text2);
  153. break;
  154. case 2:
  155. return (comp_response_value_text3);
  156. break;
  157. case 3:
  158. return (comp_response_value_text4);
  159. break;
  160. }
  161. return ('\0');
  162. }
  163. char comp_limit_value_text1[] = "soft Knee";
  164. char comp_limit_value_text2[] = "hard Knee";
  165. char* get_comp_limit_value_text(void)
  166. {
  167. if (configuration.comp_limit == false)
  168. return (comp_limit_value_text1);
  169. else
  170. return (comp_limit_value_text2);
  171. }
  172. char comp_threshold_value_text1[] = " ";
  173. char* get_comp_threshold_value_text(void)
  174. {
  175. if (configuration.comp_threshold == 0)
  176. sprintf(comp_threshold_value_text1, " %0d dBFS", configuration.comp_threshold);
  177. else
  178. sprintf(comp_threshold_value_text1, "-%0d dBFS", configuration.comp_threshold);
  179. return (comp_threshold_value_text1);
  180. }
  181. char comp_attack_value_text1[] = " ";
  182. char* get_comp_attack_value_text(void)
  183. {
  184. sprintf(comp_attack_value_text1, "%0.1f dB/s", (float)configuration.comp_attack / 10);
  185. return (comp_attack_value_text1);
  186. }
  187. char comp_decay_value_text1[] = " ";
  188. char* get_comp_decay_value_text(void)
  189. {
  190. sprintf(comp_decay_value_text1, "%0.1f dB/s", float(configuration.comp_decay) / 10);
  191. return (comp_decay_value_text1);
  192. }
  193. char tune_value_text1[] = " ";
  194. char* get_tune_value_text(void)
  195. {
  196. sprintf(tune_value_text1, "%3d cent", configuration.tune);
  197. return (tune_value_text1);
  198. }
  199. char chorus_frequency_value_text1[] = " ";
  200. char* get_chorus_frequency_value_text(void)
  201. {
  202. sprintf(chorus_frequency_value_text1, "%2.1f Hz", float(configuration.chorus_frequency) / 10);
  203. return (chorus_frequency_value_text1);
  204. }
  205. char chorus_waveform_value_text1[] = " ";
  206. char* get_chorus_waveform_value_text(void)
  207. {
  208. switch (configuration.chorus_waveform)
  209. {
  210. case 1:
  211. sprintf(chorus_waveform_value_text1, "TRIANGLE");
  212. break;
  213. case 2:
  214. sprintf(chorus_waveform_value_text1, "SINE");
  215. break;
  216. default:
  217. sprintf(chorus_waveform_value_text1, "TRIANGLE");
  218. }
  219. return (chorus_waveform_value_text1);
  220. }
  221. char midi_channel_value_text1[] = " ";
  222. char* get_midi_channel_value_text(void)
  223. {
  224. if (configuration.midi_channel == 0)
  225. sprintf(midi_channel_value_text1, "OMNI");
  226. else
  227. sprintf(midi_channel_value_text1, "%02d", configuration.midi_channel);
  228. return (midi_channel_value_text1);
  229. }
  230. char midi_soft_thru_value_text1[] = " ";
  231. char* get_midi_soft_thru_value_text(void)
  232. {
  233. if (configuration.midi_soft_thru == false)
  234. sprintf(midi_soft_thru_value_text1, "Off");
  235. else
  236. sprintf(midi_soft_thru_value_text1, "On ");
  237. return (midi_soft_thru_value_text1);
  238. }
  239. char mono_value_text1[] = " ";
  240. char* get_mono_value_text(void)
  241. {
  242. if (configuration.mono == 0)
  243. sprintf(mono_value_text1, "Stereo");
  244. else if (configuration.mono == 1)
  245. sprintf(mono_value_text1, "Mono ");
  246. else if (configuration.mono == 2)
  247. sprintf(mono_value_text1, "Mono R");
  248. else
  249. sprintf(mono_value_text1, "Mono L");
  250. return (mono_value_text1);
  251. }
  252. char yes_no_value_text1[] = " ";
  253. char* get_yes_no_value_text(void)
  254. {
  255. if (yes_no == false)
  256. sprintf(yes_no_value_text1, "No ");
  257. else
  258. sprintf(yes_no_value_text1, "Yes");
  259. return (yes_no_value_text1);
  260. }
  261. /******************************************
  262. MAIN MENU
  263. ******************************************/
  264. #define NUM_MAIN_MENUS 6
  265. const char main_text1[] PROGMEM = "Load Sound";
  266. const char main_text2[] PROGMEM = "Edit Sound";
  267. const char main_text3[] PROGMEM = "Effects";
  268. const char main_text4[] PROGMEM = "Save Sound";
  269. const char main_text5[] PROGMEM = "System";
  270. const char main_text6[] PROGMEM = "Info";
  271. LiquidLine main_line1(1, 0, main_text1);
  272. LiquidLine main_line2(1, 1, main_text2);
  273. LiquidLine main_line3(1, 1, main_text3);
  274. LiquidLine main_line4(1, 1, main_text4);
  275. LiquidLine main_line5(1, 1, main_text5);
  276. LiquidLine main_line6(1, 1, main_text6);
  277. LiquidScreen main_screen;
  278. LiquidMenu main_menu(lcd);
  279. /******************************************
  280. LOAD SOUND MENU
  281. ******************************************/
  282. #define NUM_LOAD_SOUNDS_MENUS 1
  283. const char load_sound_text1[] PROGMEM = "Load Sound";
  284. LiquidLine load_sound_line1(1, 0, load_sound_text1);
  285. LiquidLine load_sound_line2(1, 1, sound);
  286. LiquidScreen load_sound_screen;
  287. LiquidMenu load_sound_menu(lcd);
  288. /******************************************
  289. EDIT SOUND MENU
  290. ******************************************/
  291. #define NUM_EDIT_SOUND_MENUS 9
  292. const char edit_sound_text1[] PROGMEM = "Decay";
  293. const char edit_sound_text2[] PROGMEM = "Release";
  294. const char edit_sound_text3[] PROGMEM = "Hardness";
  295. const char edit_sound_text4[] PROGMEM = "Treble";
  296. const char edit_sound_text5[] PROGMEM = "Stereo Level";
  297. const char edit_sound_text6[] PROGMEM = "Transpose";
  298. const char edit_sound_text7[] PROGMEM = "Tune";
  299. const char edit_sound_text8[] PROGMEM = "Detune";
  300. const char edit_sound_text9[] PROGMEM = "Velocity Sense";
  301. LiquidLine edit_sound_line1(1, 0, edit_sound_text1);
  302. LiquidLine edit_sound_line2(1, 1, edit_sound_text2);
  303. LiquidLine edit_sound_line3(1, 1, edit_sound_text3);
  304. LiquidLine edit_sound_line4(1, 1, edit_sound_text4);
  305. LiquidLine edit_sound_line5(1, 1, edit_sound_text5);
  306. LiquidLine edit_sound_line6(1, 1, edit_sound_text6);
  307. LiquidLine edit_sound_line7(1, 1, edit_sound_text7);
  308. LiquidLine edit_sound_line8(1, 1, edit_sound_text8);
  309. LiquidLine edit_sound_line9(1, 1, edit_sound_text9);
  310. LiquidScreen edit_sound_screen;
  311. LiquidMenu edit_sound_menu(lcd);
  312. /******************************************
  313. DECAY MENU
  314. ******************************************/
  315. #define NUM_DECAY_MENUS 1
  316. const char decay_text1[] PROGMEM = "Decay";
  317. LiquidLine decay_line1(1, 0, decay_text1);
  318. LiquidLine decay_line2(1, 1, configuration.decay);
  319. LiquidScreen decay_screen;
  320. LiquidMenu decay_menu(lcd);
  321. /******************************************
  322. RELEASE MENU
  323. ******************************************/
  324. #define NUM_RELEASE_MENUS 1
  325. const char release_text1[] PROGMEM = "Release";
  326. LiquidLine release_line1(1, 0, release_text1);
  327. LiquidLine release_line2(1, 1, configuration.release);
  328. LiquidScreen release_screen;
  329. LiquidMenu release_menu(lcd);
  330. /******************************************
  331. HARDNESS MENU
  332. ******************************************/
  333. #define NUM_HARDNESS_MENUS 1
  334. const char hardness_text1[] PROGMEM = "Hardness";
  335. LiquidLine hardness_line1(1, 0, hardness_text1);
  336. LiquidLine hardness_line2(1, 1, configuration.hardness);
  337. LiquidScreen hardness_screen;
  338. LiquidMenu hardness_menu(lcd);
  339. /******************************************
  340. TREBLE MENU
  341. ******************************************/
  342. #define NUM_TREBLE_MENUS 1
  343. const char treble_text1[] PROGMEM = "Treble";
  344. LiquidLine treble_line1(1, 0, treble_text1);
  345. LiquidLine treble_line2(1, 1, configuration.treble);
  346. LiquidScreen treble_screen;
  347. LiquidMenu treble_menu(lcd);
  348. /******************************************
  349. STEREO MENU
  350. ******************************************/
  351. #define NUM_TREBLE_MENUS 1
  352. const char stereo_text1[] PROGMEM = "Stereo";
  353. LiquidLine stereo_line1(1, 0, stereo_text1);
  354. LiquidLine stereo_line2(1, 1, configuration.stereo);
  355. LiquidScreen stereo_screen;
  356. LiquidMenu stereo_menu(lcd);
  357. /******************************************
  358. TRANSPOSE MENU
  359. ******************************************/
  360. #define NUM_TRANSPOSE_MENUS 1
  361. const char transpose_text1[] PROGMEM = "Transpose";
  362. LiquidLine transpose_line1(1, 0, transpose_text1);
  363. LiquidLine transpose_line2(1, 1, configuration.transpose);
  364. LiquidScreen transpose_screen;
  365. LiquidMenu transpose_menu(lcd);
  366. /******************************************
  367. TUNE MENU
  368. ******************************************/
  369. #define NUM_TUNE_MENUS 1
  370. const char tune_text1[] PROGMEM = "Tune";
  371. LiquidLine tune_line1(1, 0, tune_text1);
  372. //LiquidLine tune_line2(1, 1, configuration.tune);
  373. LiquidLine tune_line2(1, 1, get_tune_value_text);
  374. LiquidScreen tune_screen;
  375. LiquidMenu tune_menu(lcd);
  376. /******************************************
  377. DETUNE MENU
  378. ******************************************/
  379. #define NUM_DETUNE_MENUS 1
  380. const char detune_text1[] PROGMEM = "Detune";
  381. LiquidLine detune_line1(1, 0, detune_text1);
  382. LiquidLine detune_line2(1, 1, configuration.detune);
  383. LiquidScreen detune_screen;
  384. LiquidMenu detune_menu(lcd);
  385. /******************************************
  386. VELOCITY MENU
  387. ******************************************/
  388. #define NUM_VELOCITY_MENUS 1
  389. const char velocity_sense_text1[] PROGMEM = "Velocity Sense";
  390. LiquidLine velocity_sense_line1(1, 0, velocity_sense_text1);
  391. LiquidLine velocity_sense_line2(1, 1, configuration.velocity_sense);
  392. LiquidScreen velocity_sense_screen;
  393. LiquidMenu velocity_sense_menu(lcd);
  394. /******************************************
  395. EFFECTS MENU
  396. ******************************************/
  397. #define NUM_EFFECTS_MENUS 20
  398. const char effects_text1[] PROGMEM = "Pan/Trem Freq.";
  399. const char effects_text2[] PROGMEM = "Pan/Trem Level";
  400. const char effects_text3[] PROGMEM = "Overdrive";
  401. const char effects_text4[] PROGMEM = "Comp. Gain";
  402. const char effects_text5[] PROGMEM = "Comp. Response";
  403. const char effects_text6[] PROGMEM = "Comp. Limit";
  404. const char effects_text7[] PROGMEM = "Comp. Threshold";
  405. const char effects_text8[] PROGMEM = "Comp. Attack";
  406. const char effects_text9[] PROGMEM = "Comp. Decay";
  407. const char effects_text10[] PROGMEM = "Reverb Roomsize";
  408. const char effects_text11[] PROGMEM = "Reverb Damping";
  409. const char effects_text12[] PROGMEM = "Reverb Level";
  410. const char effects_text13[] PROGMEM = "Chorus Freq.";
  411. const char effects_text14[] PROGMEM = "Chorus Intens.";
  412. const char effects_text15[] PROGMEM = "Chorus Waveform";
  413. const char effects_text16[] PROGMEM = "Chorus Level";
  414. const char effects_text17[] PROGMEM = "Bass LR Level";
  415. const char effects_text18[] PROGMEM = "Bass M Level";
  416. const char effects_text19[] PROGMEM = "EQ Bass";
  417. const char effects_text20[] PROGMEM = "EQ Treble";
  418. LiquidLine effects_line1(1, 0, effects_text1);
  419. LiquidLine effects_line2(1, 1, effects_text2);
  420. LiquidLine effects_line3(1, 1, effects_text3);
  421. LiquidLine effects_line4(1, 1, effects_text4);
  422. LiquidLine effects_line5(1, 1, effects_text5);
  423. LiquidLine effects_line6(1, 1, effects_text6);
  424. LiquidLine effects_line7(1, 1, effects_text7);
  425. LiquidLine effects_line8(1, 1, effects_text8);
  426. LiquidLine effects_line9(1, 1, effects_text9);
  427. LiquidLine effects_line10(1, 1, effects_text10);
  428. LiquidLine effects_line11(1, 1, effects_text11);
  429. LiquidLine effects_line12(1, 1, effects_text12);
  430. LiquidLine effects_line13(1, 1, effects_text13);
  431. LiquidLine effects_line14(1, 1, effects_text14);
  432. LiquidLine effects_line15(1, 1, effects_text15);
  433. LiquidLine effects_line16(1, 1, effects_text16);
  434. LiquidLine effects_line17(1, 1, effects_text17);
  435. LiquidLine effects_line18(1, 1, effects_text18);
  436. LiquidLine effects_line19(1, 1, effects_text19);
  437. LiquidLine effects_line20(1, 1, effects_text20);
  438. LiquidScreen effects_screen;
  439. LiquidMenu effects_menu(lcd);
  440. /******************************************
  441. PAN_TREM_FRQUENCY MENU
  442. ******************************************/
  443. #define NUM_PAN_TREM_FRQUENCY_MENUS 1
  444. const char pan_trem_frequency_text1[] PROGMEM = "PAN/Trem Freq.";
  445. LiquidLine pan_trem_frequency_line1(1, 0, pan_trem_frequency_text1);
  446. LiquidLine pan_trem_frequency_line2(1, 1, configuration.pan_trem_frequency);
  447. LiquidScreen pan_trem_frequency_screen;
  448. LiquidMenu pan_trem_frequency_menu(lcd);
  449. /******************************************
  450. PAN_TREM_LEVEL MENU
  451. ******************************************/
  452. #define NUM_PAN_TREM_LEVEL_MENUS 1
  453. const char pan_trem_level_text1[] PROGMEM = "Pan/Trem Level";
  454. LiquidLine pan_trem_level_line1(1, 0, pan_trem_level_text1);
  455. LiquidLine pan_trem_level_line2(1, 1, configuration.pan_trem_level);
  456. LiquidScreen pan_trem_level_screen;
  457. LiquidMenu pan_trem_level_menu(lcd);
  458. /******************************************
  459. OVERDRIVE MENU
  460. ******************************************/
  461. #define NUM_OVERDRIVE_MENUS 1
  462. const char overdrive_text1[] PROGMEM = "Overdrive";
  463. LiquidLine overdrive_line1(1, 0, overdrive_text1);
  464. LiquidLine overdrive_line2(1, 1, configuration.overdrive);
  465. LiquidScreen overdrive_screen;
  466. LiquidMenu overdrive_menu(lcd);
  467. /******************************************
  468. COMP_GAIN MENU
  469. ******************************************/
  470. #define NUM_COMP_GAIN_MENUS 1
  471. const char comp_gain_text1[] PROGMEM = "Comp. Gain";
  472. LiquidLine comp_gain_line1(1, 0, comp_gain_text1);
  473. //LiquidLine comp_gain_line2(1, 1, configuration.comp_gain);
  474. LiquidLine comp_gain_line2(1, 1, get_comp_gain_value_text);
  475. LiquidScreen comp_gain_screen;
  476. LiquidMenu comp_gain_menu(lcd);
  477. /******************************************
  478. COMP_RESPONSE MENU
  479. ******************************************/
  480. #define NUM_COMP_RESPONSE_MENUS 1
  481. const char comp_response_text1[] PROGMEM = "Comp. Response";
  482. LiquidLine comp_response_line1(1, 0, comp_response_text1);
  483. LiquidLine comp_response_line2(1, 1, get_comp_response_value_text);
  484. LiquidScreen comp_response_screen;
  485. LiquidMenu comp_response_menu(lcd);
  486. /******************************************
  487. COMP_LIMIT MENU
  488. ******************************************/
  489. #define NUM_COMP_LIMIT_MENUS 1
  490. const char comp_limit_text1[] PROGMEM = "Comp. Limit";
  491. LiquidLine comp_limit_line1(1, 0, comp_limit_text1);
  492. LiquidLine comp_limit_line2(1, 1, get_comp_limit_value_text);
  493. LiquidScreen comp_limit_screen;
  494. LiquidMenu comp_limit_menu(lcd);
  495. /******************************************
  496. COMP_THRESHOLD MENU
  497. ******************************************/
  498. #define NUM_COMP_THRESHOLD_MENUS 1
  499. const char comp_threshold_text1[] PROGMEM = "Comp. Threshold";
  500. LiquidLine comp_threshold_line1(1, 0, comp_threshold_text1);
  501. LiquidLine comp_threshold_line2(1, 1, get_comp_threshold_value_text);
  502. LiquidScreen comp_threshold_screen;
  503. LiquidMenu comp_threshold_menu(lcd);
  504. /******************************************
  505. COMP_ATTACK MENU
  506. ******************************************/
  507. #define NUM_COMP_ATTACK_MENUS 1
  508. const char comp_attack_text1[] PROGMEM = "Comp. Attack";
  509. LiquidLine comp_attack_line1(1, 0, comp_attack_text1);
  510. LiquidLine comp_attack_line2(1, 1, get_comp_attack_value_text);
  511. LiquidScreen comp_attack_screen;
  512. LiquidMenu comp_attack_menu(lcd);
  513. /******************************************
  514. COMP_DECAY MENU
  515. ******************************************/
  516. #define NUM_COMP_DECAY_MENUS 1
  517. const char comp_decay_text1[] PROGMEM = "Comp. Decay";
  518. LiquidLine comp_decay_line1(1, 0, comp_decay_text1);
  519. //LiquidLine comp_decay_line2(1, 1, configuration.comp_decay);
  520. LiquidLine comp_decay_line2(1, 1, get_comp_decay_value_text);
  521. LiquidScreen comp_decay_screen;
  522. LiquidMenu comp_decay_menu(lcd);
  523. /******************************************
  524. REVERB_ROOMSIZE MENU
  525. ******************************************/
  526. #define NUM_REVERB_ROOMSIZE_MENUS 1
  527. const char reverb_roomsize_text1[] PROGMEM = "Reverb Roomsize";
  528. LiquidLine reverb_roomsize_line1(1, 0, reverb_roomsize_text1);
  529. LiquidLine reverb_roomsize_line2(1, 1, configuration.reverb_roomsize);
  530. LiquidScreen reverb_roomsize_screen;
  531. LiquidMenu reverb_roomsize_menu(lcd);
  532. /******************************************
  533. REVERB_DAMPING MENU
  534. ******************************************/
  535. #define NUM_REVERB_DAMPING_MENUS 1
  536. const char reverb_damping_text1[] PROGMEM = "Reverb Damping";
  537. LiquidLine reverb_damping_line1(1, 0, reverb_damping_text1);
  538. LiquidLine reverb_damping_line2(1, 1, configuration.reverb_damping);
  539. LiquidScreen reverb_damping_screen;
  540. LiquidMenu reverb_damping_menu(lcd);
  541. /******************************************
  542. REVERB_LEVEL MENU
  543. ******************************************/
  544. #define NUM_REVERB_LEVEL_MENUS 1
  545. const char reverb_level_text1[] PROGMEM = "Reverb Level";
  546. LiquidLine reverb_level_line1(1, 0, reverb_level_text1);
  547. LiquidLine reverb_level_line2(1, 1, configuration.reverb_level);
  548. LiquidScreen reverb_level_screen;
  549. LiquidMenu reverb_level_menu(lcd);
  550. /******************************************
  551. CHORUS_FREQUENCY MENU
  552. ******************************************/
  553. #define NUM_CHORUS_FREQUENCY_MENUS 1
  554. const char chorus_frequency_text1[] PROGMEM = "Chorus Freq.";
  555. LiquidLine chorus_frequency_line1(1, 0, chorus_frequency_text1);
  556. LiquidLine chorus_frequency_line2(1, 1, get_chorus_frequency_value_text);
  557. LiquidScreen chorus_frequency_screen;
  558. LiquidMenu chorus_frequency_menu(lcd);
  559. /******************************************
  560. CHORUS_INTENSITY MENU
  561. ******************************************/
  562. #define NUM_CHORUS_INTENSITY_MENUS 1
  563. const char chorus_intensity_text1[] PROGMEM = "Chorus Intens.";
  564. LiquidLine chorus_intensity_line1(1, 0, chorus_intensity_text1);
  565. LiquidLine chorus_intensity_line2(1, 1, configuration.chorus_intensity);
  566. LiquidScreen chorus_intensity_screen;
  567. LiquidMenu chorus_intensity_menu(lcd);
  568. /******************************************
  569. CHORUS_WAVEFORM MENU
  570. ******************************************/
  571. #define NUM_CHORUS_WAVEFORM_MENUS 1
  572. const char chorus_waveform_text1[] PROGMEM = "Chorus Waveform";
  573. LiquidLine chorus_waveform_line1(1, 0, chorus_waveform_text1);
  574. LiquidLine chorus_waveform_line2(1, 1, get_chorus_waveform_value_text);
  575. LiquidScreen chorus_waveform_screen;
  576. LiquidMenu chorus_waveform_menu(lcd);
  577. /******************************************
  578. CHORUS_LEVEL MENU
  579. ******************************************/
  580. #define NUM_CHORUS_LEVEL_MENUS 1
  581. const char chorus_level_text1[] PROGMEM = "Chorus Level";
  582. LiquidLine chorus_level_line1(1, 0, chorus_level_text1);
  583. LiquidLine chorus_level_line2(1, 1, configuration.chorus_level);
  584. LiquidScreen chorus_level_screen;
  585. LiquidMenu chorus_level_menu(lcd);
  586. /******************************************
  587. BASS_LR_LEVEL MENU
  588. ******************************************/
  589. #define NUM_BASS_LR_LEVEL_MENUS 1
  590. const char bass_lr_level_text1[] PROGMEM = "Bass L/R Level";
  591. LiquidLine bass_lr_level_line1(1, 0, bass_lr_level_text1);
  592. LiquidLine bass_lr_level_line2(1, 1, configuration.bass_lr_level);
  593. LiquidScreen bass_lr_level_screen;
  594. LiquidMenu bass_lr_level_menu(lcd);
  595. /******************************************
  596. BASS_MONO_LEVEL MENU
  597. ******************************************/
  598. #define NUM_BASS_MONO_LEVEL_MENUS 1
  599. const char bass_mono_level_text1[] PROGMEM = "Bass mono Level";
  600. LiquidLine bass_mono_level_line1(1, 0, bass_mono_level_text1);
  601. LiquidLine bass_mono_level_line2(1, 1, configuration.bass_mono_level);
  602. LiquidScreen bass_mono_level_screen;
  603. LiquidMenu bass_mono_level_menu(lcd);
  604. /******************************************
  605. EQ_BASS MENU
  606. ******************************************/
  607. #define NUM_EQ_BASS_MENUS 1
  608. const char eq_bass_text1[] PROGMEM = "EQ Bass";
  609. LiquidLine eq_bass_line1(1, 0, eq_bass_text1);
  610. LiquidLine eq_bass_line2(1, 1, configuration.eq_bass);
  611. LiquidScreen eq_bass_screen;
  612. LiquidMenu eq_bass_menu(lcd);
  613. /******************************************
  614. EQ_TREBLE MENU
  615. ******************************************/
  616. #define NUM_EQ_TREBLE_MENUS 1
  617. const char eq_treble_text1[] PROGMEM = "EQ Treble";
  618. LiquidLine eq_treble_line1(1, 0, eq_treble_text1);
  619. LiquidLine eq_treble_line2(1, 1, configuration.eq_treble);
  620. LiquidScreen eq_treble_screen;
  621. LiquidMenu eq_treble_menu(lcd);
  622. /******************************************
  623. SAVE SOUND MENU
  624. ******************************************/
  625. #define NUM_SAVE_SOUNDS_MENUS 2
  626. const char save_sound_text1[] PROGMEM = "Save Sound";
  627. LiquidLine save_sound_line1(1, 0, save_sound_text1);
  628. LiquidLine save_sound_line2(1, 1, sound);
  629. LiquidScreen save_sound_screen;
  630. LiquidMenu save_sound_menu(lcd);
  631. /******************************************
  632. SYSTEM MENU
  633. ******************************************/
  634. #define NUM_SYSTEM_MENUS 6
  635. const char system_text1[] PROGMEM = "Loudness";
  636. const char system_text2[] PROGMEM = "MIDI Channel";
  637. const char system_text3[] PROGMEM = "MIDI Soft-Thru";
  638. const char system_text4[] PROGMEM = "Max. Polyphony";
  639. const char system_text5[] PROGMEM = "Mono/Stereo";
  640. const char system_text6[] PROGMEM = "Panorama";
  641. LiquidLine system_line1(1, 0, system_text1);
  642. LiquidLine system_line2(1, 1, system_text2);
  643. LiquidLine system_line3(1, 1, system_text3);
  644. LiquidLine system_line4(1, 1, system_text4);
  645. LiquidLine system_line5(1, 1, system_text5);
  646. LiquidLine system_line6(1, 1, system_text6);
  647. LiquidScreen system_screen;
  648. LiquidMenu system_menu(lcd);
  649. /******************************************
  650. LOUDNESS MENU
  651. ******************************************/
  652. #define NUM_LOUDNESS_MENUS 1
  653. const char loudness_text1[] PROGMEM = "Loudness";
  654. LiquidLine loudness_line1(1, 0, loudness_text1);
  655. LiquidLine loudness_line2(1, 1, configuration.loudness);
  656. LiquidScreen loudness_screen;
  657. LiquidMenu loudness_menu(lcd);
  658. /******************************************
  659. MIDI_CHANNEL MENU
  660. ******************************************/
  661. #define NUM_MIDI_CHANNEL_MENUS 1
  662. const char midi_channel_text1[] PROGMEM = "MIDI Channel";
  663. LiquidLine midi_channel_line1(1, 0, midi_channel_text1);
  664. LiquidLine midi_channel_line2(1, 1, get_midi_channel_value_text);
  665. LiquidScreen midi_channel_screen;
  666. LiquidMenu midi_channel_menu(lcd);
  667. /******************************************
  668. MIDI_SOFT_THRU MENU
  669. ******************************************/
  670. #define NUM_MIDI_SOFT_THRU_MENUS 1
  671. const char midi_soft_thru_text1[] PROGMEM = "MIDI Soft Thru";
  672. LiquidLine midi_soft_thru_line1(1, 0, midi_soft_thru_text1);
  673. LiquidLine midi_soft_thru_line2(1, 1, get_midi_soft_thru_value_text);
  674. LiquidScreen midi_soft_thru_screen;
  675. LiquidMenu midi_soft_thru_menu(lcd);
  676. /******************************************
  677. MAX_POLY MENU
  678. ******************************************/
  679. #define NUM_MAX_POLY_MENUS 1
  680. const char max_poly_text1[] PROGMEM = "Max. Polyphony";
  681. LiquidLine max_poly_line1(1, 0, max_poly_text1);
  682. LiquidLine max_poly_line2(1, 1, configuration.max_poly);
  683. LiquidScreen max_poly_screen;
  684. LiquidMenu max_poly_menu(lcd);
  685. /******************************************
  686. MONO/STEREO MENU
  687. ******************************************/
  688. #define NUM_MONO_MENUS 1
  689. const char mono_text1[] PROGMEM = "Mono/Stereo";
  690. LiquidLine mono_line1(1, 0, mono_text1);
  691. LiquidLine mono_line2(1, 1, get_mono_value_text);
  692. LiquidScreen mono_screen;
  693. LiquidMenu mono_menu(lcd);
  694. /******************************************
  695. PANORAMA MENU
  696. ******************************************/
  697. #define NUM_PANORAMA_MENUS 1
  698. const char panorama_text1[] PROGMEM = "Panorama";
  699. LiquidLine panorama_line1(1, 0, panorama_text1);
  700. LiquidLine panorama_line2(1, 1, configuration.pan);
  701. LiquidScreen panorama_screen;
  702. LiquidMenu panorama_menu(lcd);
  703. /******************************************
  704. INFO MENU
  705. ******************************************/
  706. #define NUM_INFO_MENUS 1
  707. const char info_text1[] PROGMEM = "MicroMDAEPiano";
  708. const char info_text2[] PROGMEM = MICRO_MDAEPIANO_VERSION;
  709. LiquidLine info_line1(0, 0, info_text1);
  710. LiquidLine info_line2(0, 1, info_text2);
  711. LiquidScreen info_screen;
  712. LiquidMenu info_menu(lcd);
  713. /******************************************
  714. MASTER_VOLUME DISPLAY
  715. ******************************************/
  716. const char master_volume_text1[] PROGMEM = "Master Volume";
  717. LiquidLine master_volume_line1(1, 0, master_volume_text1);
  718. LiquidLine master_volume_line2(1, 1, master_volume);
  719. LiquidScreen master_volume_screen;
  720. LiquidMenu master_volume_menu(lcd);
  721. /******************************************
  722. STORE_QUESTION DISPLAY
  723. ******************************************/
  724. const char store_question_text1[] PROGMEM = "Overwrite?";
  725. LiquidLine store_question_line1(1, 0, store_question_text1);
  726. LiquidLine store_question_line2(1, 1, get_yes_no_value_text);
  727. LiquidScreen store_question_screen;
  728. LiquidMenu store_question_menu(lcd);
  729. /******************************************
  730. GLOBAL MENU OBJECTS
  731. ******************************************/
  732. LiquidSystem menu_system;
  733. /******************************************
  734. LOAD SOUND CALLBACKS
  735. ******************************************/
  736. void callback_load_sound_function(void) {
  737. #ifdef SHOW_DEBUG
  738. Serial.println(F("callback_load_sound_function"));
  739. #endif
  740. menu_system.change_menu(load_sound_menu);
  741. menu_position[MAIN] = encoder_value[RIGHT_ENCODER];
  742. encoder_value[RIGHT_ENCODER] = sound;
  743. enc[RIGHT_ENCODER].write(sound, 1, MAX_SOUNDS);
  744. menu_system.update();
  745. }
  746. /******************************************
  747. EDIT SOUND CALLBACKS
  748. ******************************************/
  749. void callback_edit_sound_function(void)
  750. {
  751. #ifdef SHOW_DEBUG
  752. Serial.print(F("callback_edit_sound_function, focus position:"));
  753. Serial.println(menu_position[EDIT_SOUND], DEC);
  754. #endif
  755. menu_system.change_menu(edit_sound_menu);
  756. menu_system.set_focusPosition(Position::LEFT);
  757. menu_position[MAIN] = encoder_value[RIGHT_ENCODER];
  758. if (menu_position[EDIT_SOUND] < 0)
  759. {
  760. menu_position[EDIT_SOUND] = 0;
  761. encoder_value[RIGHT_ENCODER] = 0;
  762. enc[RIGHT_ENCODER].write(0, 0, NUM_EDIT_SOUND_MENUS - 1);
  763. menu_system.switch_focus();
  764. }
  765. else
  766. {
  767. encoder_value[RIGHT_ENCODER] = menu_position[EDIT_SOUND];
  768. enc[RIGHT_ENCODER].write(menu_position[EDIT_SOUND], 0, NUM_EDIT_SOUND_MENUS - 1);
  769. }
  770. menu_system.update();
  771. }
  772. void callback_decay_function(void)
  773. {
  774. #ifdef SHOW_DEBUG
  775. Serial.println(F("callback_decay_function"));
  776. #endif
  777. menu_system.change_menu(decay_menu);
  778. menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER];
  779. encoder_value[RIGHT_ENCODER] = configuration.decay;
  780. enc[RIGHT_ENCODER].write(configuration.decay, ENC_DECAY_MIN, ENC_DECAY_MAX);
  781. menu_system.update();
  782. }
  783. void callback_release_function(void)
  784. {
  785. #ifdef SHOW_DEBUG
  786. Serial.println(F("callback_release_function"));
  787. #endif
  788. menu_system.change_menu(release_menu);
  789. menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER];
  790. encoder_value[RIGHT_ENCODER] = configuration.release;
  791. enc[RIGHT_ENCODER].write(configuration.release, ENC_RELEASE_MIN, ENC_RELEASE_MAX);
  792. menu_system.update();
  793. }
  794. void callback_hardness_function(void)
  795. {
  796. #ifdef SHOW_DEBUG
  797. Serial.println(F("callback_hardness_function"));
  798. #endif
  799. menu_system.change_menu(hardness_menu);
  800. menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER];
  801. encoder_value[RIGHT_ENCODER] = configuration.hardness;
  802. enc[RIGHT_ENCODER].write(configuration.hardness, ENC_HARDNESS_MIN, ENC_HARDNESS_MAX);
  803. menu_system.update();
  804. }
  805. void callback_treble_function(void)
  806. {
  807. #ifdef SHOW_DEBUG
  808. Serial.println(F("callback_treble_function"));
  809. #endif
  810. menu_system.change_menu(treble_menu);
  811. menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER];
  812. encoder_value[RIGHT_ENCODER] = configuration.treble;
  813. enc[RIGHT_ENCODER].write(configuration.treble, ENC_TREBLE_MIN, ENC_TREBLE_MAX);
  814. menu_system.update();
  815. }
  816. void callback_stereo_function(void)
  817. {
  818. #ifdef SHOW_DEBUG
  819. Serial.println(F("callback_stereo_function"));
  820. #endif
  821. menu_system.change_menu(stereo_menu);
  822. menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER];
  823. encoder_value[RIGHT_ENCODER] = configuration.stereo;
  824. enc[RIGHT_ENCODER].write(configuration.stereo, ENC_STEREO_MIN, ENC_STEREO_MAX);
  825. menu_system.update();
  826. }
  827. void callback_transpose_function(void)
  828. {
  829. #ifdef SHOW_DEBUG
  830. Serial.println(F("callback_transpose_function"));
  831. #endif
  832. menu_system.change_menu(transpose_menu);
  833. menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER];
  834. encoder_value[RIGHT_ENCODER] = configuration.transpose;
  835. enc[RIGHT_ENCODER].write(configuration.transpose, ENC_TRANSPOSE_MIN, ENC_TRANSPOSE_MAX);
  836. menu_system.update();
  837. }
  838. void callback_tune_function(void)
  839. {
  840. #ifdef SHOW_DEBUG
  841. Serial.println(F("callback_tune_function"));
  842. #endif
  843. menu_system.change_menu(tune_menu);
  844. menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER];
  845. encoder_value[RIGHT_ENCODER] = configuration.tune;
  846. enc[RIGHT_ENCODER].write(configuration.tune, ENC_TUNE_MIN, ENC_TUNE_MAX);
  847. menu_system.update();
  848. }
  849. void callback_detune_function(void)
  850. {
  851. #ifdef SHOW_DEBUG
  852. Serial.println(F("callback_detune_function"));
  853. #endif
  854. menu_system.change_menu(detune_menu);
  855. menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER];
  856. encoder_value[RIGHT_ENCODER] = configuration.detune;
  857. enc[RIGHT_ENCODER].write(configuration.detune, ENC_DETUNE_MIN, ENC_DETUNE_MAX);
  858. menu_system.update();
  859. }
  860. void callback_velocity_sense_function(void)
  861. {
  862. #ifdef SHOW_DEBUG
  863. Serial.print(F("callback_velocity_sense_function"));
  864. #endif
  865. menu_system.change_menu(velocity_sense_menu);
  866. menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER];
  867. encoder_value[RIGHT_ENCODER] = configuration.velocity_sense;
  868. enc[RIGHT_ENCODER].write(configuration.velocity_sense, ENC_VELOCITY_SENSE_MIN, ENC_VELOCITY_SENSE_MAX);
  869. menu_system.update();
  870. }
  871. /******************************************
  872. EFFECTS CALLBACKS
  873. ******************************************/
  874. void callback_effect_function(void)
  875. {
  876. #ifdef SHOW_DEBUG
  877. Serial.print(F("callback_effect_function, focus position:"));
  878. Serial.println(menu_position[EFFECTS]);
  879. #endif
  880. menu_system.change_menu(effects_menu);
  881. menu_system.set_focusPosition(Position::LEFT);
  882. menu_position[MAIN] = encoder_value[RIGHT_ENCODER];
  883. if (menu_position[EFFECTS] < 0)
  884. {
  885. menu_position[EFFECTS] = 0;
  886. encoder_value[RIGHT_ENCODER] = 0;
  887. enc[RIGHT_ENCODER].write(0, 0, NUM_EFFECTS_MENUS - 1);
  888. menu_system.switch_focus();
  889. }
  890. else
  891. {
  892. encoder_value[RIGHT_ENCODER] = menu_position[EFFECTS];
  893. enc[RIGHT_ENCODER].write(menu_position[EFFECTS], 0, NUM_EFFECTS_MENUS - 1);
  894. }
  895. menu_system.update();
  896. }
  897. void callback_pan_trem_frequency_function(void)
  898. {
  899. #ifdef SHOW_DEBUG
  900. Serial.println(F("callback_pan_trem_frequency_function"));
  901. #endif
  902. menu_system.change_menu(pan_trem_frequency_menu);
  903. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  904. encoder_value[RIGHT_ENCODER] = configuration.pan_trem_frequency;
  905. enc[RIGHT_ENCODER].write(configuration.pan_trem_frequency, ENC_PAN_TREM_FREQUENCY_MIN, ENC_PAN_TREM_FREQUENCY_MAX);
  906. menu_system.update();
  907. }
  908. void callback_pan_trem_level_function(void)
  909. {
  910. #ifdef SHOW_DEBUG
  911. Serial.println(F("callback_pan_trem_level_function"));
  912. #endif
  913. menu_system.change_menu(pan_trem_level_menu);
  914. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  915. encoder_value[RIGHT_ENCODER] = configuration.pan_trem_level;
  916. enc[RIGHT_ENCODER].write(configuration.pan_trem_level, ENC_PAN_TREM_LEVEL_MIN, ENC_PAN_TREM_LEVEL_MAX);
  917. menu_system.update();
  918. }
  919. void callback_overdrive_function(void)
  920. {
  921. #ifdef SHOW_DEBUG
  922. Serial.println(F("callback_overdrive_function"));
  923. #endif
  924. menu_system.change_menu(overdrive_menu);
  925. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  926. encoder_value[RIGHT_ENCODER] = configuration.overdrive;
  927. enc[RIGHT_ENCODER].write(configuration.overdrive, ENC_OVERDRIVE_MIN, ENC_OVERDRIVE_MAX);
  928. menu_system.update();
  929. }
  930. void callback_comp_gain_function(void)
  931. {
  932. #ifdef SHOW_DEBUG
  933. Serial.println(F("callback_comp_gain_function"));
  934. #endif
  935. menu_system.change_menu(comp_gain_menu);
  936. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  937. encoder_value[RIGHT_ENCODER] = configuration.comp_gain;
  938. enc[RIGHT_ENCODER].write(configuration.comp_gain, ENC_COMP_GAIN_MIN, ENC_COMP_GAIN_MAX);
  939. menu_system.update();
  940. }
  941. void callback_comp_response_function(void)
  942. {
  943. #ifdef SHOW_DEBUG
  944. Serial.println(F("callback_comp_response_function"));
  945. #endif
  946. menu_system.change_menu(comp_response_menu);
  947. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  948. encoder_value[RIGHT_ENCODER] = configuration.comp_response;
  949. enc[RIGHT_ENCODER].write(configuration.comp_response, ENC_COMP_RESPONSE_MIN, ENC_COMP_RESPONSE_MAX);
  950. menu_system.update();
  951. }
  952. void callback_comp_limit_function(void)
  953. {
  954. #ifdef SHOW_DEBUG
  955. Serial.println(F("callback_comp_limit_function"));
  956. #endif
  957. menu_system.change_menu(comp_limit_menu);
  958. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  959. encoder_value[RIGHT_ENCODER] = configuration.comp_limit;
  960. enc[RIGHT_ENCODER].write(configuration.comp_limit, ENC_COMP_LIMIT_MIN, ENC_COMP_LIMIT_MAX);
  961. menu_system.update();
  962. }
  963. void callback_comp_threshold_function(void)
  964. {
  965. #ifdef SHOW_DEBUG
  966. Serial.println(F("callback_comp_threshold_function"));
  967. #endif
  968. menu_system.change_menu(comp_threshold_menu);
  969. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  970. encoder_value[RIGHT_ENCODER] = configuration.comp_threshold;
  971. enc[RIGHT_ENCODER].write(configuration.comp_threshold, ENC_COMP_THRESHOLD_MIN, ENC_COMP_THRESHOLD_MAX);
  972. menu_system.update();
  973. }
  974. void callback_comp_attack_function(void)
  975. {
  976. #ifdef SHOW_DEBUG
  977. Serial.println(F("callback_comp_attack_function"));
  978. #endif
  979. menu_system.change_menu(comp_attack_menu);
  980. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  981. encoder_value[RIGHT_ENCODER] = configuration.comp_attack;
  982. enc[RIGHT_ENCODER].write(configuration.comp_attack, ENC_COMP_ATTACK_MIN, ENC_COMP_ATTACK_MAX);
  983. menu_system.update();
  984. }
  985. void callback_comp_decay_function(void)
  986. {
  987. #ifdef SHOW_DEBUG
  988. Serial.println(F("callback_comp_decay_function"));
  989. #endif
  990. menu_system.change_menu(comp_decay_menu);
  991. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  992. encoder_value[RIGHT_ENCODER] = configuration.comp_decay;
  993. enc[RIGHT_ENCODER].write(configuration.comp_decay, ENC_COMP_DECAY_MIN, ENC_COMP_DECAY_MAX);
  994. menu_system.update();
  995. }
  996. void callback_reverb_roomsize_function(void)
  997. {
  998. #ifdef SHOW_DEBUG
  999. Serial.println(F("callback_reverb_roomsize_function"));
  1000. #endif
  1001. menu_system.change_menu(reverb_roomsize_menu);
  1002. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  1003. encoder_value[RIGHT_ENCODER] = configuration.reverb_roomsize;
  1004. enc[RIGHT_ENCODER].write(configuration.reverb_roomsize, ENC_REVERB_ROOMSIZE_MIN, ENC_REVERB_ROOMSIZE_MAX);
  1005. menu_system.update();
  1006. }
  1007. void callback_reverb_damping_function(void)
  1008. {
  1009. #ifdef SHOW_DEBUG
  1010. Serial.println(F("callback_reverb_damping_function"));
  1011. #endif
  1012. menu_system.change_menu(reverb_damping_menu);
  1013. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  1014. encoder_value[RIGHT_ENCODER] = configuration.reverb_damping;
  1015. enc[RIGHT_ENCODER].write(configuration.reverb_damping, ENC_REVERB_DAMPING_MIN, ENC_REVERB_DAMPING_MAX);
  1016. menu_system.update();
  1017. }
  1018. void callback_reverb_level_function(void)
  1019. {
  1020. #ifdef SHOW_DEBUG
  1021. Serial.println(F("callback_reverb_level_function"));
  1022. #endif
  1023. menu_system.change_menu(reverb_level_menu);
  1024. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  1025. encoder_value[RIGHT_ENCODER] = configuration.reverb_level;
  1026. enc[RIGHT_ENCODER].write(configuration.reverb_level, ENC_REVERB_LEVEL_MIN, ENC_REVERB_LEVEL_MAX);
  1027. menu_system.update();
  1028. }
  1029. void callback_chorus_frequency_function(void)
  1030. {
  1031. #ifdef SHOW_DEBUG
  1032. Serial.println(F("callback_chorus_frequency_function"));
  1033. #endif
  1034. menu_system.change_menu(chorus_frequency_menu);
  1035. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  1036. encoder_value[RIGHT_ENCODER] = configuration.chorus_frequency;
  1037. enc[RIGHT_ENCODER].write(configuration.chorus_frequency, ENC_CHORUS_FREQUENCY_MIN, ENC_CHORUS_FREQUENCY_MAX);
  1038. menu_system.update();
  1039. }
  1040. void callback_chorus_intensity_function(void)
  1041. {
  1042. #ifdef SHOW_DEBUG
  1043. Serial.println(F("callback_chorus_intensity_function"));
  1044. #endif
  1045. menu_system.change_menu(chorus_intensity_menu);
  1046. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  1047. encoder_value[RIGHT_ENCODER] = configuration.chorus_intensity;
  1048. enc[RIGHT_ENCODER].write(configuration.chorus_intensity, ENC_CHORUS_INTENSITY_MIN, ENC_CHORUS_INTENSITY_MAX);
  1049. menu_system.update();
  1050. }
  1051. void callback_chorus_waveform_function(void)
  1052. {
  1053. #ifdef SHOW_DEBUG
  1054. Serial.println(F("callback_chorus_waveform_function"));
  1055. #endif
  1056. menu_system.change_menu(chorus_waveform_menu);
  1057. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  1058. encoder_value[RIGHT_ENCODER] = configuration.chorus_waveform;
  1059. enc[RIGHT_ENCODER].write(configuration.chorus_waveform, ENC_CHORUS_WAVEFORM_MIN, ENC_CHORUS_WAVEFORM_MAX);
  1060. menu_system.update();
  1061. }
  1062. void callback_chorus_level_function(void)
  1063. {
  1064. #ifdef SHOW_DEBUG
  1065. Serial.println(F("callback_chorus_level_function"));
  1066. #endif
  1067. menu_system.change_menu(chorus_level_menu);
  1068. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  1069. encoder_value[RIGHT_ENCODER] = configuration.chorus_level;
  1070. enc[RIGHT_ENCODER].write(configuration.chorus_level, ENC_CHORUS_LEVEL_MIN, ENC_CHORUS_LEVEL_MAX);
  1071. menu_system.update();
  1072. }
  1073. void callback_bass_lr_level_function(void)
  1074. {
  1075. #ifdef SHOW_DEBUG
  1076. Serial.println(F("callback_bass_lr_level_function"));
  1077. #endif
  1078. menu_system.change_menu(bass_lr_level_menu);
  1079. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  1080. encoder_value[RIGHT_ENCODER] = configuration.bass_lr_level;
  1081. enc[RIGHT_ENCODER].write(configuration.bass_lr_level, ENC_BASS_LR_LEVEL_MIN, ENC_BASS_LR_LEVEL_MAX);
  1082. menu_system.update();
  1083. }
  1084. void callback_bass_mono_level_function(void)
  1085. {
  1086. #ifdef SHOW_DEBUG
  1087. Serial.println(F("callback_bass_mono_level_function"));
  1088. #endif
  1089. menu_system.change_menu(bass_mono_level_menu);
  1090. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  1091. encoder_value[RIGHT_ENCODER] = configuration.bass_mono_level;
  1092. enc[RIGHT_ENCODER].write(configuration.bass_mono_level, ENC_BASS_MONO_LEVEL_MIN, ENC_BASS_MONO_LEVEL_MAX);
  1093. menu_system.update();
  1094. }
  1095. void callback_eq_bass_function(void)
  1096. {
  1097. #ifdef SHOW_DEBUG
  1098. Serial.println(F("callback_eq_bass_function"));
  1099. #endif
  1100. menu_system.change_menu(eq_bass_menu);
  1101. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  1102. encoder_value[RIGHT_ENCODER] = configuration.eq_bass;
  1103. enc[RIGHT_ENCODER].write(configuration.eq_bass, ENC_EQ_BASS_MIN, ENC_EQ_BASS_MAX);
  1104. menu_system.update();
  1105. }
  1106. void callback_eq_treble_function(void)
  1107. {
  1108. #ifdef SHOW_DEBUG
  1109. Serial.println(F("callback_eq_treble_function"));
  1110. #endif
  1111. menu_system.change_menu(eq_treble_menu);
  1112. menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
  1113. encoder_value[RIGHT_ENCODER] = configuration.eq_treble;
  1114. enc[RIGHT_ENCODER].write(configuration.eq_treble, ENC_EQ_TREBLE_MIN, ENC_EQ_TREBLE_MAX);
  1115. menu_system.update();
  1116. }
  1117. /******************************************
  1118. SAVE SOUND CALLBACKS
  1119. ******************************************/
  1120. void callback_save_sound_function(void)
  1121. {
  1122. #ifdef SHOW_DEBUG
  1123. Serial.println(F("callback_save_sound_function"));
  1124. #endif
  1125. menu_system.change_menu(save_sound_menu);
  1126. menu_position[MAIN] = encoder_value[RIGHT_ENCODER];
  1127. encoder_value[RIGHT_ENCODER] = sound;
  1128. enc[RIGHT_ENCODER].write(sound, 1, MAX_SOUNDS);
  1129. menu_system.update();
  1130. }
  1131. void callback_store_question_function(void)
  1132. {
  1133. #ifdef SHOW_DEBUG
  1134. Serial.println(F("callback_store_question_function"));
  1135. #endif
  1136. menu_system.change_menu(store_question_menu);
  1137. //menu_position[MAIN] = encoder_value[RIGHT_ENCODER];
  1138. encoder_value[RIGHT_ENCODER] = yes_no;
  1139. enc[RIGHT_ENCODER].write(yes_no, 0, 1);
  1140. menu_system.update();
  1141. }
  1142. /******************************************
  1143. SYSTEM MENU CALLBACKS
  1144. ******************************************/
  1145. void callback_system_function(void)
  1146. {
  1147. #ifdef SHOW_DEBUG
  1148. Serial.print(F("callback_system_function, focus position:"));
  1149. Serial.println(menu_position[SYSTEM]);
  1150. #endif
  1151. menu_system.change_menu(system_menu);
  1152. menu_system.set_focusPosition(Position::LEFT);
  1153. menu_position[MAIN] = encoder_value[RIGHT_ENCODER];
  1154. if (menu_position[SYSTEM] < 0)
  1155. {
  1156. menu_position[SYSTEM] = 0;
  1157. encoder_value[RIGHT_ENCODER] = 0;
  1158. enc[RIGHT_ENCODER].write(0, 0, NUM_SYSTEM_MENUS - 1);
  1159. menu_system.switch_focus();
  1160. }
  1161. else
  1162. {
  1163. encoder_value[RIGHT_ENCODER] = menu_position[SYSTEM];
  1164. enc[RIGHT_ENCODER].write(menu_position[SYSTEM], 0, NUM_SYSTEM_MENUS - 1);
  1165. }
  1166. menu_system.update();
  1167. }
  1168. void callback_loudness_function(void)
  1169. {
  1170. #ifdef SHOW_DEBUG
  1171. Serial.println(F("callback_loudness_function"));
  1172. #endif
  1173. menu_system.change_menu(loudness_menu);
  1174. menu_position[SYSTEM] = encoder_value[RIGHT_ENCODER];
  1175. encoder_value[RIGHT_ENCODER] = configuration.loudness;
  1176. enc[RIGHT_ENCODER].write(configuration.loudness, ENC_LOUDNESS_MIN, ENC_LOUDNESS_MAX);
  1177. menu_system.update();
  1178. }
  1179. void callback_midi_channel_function(void)
  1180. {
  1181. #ifdef SHOW_DEBUG
  1182. Serial.println(F("callback_midi_channel_function"));
  1183. #endif
  1184. menu_system.change_menu(midi_channel_menu);
  1185. menu_position[SYSTEM] = encoder_value[RIGHT_ENCODER];
  1186. encoder_value[RIGHT_ENCODER] = configuration.midi_channel;
  1187. enc[RIGHT_ENCODER].write(configuration.midi_channel, ENC_MIDI_CHANNEL_MIN, ENC_MIDI_CHANNEL_MAX);
  1188. menu_system.update();
  1189. }
  1190. void callback_midi_soft_thru_function(void)
  1191. {
  1192. #ifdef SHOW_DEBUG
  1193. Serial.println(F("callback_midi_soft_thru_function"));
  1194. #endif
  1195. menu_system.change_menu(midi_soft_thru_menu);
  1196. menu_position[SYSTEM] = encoder_value[RIGHT_ENCODER];
  1197. encoder_value[RIGHT_ENCODER] = configuration.midi_soft_thru;
  1198. enc[RIGHT_ENCODER].write(configuration.midi_soft_thru, ENC_MIDI_SOFT_THRU_MIN, ENC_MIDI_SOFT_THRU_MAX);
  1199. menu_system.update();
  1200. }
  1201. void callback_max_poly_function(void)
  1202. {
  1203. #ifdef SHOW_DEBUG
  1204. Serial.println(F("callback_max_poly_function"));
  1205. #endif
  1206. menu_system.change_menu(max_poly_menu);
  1207. menu_position[SYSTEM] = encoder_value[RIGHT_ENCODER];
  1208. encoder_value[RIGHT_ENCODER] = configuration.max_poly;
  1209. enc[RIGHT_ENCODER].write(configuration.max_poly, ENC_MAX_POLY_MIN, ENC_MAX_POLY_MAX);
  1210. menu_system.update();
  1211. }
  1212. void callback_mono_function(void)
  1213. {
  1214. #ifdef SHOW_DEBUG
  1215. Serial.println(F("callback_mono_function"));
  1216. #endif
  1217. menu_system.change_menu(mono_menu);
  1218. menu_position[SYSTEM] = encoder_value[RIGHT_ENCODER];
  1219. encoder_value[RIGHT_ENCODER] = configuration.mono;
  1220. enc[RIGHT_ENCODER].write(configuration.mono, ENC_MONO_MIN, ENC_MONO_MAX);
  1221. menu_system.update();
  1222. }
  1223. void callback_panorama_function(void)
  1224. {
  1225. #ifdef SHOW_DEBUG
  1226. Serial.println(F("callback_panorama_function"));
  1227. #endif
  1228. menu_system.change_menu(panorama_menu);
  1229. menu_position[SYSTEM] = encoder_value[RIGHT_ENCODER];
  1230. encoder_value[RIGHT_ENCODER] = configuration.mono;
  1231. enc[RIGHT_ENCODER].write(configuration.mono, ENC_MASTER_PAN_MIN, ENC_MASTER_PAN_MAX);
  1232. menu_system.update();
  1233. }
  1234. /******************************************
  1235. INFO MENU CALLBACKS
  1236. ******************************************/
  1237. void callback_info_function(void)
  1238. {
  1239. #ifdef SHOW_DEBUG
  1240. Serial.println(F("callback_info_function"));
  1241. #endif
  1242. menu_system.change_menu(info_menu);
  1243. menu_position[MAIN] = encoder_value[RIGHT_ENCODER];
  1244. menu_system.update();
  1245. }
  1246. /******************************************
  1247. HELPER MENU FUNCTION
  1248. ******************************************/
  1249. float mapfloat(float val, float in_min, float in_max, float out_min, float out_max)
  1250. // e.g. mapfloat(float(effect_delay_feedback), 0, ENC_DELAY_FB_STEPS, 0.0, 1.0)
  1251. {
  1252. return (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
  1253. }
  1254. void encoder_switch_focus(uint8_t encoder_last, uint8_t encoder_value)
  1255. {
  1256. uint8_t i;
  1257. int8_t diff;
  1258. diff = encoder_value - encoder_last;
  1259. for (i = 0; i < abs(diff); i++)
  1260. {
  1261. if (diff < 0)
  1262. menu_system.switch_focus(true);
  1263. else
  1264. menu_system.switch_focus(false);
  1265. }
  1266. }
  1267. void goto_main_menu(uint8_t menu_number)
  1268. {
  1269. menu_position[menu_number] = enc[RIGHT_ENCODER].read();
  1270. menu_system.change_menu(main_menu);
  1271. menu_system.set_focusPosition(Position::LEFT);
  1272. encoder_value[RIGHT_ENCODER] = menu_position[MAIN];
  1273. enc[RIGHT_ENCODER].write(menu_position[MAIN], 0, NUM_MAIN_MENUS - 1);
  1274. }
  1275. void goto_edit_sound_menu(uint8_t menu_number)
  1276. {
  1277. menu_position[menu_number] = enc[RIGHT_ENCODER].read();
  1278. menu_system.change_menu(edit_sound_menu);
  1279. menu_system.set_focusPosition(Position::LEFT);
  1280. encoder_value[RIGHT_ENCODER] = menu_position[EDIT_SOUND];
  1281. enc[RIGHT_ENCODER].write(menu_position[EDIT_SOUND], 0, NUM_EDIT_SOUND_MENUS - 1);
  1282. }
  1283. void goto_effects_menu(uint8_t menu_number)
  1284. {
  1285. menu_position[menu_number] = enc[RIGHT_ENCODER].read();
  1286. menu_system.change_menu(effects_menu);
  1287. menu_system.set_focusPosition(Position::LEFT);
  1288. encoder_value[RIGHT_ENCODER] = menu_position[EFFECTS];
  1289. enc[RIGHT_ENCODER].write(menu_position[EFFECTS], 0, NUM_EFFECTS_MENUS - 1);
  1290. }
  1291. void goto_system_menu(uint8_t menu_number)
  1292. {
  1293. menu_position[menu_number] = enc[RIGHT_ENCODER].read();
  1294. menu_system.change_menu(system_menu);
  1295. menu_system.set_focusPosition(Position::LEFT);
  1296. encoder_value[RIGHT_ENCODER] = menu_position[SYSTEM];
  1297. enc[RIGHT_ENCODER].write(menu_position[SYSTEM], 0, NUM_SYSTEM_MENUS - 1);
  1298. }
  1299. void goto_store_question_menu(uint8_t menu_number)
  1300. {
  1301. menu_position[menu_number] = enc[RIGHT_ENCODER].read();
  1302. menu_system.change_menu(store_question_menu);
  1303. menu_system.set_focusPosition(Position::LEFT);
  1304. //encoder_value[RIGHT_ENCODER] = menu_position[STORE_QUESTION];
  1305. enc[RIGHT_ENCODER].write(menu_position[STORE_QUESTION], 0, 1);
  1306. }
  1307. /******************************************
  1308. INIT MENU FUNCTION
  1309. ******************************************/
  1310. void init_menus(void)
  1311. {
  1312. uint8_t i;
  1313. // LCD display setup
  1314. lcd.init();
  1315. lcd.blink_off();
  1316. lcd.cursor_off();
  1317. lcd.backlight();
  1318. lcd.clear();
  1319. lcd.setCursor(1, 0);
  1320. lcd.print("MicroMDAEPiano");
  1321. lcd.setCursor(0, 1);
  1322. lcd.print("(c)parasiTstudio");
  1323. delay(1000);
  1324. // setup main menu
  1325. main_screen.add_line(main_line1);
  1326. main_screen.add_line(main_line2);
  1327. main_screen.add_line(main_line3);
  1328. main_screen.add_line(main_line4);
  1329. main_screen.add_line(main_line5);
  1330. main_screen.add_line(main_line6);
  1331. main_screen.set_displayLineCount(2);
  1332. main_menu.add_screen(main_screen);
  1333. main_line1.attach_function(LOAD_SOUND, callback_load_sound_function);
  1334. main_line2.attach_function(EDIT_SOUND, callback_edit_sound_function);
  1335. main_line3.attach_function(EFFECTS, callback_effect_function);
  1336. main_line4.attach_function(SAVE_SOUND, callback_save_sound_function);
  1337. main_line5.attach_function(SYSTEM, callback_system_function);
  1338. main_line6.attach_function(INFO, callback_info_function);
  1339. // setup load_sound menu
  1340. load_sound_screen.add_line(load_sound_line1);
  1341. load_sound_screen.add_line(load_sound_line2);
  1342. load_sound_screen.set_displayLineCount(2);
  1343. load_sound_menu.add_screen(load_sound_screen);
  1344. // setup sound menu
  1345. edit_sound_screen.add_line(edit_sound_line1);
  1346. edit_sound_screen.add_line(edit_sound_line2);
  1347. edit_sound_screen.add_line(edit_sound_line3);
  1348. edit_sound_screen.add_line(edit_sound_line4);
  1349. edit_sound_screen.add_line(edit_sound_line5);
  1350. edit_sound_screen.add_line(edit_sound_line6);
  1351. edit_sound_screen.add_line(edit_sound_line7);
  1352. edit_sound_screen.add_line(edit_sound_line8);
  1353. edit_sound_screen.add_line(edit_sound_line9);
  1354. edit_sound_screen.set_displayLineCount(2);
  1355. edit_sound_menu.add_screen(edit_sound_screen);
  1356. edit_sound_line1.attach_function(DECAY, callback_decay_function);
  1357. edit_sound_line2.attach_function(RELEASE, callback_release_function);
  1358. edit_sound_line3.attach_function(HARDNESS, callback_hardness_function);
  1359. edit_sound_line4.attach_function(TREBLE, callback_treble_function);
  1360. edit_sound_line5.attach_function(STEREO_LEVEL, callback_stereo_function);
  1361. edit_sound_line6.attach_function(TRANSPOSE, callback_transpose_function);
  1362. edit_sound_line7.attach_function(TUNE, callback_tune_function);
  1363. edit_sound_line8.attach_function(DETUNE, callback_detune_function);
  1364. edit_sound_line9.attach_function(VELOCITY_SENSE, callback_velocity_sense_function);
  1365. // setup decay menu
  1366. decay_screen.add_line(decay_line1);
  1367. decay_screen.add_line(decay_line2);
  1368. decay_screen.set_displayLineCount(2);
  1369. decay_menu.add_screen(decay_screen);
  1370. // setup release menu
  1371. release_screen.add_line(release_line1);
  1372. release_screen.add_line(release_line2);
  1373. release_screen.set_displayLineCount(2);
  1374. release_menu.add_screen(release_screen);
  1375. // setup hardness menu
  1376. hardness_screen.add_line(hardness_line1);
  1377. hardness_screen.add_line(hardness_line2);
  1378. hardness_screen.set_displayLineCount(2);
  1379. hardness_menu.add_screen(hardness_screen);
  1380. // setup treble menu
  1381. treble_screen.add_line(treble_line1);
  1382. treble_screen.add_line(treble_line2);
  1383. treble_screen.set_displayLineCount(2);
  1384. treble_menu.add_screen(treble_screen);
  1385. // setup stereo menu
  1386. stereo_screen.add_line(stereo_line1);
  1387. stereo_screen.add_line(stereo_line2);
  1388. stereo_screen.set_displayLineCount(2);
  1389. stereo_menu.add_screen(stereo_screen);
  1390. // setup transpose menu
  1391. transpose_screen.add_line(transpose_line1);
  1392. transpose_screen.add_line(transpose_line2);
  1393. transpose_screen.set_displayLineCount(2);
  1394. transpose_menu.add_screen(transpose_screen);
  1395. // setup tune menu
  1396. tune_screen.add_line(tune_line1);
  1397. tune_screen.add_line(tune_line2);
  1398. tune_screen.set_displayLineCount(2);
  1399. tune_menu.add_screen(tune_screen);
  1400. // setup detune menu
  1401. detune_screen.add_line(detune_line1);
  1402. detune_screen.add_line(detune_line2);
  1403. detune_screen.set_displayLineCount(2);
  1404. detune_menu.add_screen(detune_screen);
  1405. // setup velocity_sense menu
  1406. velocity_sense_screen.add_line(velocity_sense_line1);
  1407. velocity_sense_screen.add_line(velocity_sense_line2);
  1408. velocity_sense_screen.set_displayLineCount(2);
  1409. velocity_sense_menu.add_screen(velocity_sense_screen);
  1410. // setup effects menu
  1411. effects_screen.add_line(effects_line1);
  1412. effects_screen.add_line(effects_line2);
  1413. effects_screen.add_line(effects_line3);
  1414. effects_screen.add_line(effects_line4);
  1415. effects_screen.add_line(effects_line5);
  1416. effects_screen.add_line(effects_line6);
  1417. effects_screen.add_line(effects_line7);
  1418. effects_screen.add_line(effects_line8);
  1419. effects_screen.add_line(effects_line9);
  1420. effects_screen.add_line(effects_line10);
  1421. effects_screen.add_line(effects_line11);
  1422. effects_screen.add_line(effects_line12);
  1423. effects_screen.add_line(effects_line13);
  1424. effects_screen.add_line(effects_line14);
  1425. effects_screen.add_line(effects_line15);
  1426. effects_screen.add_line(effects_line16);
  1427. effects_screen.add_line(effects_line17);
  1428. effects_screen.add_line(effects_line18);
  1429. effects_screen.add_line(effects_line19);
  1430. effects_screen.add_line(effects_line20);
  1431. effects_screen.set_displayLineCount(2);
  1432. effects_menu.add_screen(effects_screen);
  1433. effects_line1.attach_function(PAN_TREM_FREQUENCY, callback_pan_trem_frequency_function);
  1434. effects_line2.attach_function(PAN_TREM_LEVEL, callback_pan_trem_level_function);
  1435. effects_line3.attach_function(OVERDRIVE, callback_overdrive_function);
  1436. effects_line4.attach_function(COMP_GAIN, callback_comp_gain_function);
  1437. effects_line5.attach_function(COMP_RESPONSE, callback_comp_response_function);
  1438. effects_line6.attach_function(COMP_LIMIT, callback_comp_limit_function);
  1439. effects_line7.attach_function(COMP_THRESHOLD, callback_comp_threshold_function);
  1440. effects_line8.attach_function(COMP_ATTACK, callback_comp_attack_function);
  1441. effects_line9.attach_function(COMP_DECAY, callback_comp_decay_function);
  1442. effects_line10.attach_function(REV_ROOMSIZE, callback_reverb_roomsize_function);
  1443. effects_line11.attach_function(REV_DAMPING, callback_reverb_damping_function);
  1444. effects_line12.attach_function(REV_LEVEL, callback_reverb_level_function);
  1445. effects_line13.attach_function(CHORUS_FREQ, callback_chorus_frequency_function);
  1446. effects_line14.attach_function(CHORUS_INTENSITY, callback_chorus_intensity_function);
  1447. effects_line15.attach_function(CHORUS_WAVEFORM, callback_chorus_waveform_function);
  1448. effects_line16.attach_function(CHORUS_LEVEL, callback_chorus_level_function);
  1449. effects_line17.attach_function(BASS_LR_LEVEL, callback_bass_lr_level_function);
  1450. effects_line18.attach_function(BASS_MONO_LEVEL, callback_bass_mono_level_function);
  1451. effects_line19.attach_function(EQ_BASS, callback_eq_bass_function);
  1452. effects_line20.attach_function(EQ_TREBLE, callback_eq_treble_function);
  1453. // setup pan_trem_frequency menu
  1454. pan_trem_frequency_screen.add_line(pan_trem_frequency_line1);
  1455. pan_trem_frequency_screen.add_line(pan_trem_frequency_line2);
  1456. pan_trem_frequency_screen.set_displayLineCount(2);
  1457. pan_trem_frequency_menu.add_screen(pan_trem_frequency_screen);
  1458. // setup pan_trem_level menu
  1459. pan_trem_level_screen.add_line(pan_trem_level_line1);
  1460. pan_trem_level_screen.add_line(pan_trem_level_line2);
  1461. pan_trem_level_screen.set_displayLineCount(2);
  1462. pan_trem_level_menu.add_screen(pan_trem_level_screen);
  1463. // setup overdrive menu
  1464. overdrive_screen.add_line(overdrive_line1);
  1465. overdrive_screen.add_line(overdrive_line2);
  1466. overdrive_screen.set_displayLineCount(2);
  1467. overdrive_menu.add_screen(overdrive_screen);
  1468. // setup comp_gain menu
  1469. comp_gain_screen.add_line(comp_gain_line1);
  1470. comp_gain_screen.add_line(comp_gain_line2);
  1471. comp_gain_screen.set_displayLineCount(2);
  1472. comp_gain_menu.add_screen(comp_gain_screen);
  1473. // setup comp_response menu
  1474. comp_response_screen.add_line(comp_response_line1);
  1475. comp_response_screen.add_line(comp_response_line2);
  1476. comp_response_screen.set_displayLineCount(2);
  1477. comp_response_menu.add_screen(comp_response_screen);
  1478. // setup comp_limit menu
  1479. comp_limit_screen.add_line(comp_limit_line1);
  1480. comp_limit_screen.add_line(comp_limit_line2);
  1481. comp_limit_screen.set_displayLineCount(2);
  1482. comp_limit_menu.add_screen(comp_limit_screen);
  1483. // setup comp_threshold menu
  1484. comp_threshold_screen.add_line(comp_threshold_line1);
  1485. comp_threshold_screen.add_line(comp_threshold_line2);
  1486. comp_threshold_screen.set_displayLineCount(2);
  1487. comp_threshold_menu.add_screen(comp_threshold_screen);
  1488. // setup comp_attack menu
  1489. comp_attack_screen.add_line(comp_attack_line1);
  1490. comp_attack_screen.add_line(comp_attack_line2);
  1491. comp_attack_screen.set_displayLineCount(2);
  1492. comp_attack_menu.add_screen(comp_attack_screen);
  1493. // setup comp_decay menu
  1494. comp_decay_screen.add_line(comp_decay_line1);
  1495. comp_decay_screen.add_line(comp_decay_line2);
  1496. comp_decay_screen.set_displayLineCount(2);
  1497. comp_decay_menu.add_screen(comp_decay_screen);
  1498. // setup reverb_roomsize menu
  1499. reverb_roomsize_screen.add_line(reverb_roomsize_line1);
  1500. reverb_roomsize_screen.add_line(reverb_roomsize_line2);
  1501. reverb_roomsize_screen.set_displayLineCount(2);
  1502. reverb_roomsize_menu.add_screen(reverb_roomsize_screen);
  1503. // setup reverb_damping menu
  1504. reverb_damping_screen.add_line(reverb_damping_line1);
  1505. reverb_damping_screen.add_line(reverb_damping_line2);
  1506. reverb_damping_screen.set_displayLineCount(2);
  1507. reverb_damping_menu.add_screen(reverb_damping_screen);
  1508. // setup reverb_level menu
  1509. reverb_level_screen.add_line(reverb_level_line1);
  1510. reverb_level_screen.add_line(reverb_level_line2);
  1511. reverb_level_screen.set_displayLineCount(2);
  1512. reverb_level_menu.add_screen(reverb_level_screen);
  1513. // setup chorus_frequency menu
  1514. chorus_frequency_screen.add_line(chorus_frequency_line1);
  1515. chorus_frequency_screen.add_line(chorus_frequency_line2);
  1516. chorus_frequency_screen.set_displayLineCount(2);
  1517. chorus_frequency_menu.add_screen(chorus_frequency_screen);
  1518. // setup chorus_intensity menu
  1519. chorus_intensity_screen.add_line(chorus_intensity_line1);
  1520. chorus_intensity_screen.add_line(chorus_intensity_line2);
  1521. chorus_intensity_screen.set_displayLineCount(2);
  1522. chorus_intensity_menu.add_screen(chorus_intensity_screen);
  1523. // setup chorus_waveform menu
  1524. chorus_waveform_screen.add_line(chorus_waveform_line1);
  1525. chorus_waveform_screen.add_line(chorus_waveform_line2);
  1526. chorus_waveform_screen.set_displayLineCount(2);
  1527. chorus_waveform_menu.add_screen(chorus_waveform_screen);
  1528. // setup chorus_level menu
  1529. chorus_level_screen.add_line(chorus_level_line1);
  1530. chorus_level_screen.add_line(chorus_level_line2);
  1531. chorus_level_screen.set_displayLineCount(2);
  1532. chorus_level_menu.add_screen(chorus_level_screen);
  1533. // setup bass_lr_level menu
  1534. bass_lr_level_screen.add_line(bass_lr_level_line1);
  1535. bass_lr_level_screen.add_line(bass_lr_level_line2);
  1536. bass_lr_level_screen.set_displayLineCount(2);
  1537. bass_lr_level_menu.add_screen(bass_lr_level_screen);
  1538. // setup bass_mono_level menu
  1539. bass_mono_level_screen.add_line(bass_mono_level_line1);
  1540. bass_mono_level_screen.add_line(bass_mono_level_line2);
  1541. bass_mono_level_screen.set_displayLineCount(2);
  1542. bass_mono_level_menu.add_screen(bass_mono_level_screen);
  1543. // setup eq_bass menu
  1544. eq_bass_screen.add_line(eq_bass_line1);
  1545. eq_bass_screen.add_line(eq_bass_line2);
  1546. eq_bass_screen.set_displayLineCount(2);
  1547. eq_bass_menu.add_screen(eq_bass_screen);
  1548. // setup eq_treble menu
  1549. eq_treble_screen.add_line(eq_treble_line1);
  1550. eq_treble_screen.add_line(eq_treble_line2);
  1551. eq_treble_screen.set_displayLineCount(2);
  1552. eq_treble_menu.add_screen(eq_treble_screen);
  1553. // setup save_sound menu
  1554. save_sound_screen.add_line(save_sound_line1);
  1555. save_sound_screen.add_line(save_sound_line2);
  1556. save_sound_screen.set_displayLineCount(2);
  1557. save_sound_menu.add_screen(save_sound_screen);
  1558. // setup store_question display
  1559. store_question_line1.attach_function(STORE_QUESTION, callback_store_question_function);
  1560. store_question_screen.add_line(store_question_line1);
  1561. store_question_screen.add_line(store_question_line2);
  1562. store_question_screen.set_displayLineCount(2);
  1563. store_question_menu.add_screen(store_question_screen);
  1564. // setup system menu
  1565. system_screen.add_line(system_line1);
  1566. system_screen.add_line(system_line2);
  1567. system_screen.add_line(system_line3);
  1568. system_screen.add_line(system_line4);
  1569. system_screen.add_line(system_line5);
  1570. system_screen.add_line(system_line6);
  1571. system_screen.set_displayLineCount(2);
  1572. system_menu.add_screen(system_screen);
  1573. system_line1.attach_function(LOUDNESS, callback_loudness_function);
  1574. system_line2.attach_function(MIDI_CHANNEL, callback_midi_channel_function);
  1575. system_line3.attach_function(MIDI_SOFT_THRU, callback_midi_soft_thru_function);
  1576. system_line4.attach_function(MAX_POLY, callback_max_poly_function);
  1577. system_line5.attach_function(MONO, callback_mono_function);
  1578. system_line6.attach_function(PANORAMA, callback_panorama_function);
  1579. // setup loudness
  1580. loudness_screen.add_line(loudness_line1);
  1581. loudness_screen.add_line(loudness_line2);
  1582. loudness_screen.set_displayLineCount(2);
  1583. loudness_menu.add_screen(loudness_screen);
  1584. // setup midi_channel
  1585. midi_channel_screen.add_line(midi_channel_line1);
  1586. midi_channel_screen.add_line(midi_channel_line2);
  1587. midi_channel_screen.set_displayLineCount(2);
  1588. midi_channel_menu.add_screen(midi_channel_screen);
  1589. // setup midi_soft_thru
  1590. midi_soft_thru_screen.add_line(midi_soft_thru_line1);
  1591. midi_soft_thru_screen.add_line(midi_soft_thru_line2);
  1592. midi_soft_thru_screen.set_displayLineCount(2);
  1593. midi_soft_thru_menu.add_screen(midi_soft_thru_screen);
  1594. // setup max_poly
  1595. max_poly_screen.add_line(max_poly_line1);
  1596. max_poly_screen.add_line(max_poly_line2);
  1597. max_poly_screen.set_displayLineCount(2);
  1598. max_poly_menu.add_screen(max_poly_screen);
  1599. // setup mono
  1600. mono_screen.add_line(mono_line1);
  1601. mono_screen.add_line(mono_line2);
  1602. mono_screen.set_displayLineCount(2);
  1603. mono_menu.add_screen(mono_screen);
  1604. // setup panorama
  1605. panorama_screen.add_line(panorama_line1);
  1606. panorama_screen.add_line(panorama_line2);
  1607. panorama_screen.set_displayLineCount(2);
  1608. panorama_menu.add_screen(panorama_screen);
  1609. // setup info menu
  1610. info_screen.add_line(info_line1);
  1611. info_screen.add_line(info_line2);
  1612. info_screen.set_displayLineCount(2);
  1613. info_menu.add_screen(info_screen);
  1614. // setup master_volume display
  1615. master_volume_screen.add_line(master_volume_line1);
  1616. master_volume_screen.add_line(master_volume_line2);
  1617. master_volume_screen.set_displayLineCount(2);
  1618. master_volume_menu.add_screen(master_volume_screen);
  1619. // setup global system menu
  1620. menu_system.add_menu(main_menu);
  1621. menu_system.add_menu(load_sound_menu);
  1622. menu_system.add_menu(edit_sound_menu);
  1623. menu_system.add_menu(effects_menu);
  1624. menu_system.add_menu(decay_menu);
  1625. menu_system.add_menu(release_menu);
  1626. menu_system.add_menu(hardness_menu);
  1627. menu_system.add_menu(treble_menu);
  1628. menu_system.add_menu(stereo_menu);
  1629. menu_system.add_menu(transpose_menu);
  1630. menu_system.add_menu(tune_menu);
  1631. menu_system.add_menu(detune_menu);
  1632. menu_system.add_menu(velocity_sense_menu);
  1633. menu_system.add_menu(effects_menu);
  1634. menu_system.add_menu(pan_trem_frequency_menu);
  1635. menu_system.add_menu(pan_trem_level_menu);
  1636. menu_system.add_menu(overdrive_menu);
  1637. menu_system.add_menu(comp_gain_menu);
  1638. menu_system.add_menu(comp_response_menu);
  1639. menu_system.add_menu(comp_limit_menu);
  1640. menu_system.add_menu(comp_threshold_menu);
  1641. menu_system.add_menu(comp_attack_menu);
  1642. menu_system.add_menu(comp_decay_menu);
  1643. menu_system.add_menu(reverb_roomsize_menu);
  1644. menu_system.add_menu(reverb_damping_menu);
  1645. menu_system.add_menu(reverb_level_menu);
  1646. menu_system.add_menu(chorus_frequency_menu);
  1647. menu_system.add_menu(chorus_intensity_menu);
  1648. menu_system.add_menu(chorus_waveform_menu);
  1649. menu_system.add_menu(chorus_level_menu);
  1650. menu_system.add_menu(bass_lr_level_menu);
  1651. menu_system.add_menu(bass_mono_level_menu);
  1652. menu_system.add_menu(eq_bass_menu);
  1653. menu_system.add_menu(eq_treble_menu);
  1654. menu_system.add_menu(save_sound_menu);
  1655. menu_system.add_menu(store_question_menu);
  1656. menu_system.add_menu(system_menu);
  1657. menu_system.add_menu(loudness_menu);
  1658. menu_system.add_menu(midi_channel_menu);
  1659. menu_system.add_menu(midi_soft_thru_menu);
  1660. menu_system.add_menu(max_poly_menu);
  1661. menu_system.add_menu(mono_menu);
  1662. menu_system.add_menu(panorama_menu);
  1663. menu_system.add_menu(info_menu);
  1664. menu_system.add_menu(master_volume_menu);
  1665. menu_system.set_focusPosition(Position::LEFT);
  1666. menu_system.switch_focus();
  1667. menu_system.update();
  1668. for ( i = 0; i < NUM_MENUS; i++)
  1669. menu_position[i] = -1;
  1670. menu_position[MAIN] = 0;
  1671. // setup encoder
  1672. for (i = 0; i < NUM_ENCODER; i++)
  1673. but[i].update();
  1674. master_volume = EEPROM.read(EEPROM_MASTER_VOLUME);
  1675. enc[LEFT_ENCODER].write(master_volume, ENC_MASTER_VOLUME_MIN, ENC_MASTER_VOLUME_MAX);
  1676. encoder_value[LEFT_ENCODER] = master_volume;
  1677. enc[RIGHT_ENCODER].write(0, 0, NUM_MAIN_MENUS - 1);
  1678. encoder_value[RIGHT_ENCODER] = 0;
  1679. }
  1680. void load_sound(void)
  1681. {
  1682. #ifdef SHOW_DEBUG
  1683. Serial.print(F("Load sound "));
  1684. Serial.println(sound, DEC);
  1685. #endif
  1686. EEPROM.update(EEPROM_SOUND, sound);
  1687. config_from_eeprom();
  1688. }
  1689. void save_sound(void)
  1690. {
  1691. #ifdef SHOW_DEBUG
  1692. Serial.print(F("Save sound "));
  1693. Serial.println(sound);
  1694. #endif
  1695. eeprom_config_write(sound);
  1696. yes_no = false;
  1697. }
  1698. void set_decay(uint8_t value)
  1699. {
  1700. if (value > ENC_DECAY_MAX)
  1701. value = ENC_DECAY_MAX;
  1702. #ifdef SHOW_DEBUG
  1703. Serial.print(F("Set DECAY "));
  1704. Serial.println(value);
  1705. #endif
  1706. float tmp = mapfloat(float(value), ENC_DECAY_MIN, ENC_DECAY_MAX, 0.0, 1.0);
  1707. ep->setDecay(tmp);
  1708. configuration.decay = value;
  1709. }
  1710. void set_release(uint8_t value)
  1711. {
  1712. if (value > ENC_RELEASE_MAX)
  1713. value = ENC_RELEASE_MAX;
  1714. #ifdef SHOW_DEBUG
  1715. Serial.print(F("Set RELEASE "));
  1716. Serial.println(value);
  1717. #endif
  1718. float tmp = mapfloat(float(value), ENC_RELEASE_MIN, ENC_RELEASE_MAX, 0.0, 1.0);
  1719. ep->setRelease(tmp);
  1720. configuration.release = value;
  1721. }
  1722. void set_hardness(uint8_t value)
  1723. {
  1724. if (value > ENC_HARDNESS_MAX)
  1725. value = ENC_HARDNESS_MAX;
  1726. #ifdef SHOW_DEBUG
  1727. Serial.print(F("Set HARDNESS "));
  1728. Serial.println(value);
  1729. #endif
  1730. float tmp = mapfloat(float(value), ENC_HARDNESS_MIN, ENC_HARDNESS_MAX, 0.0, 1.0);
  1731. ep->setHardness(tmp);
  1732. configuration.hardness = value;
  1733. }
  1734. void set_treble(uint8_t value)
  1735. {
  1736. if (value > ENC_TREBLE_MAX)
  1737. value = ENC_TREBLE_MAX;
  1738. #ifdef SHOW_DEBUG
  1739. Serial.print(F("Set TREBLE "));
  1740. Serial.println(value);
  1741. #endif
  1742. float tmp = mapfloat(float(value), ENC_TREBLE_MIN, ENC_TREBLE_MAX, 0.0, 1.0);
  1743. ep->setTreble(tmp);
  1744. configuration.treble = value;
  1745. }
  1746. void set_stereo(uint8_t value)
  1747. {
  1748. if (value > ENC_STEREO_MAX)
  1749. value = ENC_STEREO_MAX;
  1750. #ifdef SHOW_DEBUG
  1751. Serial.print(F("Set STEREO "));
  1752. Serial.println(value);
  1753. #endif
  1754. float tmp = mapfloat(float(value), ENC_STEREO_MIN, ENC_STEREO_MAX, 0.0, 1.0);
  1755. ep->setStereo(tmp);
  1756. configuration.stereo = value;
  1757. }
  1758. void set_transpose(int8_t value)
  1759. {
  1760. if (value < ENC_TRANSPOSE_MIN)
  1761. value = ENC_TRANSPOSE_MIN;
  1762. if (value > ENC_TRANSPOSE_MAX)
  1763. value = ENC_TRANSPOSE_MAX;
  1764. #ifdef SHOW_DEBUG
  1765. Serial.print(F("Set TRANSPOSE "));
  1766. Serial.println(value);
  1767. #endif
  1768. // Nothing special todo, because value will be added inside NoteOn/NoteOff
  1769. configuration.transpose = value;
  1770. }
  1771. void set_tune(int8_t value)
  1772. {
  1773. if (value < ENC_TUNE_MIN)
  1774. value = ENC_TUNE_MIN;
  1775. if (value > ENC_TUNE_MAX)
  1776. value = ENC_TUNE_MAX;
  1777. #ifdef SHOW_DEBUG
  1778. Serial.print(F("Set TUNE "));
  1779. Serial.println(value);
  1780. #endif
  1781. float tmp = mapfloat(float(value), ENC_TUNE_MIN, ENC_TUNE_MAX, 0.0, 1.0);
  1782. ep->setTune(tmp);
  1783. configuration.tune = value;
  1784. }
  1785. void set_detune(uint8_t value)
  1786. {
  1787. if (value > ENC_DETUNE_MAX)
  1788. value = ENC_DETUNE_MAX;
  1789. #ifdef SHOW_DEBUG
  1790. Serial.print(F("Set DETUNE "));
  1791. Serial.println(value);
  1792. #endif
  1793. float tmp = mapfloat(float(value), ENC_DETUNE_MIN, ENC_DETUNE_MAX, 0.0, 1.0);
  1794. ep->setDetune(tmp);
  1795. configuration.detune = value;
  1796. }
  1797. void set_velocity_sense(uint8_t value)
  1798. {
  1799. if (value > ENC_VELOCITY_SENSE_MAX)
  1800. value = ENC_VELOCITY_SENSE_MAX;
  1801. #ifdef SHOW_DEBUG
  1802. Serial.print(F("Set VELOCITY_SENSE "));
  1803. Serial.println(value);
  1804. #endif
  1805. float tmp = mapfloat(float(value), ENC_VELOCITY_SENSE_MIN, ENC_VELOCITY_SENSE_MAX, 0.0, 1.0);
  1806. ep->setVelocitySense(tmp);
  1807. configuration.velocity_sense = value;
  1808. }
  1809. void set_pan_trem_frequency(int8_t value)
  1810. {
  1811. if (value > ENC_PAN_TREM_FREQUENCY_MAX)
  1812. value = ENC_PAN_TREM_FREQUENCY_MAX;
  1813. #ifdef SHOW_DEBUG
  1814. Serial.print(F("Set PAN_TREM_FREQENCY "));
  1815. Serial.println(value);
  1816. #endif
  1817. float tmp = mapfloat(float(value), ENC_PAN_TREM_FREQUENCY_MIN, ENC_PAN_TREM_FREQUENCY_MAX, 0.0, 1.0);
  1818. ep->setPanLFO(tmp);
  1819. configuration.pan_trem_frequency = value;
  1820. }
  1821. void set_pan_trem_level(uint8_t value)
  1822. {
  1823. if (value > ENC_PAN_TREM_LEVEL_MAX)
  1824. value = ENC_PAN_TREM_LEVEL_MAX;
  1825. #ifdef SHOW_DEBUG
  1826. Serial.print(F("Set PAN_TREM_LEVEL "));
  1827. Serial.println(value);
  1828. #endif
  1829. float tmp = mapfloat(float(value), ENC_PAN_TREM_LEVEL_MIN, ENC_PAN_TREM_LEVEL_MAX, 0.0, 1.0);
  1830. ep->setPanTremolo(tmp);
  1831. configuration.pan_trem_level = value;
  1832. }
  1833. void set_overdrive(uint8_t value)
  1834. {
  1835. if (value > ENC_OVERDRIVE_MAX)
  1836. value = ENC_OVERDRIVE_MAX;
  1837. #ifdef SHOW_DEBUG
  1838. Serial.print(F("Set OVERDRIVE "));
  1839. Serial.println(value);
  1840. #endif
  1841. float tmp = mapfloat(float(value), ENC_OVERDRIVE_MIN, ENC_OVERDRIVE_MAX, 0.0, 1.0);
  1842. ep->setOverdrive(tmp);
  1843. configuration.overdrive = value;
  1844. }
  1845. void set_comp_gain(uint8_t value)
  1846. {
  1847. if (value > ENC_COMP_GAIN_MAX)
  1848. value = ENC_COMP_GAIN_MAX;
  1849. #ifdef SHOW_DEBUG
  1850. Serial.print(F("Set COMP_GAIN "));
  1851. Serial.println(value);
  1852. #endif
  1853. float tmp = mapfloat(float(value), ENC_COMP_GAIN_MIN, ENC_COMP_GAIN_MAX, 0.0, 1.0);
  1854. sgtl5000_1.autoVolumeControl(tmp, configuration.comp_response, configuration.comp_limit, (float)configuration.comp_threshold, (float)configuration.comp_attack / 10, (float)configuration.comp_decay / 10); // maxGain, response, hardLimit, threshold, attack, decay, e.g.: 1, 1, 1, 0.9, 0.01, 0.05
  1855. configuration.comp_gain = value;
  1856. }
  1857. void set_comp_response(uint8_t value)
  1858. {
  1859. if (value > ENC_COMP_RESPONSE_MAX)
  1860. value = ENC_COMP_RESPONSE_MAX;
  1861. #ifdef SHOW_DEBUG
  1862. Serial.print(F("Set COMP_RESPONSE "));
  1863. Serial.println(value);
  1864. #endif
  1865. float tmp = mapfloat(float(value), ENC_COMP_RESPONSE_MIN, ENC_COMP_RESPONSE_MAX, 0.0, 1.0);
  1866. sgtl5000_1.autoVolumeControl(configuration.comp_gain, tmp, configuration.comp_limit, (float)configuration.comp_threshold, (float)configuration.comp_attack / 10, (float)configuration.comp_decay / 10); // maxGain, response, hardLimit, threshold, attack, decay, e.g.: 1, 1, 1, 0.9, 0.01, 0.05
  1867. configuration.comp_response = value;
  1868. }
  1869. void set_comp_limit(uint8_t value)
  1870. {
  1871. if (value > ENC_COMP_LIMIT_MAX)
  1872. value = ENC_COMP_LIMIT_MAX;
  1873. #ifdef SHOW_DEBUG
  1874. Serial.print(F("Set COMP_LIMIT "));
  1875. Serial.println(value);
  1876. #endif
  1877. float tmp = mapfloat(float(value), ENC_COMP_LIMIT_MIN, ENC_COMP_LIMIT_MAX, 0.0, 1.0);
  1878. sgtl5000_1.autoVolumeControl(configuration.comp_gain, configuration.comp_response, tmp, (float)configuration.comp_threshold, (float)configuration.comp_attack / 10, (float)configuration.comp_decay / 10); // maxGain, response, hardLimit, threshold, attack, decay, e.g.: 1, 1, 1, 0.9, 0.01, 0.05
  1879. configuration.comp_limit = value;
  1880. }
  1881. void set_comp_threshold(uint8_t value)
  1882. {
  1883. if (value > ENC_COMP_THRESHOLD_MAX)
  1884. value = ENC_COMP_THRESHOLD_MAX;
  1885. #ifdef SHOW_DEBUG
  1886. Serial.print(F("Set COMP_THRESHOLD "));
  1887. Serial.println(value);
  1888. #endif
  1889. //float tmp = mapfloat(float(value), ENC_COMP_THRESHOLD_MIN, ENC_COMP_THRESHOLD_MAX, 0.0, 1.0);
  1890. sgtl5000_1.autoVolumeControl(configuration.comp_gain, configuration.comp_response, configuration.comp_limit, (float)value, (float)configuration.comp_attack / 10, (float)configuration.comp_decay / 10); // maxGain, response, hardLimit, threshold, attack, decay, e.g.: 1, 1, 1, 0.9, 0.01, 0.05
  1891. configuration.comp_threshold = value;
  1892. }
  1893. void set_comp_attack(uint8_t value)
  1894. {
  1895. if (value > ENC_COMP_ATTACK_MAX)
  1896. value = ENC_COMP_ATTACK_MAX;
  1897. #ifdef SHOW_DEBUG
  1898. Serial.print(F("Set COMP_ATTACK "));
  1899. Serial.println(value);
  1900. #endif
  1901. //float tmp = mapfloat(float(value), ENC_COMP_ATTACK_MIN, ENC_COMP_ATTACK_MAX, 0.0, 1.0);
  1902. sgtl5000_1.autoVolumeControl(configuration.comp_gain, configuration.comp_response, configuration.comp_limit, (float)configuration.comp_threshold, (float)value / 10, (float)configuration.comp_decay / 10); // maxGain, response, hardLimit, threshold, attack, decay, e.g.: 1, 1, 1, 0.9, 0.01, 0.05
  1903. configuration.comp_attack = value;
  1904. }
  1905. void set_comp_decay(uint8_t value)
  1906. {
  1907. if (value > ENC_COMP_DECAY_MAX)
  1908. value = ENC_COMP_DECAY_MAX;
  1909. #ifdef SHOW_DEBUG
  1910. Serial.print(F("Set COMP_DECAY "));
  1911. Serial.println(value);
  1912. #endif
  1913. //float tmp = mapfloat(float(value), ENC_COMP_DECAY_MIN, ENC_COMP_DECAY_MAX, 0.0, 1.0);
  1914. sgtl5000_1.autoVolumeControl(configuration.comp_gain, configuration.comp_response, configuration.comp_limit, (float)configuration.comp_threshold, (float)configuration.comp_attack / 10, (float)value / 10); // maxGain, response, hardLimit, threshold, attack, decay, e.g.: 1, 1, 1, 0.9, 0.01, 0.05
  1915. configuration.comp_decay = value;
  1916. }
  1917. void set_reverb_roomsize(uint8_t value)
  1918. {
  1919. if (value > ENC_REVERB_ROOMSIZE_MAX)
  1920. value = ENC_REVERB_ROOMSIZE_MAX;
  1921. #ifdef SHOW_DEBUG
  1922. Serial.print(F("Set REVERB_ROOMSIZE "));
  1923. Serial.println(value);
  1924. #endif
  1925. float tmp = mapfloat(float(value), ENC_REVERB_ROOMSIZE_MIN, ENC_REVERB_ROOMSIZE_MAX, 0.0, 1.0);
  1926. freeverb_r.roomsize(tmp);
  1927. freeverb_l.roomsize(tmp);
  1928. configuration.reverb_roomsize = value;
  1929. }
  1930. void set_reverb_damping(uint8_t value)
  1931. {
  1932. if (value > ENC_REVERB_DAMPING_MAX)
  1933. value = ENC_REVERB_DAMPING_MAX;
  1934. #ifdef SHOW_DEBUG
  1935. Serial.print(F("Set REVERB_DAMPING "));
  1936. Serial.println(value);
  1937. #endif
  1938. float tmp = mapfloat(float(value), ENC_REVERB_DAMPING_MIN, ENC_REVERB_DAMPING_MAX, 0.0, 1.0);
  1939. freeverb_r.damping(tmp);
  1940. freeverb_l.damping(tmp);
  1941. configuration.reverb_damping = value;
  1942. }
  1943. void set_reverb_level(uint8_t value)
  1944. {
  1945. if (value > ENC_REVERB_LEVEL_MAX)
  1946. value = ENC_REVERB_LEVEL_MAX;
  1947. #ifdef SHOW_DEBUG
  1948. Serial.print(F("Set REVERB_LEVEL "));
  1949. Serial.println(value);
  1950. #endif
  1951. float tmp = mapfloat(float(value), ENC_REVERB_LEVEL_MIN, ENC_REVERB_LEVEL_MAX, 0.0, 1.0);
  1952. mixer_r.gain(1, tmp);
  1953. mixer_l.gain(1, tmp);
  1954. configuration.reverb_level = value;
  1955. }
  1956. void set_chorus_frequency(uint8_t value)
  1957. {
  1958. if (value > ENC_CHORUS_FREQUENCY_MAX)
  1959. value = ENC_CHORUS_FREQUENCY_MAX;
  1960. #ifdef SHOW_DEBUG
  1961. Serial.print(F("Set CHORUS_FREQUENCY "));
  1962. Serial.println(value);
  1963. #endif
  1964. modulator.frequency(float(value) / 10);
  1965. configuration.chorus_frequency = value;
  1966. }
  1967. void set_chorus_intensity(uint8_t value)
  1968. {
  1969. if (value > ENC_CHORUS_INTENSITY_MAX)
  1970. value = ENC_CHORUS_INTENSITY_MAX;
  1971. #ifdef SHOW_DEBUG
  1972. Serial.print(F("Set CHORUS_INTENSITY "));
  1973. Serial.println(value);
  1974. #endif
  1975. modulator.amplitude(mapfloat(float(value), ENC_CHORUS_INTENSITY_MIN, ENC_CHORUS_INTENSITY_MAX, 0.0, 1.0));
  1976. configuration.chorus_intensity = value;
  1977. }
  1978. void set_chorus_waveform(uint8_t value)
  1979. {
  1980. #ifdef SHOW_DEBUG
  1981. Serial.print(F("Set CHORUS_WAVEFORM "));
  1982. #endif
  1983. switch (value)
  1984. {
  1985. case 1:
  1986. modulator.begin(WAVEFORM_TRIANGLE);
  1987. break;
  1988. case 2:
  1989. modulator.begin(WAVEFORM_SINE);
  1990. break;
  1991. default:
  1992. modulator.begin(WAVEFORM_TRIANGLE);
  1993. value = 1;
  1994. break;
  1995. }
  1996. configuration.chorus_waveform = value;
  1997. Serial.println(value);
  1998. }
  1999. void set_chorus_level(uint8_t value)
  2000. {
  2001. if (value > ENC_CHORUS_LEVEL_MAX)
  2002. value = ENC_CHORUS_LEVEL_MAX;
  2003. #ifdef SHOW_DEBUG
  2004. Serial.print(F("Set CHORUS_LEVEL "));
  2005. Serial.println(value);
  2006. #endif
  2007. float tmp = mapfloat(float(value), ENC_CHORUS_LEVEL_MIN, ENC_CHORUS_LEVEL_MAX, 0.0, 0.5);
  2008. mixer_r.gain(0, 1.0 - tmp);
  2009. mixer_l.gain(0, 1.0 - tmp);
  2010. mixer_r.gain(2, tmp);
  2011. mixer_l.gain(2, tmp);
  2012. configuration.chorus_level = value;
  2013. }
  2014. void set_bass_lr_level(uint8_t value)
  2015. {
  2016. if (value > ENC_BASS_MONO_LEVEL_MAX)
  2017. value = ENC_BASS_MONO_LEVEL_MAX;
  2018. #ifdef SHOW_DEBUG
  2019. Serial.print(F("Set BASS_LR_LEVEL "));
  2020. Serial.println(value);
  2021. #endif
  2022. float tmp1 = mapfloat(float(value), ENC_BASS_LR_LEVEL_MIN, ENC_BASS_LR_LEVEL_MAX, 0.0, 1.0);
  2023. float tmp2 = mapfloat(float(configuration.bass_mono_level), ENC_BASS_MONO_LEVEL_MIN, ENC_BASS_MONO_LEVEL_MAX, 0.0, 1.0);
  2024. sgtl5000_1.enhanceBass(tmp1, tmp2);
  2025. configuration.bass_lr_level = value;
  2026. }
  2027. void set_bass_mono_level(uint8_t value)
  2028. {
  2029. if (value > ENC_BASS_LR_LEVEL_MAX)
  2030. value = ENC_BASS_LR_LEVEL_MAX;
  2031. #ifdef SHOW_DEBUG
  2032. Serial.print(F("Set BASS_MONO_LEVEL "));
  2033. Serial.println(value);
  2034. #endif
  2035. float tmp1 = mapfloat(float(configuration.bass_lr_level), ENC_BASS_LR_LEVEL_MIN, ENC_BASS_LR_LEVEL_MAX, 0.0, 1.0);
  2036. float tmp2 = mapfloat(float(value), ENC_BASS_MONO_LEVEL_MIN, ENC_BASS_MONO_LEVEL_MAX, 0.0, 1.0);
  2037. sgtl5000_1.enhanceBass(tmp1, tmp2);
  2038. configuration.bass_mono_level = value;
  2039. }
  2040. void set_eq_bass(int8_t value)
  2041. {
  2042. if (value > ENC_EQ_TREBLE_MAX)
  2043. value = ENC_EQ_TREBLE_MAX;
  2044. #ifdef SHOW_DEBUG
  2045. Serial.print(F("Set EQ_BASS "));
  2046. Serial.println(value);
  2047. #endif
  2048. float tmp1 = mapfloat(float(value), ENC_EQ_BASS_MIN, ENC_EQ_BASS_MAX, -1.0, 1.0);
  2049. float tmp2 = mapfloat(float(configuration.eq_treble), ENC_EQ_TREBLE_MIN, ENC_EQ_TREBLE_MAX, -1.0, 1.0);
  2050. sgtl5000_1.eqBands(tmp1, tmp2);
  2051. configuration.eq_bass = value;
  2052. }
  2053. void set_eq_treble(int8_t value)
  2054. {
  2055. if (value > ENC_EQ_BASS_MAX )
  2056. value = ENC_EQ_BASS_MAX;
  2057. #ifdef SHOW_DEBUG
  2058. Serial.print(F("Set EQ_TREBLE "));
  2059. Serial.println(value);
  2060. #endif
  2061. float tmp1 = mapfloat(float(configuration.eq_bass), ENC_EQ_BASS_MIN, ENC_EQ_BASS_MAX, -1.0, 1.0);
  2062. float tmp2 = mapfloat(float(value), ENC_EQ_TREBLE_MIN, ENC_EQ_TREBLE_MAX, -1.0, 1.0);
  2063. sgtl5000_1.eqBands(tmp1, tmp2);
  2064. configuration.eq_treble = value;
  2065. }
  2066. void set_loudness(uint8_t value)
  2067. {
  2068. if (value > ENC_LOUDNESS_MAX)
  2069. value = ENC_LOUDNESS_MAX;
  2070. #ifdef SHOW_DEBUG
  2071. Serial.print(F("Set LOUDNESS "));
  2072. Serial.println(value);
  2073. #endif
  2074. ep->setLoudness(mapfloat(float(value), ENC_LOUDNESS_MIN, ENC_LOUDNESS_MAX, 0.0, 1.0));
  2075. //volume_r.gain(tmp);
  2076. //volume_l.gain(tmp);
  2077. configuration.loudness = value;
  2078. }
  2079. void set_midi_channel(uint8_t value)
  2080. {
  2081. if (value > 16)
  2082. value = 16;
  2083. #ifdef SHOW_DEBUG
  2084. Serial.print(F("Set MIDI_CHANNEL "));
  2085. Serial.println(value);
  2086. #endif
  2087. configuration.midi_channel = value;
  2088. }
  2089. void set_midi_soft_thru(uint8_t value)
  2090. {
  2091. if (value > 1)
  2092. value = 1;
  2093. #ifdef SHOW_DEBUG
  2094. Serial.print(F("Set MIDI_SOFT_THRU "));
  2095. Serial.println(value);
  2096. #endif
  2097. configuration.midi_soft_thru = value;
  2098. }
  2099. void set_max_poly(uint8_t value)
  2100. {
  2101. if (value > ENC_MAX_POLY_MAX)
  2102. value = ENC_MAX_POLY_MAX;
  2103. #ifdef SHOW_DEBUG
  2104. Serial.print(F("Set MAX_POLY "));
  2105. Serial.println(value);
  2106. #endif
  2107. ep->setMaxPolyphony(value);
  2108. configuration.max_poly = value;
  2109. ep->reset_voices();
  2110. }
  2111. void set_mono(uint8_t mode)
  2112. {
  2113. #ifdef SHOW_DEBUG
  2114. Serial.print(F("Set MONO "));
  2115. Serial.println(mode);
  2116. #endif
  2117. configuration.mono = mode;
  2118. if (mode == 0)
  2119. {
  2120. // stereo
  2121. ep->setStereo(mapfloat(float(configuration.stereo), ENC_STEREO_MIN, ENC_STEREO_MAX, 0.0, 1.0));
  2122. inverter.gain(-1.0); // change phase for second modulated delay (faked stereo mode)
  2123. }
  2124. else
  2125. {
  2126. // mono
  2127. ep->setStereo(0.0);
  2128. inverter.gain(1.0);
  2129. set_master_volume(master_volume);
  2130. }
  2131. }
  2132. void set_panorama(uint8_t value)
  2133. {
  2134. if (value < ENC_MASTER_PAN_MIN)
  2135. value = ENC_MASTER_PAN_MIN;
  2136. if (value > ENC_MASTER_PAN_MAX)
  2137. #ifdef SHOW_DEBUG
  2138. Serial.print(F("Set MASTER_PANORAMA "));
  2139. Serial.println(value);
  2140. #endif
  2141. configuration.pan = value;
  2142. set_master_volume(master_volume);
  2143. }
  2144. void set_complete_configuration(void)
  2145. {
  2146. set_decay(configuration.decay);
  2147. set_release(configuration.release);
  2148. set_hardness(configuration.hardness);
  2149. set_treble(configuration.treble);
  2150. set_stereo(configuration.stereo);
  2151. set_tune(configuration.tune);
  2152. set_detune(configuration.detune);
  2153. set_velocity_sense(configuration.velocity_sense);
  2154. set_pan_trem_frequency(configuration.pan_trem_frequency);
  2155. set_pan_trem_level(configuration.pan_trem_level);
  2156. set_overdrive(configuration.overdrive);
  2157. set_comp_gain(configuration.comp_gain);
  2158. set_comp_response(configuration.comp_response);
  2159. set_comp_limit(configuration.comp_limit);
  2160. set_comp_threshold(configuration.comp_threshold);
  2161. set_comp_attack(configuration.comp_attack);
  2162. set_comp_decay(configuration.comp_decay);
  2163. set_reverb_roomsize(configuration.reverb_roomsize);
  2164. set_reverb_damping(configuration.reverb_damping);
  2165. set_reverb_level(configuration.reverb_level);
  2166. set_chorus_frequency(configuration.chorus_frequency);
  2167. set_chorus_intensity(configuration.chorus_intensity);
  2168. set_chorus_waveform(configuration.chorus_waveform);
  2169. set_chorus_level(configuration.chorus_level);
  2170. set_bass_lr_level(configuration.bass_lr_level);
  2171. set_bass_mono_level(configuration.bass_mono_level);
  2172. set_eq_bass(configuration.eq_bass);
  2173. set_eq_treble(configuration.eq_treble);
  2174. set_loudness(configuration.loudness);
  2175. set_midi_channel(configuration.midi_channel);
  2176. set_midi_soft_thru(configuration.midi_soft_thru);
  2177. set_max_poly(configuration.max_poly);
  2178. set_mono(configuration.mono);
  2179. set_panorama(configuration.pan);
  2180. }
  2181. //********************************************************************************************+
  2182. void handle_ui(void)
  2183. {
  2184. uint8_t i;
  2185. int32_t encoder_tmp;
  2186. if (back_to_main > BACK_TO_MAIN_MS && menu_system.get_currentScreen() == &master_volume_screen)
  2187. {
  2188. {
  2189. #ifdef SHOW_DEBUG
  2190. Serial.println(F("from master_volume to main"));
  2191. #endif
  2192. goto_main_menu(MASTER_VOLUME);
  2193. }
  2194. }
  2195. for (i = 0; i < NUM_ENCODER; i++)
  2196. {
  2197. but[i].update();
  2198. switch (i)
  2199. {
  2200. case RIGHT_ENCODER:
  2201. // Encoder handling
  2202. encoder_tmp = enc[RIGHT_ENCODER].read();
  2203. if (menu_system.get_currentScreen() == &load_sound_screen)
  2204. {
  2205. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2206. {
  2207. // value up/down
  2208. sound = encoder_tmp;
  2209. menu_system.update();
  2210. }
  2211. }
  2212. else if (menu_system.get_currentScreen() == &decay_screen)
  2213. {
  2214. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2215. {
  2216. // value up/down
  2217. set_decay(encoder_tmp);
  2218. menu_system.update();
  2219. }
  2220. }
  2221. else if (menu_system.get_currentScreen() == &release_screen)
  2222. {
  2223. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2224. {
  2225. // value up/down
  2226. set_release(encoder_tmp);
  2227. menu_system.update();
  2228. }
  2229. }
  2230. else if (menu_system.get_currentScreen() == &hardness_screen)
  2231. {
  2232. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2233. {
  2234. // value up/down
  2235. set_hardness(encoder_tmp);
  2236. menu_system.update();
  2237. }
  2238. }
  2239. else if (menu_system.get_currentScreen() == &treble_screen)
  2240. {
  2241. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2242. {
  2243. // value up/down
  2244. set_treble(encoder_tmp);
  2245. menu_system.update();
  2246. }
  2247. }
  2248. else if (menu_system.get_currentScreen() == &stereo_screen)
  2249. {
  2250. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2251. {
  2252. // value up/down
  2253. set_stereo(encoder_tmp);
  2254. menu_system.update();
  2255. }
  2256. }
  2257. else if (menu_system.get_currentScreen() == &transpose_screen)
  2258. {
  2259. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2260. {
  2261. // value up/down
  2262. set_transpose(encoder_tmp);
  2263. menu_system.update();
  2264. }
  2265. }
  2266. else if (menu_system.get_currentScreen() == &tune_screen)
  2267. {
  2268. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2269. {
  2270. // value up/down
  2271. set_tune(encoder_tmp);
  2272. menu_system.update();
  2273. }
  2274. }
  2275. else if (menu_system.get_currentScreen() == &detune_screen)
  2276. {
  2277. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2278. {
  2279. // value up/down
  2280. set_detune(encoder_tmp);
  2281. menu_system.update();
  2282. }
  2283. }
  2284. else if (menu_system.get_currentScreen() == &velocity_sense_screen)
  2285. {
  2286. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2287. {
  2288. // value up/down
  2289. set_velocity_sense(encoder_tmp);
  2290. menu_system.update();
  2291. }
  2292. }
  2293. else if (menu_system.get_currentScreen() == &pan_trem_frequency_screen)
  2294. {
  2295. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2296. {
  2297. // value up/down
  2298. set_pan_trem_frequency(encoder_tmp);
  2299. menu_system.update();
  2300. }
  2301. }
  2302. else if (menu_system.get_currentScreen() == &pan_trem_level_screen)
  2303. {
  2304. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2305. {
  2306. // value up/down
  2307. set_pan_trem_level(encoder_tmp);
  2308. menu_system.update();
  2309. }
  2310. }
  2311. else if (menu_system.get_currentScreen() == &overdrive_screen)
  2312. {
  2313. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2314. {
  2315. // value up/down
  2316. set_overdrive(encoder_tmp);
  2317. menu_system.update();
  2318. }
  2319. }
  2320. else if (menu_system.get_currentScreen() == &comp_gain_screen)
  2321. {
  2322. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2323. {
  2324. // value up/down
  2325. set_comp_gain(encoder_tmp);
  2326. menu_system.update();
  2327. }
  2328. }
  2329. else if (menu_system.get_currentScreen() == &comp_response_screen)
  2330. {
  2331. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2332. {
  2333. // value up/down
  2334. set_comp_response(encoder_tmp);
  2335. menu_system.update();
  2336. }
  2337. }
  2338. else if (menu_system.get_currentScreen() == &comp_limit_screen)
  2339. {
  2340. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2341. {
  2342. // value up/down
  2343. set_comp_limit(encoder_tmp);
  2344. menu_system.update();
  2345. }
  2346. }
  2347. else if (menu_system.get_currentScreen() == &comp_threshold_screen)
  2348. {
  2349. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2350. {
  2351. // value up/down
  2352. set_comp_threshold(encoder_tmp);
  2353. menu_system.update();
  2354. }
  2355. }
  2356. else if (menu_system.get_currentScreen() == &comp_attack_screen)
  2357. {
  2358. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2359. {
  2360. // value up/down
  2361. set_comp_attack(encoder_tmp);
  2362. menu_system.update();
  2363. }
  2364. }
  2365. else if (menu_system.get_currentScreen() == &comp_decay_screen)
  2366. {
  2367. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2368. {
  2369. // value up/down
  2370. set_comp_decay(encoder_tmp);
  2371. menu_system.update();
  2372. }
  2373. }
  2374. else if (menu_system.get_currentScreen() == &reverb_roomsize_screen)
  2375. {
  2376. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2377. {
  2378. // value up/down
  2379. set_reverb_roomsize(encoder_tmp);
  2380. menu_system.update();
  2381. }
  2382. }
  2383. else if (menu_system.get_currentScreen() == &reverb_damping_screen)
  2384. {
  2385. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2386. {
  2387. // value up/down
  2388. set_reverb_damping(encoder_tmp);
  2389. menu_system.update();
  2390. }
  2391. }
  2392. else if (menu_system.get_currentScreen() == &reverb_level_screen)
  2393. {
  2394. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2395. {
  2396. // value up/down
  2397. set_reverb_level(encoder_tmp);
  2398. menu_system.update();
  2399. }
  2400. }
  2401. else if (menu_system.get_currentScreen() == &chorus_frequency_screen)
  2402. {
  2403. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2404. {
  2405. // value up/down
  2406. set_chorus_frequency(encoder_tmp);
  2407. menu_system.update();
  2408. }
  2409. }
  2410. else if (menu_system.get_currentScreen() == &chorus_intensity_screen)
  2411. {
  2412. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2413. {
  2414. // value up/down
  2415. set_chorus_intensity(encoder_tmp);
  2416. menu_system.update();
  2417. }
  2418. }
  2419. else if (menu_system.get_currentScreen() == &chorus_waveform_screen)
  2420. {
  2421. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2422. {
  2423. // value up/down
  2424. set_chorus_waveform(encoder_tmp);
  2425. menu_system.update();
  2426. }
  2427. }
  2428. else if (menu_system.get_currentScreen() == &chorus_level_screen)
  2429. {
  2430. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2431. {
  2432. // value up/down
  2433. set_chorus_level(encoder_tmp);
  2434. menu_system.update();
  2435. }
  2436. }
  2437. else if (menu_system.get_currentScreen() == &bass_lr_level_screen)
  2438. {
  2439. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2440. {
  2441. // value up/down
  2442. set_bass_lr_level(encoder_tmp);
  2443. menu_system.update();
  2444. }
  2445. }
  2446. else if (menu_system.get_currentScreen() == &bass_mono_level_screen)
  2447. {
  2448. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2449. {
  2450. // value up/down
  2451. set_bass_mono_level(encoder_tmp);
  2452. menu_system.update();
  2453. }
  2454. }
  2455. else if (menu_system.get_currentScreen() == &eq_bass_screen)
  2456. {
  2457. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2458. {
  2459. // value up/down
  2460. set_eq_bass(encoder_tmp);
  2461. menu_system.update();
  2462. }
  2463. }
  2464. else if (menu_system.get_currentScreen() == &eq_treble_screen)
  2465. {
  2466. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2467. {
  2468. // value up/down
  2469. set_eq_treble(encoder_tmp);
  2470. menu_system.update();
  2471. }
  2472. }
  2473. else if (menu_system.get_currentScreen() == &save_sound_screen)
  2474. {
  2475. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2476. {
  2477. // value up/down
  2478. sound = encoder_tmp;
  2479. menu_system.update();
  2480. }
  2481. }
  2482. else if (menu_system.get_currentScreen() == &store_question_screen)
  2483. {
  2484. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2485. {
  2486. // value up/down
  2487. yes_no = encoder_tmp;
  2488. menu_system.update();
  2489. }
  2490. }
  2491. else if (menu_system.get_currentScreen() == &loudness_screen)
  2492. {
  2493. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2494. {
  2495. // value up/down
  2496. set_loudness(encoder_tmp);
  2497. menu_system.update();
  2498. }
  2499. }
  2500. else if (menu_system.get_currentScreen() == &midi_channel_screen)
  2501. {
  2502. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2503. {
  2504. // value up/down
  2505. set_midi_channel(encoder_tmp);
  2506. menu_system.update();
  2507. }
  2508. }
  2509. else if (menu_system.get_currentScreen() == &midi_soft_thru_screen)
  2510. {
  2511. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2512. {
  2513. // value up/down
  2514. set_midi_soft_thru(encoder_tmp);
  2515. menu_system.update();
  2516. }
  2517. }
  2518. else if (menu_system.get_currentScreen() == &max_poly_screen)
  2519. {
  2520. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2521. {
  2522. // value up/down
  2523. set_max_poly(encoder_tmp);
  2524. menu_system.update();
  2525. }
  2526. }
  2527. else if (menu_system.get_currentScreen() == &mono_screen)
  2528. {
  2529. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2530. {
  2531. // value up/down
  2532. set_mono(encoder_tmp);
  2533. menu_system.update();
  2534. }
  2535. }
  2536. else if (menu_system.get_currentScreen() == &panorama_screen)
  2537. {
  2538. if (encoder_tmp != encoder_value[RIGHT_ENCODER])
  2539. {
  2540. // value up/down
  2541. set_panorama(encoder_tmp);
  2542. menu_system.update();
  2543. }
  2544. }
  2545. else
  2546. {
  2547. // Move menu focus
  2548. if (encoder_tmp > encoder_value[RIGHT_ENCODER])
  2549. {
  2550. // move down
  2551. #ifdef SHOW_DEBUG
  2552. Serial.print(F("ENC-R-DOWN: "));
  2553. Serial.println(encoder_tmp);
  2554. #endif
  2555. encoder_switch_focus(encoder_tmp, encoder_value[RIGHT_ENCODER]);
  2556. menu_system.softUpdate();
  2557. }
  2558. else if (encoder_tmp < encoder_value[RIGHT_ENCODER])
  2559. {
  2560. // move up
  2561. #ifdef SHOW_DEBUG
  2562. Serial.print(F("ENC-R-UP: "));
  2563. Serial.println(encoder_tmp);
  2564. #endif
  2565. encoder_switch_focus(encoder_tmp, encoder_value[RIGHT_ENCODER]);
  2566. menu_system.softUpdate();
  2567. }
  2568. }
  2569. encoder_value[RIGHT_ENCODER] = encoder_tmp;
  2570. // button handling
  2571. if (but[i].fallingEdge()) // SELECT
  2572. {
  2573. #ifdef SHOW_DEBUG
  2574. Serial.println(F("SELECT-R"));
  2575. #endif
  2576. if (menu_system.get_currentScreen() == &load_sound_screen)
  2577. {
  2578. // load sound
  2579. #ifdef SHOW_DEBUG
  2580. Serial.print("Load sound ");
  2581. Serial.println();
  2582. #endif
  2583. load_sound();
  2584. goto_main_menu(LOAD_SOUND);
  2585. }
  2586. else if (menu_system.get_currentScreen() == &save_sound_screen)
  2587. {
  2588. // ask for storing sound
  2589. #ifdef SHOW_DEBUG
  2590. Serial.print("Storing sound?");
  2591. Serial.println();
  2592. #endif
  2593. goto_store_question_menu(SAVE_SOUND);
  2594. }
  2595. else if (menu_system.get_currentScreen() == &store_question_screen)
  2596. {
  2597. // save sound
  2598. if (encoder_tmp == 1)
  2599. {
  2600. #ifdef SHOW_DEBUG
  2601. Serial.print(F("Save sound "));
  2602. Serial.println(sound, DEC);
  2603. #endif
  2604. save_sound();
  2605. }
  2606. #ifdef SHOW_DEBUG
  2607. else
  2608. Serial.println(F("Not saving sound!"));
  2609. #endif
  2610. goto_main_menu(SAVE_SOUND);
  2611. }
  2612. else
  2613. {
  2614. uint8_t menu_callback_offset = 0;
  2615. if (menu_system.get_currentScreen() == &edit_sound_screen)
  2616. menu_callback_offset = NUM_MAIN_MENUS;
  2617. else if (menu_system.get_currentScreen() == &effects_screen)
  2618. menu_callback_offset = NUM_MAIN_MENUS + NUM_EDIT_SOUND_MENUS;
  2619. else if (menu_system.get_currentScreen() == &system_screen)
  2620. menu_callback_offset = NUM_MAIN_MENUS + NUM_EDIT_SOUND_MENUS + NUM_EFFECTS_MENUS;
  2621. #ifdef SHOW_DEBUG
  2622. Serial.print(F("Starting callback number "));
  2623. Serial.println(encoder_value[RIGHT_ENCODER] + menu_callback_offset, DEC);
  2624. Serial.print(F("encoder_value[RIGHT_ENCODER]="));
  2625. Serial.print(encoder_value[RIGHT_ENCODER], DEC);
  2626. Serial.print(F(" menu_callback_offset="));
  2627. Serial.println(menu_callback_offset, DEC);
  2628. #endif
  2629. if (menu_system.is_callable(encoder_value[RIGHT_ENCODER] + 1 + menu_callback_offset))
  2630. {
  2631. // change menu
  2632. menu_system.call_function(encoder_value[RIGHT_ENCODER] + 1 + menu_callback_offset);
  2633. //menu_system.update();
  2634. }
  2635. #ifdef SHOW_DEBUG
  2636. else
  2637. {
  2638. Serial.print(F("No callback for "));
  2639. Serial.println(encoder_value[RIGHT_ENCODER] + 1 + menu_callback_offset, DEC);
  2640. }
  2641. #endif
  2642. }
  2643. }
  2644. break;
  2645. case LEFT_ENCODER:
  2646. // Encoder handling
  2647. encoder_tmp = enc[LEFT_ENCODER].read();
  2648. // Change volume
  2649. if (encoder_tmp > encoder_value[LEFT_ENCODER])
  2650. {
  2651. // move down
  2652. #ifdef SHOW_DEBUG
  2653. Serial.print(F("ENC-L-DOWN: "));
  2654. Serial.println(encoder_tmp);
  2655. #endif
  2656. }
  2657. else if (encoder_tmp < encoder_value[LEFT_ENCODER])
  2658. {
  2659. // move up
  2660. #ifdef SHOW_DEBUG
  2661. Serial.print(F("ENC-L-UP: "));
  2662. Serial.println(encoder_tmp);
  2663. #endif
  2664. }
  2665. if (encoder_tmp != encoder_value[LEFT_ENCODER])
  2666. {
  2667. master_volume = encoder_tmp;
  2668. set_master_volume(master_volume);
  2669. #ifdef SHOW_DEBUG
  2670. Serial.print(F("master_volume: "));
  2671. Serial.println(master_volume);
  2672. #endif
  2673. menu_system.change_menu(master_volume_menu);
  2674. menu_system.update();
  2675. back_to_main = 0;
  2676. }
  2677. encoder_value[LEFT_ENCODER] = encoder_tmp;
  2678. // button handling
  2679. if (but[i].fallingEdge()) // BACK
  2680. {
  2681. #ifdef SHOW_DEBUG
  2682. Serial.print("Back press detected: ");
  2683. #endif
  2684. if (menu_system.get_currentScreen() == &load_sound_screen) // load_sound menu
  2685. {
  2686. #ifdef SHOW_DEBUG
  2687. Serial.println(F("from load_sound to main"));
  2688. #endif
  2689. goto_main_menu(LOAD_SOUND);
  2690. }
  2691. else if (menu_system.get_currentScreen() == &edit_sound_screen) // sound menu
  2692. {
  2693. #ifdef SHOW_DEBUG
  2694. Serial.println(F("from edit_sound to main"));
  2695. #endif
  2696. goto_main_menu(EDIT_SOUND);
  2697. }
  2698. else if (menu_system.get_currentScreen() == &decay_screen) // decay menu
  2699. {
  2700. #ifdef SHOW_DEBUG
  2701. Serial.println(F("from decay to edit_sound"));
  2702. #endif
  2703. goto_edit_sound_menu(DECAY);
  2704. }
  2705. else if (menu_system.get_currentScreen() == &release_screen) // release menu
  2706. {
  2707. #ifdef SHOW_DEBUG
  2708. Serial.println(F("from release to edit_sound"));
  2709. #endif
  2710. goto_edit_sound_menu(RELEASE);
  2711. }
  2712. else if (menu_system.get_currentScreen() == &hardness_screen) // hardness menu
  2713. {
  2714. #ifdef SHOW_DEBUG
  2715. Serial.println(F("from hardness to edit_sound"));
  2716. #endif
  2717. goto_edit_sound_menu(HARDNESS);
  2718. }
  2719. else if (menu_system.get_currentScreen() == &treble_screen) // treble menu
  2720. {
  2721. #ifdef SHOW_DEBUG
  2722. Serial.println(F("from treble to edit_sound"));
  2723. #endif
  2724. goto_edit_sound_menu(TREBLE);
  2725. }
  2726. else if (menu_system.get_currentScreen() == &stereo_screen) // stereo menu
  2727. {
  2728. #ifdef SHOW_DEBUG
  2729. Serial.println(F("from stereo to edit_sound"));
  2730. #endif
  2731. goto_edit_sound_menu(STEREO_LEVEL);
  2732. }
  2733. else if (menu_system.get_currentScreen() == &transpose_screen) // transpose menu
  2734. {
  2735. #ifdef SHOW_DEBUG
  2736. Serial.println(F("from transpose to edit_sound"));
  2737. #endif
  2738. goto_edit_sound_menu(TRANSPOSE);
  2739. }
  2740. else if (menu_system.get_currentScreen() == &tune_screen) // tune menu
  2741. {
  2742. #ifdef SHOW_DEBUG
  2743. Serial.println(F("from tune to edit_sound"));
  2744. #endif
  2745. goto_edit_sound_menu(TUNE);
  2746. }
  2747. else if (menu_system.get_currentScreen() == &detune_screen) // detune menu
  2748. {
  2749. #ifdef SHOW_DEBUG
  2750. Serial.println(F("from detune to edit_sound"));
  2751. #endif
  2752. goto_edit_sound_menu(DETUNE);
  2753. }
  2754. else if (menu_system.get_currentScreen() == &velocity_sense_screen) // velocity_sense menu
  2755. {
  2756. #ifdef SHOW_DEBUG
  2757. Serial.println(F("from velocity_sense to edit_sound"));
  2758. #endif
  2759. goto_edit_sound_menu(VELOCITY_SENSE);
  2760. }
  2761. else if (menu_system.get_currentScreen() == &effects_screen) // effect menu
  2762. {
  2763. #ifdef SHOW_DEBUG
  2764. Serial.println(F("from effect to main"));
  2765. #endif
  2766. goto_main_menu(EFFECTS);
  2767. }
  2768. else if (menu_system.get_currentScreen() == &pan_trem_frequency_screen) //pan_trem_frequency menu
  2769. {
  2770. #ifdef SHOW_DEBUG
  2771. Serial.println(F("from pan_trem_frequency to effects"));
  2772. #endif
  2773. goto_effects_menu(PAN_TREM_FREQUENCY);
  2774. }
  2775. else if (menu_system.get_currentScreen() == &pan_trem_level_screen) // pan_trem_level menu
  2776. {
  2777. #ifdef SHOW_DEBUG
  2778. Serial.println(F("from pan_trem_level to effects"));
  2779. #endif
  2780. goto_effects_menu(PAN_TREM_LEVEL);
  2781. }
  2782. else if (menu_system.get_currentScreen() == &overdrive_screen) // overdrive menu
  2783. {
  2784. #ifdef SHOW_DEBUG
  2785. Serial.println(F("from overdrive to effects"));
  2786. #endif
  2787. goto_effects_menu(OVERDRIVE);
  2788. }
  2789. else if (menu_system.get_currentScreen() == &comp_gain_screen) // comp_gain menu
  2790. {
  2791. #ifdef SHOW_DEBUG
  2792. Serial.println(F("from comp_gain to effects"));
  2793. #endif
  2794. goto_effects_menu(COMP_GAIN);
  2795. }
  2796. else if (menu_system.get_currentScreen() == &comp_response_screen) // comp_response menu
  2797. {
  2798. #ifdef SHOW_DEBUG
  2799. Serial.println(F("from comp_response to effects"));
  2800. #endif
  2801. goto_effects_menu(COMP_RESPONSE);
  2802. }
  2803. else if (menu_system.get_currentScreen() == &comp_limit_screen) // comp_limit menu
  2804. {
  2805. #ifdef SHOW_DEBUG
  2806. Serial.println(F("from comp_limit to effects"));
  2807. #endif
  2808. goto_effects_menu(COMP_LIMIT);
  2809. }
  2810. else if (menu_system.get_currentScreen() == &comp_threshold_screen) // comp_threshold menu
  2811. {
  2812. #ifdef SHOW_DEBUG
  2813. Serial.println(F("from comp_threshold to effects"));
  2814. #endif
  2815. goto_effects_menu(COMP_THRESHOLD);
  2816. }
  2817. else if (menu_system.get_currentScreen() == &comp_attack_screen) // comp_attack menu
  2818. {
  2819. #ifdef SHOW_DEBUG
  2820. Serial.println(F("from comp_attack to effects"));
  2821. #endif
  2822. goto_effects_menu(COMP_ATTACK);
  2823. }
  2824. else if (menu_system.get_currentScreen() == &comp_decay_screen) // comp_decay menu
  2825. {
  2826. #ifdef SHOW_DEBUG
  2827. Serial.println(F("from comp_decay to effects"));
  2828. #endif
  2829. goto_effects_menu(COMP_DECAY);
  2830. }
  2831. else if (menu_system.get_currentScreen() == &reverb_roomsize_screen) // reverb_roomsize menu
  2832. {
  2833. #ifdef SHOW_DEBUG
  2834. Serial.println(F("from reverb_roomsize to effects"));
  2835. #endif
  2836. goto_effects_menu(REV_ROOMSIZE);
  2837. }
  2838. else if (menu_system.get_currentScreen() == &reverb_damping_screen) // reverb_damping menu
  2839. {
  2840. #ifdef SHOW_DEBUG
  2841. Serial.println(F("from reverb_damping to effects"));
  2842. #endif
  2843. goto_effects_menu(REV_DAMPING);
  2844. }
  2845. else if (menu_system.get_currentScreen() == &reverb_level_screen) // reverb_level menu
  2846. {
  2847. #ifdef SHOW_DEBUG
  2848. Serial.println(F("from reverb_level to effects"));
  2849. #endif
  2850. goto_effects_menu(REV_LEVEL);
  2851. }
  2852. else if (menu_system.get_currentScreen() == &chorus_frequency_screen) // chorus_frequency menu
  2853. {
  2854. #ifdef SHOW_DEBUG
  2855. Serial.println(F("from chorus_frequency to effects"));
  2856. #endif
  2857. goto_effects_menu(CHORUS_FREQ);
  2858. }
  2859. else if (menu_system.get_currentScreen() == &chorus_intensity_screen) // chorus_intensity menu
  2860. {
  2861. #ifdef SHOW_DEBUG
  2862. Serial.println(F("from chorus_intensity to effects"));
  2863. #endif
  2864. goto_effects_menu(CHORUS_INTENSITY);
  2865. }
  2866. else if (menu_system.get_currentScreen() == &chorus_waveform_screen) // chorus_waveform menu
  2867. {
  2868. #ifdef SHOW_DEBUG
  2869. Serial.println(F("from chorus_waveform to effects"));
  2870. #endif
  2871. goto_effects_menu(CHORUS_WAVEFORM);
  2872. }
  2873. else if (menu_system.get_currentScreen() == &chorus_level_screen) // chorus_level menu
  2874. {
  2875. #ifdef SHOW_DEBUG
  2876. Serial.println(F("from chorus_level to effects"));
  2877. #endif
  2878. goto_effects_menu(CHORUS_LEVEL);
  2879. }
  2880. else if (menu_system.get_currentScreen() == &bass_lr_level_screen) // bass_lr_level menu
  2881. {
  2882. #ifdef SHOW_DEBUG
  2883. Serial.println(F("from bass_lr_level to effects"));
  2884. #endif
  2885. goto_effects_menu(BASS_LR_LEVEL);
  2886. }
  2887. else if (menu_system.get_currentScreen() == &bass_mono_level_screen) // bass_mono_level menu
  2888. {
  2889. #ifdef SHOW_DEBUG
  2890. Serial.println(F("from bass_mono_level to effects"));
  2891. #endif
  2892. goto_effects_menu(BASS_MONO_LEVEL);
  2893. }
  2894. else if (menu_system.get_currentScreen() == &eq_bass_screen) // eq_bass menu
  2895. {
  2896. #ifdef SHOW_DEBUG
  2897. Serial.println(F("from eq_bass to effects"));
  2898. #endif
  2899. goto_effects_menu(EQ_BASS);
  2900. }
  2901. else if (menu_system.get_currentScreen() == &eq_treble_screen) // eq_treble menu
  2902. {
  2903. #ifdef SHOW_DEBUG
  2904. Serial.println(F("from eq_treble to main"));
  2905. #endif
  2906. goto_effects_menu(EQ_TREBLE);
  2907. }
  2908. else if (menu_system.get_currentScreen() == &save_sound_screen) // save_sound menu
  2909. {
  2910. #ifdef SHOW_DEBUG
  2911. Serial.println(F("from save_sound to main"));
  2912. #endif
  2913. goto_main_menu(SAVE_SOUND);
  2914. }
  2915. else if (menu_system.get_currentScreen() == &store_question_screen) // store_question menu
  2916. {
  2917. #ifdef SHOW_DEBUG
  2918. Serial.println(F("from store_question to main"));
  2919. #endif
  2920. goto_main_menu(SAVE_SOUND);
  2921. }
  2922. else if (menu_system.get_currentScreen() == &system_screen) // system menu
  2923. {
  2924. #ifdef SHOW_DEBUG
  2925. Serial.println(F("from system to main"));
  2926. #endif
  2927. goto_main_menu(SYSTEM);
  2928. }
  2929. else if (menu_system.get_currentScreen() == &loudness_screen) // loudness menu
  2930. {
  2931. #ifdef SHOW_DEBUG
  2932. Serial.println(F("from loudness to system"));
  2933. #endif
  2934. goto_system_menu(LOUDNESS);
  2935. }
  2936. else if (menu_system.get_currentScreen() == &midi_channel_screen) // midi_channel menu
  2937. {
  2938. #ifdef SHOW_DEBUG
  2939. Serial.println(F("from midi_channel to system"));
  2940. #endif
  2941. goto_system_menu(MIDI_CHANNEL);
  2942. }
  2943. else if (menu_system.get_currentScreen() == &midi_soft_thru_screen) // midi_soft_thru menu
  2944. {
  2945. #ifdef SHOW_DEBUG
  2946. Serial.println(F("from midi_soft_thru to system"));
  2947. #endif
  2948. goto_system_menu(MIDI_SOFT_THRU);
  2949. }
  2950. else if (menu_system.get_currentScreen() == &max_poly_screen) // max_poly menu
  2951. {
  2952. #ifdef SHOW_DEBUG
  2953. Serial.println(F("from max_poly to system"));
  2954. #endif
  2955. goto_system_menu(MAX_POLY);
  2956. }
  2957. else if (menu_system.get_currentScreen() == &mono_screen) // mono menu
  2958. {
  2959. #ifdef SHOW_DEBUG
  2960. Serial.println(F("from mono to system"));
  2961. #endif
  2962. goto_system_menu(MONO);
  2963. }
  2964. else if (menu_system.get_currentScreen() == &panorama_screen) // panorama menu
  2965. {
  2966. #ifdef SHOW_DEBUG
  2967. Serial.println(F("from panorama to system"));
  2968. #endif
  2969. goto_system_menu(PANORAMA);
  2970. }
  2971. else if (menu_system.get_currentScreen() == &info_screen) // info menu
  2972. {
  2973. #ifdef SHOW_DEBUG
  2974. Serial.println(F("from info to main"));
  2975. #endif
  2976. goto_main_menu(INFO);
  2977. }
  2978. }
  2979. }
  2980. }
  2981. }
  2982. #endif