diff --git a/MicroDexed.ino b/MicroDexed.ino index 7558ada..a208ed3 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -35,7 +35,6 @@ #include "effect_modulated_delay.h" #include "effect_stereo_mono.h" #include "effect_mono_stereo.h" -//#include "mixer8.h" #ifdef USE_PLATEREVERB #include "effect_platervbstereo.h" #else @@ -77,10 +76,6 @@ AudioAmplifier volume_l; AudioEffectStereoMono stereo2mono; AudioAnalyzePeak master_peak_r; AudioAnalyzePeak master_peak_l; -#if defined(ANTIALIAS_FRQ) -AudioFilterBiquad antialias_r; -AudioFilterBiquad antialias_l; -#endif #if defined(TEENSY_AUDIO_BOARD) && defined(SGTL5000_AUDIO_THRU) AudioMixer4 audio_thru_mixer_r; AudioMixer4 audio_thru_mixer_l; @@ -108,77 +103,70 @@ AudioConnection patchCord2(freeverb, 0, master_mixer_r, 3); AudioConnection patchCord3(freeverb, 1, master_mixer_l, 3); #endif #endif -#if defined(ANTIALIAS_FRQ) -AudioConnection patchCord6(master_mixer_r, antialias_r); -AudioConnection patchCord7(master_mixer_l, antialias_l); -AudioConnection patchCord8(antialias_r, volume_r); -AudioConnection patchCord9(antialias_l, volume_l); -#else -AudioConnection patchCord6(master_mixer_r, volume_r); -AudioConnection patchCord7(master_mixer_l, volume_l); -#endif -AudioConnection patchCord10(volume_r, 0, stereo2mono, 0); -AudioConnection patchCord11(volume_l, 0, stereo2mono, 1); -AudioConnection patchCord12(stereo2mono, 0, master_peak_r, 0); -AudioConnection patchCord13(stereo2mono, 0, master_peak_l, 0); +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); // Outputs #if defined(TEENSY_AUDIO_BOARD) AudioOutputI2S i2s1; #ifndef SGTL5000_AUDIO_THRU -AudioConnection patchCord14(stereo2mono, 0, i2s1, 0); -AudioConnection patchCord15(stereo2mono, 1, i2s1, 1); +AudioConnection patchCord10(stereo2mono, 0, i2s1, 0); +AudioConnection patchCord11(stereo2mono, 1, i2s1, 1); #endif AudioControlSGTL5000 sgtl5000_1; #elif defined (I2S_AUDIO_ONLY) AudioOutputI2S i2s1; -AudioConnection patchCord14(stereo2mono, 0, i2s1, 0); -AudioConnection patchCord15(stereo2mono, 1, i2s1, 1); +AudioConnection patchCord10(stereo2mono, 0, i2s1, 0); +AudioConnection patchCord11(stereo2mono, 1, i2s1, 1); #elif defined(TGA_AUDIO_BOARD) AudioOutputI2S i2s1; -AudioConnection patchCord14(stereo2mono, 0, i2s1, 0); -AudioConnection patchCord15(stereo2mono, 1, i2s1, 1); +AudioConnection patchCord10(stereo2mono, 0, i2s1, 0); +AudioConnection patchCord11(stereo2mono, 1, i2s1, 1); AudioControlWM8731master wm8731_1; #elif defined(PT8211_AUDIO) AudioOutputPT8211 pt8211_1; -AudioConnection patchCord14(stereo2mono, 0, pt8211_1, 0); -AudioConnection patchCord15(stereo2mono, 1, pt8211_1, 1); +AudioConnection patchCord10(stereo2mono, 0, pt8211_1, 0); +AudioConnection patchCord11(stereo2mono, 1, pt8211_1, 1); #elif defined(TEENSY_DAC_SYMMETRIC) AudioOutputAnalogStereo dacOut; AudioMixer4 invMixer; -AudioConnection patchCord14(stereo2mono, 0, dacOut , 0); -AudioConnection patchCord15(stereo2mono, 1, invMixer, 0); -AudioConnection patchCord16(invMixer, 0, dacOut , 1); +AudioConnection patchCord10(stereo2mono, 0, dacOut , 0); +AudioConnection patchCord11(stereo2mono, 1, invMixer, 0); +AudioConnection patchCord12(invMixer, 0, dacOut , 1); #elif defined(TEENSY_DAC) AudioOutputAnalogStereo dacOut; -AudioConnection patchCord14(stereo2mono, 0, dacOut, 0); -AudioConnection patchCord15(stereo2mono, 1, dacOut, 1); +AudioConnection patchCord10(stereo2mono, 0, dacOut, 0); +AudioConnection patchCord11(stereo2mono, 1, dacOut, 1); #endif #ifdef AUDIO_DEVICE_USB AudioOutputUSB usb1; -AudioConnection patchCord17(stereo2mono, 0, usb1, 0); -AudioConnection patchCord18(stereo2mono, 1, usb1, 1); +AudioConnection patchCord13(stereo2mono, 0, usb1, 0); +AudioConnection patchCord14(stereo2mono, 1, usb1, 1); #endif #if defined(TEENSY_AUDIO_BOARD) && defined(SGTL5000_AUDIO_THRU) AudioInputI2S i2s1in; -AudioConnection patchCord19(stereo2mono, 0, audio_thru_mixer_r, 0); -AudioConnection patchCord20(stereo2mono, 1, audio_thru_mixer_l, 0); -AudioConnection patchCord21(i2s1in, 0, audio_thru_mixer_r, 1); -AudioConnection patchCord22(i2s1in, 1, audio_thru_mixer_l, 1); -AudioConnection patchCord23(audio_thru_mixer_r, 0, i2s1, 0); -AudioConnection patchCord24(audio_thru_mixer_l, 0, i2s1, 1); +AudioConnection patchCord15(stereo2mono, 0, audio_thru_mixer_r, 0); +AudioConnection patchCord16(stereo2mono, 1, audio_thru_mixer_l, 0); +AudioConnection patchCord17(i2s1in, 0, audio_thru_mixer_r, 1); +AudioConnection patchCord18(i2s1in, 1, audio_thru_mixer_l, 1); +AudioConnection patchCord19(audio_thru_mixer_r, 0, i2s1, 0); +AudioConnection patchCord20(audio_thru_mixer_l, 0, i2s1, 1); #endif #ifdef NUM_DRUMS #ifdef USE_FX -AudioConnection patchCord25(drum_mixer_r, 0, reverb_mixer_r, 4); -AudioConnection patchCord26(drum_mixer_l, 0, reverb_mixer_l, 4); -AudioConnection patchCord27(drum_mixer_r, 0, master_mixer_r, 2); -AudioConnection patchCord28(drum_mixer_l, 0, master_mixer_l, 2); +AudioConnection patchCord21(drum_mixer_r, 0, reverb_mixer_r, 2); +AudioConnection patchCord22(drum_mixer_l, 0, reverb_mixer_l, 2); +AudioConnection patchCord23(drum_mixer_r, 0, master_mixer_r, 2); +AudioConnection patchCord24(drum_mixer_l, 0, master_mixer_l, 2); #else -AudioConnection patchCord25(drum_mixer_r, 0, master_mixer_r, 2); -AudioConnection patchCord26(drum_mixer_l, 0, master_mixer_l, 2); +AudioConnection patchCord21(drum_mixer_r, 0, master_mixer_r, 2); +AudioConnection patchCord22(drum_mixer_l, 0, master_mixer_l, 2); #endif #endif @@ -2053,8 +2041,10 @@ void set_fx_params(void) #endif #ifdef NUM_DRUMS - reverb_mixer_r.gain(4, 1.0); - reverb_mixer_l.gain(4, 1.0); +#ifdef USE_FX + reverb_mixer_r.gain(2, 1.0); // Drums-Send + reverb_mixer_l.gain(2, 1.0); // Drums-Send +#endif #endif master_mixer_r.gain(3, pseudo_log_curve(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0))); diff --git a/UI.hpp b/UI.hpp index 9693500..938727d 100644 --- a/UI.hpp +++ b/UI.hpp @@ -30,7 +30,6 @@ #include "disp_plus.h" #include "effect_modulated_delay.h" #include "effect_stereo_mono.h" -//#include "mixer8.h" #ifdef USE_PLATEREVERB #include "effect_platervbstereo.h" #else diff --git a/config.h b/config.h index 12cf624..7871f87 100644 --- a/config.h +++ b/config.h @@ -99,7 +99,8 @@ //* DEXED AND EFFECTS SETTINGS //************************************************************************************************* // Number of Dexed instances -#if defined(TEENSY3_6) +#if defined(TEENSY3_6) && NUM_DEXED > 1 +#warning >>> Sorry, only one instance possible for Teensy-3.6 #define NUM_DEXED 1 // 1 or 2 - nothing else! #else #define NUM_DEXED 2 // 1 or 2 - nothing else! @@ -109,7 +110,7 @@ #define USE_FX 1 // NUMBER OF SAMPLEDRUMS -//#define NUM_DRUMS 4 +#define NUM_DRUMS 4 #define DRUM_MIDI_CHANNEL 1 // CHORUS parameters @@ -120,7 +121,7 @@ // SGTL5000 #ifdef TEENSY_AUDIO_BOARD #define SGTL5000_AUDIO_ENHANCE 1 -#define SGTL5000_AUDIO_THRU 1 +//#define SGTL5000_AUDIO_THRU 1 #define SGTL5000_HEADPHONE_VOLUME 0.8 #endif #if defined(TEENSY4) diff --git a/mixer8.cpp b/mixer8.cpp deleted file mode 100644 index 4c3d14a..0000000 --- a/mixer8.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* Audio Library for Teensy 3.X - * Copyright (c) 2014, Paul Stoffregen, paul@pjrc.com - * - * Development of this audio library was funded by PJRC.COM, LLC by sales of - * Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop - * open source software by purchasing Teensy or other PJRC products. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice, development funding notice, and this permission - * notice shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include -#include "mixer8.h" -#include "utility/dspinst.h" - -#if defined(__ARM_ARCH_7EM__) -#define MULTI_UNITYGAIN 65536 - -static void applyGain(int16_t *data, int32_t mult) -{ - uint32_t *p = (uint32_t *)data; - const uint32_t *end = (uint32_t *)(data + AUDIO_BLOCK_SAMPLES); - - do { - uint32_t tmp32 = *p; // read 2 samples from *data - int32_t val1 = signed_multiply_32x16b(mult, tmp32); - int32_t val2 = signed_multiply_32x16t(mult, tmp32); - val1 = signed_saturate_rshift(val1, 16, 0); - val2 = signed_saturate_rshift(val2, 16, 0); - *p++ = pack_16b_16b(val2, val1); - } while (p < end); -} - -static void applyGainThenAdd(int16_t *data, const int16_t *in, int32_t mult) -{ - uint32_t *dst = (uint32_t *)data; - const uint32_t *src = (uint32_t *)in; - const uint32_t *end = (uint32_t *)(data + AUDIO_BLOCK_SAMPLES); - - if (mult == MULTI_UNITYGAIN) { - do { - uint32_t tmp32 = *dst; - *dst++ = signed_add_16_and_16(tmp32, *src++); - tmp32 = *dst; - *dst++ = signed_add_16_and_16(tmp32, *src++); - } while (dst < end); - } else { - do { - uint32_t tmp32 = *src++; // read 2 samples from *data - int32_t val1 = signed_multiply_32x16b(mult, tmp32); - int32_t val2 = signed_multiply_32x16t(mult, tmp32); - val1 = signed_saturate_rshift(val1, 16, 0); - val2 = signed_saturate_rshift(val2, 16, 0); - tmp32 = pack_16b_16b(val2, val1); - uint32_t tmp32b = *dst; - *dst++ = signed_add_16_and_16(tmp32, tmp32b); - } while (dst < end); - } -} - -#elif defined(KINETISL) -#define MULTI_UNITYGAIN 256 - -static void applyGain(int16_t *data, int32_t mult) -{ - const int16_t *end = data + AUDIO_BLOCK_SAMPLES; - - do { - int32_t val = *data * mult; - *data++ = signed_saturate_rshift(val, 16, 0); - } while (data < end); -} - -static void applyGainThenAdd(int16_t *dst, const int16_t *src, int32_t mult) -{ - const int16_t *end = dst + AUDIO_BLOCK_SAMPLES; - - if (mult == MULTI_UNITYGAIN) { - do { - int32_t val = *dst + *src++; - *dst++ = signed_saturate_rshift(val, 16, 0); - } while (dst < end); - } else { - do { - int32_t val = *dst + ((*src++ * mult) >> 8); // overflow possible?? - *dst++ = signed_saturate_rshift(val, 16, 0); - } while (dst < end); - } -} - -#endif - -void AudioMixer8::update(void) -{ - audio_block_t *in, *out=NULL; - unsigned int channel; - - for (channel=0; channel < 8; channel++) { - if (!out) { - out = receiveWritable(channel); - if (out) { - int32_t mult = multiplier[channel]; - if (mult != MULTI_UNITYGAIN) applyGain(out->data, mult); - } - } else { - in = receiveReadOnly(channel); - if (in) { - applyGainThenAdd(out->data, in->data, multiplier[channel]); - release(in); - } - } - } - if (out) { - transmit(out); - release(out); - } -} diff --git a/mixer8.h b/mixer8.h deleted file mode 100644 index c23213f..0000000 --- a/mixer8.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Audio Library for Teensy 3.X - * Copyright (c) 2014, Paul Stoffregen, paul@pjrc.com - * - * Development of this audio library was funded by PJRC.COM, LLC by sales of - * Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop - * open source software by purchasing Teensy or other PJRC products. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice, development funding notice, and this permission - * notice shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef mixer8_h_ -#define mixer8_h_ - -#include "Arduino.h" -#include "AudioStream.h" - -class AudioMixer8 : public AudioStream -{ -#if defined(__ARM_ARCH_7EM__) -public: - AudioMixer8(void) : AudioStream(8, inputQueueArray) { - for (int i=0; i<8; i++) multiplier[i] = 65536; - } - virtual void update(void); - void gain(unsigned int channel, float gain) { - if (channel >= 8) return; - if (gain > 32767.0f) gain = 32767.0f; - else if (gain < -32767.0f) gain = -32767.0f; - multiplier[channel] = gain * 65536.0f; // TODO: proper roundoff? - } -private: - int32_t multiplier[8]; - audio_block_t *inputQueueArray[8]; - -#elif defined(KINETISL) -public: - AudioMixer8(void) : AudioStream(8, inputQueueArray) { - for (int i=0; i<8; i++) multiplier[i] = 256; - } - virtual void update(void); - void gain(unsigned int channel, float gain) { - if (channel >= 8) return; - if (gain > 127.0f) gain = 127.0f; - else if (gain < -127.0f) gain = -127.0f; - multiplier[channel] = gain * 256.0f; // TODO: proper roundoff? - } -private: - int16_t multiplier[8]; - audio_block_t *inputQueueArray[8]; -#endif -}; - -#endif