diff --git a/MicroDexed.ino b/MicroDexed.ino index 933591e..23914fe 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -48,13 +48,12 @@ uint8_t ui_state = UI_MAIN; uint8_t ui_main_state = UI_MAIN_VOICE; #endif -// GUItool: begin automatically generated code -AudioPlayQueue queue1; //xy=179,325 -AudioAnalyzePeak peak1; //xy=348,478 -AudioFilterStateVariable filter1; //xy=415,334 -AudioEffectDelay delay1; //xy=732,485 -AudioMixer4 mixer1; //xy=734,245 -AudioMixer4 mixer2; //xy=1055,317 +AudioPlayQueue queue1; +AudioAnalyzePeak peak1; +AudioFilterStateVariable filter1; +AudioEffectDelay delay1; +AudioMixer4 mixer1; +AudioMixer4 mixer2; AudioConnection patchCord1(queue1, peak1); AudioConnection patchCord2(queue1, 0, filter1, 0); AudioConnection patchCord3(filter1, 0, delay1, 0); @@ -65,23 +64,26 @@ AudioConnection patchCord7(delay1, 0, mixer2, 2); AudioConnection patchCord8(mixer1, delay1); AudioConnection patchCord9(queue1, 0, mixer1, 3); // for disabling the filter AudioConnection patchCord10(mixer1, 0, mixer2, 1); -#ifdef TEENSY_AUDIO_BOARD -AudioOutputI2S i2s1; //xy=1200,432 -AudioControlSGTL5000 sgtl5000_1; //xy=197,554 +#if defined(TEENSY_AUDIO_BOARD) || defined(TGA_AUDIO_BOARD) +AudioOutputI2S i2s1; AudioConnection patchCord11(mixer2, 0, i2s1, 0); AudioConnection patchCord12(mixer2, 0, i2s1, 1); +#ifdef TEENSY_AUDIO_BOARD +AudioControlSGTL5000 sgtl5000_1; +#else +AudioControlWM8731master wm8731_1; +#endif #else -AudioOutputPT8211 pt8211_1; //xy=1079,320 -AudioAmplifier volume_master; //xy=678,393 -AudioAmplifier volume_r; //xy=818,370 -AudioAmplifier volume_l; //xy=818,411 +AudioOutputPT8211 pt8211_1; +AudioAmplifier volume_master; +AudioAmplifier volume_r; +AudioAmplifier volume_l; AudioConnection patchCord11(mixer2, 0, volume_master, 0); AudioConnection patchCord12(volume_master, volume_r); AudioConnection patchCord13(volume_master, volume_l); AudioConnection patchCord14(volume_r, 0, pt8211_1, 0); AudioConnection patchCord15(volume_l, 0, pt8211_1, 1); #endif -// GUItool: end automatically generated code Dexed* dexed = new Dexed(SAMPLE_RATE); bool sd_card_available = false; @@ -157,7 +159,9 @@ void setup() setup_midi_devices(); // start audio card + AudioNoInterrupts(); AudioMemory(AUDIO_MEM); + #ifdef TEENSY_AUDIO_BOARD sgtl5000_1.enable(); sgtl5000_1.dacVolumeRamp(); @@ -168,9 +172,14 @@ void setup() sgtl5000_1.volume(1.0, 1.0); sgtl5000_1.lineOutLevel(31); Serial.println(F("Teensy-Audio-Board enabled.")); +#elif defined(TGA_AUDIO_BOARD) + wm8731_1.enable(); + wm8731_1.volume(1.0); + Serial.println(F("TGA board enabled.")); #else Serial.println(F("PT8211 enabled.")); #endif + set_volume(vol, vol_left, vol_right); // start SD card @@ -275,6 +284,7 @@ void setup() ui_show_main(); #endif + AudioInterrupts(); Serial.println(F("")); #ifdef TEST_NOTE diff --git a/config.h b/config.h index 109202d..66ffa02 100644 --- a/config.h +++ b/config.h @@ -23,26 +23,50 @@ */ +#ifndef CONFIG_H_INCLUDED +#define CONFIG_H_INCLUDED + #include "midinotes.h" // ATTENTION! For better latency you have to redefine AUDIO_BLOCK_SAMPLES from // 128 to 64 in /cores/teensy3/AudioStream.h -#ifndef CONFIG_H_INCLUDED -#define CONFIG_H_INCLUDED +#define VERSION "0.9.2" + +//************************************************************************************************* +//* DEVICE SETTINGS +//************************************************************************************************* + +// MIDI +#define MIDI_DEVICE_DIN Serial1 +#define MIDI_DEVICE_USB 1 +#define MIDI_DEVICE_USB_HOST 1 + +// AUDIO +//#define TEENSY_AUDIO_BOARD 1 +//#define TGA_AUDIO_BOARD + +//************************************************************************************************* +//* MIDI SETTINGS +//************************************************************************************************* -// Initial values -#define VERSION "0.9.1" -#define MIDI_DEVICE Serial1 -#define USE_ONBOARD_USB_HOST 1 -#define USBCON 1 // enabling onboard MIDI via programing connector -#define MIDI_MERGE_THRU 1 -#define TEENSY_AUDIO_BOARD 1 -#define VOLUME 0.6 #define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI +#define MIDI_MERGE_THRU 1 #define DEFAULT_SYSEXBANK 0 #define DEFAULT_SYSEXSOUND 0 + +//************************************************************************************************* +//* DEXED AND EFECTS SETTINGS +//************************************************************************************************* //#define DEXED_ENGINE DEXED_ENGINE_MODERN +// EFFECTS +#define FILTER_MAX_FREQ 10000 + +//************************************************************************************************* +//* AUDIO SETTINGS +//************************************************************************************************* + +#define VOLUME 0.8 #ifndef TEENSY_AUDIO_BOARD #if AUDIO_BLOCK_SAMPLES == 64 #define AUDIO_MEM 450 @@ -59,57 +83,30 @@ #define DELAY_MAX_TIME 1200.0 #endif #define SAMPLE_RATE 44100 -#define MAX_BANKS 100 -#define MAX_VOICES 32 // voices per bank -#define BANK_NAME_LEN 13 // FAT12 filenames (plus '\0') -#define VOICE_NAME_LEN 11 // 10 (plus '\0') - -#if !defined(__MK66FX1M0__) // check for Teensy-3.6 -#define MAX_NOTES 11 // No? -#undef USE_ONBOARD_USB_HOST -#else -#define MAX_NOTES 16 // Yes -#endif +#define REDUCE_LOUDNESS 1 -// EFFECTS -#define FILTER_MAX_FREQ 10000 +//************************************************************************************************* +//* DEBUG OUTPUT SETTINGS +//************************************************************************************************* -// Debug output -#define SERIAL_SPEED 38400 #define DEBUG 1 -#define SHOW_MIDI_EVENT 1 +#define SERIAL_SPEED 38400 #define SHOW_XRUN 1 #define SHOW_CPU_LOAD_MSEC 5000 -// Some optimizations -#define USE_TEENSY_DSP 1 -#define SUM_UP_AS_INT 1 -#define REDUCE_LOUDNESS 1 - -// Enable TEST_NOTE for adding code to drop some midi notes for testing without keyboard -//#define TEST_NOTE MIDI_E2 -#define TEST_VEL_MIN 60 -#define TEST_VEL_MAX 110 +//************************************************************************************************* +//* HARDWARE SETTINGS +//************************************************************************************************* -// Use these with the Teensy Audio Shield +// Teensy Audio Shield: //#define SDCARD_CS_PIN 10 //#define SDCARD_MOSI_PIN 7 //#define SDCARD_SCK_PIN 14 -// Use these with the Teensy 3.5 & 3.6 SD card +// 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 -// LCD Display -#define I2C_DISPLAY 1 -// [I2C] SCL: Pin 19, SDA: Pin 18 (https://www.pjrc.com/teensy/td_libs_Wire.html) -#define LCD_I2C_ADDRESS 0x27 -#define LCD_CHARS 16 -#define LCD_LINES 2 -#define UI_AUTO_BACK_MS 3000 -#define AUTOSTORE_MS 5000 -#define AUTOSTORE_FAST_MS 50 - // Encoder with button #define ENC_VOL_STEPS 43 #define ENC_FILTER_FRQ_STEPS 50 @@ -131,6 +128,16 @@ #define BUT_DEBOUNCE_MS 20 #define LONG_BUTTON_PRESS 500 +// LCD Display +#define I2C_DISPLAY 1 +// [I2C] SCL: Pin 19, SDA: Pin 18 (https://www.pjrc.com/teensy/td_libs_Wire.html) +#define LCD_I2C_ADDRESS 0x27 +#define LCD_CHARS 16 +#define LCD_LINES 2 +#define UI_AUTO_BACK_MS 3000 +#define AUTOSTORE_MS 5000 +#define AUTOSTORE_FAST_MS 50 + // EEPROM address #define EEPROM_OFFSET 0 #define EEPROM_DATA_LENGTH 6 @@ -150,4 +157,48 @@ #define EEPROM_UPDATE_VOL_L (1<<4) #define EEPROM_UPDATE_MIDICHANNEL (1<<5) #define EEPROM_UPDATE_CHECKSUM (1<<7) + +#define MAX_BANKS 100 +#define MAX_VOICES 32 // voices per bank +#define BANK_NAME_LEN 13 // FAT12 filenames (plus '\0') +#define VOICE_NAME_LEN 11 // 10 (plus '\0') + + +//************************************************************************************************* +//* DO NO CHANGE ANYTHING BEYOND IF YOU DON'T KNOW WHAT YOU ARE DOING !!! +//************************************************************************************************* +// MIDI +#ifdef MIDI_DEVICE_USB +#define USBCON 1 +#endif +#if !defined(__MK66FX1M0__) // check for Teensy-3.6 +#define MAX_NOTES 11 // No? +#undef USE_ONBOARD_USB_HOST +#else +#define MAX_NOTES 16 // Yes +#endif + +// MIDI +#ifdef MIDI_DEVICE_USB +#define USBCON 1 +#endif +#if defined(__MK66FX1M0__) +// Teensy-3.6 settings +#define MIDI_DEVICE_USB_HOST 1 +#else +// Teensy-3.5 settings +#undef MIDI_DEVICE_USB_HOST +#endif +// Engine +#if defined(__MK66FX1M0__) +// Teensy-3.6 settings +#define MAX_NOTES 16 +#else +#define MAX_NOTES 11 #endif + +// Some optimizations +#define USE_TEENSY_DSP 1 +#define SUM_UP_AS_INT 1 + +#endif // CONFIG_H_INCLUDED