From d65cb2a8ef620817370f986dba5168dd8cde5f1e Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Thu, 4 Jun 2020 12:53:50 +0200 Subject: [PATCH] Fixes for bitimbral mode on T_3.6 (max. 10 voices per instance). --- MicroDexed.ino | 50 +++++++++++++++++++++------------------------ UI_FX.h | 3 +-- UI_NO_FX.h | 3 +-- config.h | 18 +++++++--------- dexed.cpp | 3 ++- dexed.h | 2 +- source_microdexed.h | 4 ++-- 7 files changed, 37 insertions(+), 46 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 9a47f99..407574e 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -76,39 +76,24 @@ AudioAnalyzePeak master_peak_l; #if defined(USE_FX) AudioConnection patchCord0(reverb_mixer_r, freeverb_r); AudioConnection patchCord1(reverb_mixer_l, freeverb_l); -#if defined(REVERB_ANTIALIAS_FRQ) -AudioConnection patchCord15(freeverb_r, freeverb_antialias_r); -AudioConnection patchCord16(freeverb_l, freeverb_antialias_l); -AudioConnection patchCord2(freeverb_antialias_r, 0, master_mixer_r, 3); -AudioConnection patchCord3(freeverb_antialias_l, 0, master_mixer_l, 3); -#else -AudioConnection patchCord2(freeverb_r, 0, master_mixer_r, 3); -AudioConnection patchCord3(freeverb_l, 0, master_mixer_l, 3); -#endif -#endif -AudioConnection patchCord4(master_mixer_r, volume_r); -AudioConnection patchCord5(master_mixer_l, volume_l); -AudioConnection patchCord6(volume_r, 0, stereo2mono, 0); -AudioConnection patchCord7(volume_l, 0, stereo2mono, 1); -AudioConnection patchCord8(stereo2mono, 0, master_peak_r, 0); -AudioConnection patchCord9(stereo2mono, 0, master_peak_l, 0); +AudioConnection patchCord2(freeverb_r, freeverb_antialias_r); +AudioConnection patchCord3(freeverb_l, freeverb_antialias_l); +AudioConnection patchCord4(freeverb_antialias_r, 0, master_mixer_r, 3); +AudioConnection patchCord5(freeverb_antialias_l, 0, master_mixer_l, 3); +#endif +AudioConnection patchCord6(master_mixer_r, volume_r); +AudioConnection patchCord7(master_mixer_l, volume_l); +AudioConnection patchCord8(volume_r, 0, stereo2mono, 0); +AudioConnection patchCord9(volume_l, 0, stereo2mono, 1); +AudioConnection patchCord10(stereo2mono, 0, master_peak_r, 0); +AudioConnection patchCord11(stereo2mono, 0, master_peak_l, 0); // Outputs -#ifdef AUDIO_DEVICE_USB -AudioOutputUSB usb1; -AudioConnection patchCord10(stereo2mono, 0, usb1, 0); -AudioConnection patchCord11(stereo2mono, 1, usb1, 1); -#endif #if defined(TEENSY_AUDIO_BOARD) AudioOutputI2S i2s1; AudioConnection patchCord12(stereo2mono, 0, i2s1, 0); AudioConnection patchCord13(stereo2mono, 1, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; -#ifdef SGTL5000_AUDIO_THRU -AudioInputI2S i2s1in; -AudioConnection patchCord17(i2s1in, 0, master_mixer_r, 2); -AudioConnection patchCord18(i2s1in, 1, master_mixer_l, 2); -#endif #elif defined (I2S_AUDIO_ONLY) AudioOutputI2S i2s1; AudioConnection patchCord12(stereo2mono, 0, i2s1, 0); @@ -128,11 +113,21 @@ AudioMixer4 invMixer; AudioConnection patchCord12(stereo2mono, 0, dacOut , 0); AudioConnection patchCord13(stereo2mono, 1, invMixer, 0); AudioConnection patchCord14(invMixer, 0, dacOut , 1); -#else +#elif defined(TEENSY_DAC) AudioOutputAnalogStereo dacOut; AudioConnection patchCord12(stereo2mono, 0, dacOut, 0); AudioConnection patchCord13(stereo2mono, 1, dacOut, 1); #endif +#ifdef AUDIO_DEVICE_USB +AudioOutputUSB usb1; +AudioConnection patchCord15(stereo2mono, 0, usb1, 0); +AudioConnection patchCord16(stereo2mono, 1, usb1, 1); +#endif +#ifdef SGTL5000_AUDIO_THRU +AudioInputI2S i2s1in; +AudioConnection patchCord17(i2s1in, 0, master_mixer_r, 2); +AudioConnection patchCord18(i2s1in, 1, master_mixer_l, 2); +#endif // // Dynamic patching of MicroDexed objects @@ -358,6 +353,7 @@ void setup() Serial.println(instance_id, DEC); #endif create_audio_engine_chain(instance_id); + } #if defined(USE_FX) diff --git a/UI_FX.h b/UI_FX.h index 5a1d4c1..c52d75b 100644 --- a/UI_FX.h +++ b/UI_FX.h @@ -26,9 +26,8 @@ #define _UI_H_ boolean COND_hide() // hide a menu element -// ********************************************************************* { - return false; // hidden + return false; } LCDML_add(0, LCDML_0, 1, "Voice", NULL); diff --git a/UI_NO_FX.h b/UI_NO_FX.h index 08b8717..ea80b21 100644 --- a/UI_NO_FX.h +++ b/UI_NO_FX.h @@ -26,9 +26,8 @@ #define _UI_H_ boolean COND_hide() // hide a menu element -// ********************************************************************* { - return false; // hidden + return false; } LCDML_add(0, LCDML_0, 1, "Voice", NULL); diff --git a/config.h b/config.h index 8fb2c94..1457567 100644 --- a/config.h +++ b/config.h @@ -104,7 +104,7 @@ #define DEXED_ENGINE DEXED_ENGINE_MODERN // DEXED_ENGINE_MARKI // DEXED_ENGINE_OPL // Number of Dexed instances -#define NUM_DEXED 1 // 1 or 2 - nothing else! +#define NUM_DEXED 2 // 1 or 2 - nothing else! // FX-CHAIN ENABLE/DISABLE #define USE_FX 1 // CHORUS parameters @@ -290,13 +290,9 @@ #define MAX_NOTES 16 #else #define MAX_NOTES 12 -#endif -#else -#if F_CPU >= 216 -#define MAX_NOTES 16 -#else -#define MAX_NOTES 12 -#endif +#endif // F_CPU >= 256 +#else // NUM_DEXED != 1 +#define MAX_NOTES 10 // Due to problems with lack of RAM (12 for 180MHz, 16 for 216 MHz) #endif #else #if NUM_DEXED == 1 @@ -307,10 +303,10 @@ #else #define MAX_NOTES 13 #endif -#endif -#endif +#endif // NUM_DEXED == 1 +#endif // defined(USE_FX) #define TEENSY3_6 -#endif +#endif // defined(__MK66FX1M0__) #if defined (__MK64FX512__) // Teensy-3.5 settings diff --git a/dexed.cpp b/dexed.cpp index b7cfd14..f6f3bd6 100644 --- a/dexed.cpp +++ b/dexed.cpp @@ -62,7 +62,8 @@ Dexed::Dexed(int rate) engineOpl = new EngineOpl; engineMsfa = new FmCore; - for (i = 0; i < MAX_ACTIVE_NOTES; i++) { + for (i = 0; i < MAX_ACTIVE_NOTES; i++) + { voices[i].dx7_note = new Dx7Note; voices[i].keydown = false; voices[i].sustained = false; diff --git a/dexed.h b/dexed.h index 66b6bec..371c0ed 100644 --- a/dexed.h +++ b/dexed.h @@ -191,7 +191,7 @@ class Dexed 04, 06, 00, // algorithm, feedback, osc sync 34, 33, 00, 00, 00, 04, // lfo speed, lfo delay, lfo pitch_mod_depth, lfo_amp_mod_depth, lfo_sync, lfo_waveform 03, 24, // pitch_mod_sensitivity, transpose - 69, 68, 80, 56, 85, 76, 84, 00, 00, 00 // 10 * char for name ("DEFAULT ") + 69, 68, 80, 56, 85, 76, 84, 00, 00, 00 // 10 * char for name ("DEFAULT ") }; // FM-Piano int lastKeyDown; diff --git a/source_microdexed.h b/source_microdexed.h index cf27991..f220754 100644 --- a/source_microdexed.h +++ b/source_microdexed.h @@ -14,7 +14,7 @@ class AudioSourceMicroDexed : public AudioStream, public Dexed { void update(void) { - if (in_update) + if (in_update==true) { xrun++; return; @@ -35,7 +35,7 @@ class AudioSourceMicroDexed : public AudioStream, public Dexed { getSamples(AUDIO_BLOCK_SAMPLES, lblock->data); - if (render_time > audio_block_time_us) // everything greater 2.9ms is a buffer underrun! + if (render_time > audio_block_time_us) // everything greater audio_block_time_us (2.9ms for buffer size of 128) is a buffer underrun! xrun++; if (render_time > render_time_max)