Trying to fix Drums with FX.

pull/48/head
Holger Wirtz 3 years ago
parent 3ad706aaf4
commit 912684b132
  1. 84
      MicroDexed.ino
  2. 1
      UI.hpp
  3. 7
      config.h
  4. 132
      mixer8.cpp
  5. 69
      mixer8.h

@ -35,7 +35,6 @@
#include "effect_modulated_delay.h" #include "effect_modulated_delay.h"
#include "effect_stereo_mono.h" #include "effect_stereo_mono.h"
#include "effect_mono_stereo.h" #include "effect_mono_stereo.h"
//#include "mixer8.h"
#ifdef USE_PLATEREVERB #ifdef USE_PLATEREVERB
#include "effect_platervbstereo.h" #include "effect_platervbstereo.h"
#else #else
@ -77,10 +76,6 @@ AudioAmplifier volume_l;
AudioEffectStereoMono stereo2mono; AudioEffectStereoMono stereo2mono;
AudioAnalyzePeak master_peak_r; AudioAnalyzePeak master_peak_r;
AudioAnalyzePeak master_peak_l; AudioAnalyzePeak master_peak_l;
#if defined(ANTIALIAS_FRQ)
AudioFilterBiquad antialias_r;
AudioFilterBiquad antialias_l;
#endif
#if defined(TEENSY_AUDIO_BOARD) && defined(SGTL5000_AUDIO_THRU) #if defined(TEENSY_AUDIO_BOARD) && defined(SGTL5000_AUDIO_THRU)
AudioMixer4 audio_thru_mixer_r; AudioMixer4 audio_thru_mixer_r;
AudioMixer4 audio_thru_mixer_l; 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); AudioConnection patchCord3(freeverb, 1, master_mixer_l, 3);
#endif #endif
#endif #endif
#if defined(ANTIALIAS_FRQ) AudioConnection patchCord4(master_mixer_r, volume_r);
AudioConnection patchCord6(master_mixer_r, antialias_r); AudioConnection patchCord5(master_mixer_l, volume_l);
AudioConnection patchCord7(master_mixer_l, antialias_l); AudioConnection patchCord6(volume_r, 0, stereo2mono, 0);
AudioConnection patchCord8(antialias_r, volume_r); AudioConnection patchCord7(volume_l, 0, stereo2mono, 1);
AudioConnection patchCord9(antialias_l, volume_l); AudioConnection patchCord8(stereo2mono, 0, master_peak_r, 0);
#else AudioConnection patchCord9(stereo2mono, 0, master_peak_l, 0);
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);
// Outputs // Outputs
#if defined(TEENSY_AUDIO_BOARD) #if defined(TEENSY_AUDIO_BOARD)
AudioOutputI2S i2s1; AudioOutputI2S i2s1;
#ifndef SGTL5000_AUDIO_THRU #ifndef SGTL5000_AUDIO_THRU
AudioConnection patchCord14(stereo2mono, 0, i2s1, 0); AudioConnection patchCord10(stereo2mono, 0, i2s1, 0);
AudioConnection patchCord15(stereo2mono, 1, i2s1, 1); AudioConnection patchCord11(stereo2mono, 1, i2s1, 1);
#endif #endif
AudioControlSGTL5000 sgtl5000_1; AudioControlSGTL5000 sgtl5000_1;
#elif defined (I2S_AUDIO_ONLY) #elif defined (I2S_AUDIO_ONLY)
AudioOutputI2S i2s1; AudioOutputI2S i2s1;
AudioConnection patchCord14(stereo2mono, 0, i2s1, 0); AudioConnection patchCord10(stereo2mono, 0, i2s1, 0);
AudioConnection patchCord15(stereo2mono, 1, i2s1, 1); AudioConnection patchCord11(stereo2mono, 1, i2s1, 1);
#elif defined(TGA_AUDIO_BOARD) #elif defined(TGA_AUDIO_BOARD)
AudioOutputI2S i2s1; AudioOutputI2S i2s1;
AudioConnection patchCord14(stereo2mono, 0, i2s1, 0); AudioConnection patchCord10(stereo2mono, 0, i2s1, 0);
AudioConnection patchCord15(stereo2mono, 1, i2s1, 1); AudioConnection patchCord11(stereo2mono, 1, i2s1, 1);
AudioControlWM8731master wm8731_1; AudioControlWM8731master wm8731_1;
#elif defined(PT8211_AUDIO) #elif defined(PT8211_AUDIO)
AudioOutputPT8211 pt8211_1; AudioOutputPT8211 pt8211_1;
AudioConnection patchCord14(stereo2mono, 0, pt8211_1, 0); AudioConnection patchCord10(stereo2mono, 0, pt8211_1, 0);
AudioConnection patchCord15(stereo2mono, 1, pt8211_1, 1); AudioConnection patchCord11(stereo2mono, 1, pt8211_1, 1);
#elif defined(TEENSY_DAC_SYMMETRIC) #elif defined(TEENSY_DAC_SYMMETRIC)
AudioOutputAnalogStereo dacOut; AudioOutputAnalogStereo dacOut;
AudioMixer4 invMixer; AudioMixer4 invMixer;
AudioConnection patchCord14(stereo2mono, 0, dacOut , 0); AudioConnection patchCord10(stereo2mono, 0, dacOut , 0);
AudioConnection patchCord15(stereo2mono, 1, invMixer, 0); AudioConnection patchCord11(stereo2mono, 1, invMixer, 0);
AudioConnection patchCord16(invMixer, 0, dacOut , 1); AudioConnection patchCord12(invMixer, 0, dacOut , 1);
#elif defined(TEENSY_DAC) #elif defined(TEENSY_DAC)
AudioOutputAnalogStereo dacOut; AudioOutputAnalogStereo dacOut;
AudioConnection patchCord14(stereo2mono, 0, dacOut, 0); AudioConnection patchCord10(stereo2mono, 0, dacOut, 0);
AudioConnection patchCord15(stereo2mono, 1, dacOut, 1); AudioConnection patchCord11(stereo2mono, 1, dacOut, 1);
#endif #endif
#ifdef AUDIO_DEVICE_USB #ifdef AUDIO_DEVICE_USB
AudioOutputUSB usb1; AudioOutputUSB usb1;
AudioConnection patchCord17(stereo2mono, 0, usb1, 0); AudioConnection patchCord13(stereo2mono, 0, usb1, 0);
AudioConnection patchCord18(stereo2mono, 1, usb1, 1); AudioConnection patchCord14(stereo2mono, 1, usb1, 1);
#endif #endif
#if defined(TEENSY_AUDIO_BOARD) && defined(SGTL5000_AUDIO_THRU) #if defined(TEENSY_AUDIO_BOARD) && defined(SGTL5000_AUDIO_THRU)
AudioInputI2S i2s1in; AudioInputI2S i2s1in;
AudioConnection patchCord19(stereo2mono, 0, audio_thru_mixer_r, 0); AudioConnection patchCord15(stereo2mono, 0, audio_thru_mixer_r, 0);
AudioConnection patchCord20(stereo2mono, 1, audio_thru_mixer_l, 0); AudioConnection patchCord16(stereo2mono, 1, audio_thru_mixer_l, 0);
AudioConnection patchCord21(i2s1in, 0, audio_thru_mixer_r, 1); AudioConnection patchCord17(i2s1in, 0, audio_thru_mixer_r, 1);
AudioConnection patchCord22(i2s1in, 1, audio_thru_mixer_l, 1); AudioConnection patchCord18(i2s1in, 1, audio_thru_mixer_l, 1);
AudioConnection patchCord23(audio_thru_mixer_r, 0, i2s1, 0); AudioConnection patchCord19(audio_thru_mixer_r, 0, i2s1, 0);
AudioConnection patchCord24(audio_thru_mixer_l, 0, i2s1, 1); AudioConnection patchCord20(audio_thru_mixer_l, 0, i2s1, 1);
#endif #endif
#ifdef NUM_DRUMS #ifdef NUM_DRUMS
#ifdef USE_FX #ifdef USE_FX
AudioConnection patchCord25(drum_mixer_r, 0, reverb_mixer_r, 4); AudioConnection patchCord21(drum_mixer_r, 0, reverb_mixer_r, 2);
AudioConnection patchCord26(drum_mixer_l, 0, reverb_mixer_l, 4); AudioConnection patchCord22(drum_mixer_l, 0, reverb_mixer_l, 2);
AudioConnection patchCord27(drum_mixer_r, 0, master_mixer_r, 2); AudioConnection patchCord23(drum_mixer_r, 0, master_mixer_r, 2);
AudioConnection patchCord28(drum_mixer_l, 0, master_mixer_l, 2); AudioConnection patchCord24(drum_mixer_l, 0, master_mixer_l, 2);
#else #else
AudioConnection patchCord25(drum_mixer_r, 0, master_mixer_r, 2); AudioConnection patchCord21(drum_mixer_r, 0, master_mixer_r, 2);
AudioConnection patchCord26(drum_mixer_l, 0, master_mixer_l, 2); AudioConnection patchCord22(drum_mixer_l, 0, master_mixer_l, 2);
#endif #endif
#endif #endif
@ -2053,8 +2041,10 @@ void set_fx_params(void)
#endif #endif
#ifdef NUM_DRUMS #ifdef NUM_DRUMS
reverb_mixer_r.gain(4, 1.0); #ifdef USE_FX
reverb_mixer_l.gain(4, 1.0); reverb_mixer_r.gain(2, 1.0); // Drums-Send
reverb_mixer_l.gain(2, 1.0); // Drums-Send
#endif
#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))); master_mixer_r.gain(3, pseudo_log_curve(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0)));

