From d98fdd9997a6e86d406b0a7110822a43f99cf04d Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Tue, 17 Aug 2021 06:43:23 +0200 Subject: [PATCH] Additions for parametric graphic eq. --- MicroDexed.ino | 76 +++++---- UI.hpp | 327 ++++++++++++++++++++++++-------------- UI_FX.h | 170 ++++++++++---------- UI_FX_T4.h | 168 ++++++++++---------- config.h | 51 +++--- control_sgtl5000plus.cpp | 143 +++++++++++++++++ control_sgtl5000plus.h | 80 ++++++++++ dexed_sd.cpp | 38 +++-- sgtl5000_graphic_eq.hpp | 329 --------------------------------------- 9 files changed, 699 insertions(+), 683 deletions(-) create mode 100644 control_sgtl5000plus.cpp create mode 100644 control_sgtl5000plus.h delete mode 100644 sgtl5000_graphic_eq.hpp diff --git a/MicroDexed.ino b/MicroDexed.ino index 49a6d44..4d00888 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -52,7 +52,7 @@ using namespace TeensyTimerTool; #endif #endif #ifdef SGTL5000_AUDIO_ENHANCE -#include "sgtl5000_graphic_eq.hpp" +#include "control_sgtl5000plus.h" #endif // Audio engines @@ -118,7 +118,11 @@ AudioMixer8 drum_reverb_send_mixer_l; // Outputs #if defined(TEENSY_AUDIO_BOARD) AudioOutputI2S i2s1; -AudioControlSGTL5000 sgtl5000_1; +#ifdef SGTL5000_AUDIO_ENHANCE +AudioControlSGTL5000Plus sgtl5000(7); +#else +AudioControlSGTL5000 sgtl5000; +#endif #elif defined (I2S_AUDIO_ONLY) AudioOutputI2S i2s1; #elif defined(TGA_AUDIO_BOARD) @@ -361,10 +365,6 @@ extern void sequencer(void); extern LCDMenuLib2 LCDML; #endif -#ifdef SGTL5000_AUDIO_ENHANCE -BiquadCoef graphic_eq(7); -#endif - extern void getNoteName(char* noteName, uint8_t noteNumber); PeriodicTimer timer1; extern char seq_chord_names[7][4]; @@ -413,36 +413,34 @@ void setup() AudioMemory(AUDIO_MEM); #if defined(TEENSY_AUDIO_BOARD) - sgtl5000_1.enable(); - sgtl5000_1.lineOutLevel(SGTL5000_LINEOUT_LEVEL); - sgtl5000_1.dacVolumeRamp(); - sgtl5000_1.dacVolume(1.0); - //sgtl5000_1.dacVolumeRampLinear(); - //sgtl5000_1.dacVolumeRampDisable(); - sgtl5000_1.unmuteHeadphone(); - sgtl5000_1.unmuteLineout(); - sgtl5000_1.volume(SGTL5000_HEADPHONE_VOLUME, SGTL5000_HEADPHONE_VOLUME); // Headphone volume + sgtl5000.enable(); + sgtl5000.lineOutLevel(SGTL5000_LINEOUT_LEVEL); + sgtl5000.dacVolumeRamp(); + sgtl5000.dacVolume(1.0); + //sgtl5000.dacVolumeRampLinear(); + //sgtl5000.dacVolumeRampDisable(); + sgtl5000.unmuteHeadphone(); + sgtl5000.unmuteLineout(); + sgtl5000.volume(SGTL5000_HEADPHONE_VOLUME, SGTL5000_HEADPHONE_VOLUME); // Headphone volume #ifdef SGTL5000_AUDIO_THRU - //sgtl5000_1.audioPreProcessorEnable(); - sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN); - sgtl5000_1.lineInLevel(5); - //sgtl5000_1.adcHighPassFilterEnable(); + //sgtl5000.audioPreProcessorEnable(); + sgtl5000.inputSelect(AUDIO_INPUT_LINEIN); + sgtl5000.lineInLevel(5); + //sgtl5000.adcHighPassFilterEnable(); #endif #ifdef SGTL5000_AUDIO_ENHANCE - sgtl5000_1.audioPostProcessorEnable(); - sgtl5000_1.enhanceBassEnable(); - sgtl5000_1.enhanceBass(1.0, 1.5, 0, 5); // enhanceBass(1.0, 1.0, 1, 2); // Configures the bass enhancement by setting the levels of the original stereo signal and the bass-enhanced mono level which will be mixed together. The high-pass filter may be enabled (0) or bypassed (1). - sgtl5000_1.surroundSoundEnable(); - sgtl5000_1.surroundSound(7, 3); // Configures virtual surround width from 0 (mono) to 7 (widest). select may be set to 1 (disable), 2 (mono input) or 3 (stereo input). - sgtl5000_1.autoVolumeEnable(); - sgtl5000_1.autoVolumeControl(1, 1, 1, 0.9, 0.01, 0.05); - sgtl5000_1.eqSelect(GRAPHIC_EQUALIZER); - sgtl5000_1.eqBands(EQ_BASS_DEFAULT, EQ_MIDBASS_DEFAULT, EQ_MID_DEFAULT, EQ_MIDTREBLE_DEFAULT, EQ_TREBLE_DEFAULT); + sgtl5000.audioPostProcessorEnable(); + sgtl5000.enhanceBassEnable(); + sgtl5000.enhanceBass(1.0, 1.5, 0, 5); // enhanceBass(1.0, 1.0, 1, 2); // Configures the bass enhancement by setting the levels of the original stereo signal and the bass-enhanced mono level which will be mixed together. The high-pass filter may be enabled (0) or bypassed (1). + sgtl5000.surroundSoundEnable(); + sgtl5000.surroundSound(7, 3); // Configures virtual surround width from 0 (mono) to 7 (widest). select may be set to 1 (disable), 2 (mono input) or 3 (stereo input). + sgtl5000.autoVolumeEnable(); + sgtl5000.autoVolumeControl(1, 1, 1, 0.9, 0.01, 0.05); #else - sgtl5000_1.audioProcessorDisable(); - sgtl5000_1.autoVolumeDisable(); - sgtl5000_1.surroundSoundDisable(); - sgtl5000_1.enhanceBassDisable(); + sgtl5000.audioProcessorDisable(); + sgtl5000.autoVolumeDisable(); + sgtl5000.surroundSoundDisable(); + sgtl5000.enhanceBassDisable(); #endif #ifdef DEBUG Serial.println(F("Teensy-Audio-Board enabled.")); @@ -2205,13 +2203,13 @@ void set_fx_params(void) #endif #ifdef SGTL5000_AUDIO_ENHANCE - sgtl5000_1.eqBands( - mapfloat(configuration.fx.eq_bass, EQ_BASS_MIN, EQ_BASS_MAX, -1.0, 1.0), - mapfloat(configuration.fx.eq_midbass, EQ_MIDBASS_MIN, EQ_MIDBASS_MAX, -1.0, 1.0), - mapfloat(configuration.fx.eq_mid, EQ_MID_MIN, EQ_MID_MAX, -1.0, 1.0), - mapfloat(configuration.fx.eq_midtreble, EQ_MIDTREBLE_MIN, EQ_MIDTREBLE_MAX, -1.0, 1.0), - mapfloat(configuration.fx.eq_treble, EQ_TREBLE_MIN, EQ_TREBLE_MAX, -1.0, 1.0) - ); + sgtl5000.setEQFc(1, mapfloat(configuration.fx.eq_1, EQ_1_MIN, EQ_1_MAX, -1.0, 1.0)); + sgtl5000.setEQFc(2, mapfloat(configuration.fx.eq_2, EQ_2_MIN, EQ_2_MAX, -1.0, 1.0)); + sgtl5000.setEQFc(3, mapfloat(configuration.fx.eq_3, EQ_3_MIN, EQ_3_MAX, -1.0, 1.0)); + sgtl5000.setEQFc(4, mapfloat(configuration.fx.eq_4, EQ_4_MIN, EQ_4_MAX, -1.0, 1.0)); + sgtl5000.setEQFc(5, mapfloat(configuration.fx.eq_5, EQ_5_MIN, EQ_5_MAX, -1.0, 1.0)); + sgtl5000.setEQFc(6, mapfloat(configuration.fx.eq_6, EQ_6_MIN, EQ_6_MAX, -1.0, 1.0)); + sgtl5000.setEQFc(7, mapfloat(configuration.fx.eq_7, EQ_7_MIN, EQ_7_MAX, -1.0, 1.0)); #endif init_MIDI_send_CC(); diff --git a/UI.hpp b/UI.hpp index f0588a0..88e1b3e 100644 --- a/UI.hpp +++ b/UI.hpp @@ -26,9 +26,11 @@ #ifndef _UI_HPP_ #define _UI_HPP_ +#include +#include #include "config.h" #include "disp_plus.h" - +#include "synth_dexed.h" #include "effect_modulated_delay.h" #include "effect_stereo_mono.h" #ifdef USE_PLATEREVERB @@ -36,10 +38,6 @@ #else #include "effect_freeverbf.h" #endif -#include "synth_dexed.h" - -#include -#include #define _LCDML_DISP_cols LCD_cols #define _LCDML_DISP_rows LCD_rows @@ -107,8 +105,13 @@ extern char seq_chord_names[7][4]; extern void change_disp_sd(bool d); #endif -extern AudioControlSGTL5000 sgtl5000_1; -extern AudioSynthDexed* MicroDexed[NUM_DEXED]; +#ifdef SGTL5000_AUDIO_ENHANCE +#include "control_sgtl5000plus.h" +extern AudioControlSGTL5000Plus sgtl5000; +#else +extern AudioControlSGTL5000 sgtl5000; +#endif + #if defined(USE_FX) extern AudioSynthWaveform* chorus_modulator[NUM_DEXED]; extern AudioEffectModulatedDelay* modchorus[NUM_DEXED]; @@ -305,11 +308,13 @@ void UI_func_voice_select(uint8_t param); void UI_func_sysex_send_voice(uint8_t param); void UI_func_sysex_receive_bank(uint8_t param); void UI_func_sysex_send_bank(uint8_t param); -void UI_func_eq_bass(uint8_t param); -void UI_func_eq_midbass(uint8_t param); -void UI_func_eq_mid(uint8_t param); -void UI_func_eq_midtreble(uint8_t param); -void UI_func_eq_treble(uint8_t param); +void UI_func_eq_1(uint8_t param); +void UI_func_eq_2(uint8_t param); +void UI_func_eq_3(uint8_t param); +void UI_func_eq_4(uint8_t param); +void UI_func_eq_5(uint8_t param); +void UI_func_eq_6(uint8_t param); +void UI_func_eq_7(uint8_t param); void UI_function_not_enabled(void); void UI_function_not_implemented(uint8_t param); void UI_func_favorites(uint8_t param); @@ -4784,8 +4789,8 @@ void UI_func_arpeggio(uint8_t param) if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); - seq_temp_select_menu=0; - seq_temp_active_menu=0; + seq_temp_select_menu = 0; + seq_temp_active_menu = 0; lcd.setCursor( 0, 0); lcd.print("Oct"); lcd.setCursor(7, 0); @@ -4881,79 +4886,79 @@ void UI_func_arpeggio(uint8_t param) } } - - lcd.setCursor( 4, 0); - lcd.print(arp_oct_usersetting); - lcd.setCursor( 6, 1); - lcd.print( arp_style_names[arp_style][0] ); - lcd.print( arp_style_names[arp_style][1] ); - lcd.print( arp_style_names[arp_style][2] ); - lcd.setCursor( 11, 1); - if (arp_speed == 0)lcd.print("1/16"); else if (arp_speed == 1)lcd.print("1/8 "); - if (seq_temp_select_menu == 0) { - lcd.setCursor( 3, 0); - lcd.print("["); - lcd.setCursor( 5, 0); - lcd.print("]"); - lcd.setCursor( 5, 1); - lcd.print(" "); - lcd.setCursor( 9, 1); - lcd.print(" "); - lcd.setCursor( 10, 1); - lcd.print(" "); - lcd.setCursor( 15, 1); - lcd.print(" "); + lcd.setCursor( 4, 0); + lcd.print(arp_oct_usersetting); + lcd.setCursor( 6, 1); + lcd.print( arp_style_names[arp_style][0] ); + lcd.print( arp_style_names[arp_style][1] ); + lcd.print( arp_style_names[arp_style][2] ); + lcd.setCursor( 11, 1); + if (arp_speed == 0)lcd.print("1/16"); else if (arp_speed == 1)lcd.print("1/8 "); - } - else if (seq_temp_select_menu == 1) - { + if (seq_temp_select_menu == 0) { + lcd.setCursor( 3, 0); + lcd.print("["); + lcd.setCursor( 5, 0); + lcd.print("]"); + lcd.setCursor( 5, 1); + lcd.print(" "); + lcd.setCursor( 9, 1); + lcd.print(" "); + lcd.setCursor( 10, 1); + lcd.print(" "); + lcd.setCursor( 15, 1); + lcd.print(" "); - lcd.setCursor( 5, 1); - lcd.print("["); - lcd.setCursor( 9, 1); - lcd.print("]"); - lcd.setCursor( 3, 0); - lcd.print(" "); - lcd.setCursor( 5, 0); - lcd.print(" "); - lcd.setCursor( 11, 0); - lcd.print(" "); - lcd.setCursor( 15, 0); - lcd.print(" "); - } - else if (seq_temp_select_menu == 2) - { - lcd.setCursor( 5, 1); - lcd.print(" "); - lcd.setCursor( 9, 1); - lcd.print(" "); - lcd.setCursor( 11, 0); - lcd.print("["); - lcd.setCursor( 15, 0); - lcd.print("]"); - lcd.setCursor( 10, 1); - lcd.print(" "); - lcd.setCursor( 15, 1); - lcd.print(" "); - } - else if (seq_temp_select_menu == 3) - { - lcd.setCursor( 11, 0); - lcd.print(" "); - lcd.setCursor( 15, 0); - lcd.print(" "); - lcd.setCursor( 10, 1); - lcd.print("["); - lcd.setCursor( 15, 1); - lcd.print("]"); + } + else if (seq_temp_select_menu == 1) + { + + lcd.setCursor( 5, 1); + lcd.print("["); + lcd.setCursor( 9, 1); + lcd.print("]"); lcd.setCursor( 3, 0); - lcd.print(" "); - lcd.setCursor( 5, 0); - lcd.print(" "); + lcd.print(" "); + lcd.setCursor( 5, 0); + lcd.print(" "); + lcd.setCursor( 11, 0); + lcd.print(" "); + lcd.setCursor( 15, 0); + lcd.print(" "); + } + else if (seq_temp_select_menu == 2) + { + lcd.setCursor( 5, 1); + lcd.print(" "); + lcd.setCursor( 9, 1); + lcd.print(" "); + lcd.setCursor( 11, 0); + lcd.print("["); + lcd.setCursor( 15, 0); + lcd.print("]"); + lcd.setCursor( 10, 1); + lcd.print(" "); + lcd.setCursor( 15, 1); + lcd.print(" "); + } + else if (seq_temp_select_menu == 3) + { + lcd.setCursor( 11, 0); + lcd.print(" "); + lcd.setCursor( 15, 0); + lcd.print(" "); + lcd.setCursor( 10, 1); + lcd.print("["); + lcd.setCursor( 15, 1); + lcd.print("]"); + lcd.setCursor( 3, 0); + lcd.print(" "); + lcd.setCursor( 5, 0); + lcd.print(" "); + } + } - - } if (LCDML.FUNC_close()) // ****** STABLE END ********* { encoderDir[ENC_R].reset(); @@ -7348,14 +7353,102 @@ void UI_func_sysex_send_voice(uint8_t param) } } -void UI_func_eq_bass(uint8_t param) +void UI_func_eq_1(uint8_t param) +{ +#ifndef SGTL5000_AUDIO_ENHANCE + if (LCDML.FUNC_setup()) // ****** SETUP ********* + { + encoderDir[ENC_R].reset(); + lcd.setCursor(0, 0); + lcd.print(F("EQ 50Hz")); + lcd.setCursor(0, 1); + lcd.print(F("Not implemented.")); + } +#else + if (LCDML.FUNC_setup()) // ****** SETUP ********* + { + encoderDir[ENC_R].reset(); + lcd_special_chars(METERBAR); + } + + if (LCDML.FUNC_loop()) // ****** LOOP ********* + { + if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up())) + { + if (LCDML.BT_checkDown()) + { + configuration.fx.eq_1 = constrain(configuration.fx.eq_1 + ENCODER[ENC_R].speed(), EQ_1_MIN, EQ_1_MAX); + } + else if (LCDML.BT_checkUp()) + { + configuration.fx.eq_1 = constrain(configuration.fx.eq_1 - ENCODER[ENC_R].speed(), EQ_1_MIN, EQ_1_MAX); + } + } + lcd_display_meter_float("EQ 50Hz", configuration.fx.eq_1, 0.1, 0.0, EQ_1_MIN, EQ_1_MAX, 1, 1, false, true, true); + sgtl5000.setEQFc(1, mapfloat(configuration.fx.eq_1, EQ_1_MIN, EQ_1_MAX, -1.0, 1.0)); + } + + if (LCDML.FUNC_close()) // ****** STABLE END ********* + { + lcd_special_chars(SCROLLBAR); + encoderDir[ENC_R].reset(); + EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.eq_1), configuration.fx.eq_1); + } +#endif +} + +void UI_func_eq_2(uint8_t param) +{ +#ifndef SGTL5000_AUDIO_ENHANCE + if (LCDML.FUNC_setup()) // ****** SETUP ********* + { + encoderDir[ENC_R].reset(); + lcd.setCursor(0, 0); + lcd.print(F("EQ 120Hz")); + lcd.setCursor(0, 1); + lcd.print(F("Not implemented.")); + } +#else + if (LCDML.FUNC_setup()) // ****** SETUP ********* + { + encoderDir[ENC_R].reset(); + lcd_special_chars(METERBAR); + } + + if (LCDML.FUNC_loop()) // ****** LOOP ********* + { + if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up())) + { + if (LCDML.BT_checkDown()) + { + configuration.fx.eq_2 = constrain(configuration.fx.eq_2 + ENCODER[ENC_R].speed(), EQ_2_MIN, EQ_2_MAX); + } + else if (LCDML.BT_checkUp()) + { + configuration.fx.eq_2 = constrain(configuration.fx.eq_2 - ENCODER[ENC_R].speed(), EQ_2_MIN, EQ_2_MAX); + } + } + lcd_display_meter_float("EQ 120Hz", configuration.fx.eq_2, 0.1, 0.0, EQ_2_MIN, EQ_2_MAX, 1, 1, false, true, true); + sgtl5000.setEQFc(2, mapfloat(configuration.fx.eq_2, EQ_2_MIN, EQ_2_MAX, -1.0, 1.0)); + } + + if (LCDML.FUNC_close()) // ****** STABLE END ********* + { + lcd_special_chars(SCROLLBAR); + encoderDir[ENC_R].reset(); + EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.eq_2), configuration.fx.eq_2); + } +#endif +} + +void UI_func_eq_3(uint8_t param) { #ifndef SGTL5000_AUDIO_ENHANCE if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd.setCursor(0, 0); - lcd.print(F("EQ Bass")); + lcd.print(F("EQ 220Hz")); lcd.setCursor(0, 1); lcd.print(F("Not implemented.")); } @@ -7372,34 +7465,34 @@ void UI_func_eq_bass(uint8_t param) { if (LCDML.BT_checkDown()) { - configuration.fx.eq_bass = constrain(configuration.fx.eq_bass + ENCODER[ENC_R].speed(), EQ_BASS_MIN, EQ_BASS_MAX); + configuration.fx.eq_3 = constrain(configuration.fx.eq_3 + ENCODER[ENC_R].speed(), EQ_3_MIN, EQ_3_MAX); } else if (LCDML.BT_checkUp()) { - configuration.fx.eq_bass = constrain(configuration.fx.eq_bass - ENCODER[ENC_R].speed(), EQ_BASS_MIN, EQ_BASS_MAX); + configuration.fx.eq_3 = constrain(configuration.fx.eq_3 - ENCODER[ENC_R].speed(), EQ_3_MIN, EQ_3_MAX); } } - lcd_display_meter_float("EQ Bass", configuration.fx.eq_bass, 0.1, 0.0, EQ_BASS_MIN, EQ_BASS_MAX, 1, 1, false, true, true); - sgtl5000_1.eqBand(0, mapfloat(configuration.fx.eq_bass, EQ_BASS_MIN, EQ_BASS_MAX, -1.0, 1.0)); + lcd_display_meter_float("EQ 220Hz", configuration.fx.eq_3, 0.1, 0.0, EQ_3_MIN, EQ_3_MAX, 1, 1, false, true, true); + sgtl5000.setEQFc(3, mapfloat(configuration.fx.eq_3, EQ_3_MIN, EQ_3_MAX, -1.0, 1.0)); } if (LCDML.FUNC_close()) // ****** STABLE END ********* { lcd_special_chars(SCROLLBAR); encoderDir[ENC_R].reset(); - EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.eq_bass), configuration.fx.eq_bass); + EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.eq_3), configuration.fx.eq_3); } #endif } -void UI_func_eq_midbass(uint8_t param) +void UI_func_eq_4(uint8_t param) { #ifndef SGTL5000_AUDIO_ENHANCE if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd.setCursor(0, 0); - lcd.print(F("EQ MidBass")); + lcd.print(F("EQ 1000Hz")); lcd.setCursor(0, 1); lcd.print(F("Not implemented.")); } @@ -7416,34 +7509,34 @@ void UI_func_eq_midbass(uint8_t param) { if (LCDML.BT_checkDown()) { - configuration.fx.eq_midbass = constrain(configuration.fx.eq_midbass + ENCODER[ENC_R].speed(), EQ_MIDBASS_MIN, EQ_MIDBASS_MAX); + configuration.fx.eq_4 = constrain(configuration.fx.eq_4 + ENCODER[ENC_R].speed(), EQ_4_MIN, EQ_4_MAX); } else if (LCDML.BT_checkUp()) { - configuration.fx.eq_midbass = constrain(configuration.fx.eq_midbass - ENCODER[ENC_R].speed(), EQ_MIDBASS_MIN, EQ_MIDBASS_MAX); + configuration.fx.eq_4 = constrain(configuration.fx.eq_4 - ENCODER[ENC_R].speed(), EQ_4_MIN, EQ_4_MAX); } } - lcd_display_meter_float("EQ MidBass", configuration.fx.eq_midbass, 0.1, 0.0, EQ_MIDBASS_MIN, EQ_MIDBASS_MAX, 1, 1, false, true, true); - sgtl5000_1.eqBand(1, mapfloat(configuration.fx.eq_midbass, EQ_MIDBASS_MIN, EQ_MIDBASS_MAX, -1.0, 1.0)); + lcd_display_meter_float("EQ 1000Hz", configuration.fx.eq_4, 0.1, 0.0, EQ_4_MIN, EQ_4_MAX, 1, 1, false, true, true); + sgtl5000.setEQFc(4, mapfloat(configuration.fx.eq_4, EQ_4_MIN, EQ_4_MAX, -1.0, 1.0)); } if (LCDML.FUNC_close()) // ****** STABLE END ********* { lcd_special_chars(SCROLLBAR); encoderDir[ENC_R].reset(); - EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.eq_midbass), configuration.fx.eq_midbass); + EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.eq_4), configuration.fx.eq_4); } #endif } -void UI_func_eq_mid(uint8_t param) +void UI_func_eq_5(uint8_t param) { #ifndef SGTL5000_AUDIO_ENHANCE if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd.setCursor(0, 0); - lcd.print(F("EQ Mid")); + lcd.print(F("EQ 2000Hz")); lcd.setCursor(0, 1); lcd.print(F("Not implemented.")); } @@ -7460,34 +7553,34 @@ void UI_func_eq_mid(uint8_t param) { if (LCDML.BT_checkDown()) { - configuration.fx.eq_mid = constrain(configuration.fx.eq_mid + ENCODER[ENC_R].speed(), EQ_MID_MIN, EQ_MID_MAX); + configuration.fx.eq_5 = constrain(configuration.fx.eq_5 + ENCODER[ENC_R].speed(), EQ_5_MIN, EQ_5_MAX); } else if (LCDML.BT_checkUp()) { - configuration.fx.eq_mid = constrain(configuration.fx.eq_mid - ENCODER[ENC_R].speed(), EQ_MID_MIN, EQ_MID_MAX); + configuration.fx.eq_5 = constrain(configuration.fx.eq_5 - ENCODER[ENC_R].speed(), EQ_5_MIN, EQ_5_MAX); } } - lcd_display_meter_float("EQ Mid", configuration.fx.eq_mid, 0.1, 0.0, EQ_MID_MIN, EQ_MID_MAX, 1, 1, false, true, true); - sgtl5000_1.eqBand(2, mapfloat(configuration.fx.eq_mid, EQ_MID_MIN, EQ_MID_MAX, -1.0, 1.0)); + lcd_display_meter_float("EQ 2000Hz", configuration.fx.eq_5, 0.1, 0.0, EQ_5_MIN, EQ_5_MAX, 1, 1, false, true, true); + sgtl5000.setEQFc(5, mapfloat(configuration.fx.eq_5, EQ_5_MIN, EQ_5_MAX, -1.0, 1.0)); } if (LCDML.FUNC_close()) // ****** STABLE END ********* { lcd_special_chars(SCROLLBAR); encoderDir[ENC_R].reset(); - EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.eq_mid), configuration.fx.eq_mid); + EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.eq_5), configuration.fx.eq_5); } #endif } -void UI_func_eq_midtreble(uint8_t param) +void UI_func_eq_6(uint8_t param) { #ifndef SGTL5000_AUDIO_ENHANCE if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd.setCursor(0, 0); - lcd.print(F("EQ MidTreble")); + lcd.print(F("EQ 7000Hz")); lcd.setCursor(0, 1); lcd.print(F("Not implemented.")); } @@ -7504,34 +7597,34 @@ void UI_func_eq_midtreble(uint8_t param) { if (LCDML.BT_checkDown()) { - configuration.fx.eq_midtreble = constrain(configuration.fx.eq_midtreble + ENCODER[ENC_R].speed(), EQ_MIDTREBLE_MIN, EQ_MIDTREBLE_MAX); + configuration.fx.eq_6 = constrain(configuration.fx.eq_6 + ENCODER[ENC_R].speed(), EQ_6_MIN, EQ_6_MAX); } else if (LCDML.BT_checkUp()) { - configuration.fx.eq_midtreble = constrain(configuration.fx.eq_midtreble - ENCODER[ENC_R].speed(), EQ_MIDTREBLE_MIN, EQ_MIDTREBLE_MAX); + configuration.fx.eq_6 = constrain(configuration.fx.eq_6 - ENCODER[ENC_R].speed(), EQ_6_MIN, EQ_6_MAX); } } - lcd_display_meter_float("EQ MidTreble", configuration.fx.eq_midtreble, 0.1, 0.0, EQ_MIDTREBLE_MIN, EQ_MIDTREBLE_MAX, 1, 1, false, true, true); - sgtl5000_1.eqBand(3, mapfloat(configuration.fx.eq_midtreble, EQ_MIDTREBLE_MIN, EQ_MIDTREBLE_MAX, -1.0, 1.0)); + lcd_display_meter_float("EQ 7000Hz", configuration.fx.eq_6, 0.1, 0.0, EQ_6_MIN, EQ_6_MAX, 1, 1, false, true, true); + sgtl5000.setEQFc(6, mapfloat(configuration.fx.eq_6, EQ_6_MIN, EQ_6_MAX, -1.0, 1.0)); } if (LCDML.FUNC_close()) // ****** STABLE END ********* { lcd_special_chars(SCROLLBAR); encoderDir[ENC_R].reset(); - EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.eq_midtreble), configuration.fx.eq_midtreble); + EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.eq_6), configuration.fx.eq_6); } #endif } -void UI_func_eq_treble(uint8_t param) +void UI_func_eq_7(uint8_t param) { #ifndef SGTL5000_AUDIO_ENHANCE if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd.setCursor(0, 0); - lcd.print(F("EQ Treble")); + lcd.print(F("EQ 10000Hz")); lcd.setCursor(0, 1); lcd.print(F("Not implemented.")); } @@ -7548,22 +7641,22 @@ void UI_func_eq_treble(uint8_t param) { if (LCDML.BT_checkDown()) { - configuration.fx.eq_treble = constrain(configuration.fx.eq_treble + ENCODER[ENC_R].speed(), EQ_TREBLE_MIN, EQ_TREBLE_MAX); + configuration.fx.eq_7 = constrain(configuration.fx.eq_7 + ENCODER[ENC_R].speed(), EQ_7_MIN, EQ_7_MAX); } else if (LCDML.BT_checkUp()) { - configuration.fx.eq_treble = constrain(configuration.fx.eq_treble - ENCODER[ENC_R].speed(), EQ_TREBLE_MIN, EQ_TREBLE_MAX); + configuration.fx.eq_7 = constrain(configuration.fx.eq_7 - ENCODER[ENC_R].speed(), EQ_7_MIN, EQ_7_MAX); } } - lcd_display_meter_float("EQ Treble", configuration.fx.eq_treble, 0.1, 0.0, EQ_TREBLE_MIN, EQ_TREBLE_MAX, 1, 1, false, true, true); - sgtl5000_1.eqBand(4, mapfloat(configuration.fx.eq_treble, EQ_TREBLE_MIN, EQ_TREBLE_MAX, -1.0, 1.0)); + lcd_display_meter_float("EQ 10000Hz", configuration.fx.eq_7, 0.1, 0.0, EQ_7_MIN, EQ_7_MAX, 1, 1, false, true, true); + sgtl5000.setEQFc(7, mapfloat(configuration.fx.eq_7, EQ_7_MIN, EQ_7_MAX, -1.0, 1.0)); } if (LCDML.FUNC_close()) // ****** STABLE END ********* { lcd_special_chars(SCROLLBAR); encoderDir[ENC_R].reset(); - EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.eq_treble), configuration.fx.eq_treble); + EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.eq_7), configuration.fx.eq_7); } #endif } diff --git a/UI_FX.h b/UI_FX.h index 9be0d1f..7831762 100644 --- a/UI_FX.h +++ b/UI_FX.h @@ -54,88 +54,90 @@ LCDML_add(20, LCDML_0_1_2_3_4, 2, "Damping", UI_func_reverb_damping); LCDML_add(21, LCDML_0_1_2_3_4, 3, "Level", UI_func_reverb_level); LCDML_add(22, LCDML_0_1_2_3_4, 4, "Reverb Send", UI_func_reverb_send); LCDML_add(23, LCDML_0_1_2_3, 5, "EQ", NULL); -LCDML_add(24, LCDML_0_1_2_3_5, 1, "Bass", UI_func_eq_bass); -LCDML_add(25, LCDML_0_1_2_3_5, 2, "MidBass", UI_func_eq_midbass); -LCDML_add(26, LCDML_0_1_2_3_5, 3, "Mid", UI_func_eq_mid); -LCDML_add(27, LCDML_0_1_2_3_5, 4, "MidTreble", UI_func_eq_midtreble); -LCDML_add(28, LCDML_0_1_2_3_5, 5, "Treble", UI_func_eq_treble); -LCDML_add(29, LCDML_0_1, 3, "Controller", NULL); -LCDML_add(30, LCDML_0_1_3, 1, "Pitchbend", NULL); -LCDML_add(31, LCDML_0_1_3_1, 1, "PB Range", UI_func_pb_range); -LCDML_add(32, LCDML_0_1_3_1, 2, "PB Step", UI_func_pb_step); -LCDML_add(33, LCDML_0_1_3, 2, "Mod Wheel", NULL); -LCDML_add(34, LCDML_0_1_3_2, 1, "MW Range", UI_func_mw_range); -LCDML_add(35, LCDML_0_1_3_2, 2, "MW Assign", UI_func_mw_assign); -LCDML_add(36, LCDML_0_1_3_2, 3, "MW Mode", UI_func_mw_mode); -LCDML_add(37, LCDML_0_1_3, 3, "Aftertouch", NULL); -LCDML_add(38, LCDML_0_1_3_3, 1, "AT Range", UI_func_at_range); -LCDML_add(39, LCDML_0_1_3_3, 2, "AT Assign", UI_func_at_assign); -LCDML_add(40, LCDML_0_1_3_3, 3, "AT Mode", UI_func_at_mode); -LCDML_add(41, LCDML_0_1_3, 4, "Foot Ctrl", NULL); -LCDML_add(42, LCDML_0_1_3_4, 1, "FC Range", UI_func_fc_range); -LCDML_add(43, LCDML_0_1_3_4, 2, "FC Assign", UI_func_fc_assign); -LCDML_add(44, LCDML_0_1_3_4, 3, "FC Mode", UI_func_fc_mode); -LCDML_add(45, LCDML_0_1_3, 5, "Breath Ctrl", NULL); -LCDML_add(46, LCDML_0_1_3_5, 1, "BC Range", UI_func_bc_range); -LCDML_add(47, LCDML_0_1_3_5, 2, "BC Assign", UI_func_bc_assign); -LCDML_add(48, LCDML_0_1_3_5, 3, "BC Mode", UI_func_bc_mode); -LCDML_add(49, LCDML_0_1, 4, "MIDI", NULL); -LCDML_add(50, LCDML_0_1_4, 1, "MIDI Channel", UI_func_midi_channel); -LCDML_add(51, LCDML_0_1_4, 2, "Lowest Note", UI_func_lowest_note); -LCDML_add(52, LCDML_0_1_4, 3, "Highest Note", UI_func_highest_note); -LCDML_add(53, LCDML_0_1_4, 4, "MIDI Send Voice", UI_func_sysex_send_voice); -LCDML_add(54, LCDML_0_1, 5, "Setup", NULL); -LCDML_add(55, LCDML_0_1_5, 1, "Portamento", NULL); -LCDML_add(56, LCDML_0_1_5_1, 1, "Port. Mode", UI_func_portamento_mode); -LCDML_add(57, LCDML_0_1_5_1, 2, "Port. Gliss", UI_func_portamento_glissando); -LCDML_add(58, LCDML_0_1_5_1, 3, "Port. Time", UI_func_portamento_time); -LCDML_add(59, LCDML_0_1_5, 2, "Polyphony", UI_func_polyphony); -LCDML_add(60, LCDML_0_1_5, 3, "Transpose", UI_func_transpose); -LCDML_add(61, LCDML_0_1_5, 4, "Fine Tune", UI_func_tune); -LCDML_add(62, LCDML_0_1_5, 5, "Mono/Poly", UI_func_mono_poly); -LCDML_add(63, LCDML_0_1, 6, "Internal", NULL); -LCDML_add(64, LCDML_0_1_6, 1, "Note Refresh", UI_func_note_refresh); -LCDML_add(65, LCDML_0_1_6, 2, "Velocity Lvl", UI_func_velocity_level); -LCDML_add(66, LCDML_0_1, 7, "Operator", UI_handle_OP); -LCDML_add(67, LCDML_0_1, 8, "Save Voice", UI_func_save_voice); -LCDML_add(68, LCDML_0, 3, "Load/Save", NULL); -LCDML_add(69, LCDML_0_3, 1, "Performance", NULL); -LCDML_add(70, LCDML_0_3_1, 1, "Load Perf.", UI_func_load_performance); -LCDML_add(71, LCDML_0_3_1, 2, "Save Perf.", UI_func_save_performance); -LCDML_add(72, LCDML_0_3, 2, "Voice Config", NULL); -LCDML_add(73, LCDML_0_3_2, 1, "Load Voice Cfg", UI_func_load_voiceconfig); -LCDML_add(74, LCDML_0_3_2, 2, "Save Voice Cfg", UI_func_save_voiceconfig); -LCDML_add(75, LCDML_0_3, 3, "Effects", NULL); -LCDML_add(76, LCDML_0_3_3, 1, "Load Effects", UI_func_load_fx); -LCDML_add(77, LCDML_0_3_3, 2, "Save Effects", UI_func_save_fx); -LCDML_add(78, LCDML_0_3, 5, "MIDI", NULL); -LCDML_add(79, LCDML_0_3_5, 1, "MIDI Recv Bank", UI_func_sysex_receive_bank); -LCDML_add(80, LCDML_0_3_5, 2, "MIDI Snd Bank", UI_func_sysex_send_bank); -LCDML_add(81, LCDML_0_3_5, 3, "MIDI Snd Voice", UI_func_sysex_send_voice); -LCDML_add(82, LCDML_0, 4, "Drums", NULL); -LCDML_add(83, LCDML_0_4, 1, "Drums Main Vol", UI_func_drum_main_volume); -LCDML_add(84, LCDML_0_4, 2, "Drum Volumes", UI_func_drum_volume); -LCDML_add(85, LCDML_0_4, 3, "Drum Pan", UI_func_drum_pan); -LCDML_add(86, LCDML_0_4, 4, "Drum Rev.Send", UI_func_drum_reverb_send); -LCDML_add(87, LCDML_0, 5, "Sequencer", NULL); -LCDML_add(88, LCDML_0_5, 1, "Sequencer", UI_func_sequencer); -LCDML_add(89, LCDML_0_5, 2, "Vel./Chrd Edit", UI_func_seq_vel_editor); -LCDML_add(90, LCDML_0_5, 3, "Pattern Chain", UI_func_seq_pat_chain); -LCDML_add(91, LCDML_0_5, 4, "Arpeggio", UI_func_arpeggio); -LCDML_add(92, LCDML_0_5, 5, "Seq. Length", UI_func_seq_lenght); -LCDML_add(93, LCDML_0_5, 6, "Tempo", UI_func_seq_tempo); -LCDML_add(94, LCDML_0_5, 7, "L.Transp.Key", UI_func_seq_live_transpose_oct); -LCDML_add(95, LCDML_0_5, 8, "L.Trp.Offset", NULL); -LCDML_add(96, LCDML_0_5, 9, "Track Setup", UI_func_seq_track_setup); -LCDML_add(97, LCDML_0_5, 10, "Seq.Disp.Style", UI_func_seq_display_style); -LCDML_add(98, LCDML_0_5, 11, "LOAD Patterns", UI_func_seq_pattern_load); -LCDML_add(99, LCDML_0_5, 12, "SAVE Patterns", UI_func_seq_pattern_save); -LCDML_add(100, LCDML_0, 6, "System", NULL); -LCDML_add(101, LCDML_0_6, 1, "Stereo/Mono", UI_func_stereo_mono); -LCDML_add(102, LCDML_0_6, 2, "MIDI Soft THRU", UI_func_midi_soft_thru); -LCDML_add(103, LCDML_0_6, 3, "Favorites", UI_func_favorites); -LCDML_add(104, LCDML_0_6, 4, "EEPROM Reset", UI_func_eeprom_reset); -LCDML_add(105, LCDML_0, 7, "Info", UI_func_information); -LCDML_addAdvanced(106, LCDML_0, 8, COND_hide, "Volume", UI_func_volume, 0, _LCDML_TYPE_default); -#define _LCDML_DISP_cnt 106 +LCDML_add(24, LCDML_0_1_2_3_5, 1, "50Hz", UI_func_eq_1); +LCDML_add(25, LCDML_0_1_2_3_5, 2, "120Hz", UI_func_eq_2); +LCDML_add(26, LCDML_0_1_2_3_5, 3, "220Hz", UI_func_eq_3); +LCDML_add(27, LCDML_0_1_2_3_5, 4, "1000Hz", UI_func_eq_4); +LCDML_add(28, LCDML_0_1_2_3_5, 5, "2000Hz", UI_func_eq_5); +LCDML_add(29, LCDML_0_1_2_3_5, 6, "7000Hz", UI_func_eq_6); +LCDML_add(30, LCDML_0_1_2_3_5, 7, "10000Hz", UI_func_eq_7); +LCDML_add(31, LCDML_0_1, 3, "Controller", NULL); +LCDML_add(32, LCDML_0_1_3, 1, "Pitchbend", NULL); +LCDML_add(33, LCDML_0_1_3_1, 1, "PB Range", UI_func_pb_range); +LCDML_add(34, LCDML_0_1_3_1, 2, "PB Step", UI_func_pb_step); +LCDML_add(35, LCDML_0_1_3, 2, "Mod Wheel", NULL); +LCDML_add(36, LCDML_0_1_3_2, 1, "MW Range", UI_func_mw_range); +LCDML_add(37, LCDML_0_1_3_2, 2, "MW Assign", UI_func_mw_assign); +LCDML_add(38, LCDML_0_1_3_2, 3, "MW Mode", UI_func_mw_mode); +LCDML_add(39, LCDML_0_1_3, 3, "Aftertouch", NULL); +LCDML_add(40, LCDML_0_1_3_3, 1, "AT Range", UI_func_at_range); +LCDML_add(41, LCDML_0_1_3_3, 2, "AT Assign", UI_func_at_assign); +LCDML_add(42, LCDML_0_1_3_3, 3, "AT Mode", UI_func_at_mode); +LCDML_add(43, LCDML_0_1_3, 4, "Foot Ctrl", NULL); +LCDML_add(44, LCDML_0_1_3_4, 1, "FC Range", UI_func_fc_range); +LCDML_add(45, LCDML_0_1_3_4, 2, "FC Assign", UI_func_fc_assign); +LCDML_add(46, LCDML_0_1_3_4, 3, "FC Mode", UI_func_fc_mode); +LCDML_add(47, LCDML_0_1_3, 5, "Breath Ctrl", NULL); +LCDML_add(48, LCDML_0_1_3_5, 1, "BC Range", UI_func_bc_range); +LCDML_add(49, LCDML_0_1_3_5, 2, "BC Assign", UI_func_bc_assign); +LCDML_add(50, LCDML_0_1_3_5, 3, "BC Mode", UI_func_bc_mode); +LCDML_add(51, LCDML_0_1, 4, "MIDI", NULL); +LCDML_add(52, LCDML_0_1_4, 1, "MIDI Channel", UI_func_midi_channel); +LCDML_add(53, LCDML_0_1_4, 2, "Lowest Note", UI_func_lowest_note); +LCDML_add(54, LCDML_0_1_4, 3, "Highest Note", UI_func_highest_note); +LCDML_add(55, LCDML_0_1_4, 4, "MIDI Send Voice", UI_func_sysex_send_voice); +LCDML_add(56, LCDML_0_1, 5, "Setup", NULL); +LCDML_add(57, LCDML_0_1_5, 1, "Portamento", NULL); +LCDML_add(58, LCDML_0_1_5_1, 1, "Port. Mode", UI_func_portamento_mode); +LCDML_add(59, LCDML_0_1_5_1, 2, "Port. Gliss", UI_func_portamento_glissando); +LCDML_add(60, LCDML_0_1_5_1, 3, "Port. Time", UI_func_portamento_time); +LCDML_add(61, LCDML_0_1_5, 2, "Polyphony", UI_func_polyphony); +LCDML_add(62, LCDML_0_1_5, 3, "Transpose", UI_func_transpose); +LCDML_add(63, LCDML_0_1_5, 4, "Fine Tune", UI_func_tune); +LCDML_add(64, LCDML_0_1_5, 5, "Mono/Poly", UI_func_mono_poly); +LCDML_add(65, LCDML_0_1, 6, "Internal", NULL); +LCDML_add(66, LCDML_0_1_6, 1, "Note Refresh", UI_func_note_refresh); +LCDML_add(67, LCDML_0_1_6, 2, "Velocity Lvl", UI_func_velocity_level); +LCDML_add(68, LCDML_0_1, 7, "Operator", UI_handle_OP); +LCDML_add(69, LCDML_0_1, 8, "Save Voice", UI_func_save_voice); +LCDML_add(70, LCDML_0, 3, "Load/Save", NULL); +LCDML_add(71, LCDML_0_3, 1, "Performance", NULL); +LCDML_add(72, LCDML_0_3_1, 1, "Load Perf.", UI_func_load_performance); +LCDML_add(73, LCDML_0_3_1, 2, "Save Perf.", UI_func_save_performance); +LCDML_add(74, LCDML_0_3, 2, "Voice Config", NULL); +LCDML_add(75, LCDML_0_3_2, 1, "Load Voice Cfg", UI_func_load_voiceconfig); +LCDML_add(76, LCDML_0_3_2, 2, "Save Voice Cfg", UI_func_save_voiceconfig); +LCDML_add(77, LCDML_0_3, 3, "Effects", NULL); +LCDML_add(78, LCDML_0_3_3, 1, "Load Effects", UI_func_load_fx); +LCDML_add(79, LCDML_0_3_3, 2, "Save Effects", UI_func_save_fx); +LCDML_add(80, LCDML_0_3, 5, "MIDI", NULL); +LCDML_add(81, LCDML_0_3_5, 1, "MIDI Recv Bank", UI_func_sysex_receive_bank); +LCDML_add(82, LCDML_0_3_5, 2, "MIDI Snd Bank", UI_func_sysex_send_bank); +LCDML_add(83, LCDML_0_3_5, 3, "MIDI Snd Voice", UI_func_sysex_send_voice); +LCDML_add(84, LCDML_0, 4, "Drums", NULL); +LCDML_add(85, LCDML_0_4, 1, "Drums Main Vol", UI_func_drum_main_volume); +LCDML_add(86, LCDML_0_4, 2, "Drum Volumes", UI_func_drum_volume); +LCDML_add(87, LCDML_0_4, 3, "Drum Pan", UI_func_drum_pan); +LCDML_add(88, LCDML_0_4, 4, "Drum Rev.Send", UI_func_drum_reverb_send); +LCDML_add(89, LCDML_0, 5, "Sequencer", NULL); +LCDML_add(90, LCDML_0_5, 1, "Sequencer", UI_func_sequencer); +LCDML_add(91, LCDML_0_5, 2, "Vel./Chrd Edit", UI_func_seq_vel_editor); +LCDML_add(92, LCDML_0_5, 3, "Pattern Chain", UI_func_seq_pat_chain); +LCDML_add(93, LCDML_0_5, 4, "Arpeggio", UI_func_arpeggio); +LCDML_add(94, LCDML_0_5, 5, "Seq. Length", UI_func_seq_lenght); +LCDML_add(95, LCDML_0_5, 6, "Tempo", UI_func_seq_tempo); +LCDML_add(96, LCDML_0_5, 7, "L.Transp.Key", UI_func_seq_live_transpose_oct); +LCDML_add(97, LCDML_0_5, 8, "L.Trp.Offset", NULL); +LCDML_add(98, LCDML_0_5, 9, "Track Setup", UI_func_seq_track_setup); +LCDML_add(99, LCDML_0_5, 10, "Seq.Disp.Style", UI_func_seq_display_style); +LCDML_add(100, LCDML_0_5, 11, "LOAD Patterns", UI_func_seq_pattern_load); +LCDML_add(101, LCDML_0_5, 12, "SAVE Patterns", UI_func_seq_pattern_save); +LCDML_add(102, LCDML_0, 6, "System", NULL); +LCDML_add(103, LCDML_0_6, 1, "Stereo/Mono", UI_func_stereo_mono); +LCDML_add(104, LCDML_0_6, 2, "MIDI Soft THRU", UI_func_midi_soft_thru); +LCDML_add(105, LCDML_0_6, 3, "Favorites", UI_func_favorites); +LCDML_add(106, LCDML_0_6, 4, "EEPROM Reset", UI_func_eeprom_reset); +LCDML_add(107, LCDML_0, 7, "Info", UI_func_information); +LCDML_addAdvanced(108, LCDML_0, 8, COND_hide, "Volume", UI_func_volume, 0, _LCDML_TYPE_default); +#define _LCDML_DISP_cnt 108 #endif diff --git a/UI_FX_T4.h b/UI_FX_T4.h index 7519e5c..c89096f 100644 --- a/UI_FX_T4.h +++ b/UI_FX_T4.h @@ -57,87 +57,89 @@ LCDML_add(23, LCDML_0_1_2_3_4, 5, "Diffusion", UI_func_reverb_diffusion); LCDML_add(24, LCDML_0_1_2_3_4, 6, "Level", UI_func_reverb_level); LCDML_add(25, LCDML_0_1_2_3_4, 7, "Reverb Send", UI_func_reverb_send); LCDML_add(26, LCDML_0_1_2_3, 5, "EQ", NULL); -LCDML_add(27, LCDML_0_1_2_3_5, 1, "Bass", UI_func_eq_bass); -LCDML_add(28, LCDML_0_1_2_3_5, 2, "MidBass", UI_func_eq_midbass); -LCDML_add(29, LCDML_0_1_2_3_5, 3, "Mid", UI_func_eq_mid); -LCDML_add(30, LCDML_0_1_2_3_5, 4, "MidTreble", UI_func_eq_midtreble); -LCDML_add(31, LCDML_0_1_2_3_5, 5, "Treble", UI_func_eq_treble); -LCDML_add(32, LCDML_0_1, 3, "Controller", NULL); -LCDML_add(33, LCDML_0_1_3, 1, "Pitchbend", NULL); -LCDML_add(34, LCDML_0_1_3_1, 1, "PB Range", UI_func_pb_range); -LCDML_add(35, LCDML_0_1_3_1, 2, "PB Step", UI_func_pb_step); -LCDML_add(36, LCDML_0_1_3, 2, "Mod Wheel", NULL); -LCDML_add(37, LCDML_0_1_3_2, 1, "MW Range", UI_func_mw_range); -LCDML_add(38, LCDML_0_1_3_2, 2, "MW Assign", UI_func_mw_assign); -LCDML_add(39, LCDML_0_1_3_2, 3, "MW Mode", UI_func_mw_mode); -LCDML_add(40, LCDML_0_1_3, 3, "Aftertouch", NULL); -LCDML_add(41, LCDML_0_1_3_3, 1, "AT Range", UI_func_at_range); -LCDML_add(42, LCDML_0_1_3_3, 2, "AT Assign", UI_func_at_assign); -LCDML_add(43, LCDML_0_1_3_3, 3, "AT Mode", UI_func_at_mode); -LCDML_add(44, LCDML_0_1_3, 4, "Foot Ctrl", NULL); -LCDML_add(45, LCDML_0_1_3_4, 1, "FC Range", UI_func_fc_range); -LCDML_add(46, LCDML_0_1_3_4, 2, "FC Assign", UI_func_fc_assign); -LCDML_add(47, LCDML_0_1_3_4, 3, "FC Mode", UI_func_fc_mode); -LCDML_add(48, LCDML_0_1_3, 5, "Breath Ctrl", NULL); -LCDML_add(49, LCDML_0_1_3_5, 1, "BC Range", UI_func_bc_range); -LCDML_add(50, LCDML_0_1_3_5, 2, "BC Assign", UI_func_bc_assign); -LCDML_add(51, LCDML_0_1_3_5, 3, "BC Mode", UI_func_bc_mode); -LCDML_add(52, LCDML_0_1, 4, "MIDI", NULL); -LCDML_add(53, LCDML_0_1_4, 1, "MIDI Channel", UI_func_midi_channel); -LCDML_add(54, LCDML_0_1_4, 2, "Lowest Note", UI_func_lowest_note); -LCDML_add(55, LCDML_0_1_4, 3, "Highest Note", UI_func_highest_note); -LCDML_add(56, LCDML_0_1_4, 4, "MIDI Send Voice", UI_func_sysex_send_voice); -LCDML_add(57, LCDML_0_1, 5, "Setup", NULL); -LCDML_add(58, LCDML_0_1_5, 1, "Portamento", NULL); -LCDML_add(59, LCDML_0_1_5_1, 1, "Port. Mode", UI_func_portamento_mode); -LCDML_add(60, LCDML_0_1_5_1, 2, "Port. Gliss", UI_func_portamento_glissando); -LCDML_add(61, LCDML_0_1_5_1, 3, "Port. Time", UI_func_portamento_time); -LCDML_add(62, LCDML_0_1_5, 2, "Polyphony", UI_func_polyphony); -LCDML_add(63, LCDML_0_1_5, 3, "Transpose", UI_func_transpose); -LCDML_add(64, LCDML_0_1_5, 4, "Fine Tune", UI_func_tune); -LCDML_add(65, LCDML_0_1_5, 5, "Mono/Poly", UI_func_mono_poly); -LCDML_add(66, LCDML_0_1, 6, "Internal", NULL); -LCDML_add(67, LCDML_0_1_6, 1, "Note Refresh", UI_func_note_refresh); -LCDML_add(68, LCDML_0_1_6, 2, "Velocity Lvl", UI_func_velocity_level); -LCDML_add(69, LCDML_0_1, 7, "Operator", UI_handle_OP); -LCDML_add(70, LCDML_0_1, 8, "Save Voice", UI_func_save_voice); -LCDML_add(71, LCDML_0, 3, "Load/Save", NULL); -LCDML_add(72, LCDML_0_3, 1, "Performance", NULL); -LCDML_add(73, LCDML_0_3_1, 1, "Load Perf.", UI_func_load_performance); -LCDML_add(74, LCDML_0_3_1, 2, "Save Perf.", UI_func_save_performance); -LCDML_add(75, LCDML_0_3, 2, "Voice Config", NULL); -LCDML_add(76, LCDML_0_3_2, 1, "Load Voice Cfg", UI_func_load_voiceconfig); -LCDML_add(77, LCDML_0_3_2, 2, "Save Voice Cfg", UI_func_save_voiceconfig); -LCDML_add(78, LCDML_0_3, 3, "Effects", NULL); -LCDML_add(79, LCDML_0_3_3, 1, "Load Effects", UI_func_load_fx); -LCDML_add(80, LCDML_0_3_3, 2, "Save Effects", UI_func_save_fx); -LCDML_add(81, LCDML_0_3, 5, "MIDI", NULL); -LCDML_add(82, LCDML_0_3_5, 1, "MIDI Recv Bank", UI_func_sysex_receive_bank); -LCDML_add(83, LCDML_0_3_5, 2, "MIDI Snd Bank", UI_func_sysex_send_bank); -LCDML_add(84, LCDML_0_3_5, 3, "MIDI Snd Voice", UI_func_sysex_send_voice); -LCDML_add(85, LCDML_0, 4, "Drums", NULL); -LCDML_add(86, LCDML_0_4, 1, "Drums Main Vol", UI_func_drum_main_volume); -LCDML_add(87, LCDML_0_4, 2, "Drum Volumes", UI_func_drum_volume); -LCDML_add(88, LCDML_0_4, 3, "Drum Pan", UI_func_drum_pan); -LCDML_add(89, LCDML_0_4, 4, "Drum Rev.Send", UI_func_drum_reverb_send); -LCDML_add(90, LCDML_0, 5, "Sequencer", NULL); -LCDML_add(91, LCDML_0_5, 1, "Sequencer", UI_func_sequencer); -LCDML_add(92, LCDML_0_5, 2, "Vel./Chrd Edit", UI_func_seq_vel_editor); -LCDML_add(93, LCDML_0_5, 3, "Pattern Chain", UI_func_seq_pat_chain); -LCDML_add(94, LCDML_0_5, 4, "Arpeggio", UI_func_arpeggio); -LCDML_add(95, LCDML_0_5, 5, "Seq. Length", UI_func_seq_lenght); -LCDML_add(96, LCDML_0_5, 6, "Tempo", UI_func_seq_tempo); -LCDML_add(97, LCDML_0_5, 7, "L.Transp.Key", UI_func_seq_live_transpose_oct); -LCDML_add(98, LCDML_0_5, 8, "Track Setup", UI_func_seq_track_setup); -LCDML_add(99, LCDML_0_5, 9, "Seq.Disp.Style", UI_func_seq_display_style); -LCDML_add(100, LCDML_0_5, 10, "LOAD Patterns", UI_func_seq_pattern_load); -LCDML_add(101, LCDML_0_5, 11, "SAVE Patterns", UI_func_seq_pattern_save); -LCDML_add(102, LCDML_0, 6, "System", NULL); -LCDML_add(103, LCDML_0_6, 1, "Stereo/Mono", UI_func_stereo_mono); -LCDML_add(104, LCDML_0_6, 2, "MIDI Soft THRU", UI_func_midi_soft_thru); -LCDML_add(105, LCDML_0_6, 3, "Favorites", UI_func_favorites); -LCDML_add(106, LCDML_0_6, 4, "EEPROM Reset", UI_func_eeprom_reset); -LCDML_add(107, LCDML_0, 7, "Info", UI_func_information); -LCDML_addAdvanced(108, LCDML_0, 8, COND_hide, "Volume", UI_func_volume, 0, _LCDML_TYPE_default); -#define _LCDML_DISP_cnt 108 +LCDML_add(27, LCDML_0_1_2_3_5, 1, "50Hz", UI_func_eq_1); +LCDML_add(28, LCDML_0_1_2_3_5, 2, "110Hz", UI_func_eq_2); +LCDML_add(29, LCDML_0_1_2_3_5, 3, "220Hz", UI_func_eq_3); +LCDML_add(30, LCDML_0_1_2_3_5, 4, "1000Hz", UI_func_eq_4); +LCDML_add(31, LCDML_0_1_2_3_5, 5, "2000Hz", UI_func_eq_5); +LCDML_add(32, LCDML_0_1_2_3_5, 6, "7000Hz", UI_func_eq_6); +LCDML_add(33, LCDML_0_1_2_3_5, 7, "10000Hz", UI_func_eq_7); +LCDML_add(34, LCDML_0_1, 3, "Controller", NULL); +LCDML_add(35, LCDML_0_1_3, 1, "Pitchbend", NULL); +LCDML_add(36, LCDML_0_1_3_1, 1, "PB Range", UI_func_pb_range); +LCDML_add(37, LCDML_0_1_3_1, 2, "PB Step", UI_func_pb_step); +LCDML_add(38, LCDML_0_1_3, 2, "Mod Wheel", NULL); +LCDML_add(39, LCDML_0_1_3_2, 1, "MW Range", UI_func_mw_range); +LCDML_add(40, LCDML_0_1_3_2, 2, "MW Assign", UI_func_mw_assign); +LCDML_add(41, LCDML_0_1_3_2, 3, "MW Mode", UI_func_mw_mode); +LCDML_add(42, LCDML_0_1_3, 3, "Aftertouch", NULL); +LCDML_add(43, LCDML_0_1_3_3, 1, "AT Range", UI_func_at_range); +LCDML_add(44, LCDML_0_1_3_3, 2, "AT Assign", UI_func_at_assign); +LCDML_add(45, LCDML_0_1_3_3, 3, "AT Mode", UI_func_at_mode); +LCDML_add(46, LCDML_0_1_3, 4, "Foot Ctrl", NULL); +LCDML_add(47, LCDML_0_1_3_4, 1, "FC Range", UI_func_fc_range); +LCDML_add(48, LCDML_0_1_3_4, 2, "FC Assign", UI_func_fc_assign); +LCDML_add(49, LCDML_0_1_3_4, 3, "FC Mode", UI_func_fc_mode); +LCDML_add(50, LCDML_0_1_3, 5, "Breath Ctrl", NULL); +LCDML_add(51, LCDML_0_1_3_5, 1, "BC Range", UI_func_bc_range); +LCDML_add(52, LCDML_0_1_3_5, 2, "BC Assign", UI_func_bc_assign); +LCDML_add(53, LCDML_0_1_3_5, 3, "BC Mode", UI_func_bc_mode); +LCDML_add(54, LCDML_0_1, 4, "MIDI", NULL); +LCDML_add(55, LCDML_0_1_4, 1, "MIDI Channel", UI_func_midi_channel); +LCDML_add(56, LCDML_0_1_4, 2, "Lowest Note", UI_func_lowest_note); +LCDML_add(57, LCDML_0_1_4, 3, "Highest Note", UI_func_highest_note); +LCDML_add(58, LCDML_0_1_4, 4, "MIDI Send Voice", UI_func_sysex_send_voice); +LCDML_add(59, LCDML_0_1, 5, "Setup", NULL); +LCDML_add(60, LCDML_0_1_5, 1, "Portamento", NULL); +LCDML_add(61, LCDML_0_1_5_1, 1, "Port. Mode", UI_func_portamento_mode); +LCDML_add(62, LCDML_0_1_5_1, 2, "Port. Gliss", UI_func_portamento_glissando); +LCDML_add(63, LCDML_0_1_5_1, 3, "Port. Time", UI_func_portamento_time); +LCDML_add(64, LCDML_0_1_5, 2, "Polyphony", UI_func_polyphony); +LCDML_add(65, LCDML_0_1_5, 3, "Transpose", UI_func_transpose); +LCDML_add(66, LCDML_0_1_5, 4, "Fine Tune", UI_func_tune); +LCDML_add(67, LCDML_0_1_5, 5, "Mono/Poly", UI_func_mono_poly); +LCDML_add(68, LCDML_0_1, 6, "Internal", NULL); +LCDML_add(69, LCDML_0_1_6, 1, "Note Refresh", UI_func_note_refresh); +LCDML_add(70, LCDML_0_1_6, 2, "Velocity Lvl", UI_func_velocity_level); +LCDML_add(71, LCDML_0_1, 7, "Operator", UI_handle_OP); +LCDML_add(72, LCDML_0_1, 8, "Save Voice", UI_func_save_voice); +LCDML_add(73, LCDML_0, 3, "Load/Save", NULL); +LCDML_add(74, LCDML_0_3, 1, "Performance", NULL); +LCDML_add(75, LCDML_0_3_1, 1, "Load Perf.", UI_func_load_performance); +LCDML_add(76, LCDML_0_3_1, 2, "Save Perf.", UI_func_save_performance); +LCDML_add(77, LCDML_0_3, 2, "Voice Config", NULL); +LCDML_add(78, LCDML_0_3_2, 1, "Load Voice Cfg", UI_func_load_voiceconfig); +LCDML_add(79, LCDML_0_3_2, 2, "Save Voice Cfg", UI_func_save_voiceconfig); +LCDML_add(80, LCDML_0_3, 3, "Effects", NULL); +LCDML_add(81, LCDML_0_3_3, 1, "Load Effects", UI_func_load_fx); +LCDML_add(82, LCDML_0_3_3, 2, "Save Effects", UI_func_save_fx); +LCDML_add(83, LCDML_0_3, 5, "MIDI", NULL); +LCDML_add(84, LCDML_0_3_5, 1, "MIDI Recv Bank", UI_func_sysex_receive_bank); +LCDML_add(85, LCDML_0_3_5, 2, "MIDI Snd Bank", UI_func_sysex_send_bank); +LCDML_add(86, LCDML_0_3_5, 3, "MIDI Snd Voice", UI_func_sysex_send_voice); +LCDML_add(87, LCDML_0, 4, "Drums", NULL); +LCDML_add(88, LCDML_0_4, 1, "Drums Main Vol", UI_func_drum_main_volume); +LCDML_add(89, LCDML_0_4, 2, "Drum Volumes", UI_func_drum_volume); +LCDML_add(90, LCDML_0_4, 3, "Drum Pan", UI_func_drum_pan); +LCDML_add(91, LCDML_0_4, 4, "Drum Rev.Send", UI_func_drum_reverb_send); +LCDML_add(92, LCDML_0, 5, "Sequencer", NULL); +LCDML_add(93, LCDML_0_5, 1, "Sequencer", UI_func_sequencer); +LCDML_add(94, LCDML_0_5, 2, "Vel./Chrd Edit", UI_func_seq_vel_editor); +LCDML_add(95, LCDML_0_5, 3, "Pattern Chain", UI_func_seq_pat_chain); +LCDML_add(96, LCDML_0_5, 4, "Arpeggio", UI_func_arpeggio); +LCDML_add(97, LCDML_0_5, 5, "Seq. Length", UI_func_seq_lenght); +LCDML_add(98, LCDML_0_5, 6, "Tempo", UI_func_seq_tempo); +LCDML_add(99, LCDML_0_5, 7, "L.Transp.Key", UI_func_seq_live_transpose_oct); +LCDML_add(100, LCDML_0_5, 8, "Track Setup", UI_func_seq_track_setup); +LCDML_add(101, LCDML_0_5, 9, "Seq.Disp.Style", UI_func_seq_display_style); +LCDML_add(102, LCDML_0_5, 10, "LOAD Patterns", UI_func_seq_pattern_load); +LCDML_add(103, LCDML_0_5, 11, "SAVE Patterns", UI_func_seq_pattern_save); +LCDML_add(104, LCDML_0, 6, "System", NULL); +LCDML_add(105, LCDML_0_6, 1, "Stereo/Mono", UI_func_stereo_mono); +LCDML_add(106, LCDML_0_6, 2, "MIDI Soft THRU", UI_func_midi_soft_thru); +LCDML_add(107, LCDML_0_6, 3, "Favorites", UI_func_favorites); +LCDML_add(108, LCDML_0_6, 4, "EEPROM Reset", UI_func_eeprom_reset); +LCDML_add(109, LCDML_0, 7, "Info", UI_func_information); +LCDML_addAdvanced(110, LCDML_0, 8, COND_hide, "Volume", UI_func_volume, 0, _LCDML_TYPE_default); +#define _LCDML_DISP_cnt 110 #endif diff --git a/config.h b/config.h index 2c92167..05dc6eb 100644 --- a/config.h +++ b/config.h @@ -28,7 +28,6 @@ #include #include "midinotes.h" #include "teensy_board_detection.h" -#include "sgtl5000_graphic_eq.hpp" // If you want to test the system with Linux and without any keyboard and/or audio equipment, you can do the following: // 1. In Arduino-IDE enable "Tools->USB-Type->Serial + MIDI + Audio" @@ -605,25 +604,33 @@ #define VOICECONFIG_NUM_MAX MAX_VOICECONFIG #define VOICECONFIG_NUM_DEFAULT -1 -#define EQ_BASS_MIN -10 -#define EQ_BASS_MAX 10 -#define EQ_BASS_DEFAULT 0 +#define EQ_1_MIN -10 +#define EQ_1_MAX 10 +#define EQ_1_DEFAULT 0 -#define EQ_MIDBASS_MIN -10 -#define EQ_MIDBASS_MAX 10 -#define EQ_MIDBASS_DEFAULT 0 +#define EQ_2_MIN -10 +#define EQ_2_MAX 10 +#define EQ_2_DEFAULT 0 -#define EQ_MID_MIN -10 -#define EQ_MID_MAX 10 -#define EQ_MID_DEFAULT 0 +#define EQ_3_MIN -10 +#define EQ_3_MAX 10 +#define EQ_3_DEFAULT 0 -#define EQ_MIDTREBLE_MIN -10 -#define EQ_MIDTREBLE_MAX 10 -#define EQ_MIDTREBLE_DEFAULT 0 +#define EQ_4_MIN -10 +#define EQ_4_MAX 10 +#define EQ_4_DEFAULT 0 -#define EQ_TREBLE_MIN -10 -#define EQ_TREBLE_MAX 10 -#define EQ_TREBLE_DEFAULT 0 +#define EQ_5_MIN -10 +#define EQ_5_MAX 10 +#define EQ_5_DEFAULT 0 + +#define EQ_6_MIN -10 +#define EQ_6_MAX 10 +#define EQ65_DEFAULT 0 + +#define EQ_7_MIN -10 +#define EQ_7_MAX 10 +#define EQ_7_DEFAULT 0 // Buffer for load/save configuration as JSON @@ -681,11 +688,13 @@ typedef struct fx_s { uint8_t reverb_hidamp; uint8_t reverb_diffusion; uint8_t reverb_level; - int8_t eq_bass; - int8_t eq_midbass; - int8_t eq_mid; - int8_t eq_midtreble; - int8_t eq_treble; + int8_t eq_1; + int8_t eq_2; + int8_t eq_3; + int8_t eq_4; + int8_t eq_5; + int8_t eq_6; + int8_t eq_7; } fx_t; typedef struct performance_s { diff --git a/control_sgtl5000plus.cpp b/control_sgtl5000plus.cpp new file mode 100644 index 0000000..5a06484 --- /dev/null +++ b/control_sgtl5000plus.cpp @@ -0,0 +1,143 @@ +/* + MicroDexed + + MicroDexed is a port of the Dexed sound engine + (https://github.com/asb2m10/dexed) for the Teensy-3.5/3.6/4.x with audio shield. + Dexed ist heavily based on https://github.com/google/music-synthesizer-for-android + + (c)2018-2021 H. Wirtz + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include +#include +#include "control_sgtl5000plus.h" + +void AudioControlSGTL5000Plus::init_parametric_eq(void) +{ + eqSelect(PARAMETRIC_EQUALIZER); + eqFilterCount(num_bands); + + filter_type = new uint8_t[num_bands]; + Fc = new float[num_bands]; + Q = new float[num_bands]; + peakGainDB = new float[num_bands]; + + setEQType(1, GRAPHIC_EQ_TYPE_0); + setEQFc(1, GRAPHIC_EQ_CENTER_FRQ_0); + setEQQ(1, GRAPHIC_EQ_Q_0); + setEQGain(1, 0.0); + + if (num_bands > 1) + { + setEQType(2, GRAPHIC_EQ_TYPE_1); + setEQFc(2, GRAPHIC_EQ_CENTER_FRQ_1); + setEQQ(2, GRAPHIC_EQ_Q_1); + setEQGain(2, 0.0); + } + + if (num_bands > 2) + { + setEQType(3, GRAPHIC_EQ_TYPE_2); + setEQFc(3, GRAPHIC_EQ_CENTER_FRQ_2); + setEQQ(3, GRAPHIC_EQ_Q_2); + setEQGain(3, 0.0); + } + + if (num_bands > 3) + { + setEQType(4, GRAPHIC_EQ_TYPE_3); + setEQFc(4, GRAPHIC_EQ_CENTER_FRQ_3); + setEQQ(4, GRAPHIC_EQ_Q_3); + setEQGain(4, 0.0); + } + + if (num_bands > 4) + { + setEQType(5, GRAPHIC_EQ_TYPE_4); + setEQFc(5, GRAPHIC_EQ_CENTER_FRQ_4); + setEQQ(5, GRAPHIC_EQ_Q_4); + setEQGain(5, 0.0); + } + + if (num_bands > 5) + { + setEQType(6, GRAPHIC_EQ_TYPE_5); + setEQFc(6, GRAPHIC_EQ_CENTER_FRQ_5); + setEQQ(6, GRAPHIC_EQ_Q_5); + setEQGain(6, 0.0); + } + + if (num_bands > 6) + { + setEQType(7, GRAPHIC_EQ_TYPE_6); + setEQFc(7, GRAPHIC_EQ_CENTER_FRQ_6); + setEQQ(7, GRAPHIC_EQ_Q_6); + setEQGain(7, 0.0); + } +} + +void AudioControlSGTL5000Plus::setEQType(uint8_t band, uint8_t ft) +{ + if (filter_type) + { + int filter[5]; + + band = constrain(band, 1, num_bands); + filter_type[band - 1] = ft; + calcBiquad(filter_type[band - 1], Fc[band - 1], peakGainDB[band - 1], Q[band - 1], 524288, AUDIO_SAMPLE_RATE, filter); + //eqFilter(band, filter); + } +} + +void AudioControlSGTL5000Plus::setEQFc(uint8_t band, float frq) +{ + if (Fc) + { + int filter[5]; + + band = constrain(band, 1, num_bands); + Fc[band - 1] = frq; + calcBiquad(filter_type[band - 1], Fc[band - 1], peakGainDB[band - 1], Q[band - 1], 524288, AUDIO_SAMPLE_RATE, filter); + //eqFilter(band, filter); + } +} + +void AudioControlSGTL5000Plus::setEQQ(uint8_t band, float q) +{ + if (Q) + { + int filter[5]; + + band = constrain(band, 1, num_bands); + Q[band - 1] = q; + calcBiquad(filter_type[band - 1], Fc[band - 1], peakGainDB[band - 1], Q[band - 1], 524288, AUDIO_SAMPLE_RATE, filter); + //eqFilter(band, filter); + } +} + +void AudioControlSGTL5000Plus::setEQGain(uint8_t band, float gain) +{ + if (peakGainDB) + { + int filter[5]; + + band = constrain(band, 1, num_bands); + peakGainDB[band - 1] = gain; + calcBiquad(filter_type[band - 1], Fc[band - 1], peakGainDB[band - 1], Q[band - 1], 524288, AUDIO_SAMPLE_RATE, filter); + //eqFilter(band, filter); + } +} diff --git a/control_sgtl5000plus.h b/control_sgtl5000plus.h new file mode 100644 index 0000000..3e840f1 --- /dev/null +++ b/control_sgtl5000plus.h @@ -0,0 +1,80 @@ +/* + MicroDexed + + MicroDexed is a port of the Dexed sound engine + (https://github.com/asb2m10/dexed) for the Teensy-3.5/3.6/4.x with audio shield. + Dexed ist heavily based on https://github.com/google/music-synthesizer-for-android + + (c)2018-2021 H. Wirtz + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _SGTL5000PLUS_H_ +#define _SGTL5000PLUS_H_ + +#include +#include + +#define GRAPHIC_EQ_TYPE_0 FILTER_HIPASS +#define GRAPHIC_EQ_CENTER_FRQ_0 50.0 +#define GRAPHIC_EQ_Q_0 6.0 + +#define GRAPHIC_EQ_TYPE_1 FILTER_BANDPASS +#define GRAPHIC_EQ_CENTER_FRQ_1 120.0 +#define GRAPHIC_EQ_Q_1 6.0 + +#define GRAPHIC_EQ_TYPE_2 FILTER_BANDPASS +#define GRAPHIC_EQ_CENTER_FRQ_2 220.0 +#define GRAPHIC_EQ_Q_2 6.0 + +#define GRAPHIC_EQ_TYPE_3 FILTER_BANDPASS +#define GRAPHIC_EQ_CENTER_FRQ_3 1000.0 +#define GRAPHIC_EQ_Q_3 6.0 + +#define GRAPHIC_EQ_TYPE_4 FILTER_BANDPASS +#define GRAPHIC_EQ_CENTER_FRQ_4 2000.0 +#define GRAPHIC_EQ_Q_4 6.0 + +#define GRAPHIC_EQ_TYPE_5 FILTER_BANDPASS +#define GRAPHIC_EQ_CENTER_FRQ_5 7000.0 +#define GRAPHIC_EQ_Q_5 2.0 + +#define GRAPHIC_EQ_TYPE_6 FILTER_LOPASS +#define GRAPHIC_EQ_CENTER_FRQ_6 10000.0 +#define GRAPHIC_EQ_Q_6 6.0 + +class AudioControlSGTL5000Plus : public AudioControlSGTL5000 +{ + public: + AudioControlSGTL5000Plus(uint8_t n = 7) { + num_bands = constrain(n, 1, 7); + init_parametric_eq(); + }; + void setEQType(uint8_t band, uint8_t ft); + void setEQFc(uint8_t band, float frq); + void setEQQ(uint8_t band, float q); + void setEQGain(uint8_t band, float gain); + + private: + void init_parametric_eq(void); + uint8_t num_bands; + int* filter_coeff; + uint8_t* filter_type; + float* Fc; + float* Q; + float* peakGainDB; +}; +#endif diff --git a/dexed_sd.cpp b/dexed_sd.cpp index 95886dc..346e529 100644 --- a/dexed_sd.cpp +++ b/dexed_sd.cpp @@ -647,8 +647,13 @@ bool load_sd_fx_json(int8_t fx) configuration.fx.reverb_hidamp = data_json["reverb_hidamp"]; configuration.fx.reverb_diffusion = data_json["reverb_diffusion"]; configuration.fx.reverb_level = data_json["reverb_level"]; - configuration.fx.eq_bass = data_json["eq_bass"]; - configuration.fx.eq_treble = data_json["eq_treble"]; + configuration.fx.eq_1 = data_json["eq_1"]; + configuration.fx.eq_2 = data_json["eq_2"]; + configuration.fx.eq_3 = data_json["eq_3"]; + configuration.fx.eq_4 = data_json["eq_4"]; + configuration.fx.eq_5 = data_json["eq_5"]; + configuration.fx.eq_6 = data_json["eq_6"]; + configuration.fx.eq_7 = data_json["eq_7"]; set_fx_params(); @@ -719,9 +724,13 @@ bool save_sd_fx_json(uint8_t fx) data_json["reverb_hidamp"] = configuration.fx.reverb_hidamp; data_json["reverb_diffusion"] = configuration.fx.reverb_diffusion; data_json["reverb_level"] = configuration.fx.reverb_level; - data_json["eq_bass"] = configuration.fx.eq_bass; - data_json["eq_treble"] = configuration.fx.eq_treble; - + data_json["eq_1"] = configuration.fx.eq_1; + data_json["eq_2"] = configuration.fx.eq_2; + data_json["eq_3"] = configuration.fx.eq_3; + data_json["eq_4"] = configuration.fx.eq_4; + data_json["eq_5"] = configuration.fx.eq_5; + data_json["eq_6"] = configuration.fx.eq_6; + data_json["eq_7"] = configuration.fx.eq_7; #ifdef DEBUG Serial.println(F("Write JSON data:")); serializeJsonPretty(data_json, Serial); @@ -839,9 +848,13 @@ bool save_sd_seq_json(uint8_t seq_number) data_json["reverb_hidamp"] = configuration.fx.reverb_hidamp; data_json["reverb_diffusion"] = configuration.fx.reverb_diffusion; data_json["reverb_level"] = configuration.fx.reverb_level; - data_json["eq_bass"] = configuration.fx.eq_bass; - data_json["eq_treble"] = configuration.fx.eq_treble; - + data_json["eq_1"] = configuration.fx.eq_1; + data_json["eq_2"] = configuration.fx.eq_2; + data_json["eq_3"] = configuration.fx.eq_3; + data_json["eq_4"] = configuration.fx.eq_4; + data_json["eq_5"] = configuration.fx.eq_5; + data_json["eq_6"] = configuration.fx.eq_6; + data_json["eq_7"] = configuration.fx.eq_7; #ifdef DEBUG Serial.println(F("Write JSON data:")); serializeJsonPretty(data_json, Serial); @@ -961,8 +974,13 @@ bool load_sd_seq_json(uint8_t seq_number) configuration.fx.reverb_hidamp = data_json["reverb_hidamp"]; configuration.fx.reverb_diffusion = data_json["reverb_diffusion"]; configuration.fx.reverb_level = data_json["reverb_level"]; - configuration.fx.eq_bass = data_json["eq_bass"]; - configuration.fx.eq_treble = data_json["eq_treble"]; + configuration.fx.eq_1 = data_json["eq_1"]; + configuration.fx.eq_2 = data_json["eq_2"]; + configuration.fx.eq_3 = data_json["eq_3"]; + configuration.fx.eq_4 = data_json["eq_4"]; + configuration.fx.eq_5 = data_json["eq_5"]; + configuration.fx.eq_6 = data_json["eq_6"]; + configuration.fx.eq_7 = data_json["eq_7"]; set_fx_params(); diff --git a/sgtl5000_graphic_eq.hpp b/sgtl5000_graphic_eq.hpp deleted file mode 100644 index f6e2642..0000000 --- a/sgtl5000_graphic_eq.hpp +++ /dev/null @@ -1,329 +0,0 @@ -#ifdef SGTL5000_AUDIO_ENHANCE - -#include -#include - -#define EQ_LOWPASS 0 -#define EQ_HIGHPASS 1 -#define EQ_BANDPASS 2 -#define EQ_NOTCH 3 -#define EQ_PEAK 4 -#define EQ_LOWSHELF 5 -#define EQ_HIGHSHELF 6 - -#define GRAPHIC_EQ_TYPE_0 EQ_HIGHPASS -#define GRAPHIC_EQ_CENTER_FRQ_0 115.0 -#define GRAPHIC_EQ_Q_0 2.0 - -#define GRAPHIC_EQ_TYPE_1 EQ_BANDPASS -#define GRAPHIC_EQ_CENTER_FRQ_1 330.0 -#define GRAPHIC_EQ_Q_1 2.0 - -#define GRAPHIC_EQ_TYPE_2 EQ_BANDPASS -#define GRAPHIC_EQ_CENTER_FRQ_2 990.0 -#define GRAPHIC_EQ_Q_2 2.0 - -#define GRAPHIC_EQ_TYPE_3 EQ_BANDPASS -#define GRAPHIC_EQ_CENTER_FRQ_3 2000.0 -#define GRAPHIC_EQ_Q_3 2.0 - -#define GRAPHIC_EQ_TYPE_4 EQ_BANDPASS -#define GRAPHIC_EQ_CENTER_FRQ_4 4000.0 -#define GRAPHIC_EQ_Q_4 2.0 - -#define GRAPHIC_EQ_TYPE_5 EQ_BANDPASS -#define GRAPHIC_EQ_CENTER_FRQ_5 9900.0 -#define GRAPHIC_EQ_Q_5 2.0 - -#define GRAPHIC_EQ_TYPE_6 EQ_LOWPASS -#define GRAPHIC_EQ_CENTER_FRQ_6 11000.0 -#define GRAPHIC_EQ_Q_6 2.0 - -extern AudioControlSGTL5000 sgtl5000_1; - -class BiquadCoef -{ - public: - BiquadCoef(uint8_t num_bands); - ~BiquadCoef(); - - void set_eq_type(uint8_t band, uint8_t ft); - void set_eq_Fc(uint8_t band, float32_t frq); - void set_eq_Q(uint8_t band, float32_t q); - void set_gain(uint8_t band, float32_t gain); - void get_coef(uint8_t band, int* c); - - private: - void calcBiquadCoefficients(uint8_t band); - - uint8_t num_bands; - - uint8_t *filter_type; - float32_t *Fc; - float32_t *Q; - float32_t *peakGainDB; - - float32_t *a0; - float32_t *a1; - float32_t *a2; - float32_t *b1; - float32_t *b2; -}; - -BiquadCoef::BiquadCoef(uint8_t num_bands) -{ - num_bands = constrain(num_bands, 1, 7); - - sgtl5000_1.eqFilterCount(num_bands); - - filter_type = new uint8_t[num_bands]; - Fc = new float32_t[num_bands]; - Q = new float32_t[num_bands]; - peakGainDB = new float32_t[num_bands]; - a0 = new float32_t[num_bands]; - a1 = new float32_t[num_bands]; - a2 = new float32_t[num_bands]; - b1 = new float32_t[num_bands]; - b2 = new float32_t[num_bands]; - - set_eq_type(0, GRAPHIC_EQ_TYPE_0); - set_eq_Fc(0, GRAPHIC_EQ_CENTER_FRQ_0); - set_eq_Q(0, GRAPHIC_EQ_Q_0); - set_gain(0, 0.0); - - if (num_bands > 1) - { - set_eq_type(1, GRAPHIC_EQ_TYPE_1); - set_eq_Fc(1, GRAPHIC_EQ_CENTER_FRQ_1); - set_eq_Q(1, GRAPHIC_EQ_Q_1); - set_gain(1, 0.0); - } - - if (num_bands > 2) - { - set_eq_type(2, GRAPHIC_EQ_TYPE_2); - set_eq_Fc(2, GRAPHIC_EQ_CENTER_FRQ_2); - set_eq_Q(2, GRAPHIC_EQ_Q_2); - set_gain(2, 0.0); - } - - if (num_bands > 3) - { - set_eq_type(3, GRAPHIC_EQ_TYPE_3); - set_eq_Fc(3, GRAPHIC_EQ_CENTER_FRQ_3); - set_eq_Q(3, GRAPHIC_EQ_Q_3); - set_gain(3, 0.0); - } - - if (num_bands > 4) - { - set_eq_type(4, GRAPHIC_EQ_TYPE_4); - set_eq_Fc(4, GRAPHIC_EQ_CENTER_FRQ_4); - set_eq_Q(4, GRAPHIC_EQ_Q_4); - set_gain(4, 0.0); - } - - if (num_bands > 5) - { - set_eq_type(5, GRAPHIC_EQ_TYPE_5); - set_eq_Fc(5, GRAPHIC_EQ_CENTER_FRQ_5); - set_eq_Q(5, GRAPHIC_EQ_Q_5); - set_gain(5, 0.0); - } - - if (num_bands > 6) - { - set_eq_type(6, GRAPHIC_EQ_TYPE_6); - set_eq_Fc(6, GRAPHIC_EQ_CENTER_FRQ_6); - set_eq_Q(6, GRAPHIC_EQ_Q_6); - set_gain(6, 0.0); - } - - for (uint8_t i = 0; i < num_bands; i++) - { - int tmp[num_bands]; - - calcBiquadCoefficients(i); - get_coef(i, tmp); - sgtl5000_1.eqFilter(i, tmp); - } -} - -BiquadCoef::~BiquadCoef() -{ - ; -} - -void BiquadCoef::set_eq_type(uint8_t band, uint8_t ft) -{ - int tmp[num_bands]; - - filter_type[band] = ft; - calcBiquadCoefficients(band); - get_coef(band, tmp); - sgtl5000_1.eqFilter(band, tmp); -} - -void BiquadCoef::set_eq_Fc(uint8_t band, float32_t frq) -{ - int tmp[num_bands]; - - Fc[band] = frq; - calcBiquadCoefficients(band); - get_coef(band, tmp); - sgtl5000_1.eqFilter(band, tmp); -} - -void BiquadCoef::set_eq_Q(uint8_t band, float32_t q) -{ - int tmp[num_bands]; - - Q[band] = q; - calcBiquadCoefficients(band); - get_coef(band, tmp); - sgtl5000_1.eqFilter(band, tmp); -} - -void BiquadCoef::set_gain(uint8_t band, float32_t gain) -{ - int tmp[num_bands]; - - peakGainDB[band] = gain; - calcBiquadCoefficients(band); - get_coef(band, tmp); - sgtl5000_1.eqFilter(band, tmp); -} - -void BiquadCoef::get_coef(uint8_t band, int* c) -{ - if (c != NULL) - { - c[0] = a0[band] * 0x8000; - c[1] = a1[band] * 0x8000; - c[2] = a2[band] * 0x8000; - c[3] = b1[band] * 0x8000; - c[4] = b2[band] * 0x8000; - } -} - -// Taken from https://www.earlevel.com/main/2012/11/26/biquad-c-source-code/ -// -// Biquad.h -// -// Created by Nigel Redmon on 11/24/12 -// EarLevel Engineering: earlevel.com -// Copyright 2012 Nigel Redmon -// -// For a complete explanation of the Biquad code: -// http://www.earlevel.com/main/2012/11/25/biquad-c-source-code/ -// -// License: -// -// This source code is provided as is, without warranty. -// You may copy and distribute verbatim copies of this document. -// You may modify and use this source code to create binary code -// for your own purposes, free or commercial. -// -void BiquadCoef::calcBiquadCoefficients(uint8_t band) -{ - if (band > num_bands) - band = num_bands; - - float32_t norm; - float32_t V = pow(10, fabs(peakGainDB[band]) / 20.0); - float32_t K = tan(M_PI * Fc[band]); - switch (filter_type[band]) { - case EQ_LOWPASS: - norm = 1 / (1 + K / Q[band] + K * K); - a0[band] = K * K * norm; - a1[band] = 2 * a0[band]; - a2[band] = a0[band]; - b1[band] = 2 * (K * K - 1) * norm; - b2[band] = (1 - K / Q[band] + K * K) * norm; - break; - - case EQ_HIGHPASS: - norm = 1 / (1 + K / Q[band] + K * K); - a0[band] = 1 * norm; - a1[band] = -2 * a0[band]; - a2[band] = a0[band]; - b1[band] = 2 * (K * K - 1) * norm; - b2[band] = (1 - K / Q[band] + K * K) * norm; - break; - - case EQ_BANDPASS: - norm = 1 / (1 + K / Q[band] + K * K); - a0[band] = K / Q[band] * norm; - a1[band] = 0; - a2[band] = -a0[band]; - b1[band] = 2 * (K * K - 1) * norm; - b2[band] = (1 - K / Q[band] + K * K) * norm; - break; - - case EQ_NOTCH: - norm = 1 / (1 + K / Q[band] + K * K); - a0[band] = (1 + K * K) * norm; - a1[band] = 2 * (K * K - 1) * norm; - a2[band] = a0[band]; - b1[band] = a1[band]; - b2[band] = (1 - K / Q[band] + K * K) * norm; - break; - - case EQ_PEAK: - if (peakGainDB[band] >= 0) { // boost - norm = 1 / (1 + 1 / Q[band] * K + K * K); - a0[band] = (1 + V / Q[band] * K + K * K) * norm; - a1[band] = 2 * (K * K - 1) * norm; - a2[band] = (1 - V / Q[band] * K + K * K) * norm; - b1[band] = a1[band]; - b2[band] = (1 - 1 / Q[band] * K + K * K) * norm; - } - else { // cut - norm = 1 / (1 + V / Q[band] * K + K * K); - a0[band] = (1 + 1 / Q[band] * K + K * K) * norm; - a1[band] = 2 * (K * K - 1) * norm; - a2[band] = (1 - 1 / Q[band] * K + K * K) * norm; - b1[band] = a1[band]; - b2[band] = (1 - V / Q[band] * K + K * K) * norm; - } - break; - case EQ_LOWSHELF: - if (peakGainDB[band] >= 0) { // boost - norm = 1 / (1 + sqrt(2) * K + K * K); - a0[band] = (1 + sqrt(2 * V) * K + V * K * K) * norm; - a1[band] = 2 * (V * K * K - 1) * norm; - a2[band] = (1 - sqrt(2 * V) * K + V * K * K) * norm; - b1[band] = 2 * (K * K - 1) * norm; - b2[band] = (1 - sqrt(2) * K + K * K) * norm; - } - else { // cut - norm = 1 / (1 + sqrt(2 * V) * K + V * K * K); - a0[band] = (1 + sqrt(2) * K + K * K) * norm; - a1[band] = 2 * (K * K - 1) * norm; - a2[band] = (1 - sqrt(2) * K + K * K) * norm; - b1[band] = 2 * (V * K * K - 1) * norm; - b2[band] = (1 - sqrt(2 * V) * K + V * K * K) * norm; - } - break; - case EQ_HIGHSHELF: - if (peakGainDB[band] >= 0) { // boost - norm = 1 / (1 + sqrt(2) * K + K * K); - a0[band] = (V + sqrt(2 * V) * K + K * K) * norm; - a1[band] = 2 * (K * K - V) * norm; - a2[band] = (V - sqrt(2 * V) * K + K * K) * norm; - b1[band] = 2 * (K * K - 1) * norm; - b2[band] = (1 - sqrt(2) * K + K * K) * norm; - } - else { // cut - norm = 1 / (V + sqrt(2 * V) * K + K * K); - a0[band] = (1 + sqrt(2) * K + K * K) * norm; - a1[band] = 2 * (K * K - 1) * norm; - a2[band] = (1 - sqrt(2) * K + K * K) * norm; - b1[band] = 2 * (K * K - V) * norm; - b2[band] = (V - sqrt(2 * V) * K + K * K) * norm; - } - break; - } - return; -} -#endif