From 95ac874ef2541b045bce5a3c67978d3d522edad7 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Sat, 12 Dec 2020 11:13:40 +0100 Subject: [PATCH] Created a new header file for macros which are describing the type of Teensy board used. Extended the delay time for Teensy-4 based MicroDexeds --- UI.hpp | 10 ++++++-- config.h | 36 +++++++++++++++++++---------- teensy_board_detection.h | 50 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 14 deletions(-) create mode 100644 teensy_board_detection.h diff --git a/UI.hpp b/UI.hpp index 56dfcb9..29c1e27 100644 --- a/UI.hpp +++ b/UI.hpp @@ -1234,8 +1234,11 @@ void UI_func_delay_time(uint8_t param) encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); +#if DELAY_TIME_MAX >= 100 + lcd_display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 4, false, false, true); +#else lcd_display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 3, false, false, true); - +#endif lcd_active_instance_number(selected_instance_id); lcd.setCursor(14, 0); lcd.write(0); @@ -1270,8 +1273,11 @@ void UI_func_delay_time(uint8_t param) #endif } +#if DELAY_TIME_MAX >= 100 + lcd_display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 4, false, false, true); +#else lcd_display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 3, false, false, true); - +#endif if (configuration.fx.delay_time[selected_instance_id] <= DELAY_TIME_MIN) delay_fx[selected_instance_id]->disable(0); else diff --git a/config.h b/config.h index 02a42b9..57493b4 100644 --- a/config.h +++ b/config.h @@ -28,6 +28,7 @@ #include #include "midinotes.h" +#include "teensy_board_detection.h" // ATTENTION! For better latency you have to redefine AUDIO_BLOCK_SAMPLES from // 128 to 64 in /cores/teensy3/AudioStream.h @@ -57,7 +58,7 @@ // sed -i.orig 's/^#define USB_MIDI_SYSEX_MAX 290/#define USB_MIDI_SYSEX_MAX 4104/' /usr/local/arduino-teensy/hardware/teensy/avr/cores/teensy4/usb_midi.h //#define USB_MIDI_SYSEX_MAX 4104 -#define VERSION "1.0.11" +#define VERSION "1.0.12" //************************************************************************************************* //* DEVICE SETTINGS @@ -127,6 +128,8 @@ //************************************************************************************************* //* AUDIO SOFTWARE SETTINGS //************************************************************************************************* +#define SAMPLE_RATE 44100 + #ifndef TEENSY_AUDIO_BOARD #if AUDIO_BLOCK_SAMPLES == 64 #define AUDIO_MEM 512 @@ -156,18 +159,31 @@ 31: 1.16 Volts p-p */ #define SGTL5000_LINEOUT_LEVEL 29 +#endif + #if AUDIO_BLOCK_SAMPLES == 64 #define AUDIO_MEM 512 #else #define AUDIO_MEM 384 #endif -#endif + #if NUM_DEXED > 1 +#if defined(TEENSY3_6) #define DELAY_MAX_TIME 250 +#elif defined(TEENSY4) +#define DELAY_MAX_TIME 750 #else +#define DELAY_MAX_TIME 125 +#endif +#else +#if defined(TEENSY3_6) #define DELAY_MAX_TIME 500 +#elif defined(TEENSY4) +#define DELAY_MAX_TIME 1000 +#else +#define DELAY_MAX_TIME 250 +#endif #endif -#define SAMPLE_RATE 44100 //************************************************************************************************* //* UI @@ -233,12 +249,12 @@ #define ENC_L_PIN_A 3 #define ENC_L_PIN_B 2 #define BUT_L_PIN 4 -#if defined(ARDUINO_TEENSY36) +#if defined(TEENSY_3_6) #define ENC_R_PIN_A 28 #define ENC_R_PIN_B 29 #define BUT_R_PIN 30 #else -#if defined(ARDUINO_TEENSY40) +#if defined(TEENSY_4_0) #define ENC_R_PIN_A 6 #define ENC_R_PIN_B 5 #define BUT_R_PIN 8 @@ -287,14 +303,12 @@ #endif // Teensy-4.x settings -#if defined(__IMXRT1062__) //Teensy-4.x +#ifdef TEENSY4 #define MAX_NOTES 32 -#define TEENSY4 #endif // Teensy-3.6 settings -#if defined(__MK66FX1M0__) // Teensy-3.6 -# define TEENSY3_6 +#if defined(TEENSY3_6) # if defined(USE_FX) # if NUM_DEXED == 1 # if F_CPU == 256000000 @@ -339,12 +353,10 @@ # endif #endif -#if defined (__MK64FX512__) -// Teensy-3.5 settings +#ifdef TEENSY3_5 #undef MIDI_DEVICE_USB_HOST #define MAX_NOTES 11 #undef USE_FX -#define TEENSY3_5 #endif #define TRANSPOSE_FIX 24 diff --git a/teensy_board_detection.h b/teensy_board_detection.h new file mode 100644 index 0000000..cf233c0 --- /dev/null +++ b/teensy_board_detection.h @@ -0,0 +1,50 @@ +/* + 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-2020 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 TEENSY_BOARD_DETECTION_H_INCLUDED +#define TEENSY_BOARD_DETECTION_H_INCLUDED + + +// Teensy-4.x +#if defined(__IMXRT1062__) || defined (ARDUINO_TEENSY40) || defined (ARDUINO_TEENSY41) +#define TEENSY4 +#if defined (ARDUINO_TEENSY40) +#define TEENSY4_0 +#elif defined (ARDUINO_TEENSY41) +#define TEENSY4_1 +#endif +#endif + +// Teensy-3.6 +#if defined(__MK66FX1M0__) +# define TEENSY3_6 +#endif + +// Teensy-3.5 +#if defined (__MK64FX512__) +#define TEENSY3_5 +#endif + +#endif