@ -30,7 +30,6 @@
#include "disp_plus.h" #include "disp_plus.h"
#include "effect_modulated_delay.h" #include "effect_modulated_delay.h"
#include "effect_stereo_mono.h" #include "effect_stereo_mono.h"
//#include "mixer8.h"
#ifdef USE_PLATEREVERB #ifdef USE_PLATEREVERB
#include "effect_platervbstereo.h" #include "effect_platervbstereo.h"
#else #else

@ -99,7 +99,8 @@
//* DEXED AND EFFECTS SETTINGS //* DEXED AND EFFECTS SETTINGS
//************************************************************************************************* //*************************************************************************************************
// Number of Dexed instances // 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! #define NUM_DEXED 1 // 1 or 2 - nothing else!
#else #else
#define NUM_DEXED 2 // 1 or 2 - nothing else! #define NUM_DEXED 2 // 1 or 2 - nothing else!
@ -109,7 +110,7 @@
#define USE_FX 1 #define USE_FX 1
// NUMBER OF SAMPLEDRUMS // NUMBER OF SAMPLEDRUMS
//#define NUM_DRUMS 4 #define NUM_DRUMS 4
#define DRUM_MIDI_CHANNEL 1 #define DRUM_MIDI_CHANNEL 1
// CHORUS parameters // CHORUS parameters
@ -120,7 +121,7 @@
// SGTL5000 // SGTL5000
#ifdef TEENSY_AUDIO_BOARD #ifdef TEENSY_AUDIO_BOARD
#define SGTL5000_AUDIO_ENHANCE 1 #define SGTL5000_AUDIO_ENHANCE 1
#define SGTL5000_AUDIO_THRU 1 //#define SGTL5000_AUDIO_THRU 1
#define SGTL5000_HEADPHONE_VOLUME 0.8 #define SGTL5000_HEADPHONE_VOLUME 0.8
#endif #endif
#if defined(TEENSY4) #if defined(TEENSY4)

@ -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 <Arduino.h>
#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);
}
}

@ -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
Loading…
Cancel
Save