diff --git a/MicroDexed.ino b/MicroDexed.ino index d3c5ef3..178545e 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -176,7 +176,7 @@ void setup() pinMode(SDCARD_CS_PIN, OUTPUT); pinMode(U8X8_CS_PIN, OUTPUT); #endif - + #ifdef ENABLE_LCD_UI setup_ui(); #else @@ -313,8 +313,11 @@ void setup() master_mixer_r.gain(0, 1.0); master_mixer_l.gain(0, 1.0); +#ifdef USE_REVERB freeverbs1.roomsize(configuration.reverb_roomsize / 100.0); freeverbs1.damping(configuration.reverb_damping / 100.0); +#endif + master_mixer_r.gain(1, 0.0); master_mixer_l.gain(1, 0.0); diff --git a/UI.hpp b/UI.hpp index 5b73aab..66f983a 100644 --- a/UI.hpp +++ b/UI.hpp @@ -146,12 +146,10 @@ void UI_func_engine(uint8_t param); void UI_func_information(uint8_t param); void UI_func_voice_selection(uint8_t param); void UI_func_volume(uint8_t param); -void UI_func_back(uint8_t param); -void UI_func_goToRootMenu(uint8_t param); +void UI_function_not_enabled(void); void lcd_display_int(int16_t var, uint8_t size, bool zeros, bool brackets, bool sign); void lcd_display_float(float var, uint8_t size_number, uint8_t size_fraction, bool zeros, bool brackets, bool sign); - // normal menu LCDMenuLib2_menu LCDML_0(255, 0, 0, NULL, NULL); // normal root menu element (do not change) LCDMenuLib2 LCDML(LCDML_0, _LCDML_DISP_rows, _LCDML_DISP_cols, lcdml_menu_display, lcdml_menu_clear, lcdml_menu_control); @@ -206,20 +204,20 @@ uint8_t g_LCDML_CONTROL_prev[NUM_ENCODER] = {0, 0}; const uint8_t * flipped_scroll_bar[5]; uint8_t * rotTile(const uint8_t * tile) { - uint8_t * newt = new uint8_t[8]; - for (int x = 0; x < 8; x++) { - uint8_t newb = 0; - for (int y = 0 ; y < 8; y++){ - newb |= (tile[y] << x) & 0x80; - newb >>= 1; - } - newt[x] = newb; + uint8_t * newt = new uint8_t[8]; + for (int x = 0; x < 8; x++) { + uint8_t newb = 0; + for (int y = 0 ; y < 8; y++) { + newb |= (tile[y] << x) & 0x80; + newb >>= 1; } - return newt; + newt[x] = newb; + } + return newt; } -#endif +#endif -void setup_ui(void){ +void setup_ui(void) { // LCD Begin #ifdef I2C_DISPLAY lcd.init(); @@ -245,13 +243,13 @@ void setup_ui(void){ lcd.createChar(2, (uint8_t*)scroll_bar[2]); lcd.createChar(3, (uint8_t*)scroll_bar[3]); lcd.createChar(4, (uint8_t*)scroll_bar[4]); -#else - for (int x=0; x < 5; x++) { - flipped_scroll_bar[x] = rotTile(scroll_bar[x]); +#else + for (int x = 0; x < 5; x++) { + flipped_scroll_bar[x] = rotTile(scroll_bar[x]); } #endif -// LCDMenuLib Setup + // LCDMenuLib Setup LCDML_setup(_LCDML_DISP_cnt); // Enable Menu Rollover //LCDML.MENU_enRollover(); @@ -458,7 +456,7 @@ void encoder_right_up(void) change_disp_sd(true); #endif eeprom_write(); - + } UI_func_voice_selection(0); break; @@ -698,9 +696,9 @@ void lcdml_menu_display(void) #ifdef I2C_DISPLAY lcd.setCursor((_LCDML_DISP_cols - 1), n); lcd.write((uint8_t)0); -#else +#else lcd.drawTile((_LCDML_DISP_cols - 1), n, 1, flipped_scroll_bar[0]); - lcd.setCursor((_LCDML_DISP_cols), n+1); + lcd.setCursor((_LCDML_DISP_cols), n + 1); #endif } else { @@ -719,27 +717,27 @@ void lcdml_menu_display(void) #ifdef I2C_DISPLAY lcd.setCursor((_LCDML_DISP_cols - 1), 0); lcd.write((uint8_t)1); -#else +#else lcd.drawTile((_LCDML_DISP_cols - 1), 0, 1, flipped_scroll_bar[1]); lcd.setCursor((_LCDML_DISP_cols), 1); -#endif +#endif } else if (scrollbar_cur_pos == (scrollbar_max - 1)) { // max pos #ifdef I2C_DISPLAY lcd.setCursor((_LCDML_DISP_cols - 1), (n_max - 1)); lcd.write((uint8_t)4); -#else +#else lcd.drawTile((_LCDML_DISP_cols - 1), (n_max - 1), 1, flipped_scroll_bar[4]); lcd.setCursor((_LCDML_DISP_cols), (n_max)); -#endif +#endif } else { // between #ifdef I2C_DISPLAY lcd.setCursor((_LCDML_DISP_cols - 1), scroll_pos / n_max); lcd.write((uint8_t)(scroll_pos % n_max) + 1); -#else +#else lcd.drawTile((_LCDML_DISP_cols - 1), scroll_pos / n_max, 1, flipped_scroll_bar[(scroll_pos % n_max) + 1]); - lcd.setCursor((_LCDML_DISP_cols), (scroll_pos / n_max)+1); + lcd.setCursor((_LCDML_DISP_cols), (scroll_pos / n_max) + 1); #endif } } @@ -777,6 +775,7 @@ void UI_func_sound(uint8_t param) void UI_func_reverb_roomsize(uint8_t param) { +#ifdef USE_REVERB if (LCDML.FUNC_setup()) // ****** SETUP ********* { // setup function @@ -816,10 +815,14 @@ void UI_func_reverb_roomsize(uint8_t param) // you can here reset some global vars or do nothing eeprom_write(); } +#else + UI_function_not_enabled(); +#endif } void UI_func_reverb_damping(uint8_t param) { +#ifdef USE_REVERB if (LCDML.FUNC_setup()) // ****** SETUP ********* { // setup function @@ -859,10 +862,14 @@ void UI_func_reverb_damping(uint8_t param) // you can here reset some global vars or do nothing eeprom_write(); } +#else + UI_function_not_enabled(); +#endif } void UI_func_reverb_level(uint8_t param) { +#ifdef USE_REVERB if (LCDML.FUNC_setup()) // ****** SETUP ********* { // setup function @@ -904,6 +911,9 @@ void UI_func_reverb_level(uint8_t param) // you can here reset some global vars or do nothing eeprom_write(); } +#else + UI_function_not_enabled(); +#endif } void UI_func_chorus_frequency(uint8_t param) @@ -1677,7 +1687,7 @@ void UI_func_voice_selection(uint8_t param) break; } for (int x = 2; x < LCD_rows; x++) { - lcd.show(x, 0, LCD_cols+1, " "); + lcd.show(x, 0, LCD_cols + 1, " "); } } @@ -1706,12 +1716,37 @@ void UI_func_volume(uint8_t param) lcd.show(1, 15, 1, "]"); } +void UI_function_not_enabled(void) +{ + if (LCDML.FUNC_setup()) // ****** SETUP ********* + { + // setup function + lcd.setCursor(0, 0); + lcd.print(F("Function not")); + lcd.setCursor(0, 1); + lcd.print(F("enabled!")); + } + + if (LCDML.FUNC_loop()) // ****** LOOP ********* + { + if (LCDML.BT_checkEnter()) + { + LCDML.FUNC_goBackToMenu(); + } + } + + if (LCDML.FUNC_close()) // ****** STABLE END ********* + { + // you can here reset some global vars or do nothing + } +} + void lcd_display_int(int16_t var, uint8_t size, bool zeros, bool brackets, bool sign) { int16_t tmp = 0; uint16_t p; - bool non_zero_found=false; - + bool non_zero_found = false; + if (size < 1) return; @@ -1736,6 +1771,7 @@ void lcd_display_int(int16_t var, uint8_t size, bool zeros, bool brackets, bool { p = int(pow(10, i)); tmp = int(var / p); + if (tmp == 0) { if (zeros == true) @@ -1773,7 +1809,15 @@ void lcd_display_float(float var, uint8_t size_number, uint8_t size_fraction, bo if (brackets == true) lcd.print(F("[")); - lcd_display_int(int(number), size_number, zeros, false, sign); + if (int(number) == 0) + { + if (zeros == true) + lcd.print(F("00")); + else + lcd.print(F(" 0")); + } + else + lcd_display_int(int(number), size_number, zeros, false, sign); lcd.print(F(".")); lcd_display_int(round(fraction * pow(10, size_fraction)), size_fraction, true, false, false); diff --git a/config.h b/config.h index 224070c..12869bf 100644 --- a/config.h +++ b/config.h @@ -31,33 +31,29 @@ // ATTENTION! For better latency you have to redefine AUDIO_BLOCK_SAMPLES from // 128 to 64 in /cores/teensy3/AudioStream.h -#define AUDIO_BLOCK_SAMPLES 64 // If you want to test the system with Linux and withous any keyboard and/or audio equipment, you can do the following: // 1. In Arduino-IDE enable "Tools->USB-Type->Serial + MIDI + Audio" // 2. Build the firmware with "MIDI_DEVICE_USB" enabled in config.h. -// 3. Afterconnecting to a Linux system there should be a MIDI an audio device available that is called "MicroMDAEPiano", so you can start the following: +// 3. Afterconnecting to a Linux system there should be a MIDI an audio device available that is called "MicroMDexed", so you can start the following: // $ aplaymidi -p 20:0 # e.g. test.mid // $ arecord -f cd -Dhw:1,0 /tmp/bla.wav - -#define VERSION "0.9.7" +#define VERSION "0.9.8" //************************************************************************************************* //* DEVICE SETTINGS //************************************************************************************************* // MIDI -#define MIDI_DEVICE_DIN Serial1 -//#define AUDIO_DEVICE_USB -//#define MIDI_DEVICE_USB 1 -//#define MIDI_DEVICE_USB_HOST 1 -//#define MIDI_DEVICE_NUMBER 0 +//#define MIDI_DEVICE_DIN Serial1 +#define MIDI_DEVICE_USB 1 +#define MIDI_DEVICE_USB_HOST 1 // AUDIO // If nothing is defined Teensy internal DAC is used as audio output device! // Left and right channel audio signal is presented on pins A21 and A22. -//#define AUDIO_DEVICE_USB +#define AUDIO_DEVICE_USB //#define TEENSY_DAC //#define TEENSY_DAC_SYMMETRIC //#define TEENSY_AUDIO_BOARD @@ -84,13 +80,12 @@ #define MOD_WAVEFORM WAVEFORM_TRIANGLE // WAVEFORM_SINE WAVEFORM_TRIANGLE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE #define MOD_FILTER_OUTPUT MOD_LINKWITZ_RILEY_FILTER_OUTPUT // MOD_LINKWITZ_RILEY_FILTER_OUTPUT MOD_BUTTERWORTH_FILTER_OUTPUT MOD_NO_FILTER_OUTPUT #define MOD_FILTER_CUTOFF_HZ 3000 -#define USE_REVERB 1 +//#define USE_REVERB 1 //************************************************************************************************* //* AUDIO SETTINGS //************************************************************************************************* // https://rechneronline.de/funktionsgraphen/ -#define VOLUME_CURVE 0.07 #ifndef TEENSY_AUDIO_BOARD #if AUDIO_BLOCK_SAMPLES == 64 #define AUDIO_MEM 450 @@ -100,6 +95,7 @@ #define DELAY_MAX_TIME 600 #define REDUCE_LOUDNESS 1 #else +#define SGTL5000_LINEOUT_LEVEL 29 #if AUDIO_BLOCK_SAMPLES == 64 #define AUDIO_MEM 900 #else @@ -118,7 +114,6 @@ #define STANDARD_LCD_I2C //#define OLED_SPI - // LCD Display //I2C_DISPLAY only #ifdef STANDARD_LCD_I2C @@ -167,20 +162,19 @@ #define TEENSY4 #endif -// Teensy Audio Shield: +// Teensy Audio Shield (not used) //#define SDCARD_CS_PIN 10 //#define SDCARD_MOSI_PIN 7 //#define SDCARD_SCK_PIN 14 -#define SGTL5000_LINEOUT_LEVEL 29 #ifndef TEENSY4 // Teensy 3.5 & 3.6 SD card #define SDCARD_CS_PIN BUILTIN_SDCARD -#define SDCARD_MOSI_PIN 11 // not actually used -#define SDCARD_SCK_PIN 13 // not actually used +#define SDCARD_MOSI_PIN 11 +#define SDCARD_SCK_PIN 13 #else #define SDCARD_CS_PIN 10 -#define SDCARD_MOSI_PIN 11 // not actually used -#define SDCARD_SCK_PIN 13 // not actually used +#define SDCARD_MOSI_PIN 11 +#define SDCARD_SCK_PIN 13 #endif // Encoder with button @@ -201,8 +195,6 @@ #define BUT_DEBOUNCE_MS 20 #define LONG_BUTTON_PRESS 500 - - // Internal timer #define AUTOSTORE_MS 5000 #define VOICE_SELECTION_MS 2000 diff --git a/effect_stereo_mono.h b/effect_stereo_mono.h index 0379326..f9b39f9 100644 --- a/effect_stereo_mono.h +++ b/effect_stereo_mono.h @@ -37,7 +37,7 @@ class AudioEffectStereoMono : public AudioStream AudioEffectStereoMono(void): AudioStream(2, inputQueueArray) { - _enabled = false; + _enabled = true; } virtual void update(void);