Added freeverb as float version with stereo inputs.

pull/41/head
Holger Wirtz 4 years ago
parent 2288a84fd3
commit 72461d009c
  1. 17
      MicroDexed.ino
  2. 9
      UI.hpp
  3. 10
      config.h
  4. 55
      effect_freeverbf.cpp
  5. 2
      effect_freeverbf.h

@ -67,8 +67,7 @@ AudioMixer4 reverb_mixer_l;
#ifdef USE_PLATEREVERB
AudioEffectPlateReverb reverb;
#else
AudioEffectFreeverb freeverb_r;
AudioEffectFreeverb freeverb_l;
AudioEffectFreeverbStereoFloat freeverb;
#endif
#endif
AudioMixer4 master_mixer_r;
@ -95,10 +94,10 @@ AudioConnection patchCord1(reverb_mixer_l, 0, reverb, 1);
AudioConnection patchCord2(reverb, 0, master_mixer_r, 3);
AudioConnection patchCord3(reverb, 1, master_mixer_l, 3);
#else
AudioConnection patchCord0(reverb_mixer_r, freeverb_r);
AudioConnection patchCord1(reverb_mixer_l, freeverb_l);
AudioConnection patchCord2(freeverb_r, 0, master_mixer_r, 3);
AudioConnection patchCord3(freeverb_l, 0, master_mixer_l, 3);
AudioConnection patchCord0(reverb_mixer_r, 0, freeverb, 0);
AudioConnection patchCord1(reverb_mixer_l, 0, freeverb, 1);
AudioConnection patchCord2(freeverb, 0, master_mixer_r, 3);
AudioConnection patchCord3(freeverb, 1, master_mixer_l, 3);
#endif
#endif
#if defined(ANTIALIAS_FRQ)
@ -1895,10 +1894,8 @@ void set_fx_params(void)
reverb.hidamp(mapfloat(configuration.fx.reverb_hidamp, REVERB_HIDAMP_MIN, REVERB_HIDAMP_MAX, 0.0, 1.0));
reverb.diffusion(mapfloat(configuration.fx.reverb_diffusion, REVERB_DIFFUSION_MIN, REVERB_DIFFUSION_MAX, 0.0, 1.0));
#else
freeverb_r.roomsize(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
freeverb_r.damping(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
freeverb_l.roomsize(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
freeverb_l.damping(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
freeverb.roomsize(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
freeverb.damping(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
#endif
master_mixer_r.gain(3, pseudo_log_curve(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0)));

@ -88,8 +88,7 @@ extern AudioMixer4 reverb_mixer_l;
#ifdef USE_PLATEREVERB
extern AudioEffectPlateReverb reverb;
#else
extern AudioEffectFreeverb freeverb_r;
extern AudioEffectFreeverb freeverb_l;
extern AudioEffectFreeverbStereoFloat freeverb;
#endif
#endif
extern AudioMixer4 master_mixer_r;
@ -945,8 +944,7 @@ void UI_func_reverb_roomsize(uint8_t param)
#ifdef USE_PLATEREVERB
reverb.size(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
#else
freeverb_r.roomsize(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
freeverb_l.roomsize(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
freeverb.roomsize(mapfloat(configuration.fx.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
#endif
}
@ -981,8 +979,7 @@ void UI_func_reverb_damping(uint8_t param)
lcd_display_bar_int("Reverb Damp.", configuration.fx.reverb_damping, 1.0, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 3, false, false, false);
freeverb_l.damping(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
freeverb_r.damping(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
freeverb.damping(mapfloat(configuration.fx.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
}
if (LCDML.FUNC_close()) // ****** STABLE END *********

@ -58,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.16"
#define VERSION "1.0.17"
//*************************************************************************************************
//* DEVICE SETTINGS
@ -130,9 +130,9 @@
#ifndef TEENSY_AUDIO_BOARD
#if AUDIO_BLOCK_SAMPLES == 64
#define AUDIO_MEM 512
#define AUDIO_MEM 400
#else
#define AUDIO_MEM 384
#define AUDIO_MEM 256
#endif
#else // IF TEENSY_AUDIO_BOARD
/*
@ -160,9 +160,9 @@
#endif
#if AUDIO_BLOCK_SAMPLES == 64
#define AUDIO_MEM 512
#define AUDIO_MEM 400
#else
#define AUDIO_MEM 384
#define AUDIO_MEM 256
#endif
#if NUM_DEXED > 1

@ -246,7 +246,7 @@ void AudioEffectFreeverbFloat::update()
}
AudioEffectFreeverbStereoFloat::AudioEffectFreeverbStereoFloat() : AudioStream(1, inputQueueArray)
AudioEffectFreeverbStereoFloat::AudioEffectFreeverbStereoFloat() : AudioStream(2, inputQueueArray)
{
for (unsigned int i = 0; i < sizeof(comb1bufL) / sizeof(float); i++) comb1bufL[i] = 0.0;
for (unsigned int i = 0; i < sizeof(comb2bufL) / sizeof(float); i++) comb2bufL[i] = 0.0;
@ -320,76 +320,82 @@ AudioEffectFreeverbStereoFloat::AudioEffectFreeverbStereoFloat() : AudioStream(1
void AudioEffectFreeverbStereoFloat::update()
{
#if defined(__ARM_ARCH_7EM__)
const audio_block_t *block;
const audio_block_t *blockL;
const audio_block_t *blockR;
audio_block_t *outblockL;
audio_block_t *outblockR;
int i;
float input, bufout, outputL, outputR;
float inputL, inputR, bufout, outputL, outputR;
float sum;
block = receiveReadOnly(0);
blockL = receiveReadOnly(0);
blockR = receiveReadOnly(0);
outblockL = allocate();
outblockR = allocate();
if (!outblockL || !outblockR) {
if (outblockL) release(outblockL);
if (outblockR) release(outblockR);
if (block) release((audio_block_t *)block);
if (blockL) release((audio_block_t *)blockL);
if (blockR) release((audio_block_t *)blockR);
return;
}
if (!block) block = &zeroblock;
if (!blockL) blockL = &zeroblock;
if (!blockR) blockR = &zeroblock;
for (i = 0; i < AUDIO_BLOCK_SAMPLES; i++) {
// TODO: scale numerical range depending on roomsize & damping
//input = sat16(block->data[i] * 8738.0, 17); // for numerical headroom
input = block->data[i] / 32768.0;
inputL = blockL->data[i] / 32768.0;
inputR = blockR->data[i] / 32768.0;
sum = 0;
bufout = comb1bufL[comb1indexL];
sum += bufout;
comb1filterL = bufout * combdamp2 + comb1filterL * combdamp1;
comb1bufL[comb1indexL] = input + comb1filterL * combfeeback;
comb1bufL[comb1indexL] = inputL + comb1filterL * combfeeback;
if (++comb1indexL >= sizeof(comb1bufL) / sizeof(float)) comb1indexL = 0;
bufout = comb2bufL[comb2indexL];
sum += bufout;
comb2filterL = bufout * combdamp2 + comb2filterL * combdamp1;
comb2bufL[comb2indexL] = input + comb2filterL * combfeeback;
comb2bufL[comb2indexL] = inputL + comb2filterL * combfeeback;
if (++comb2indexL >= sizeof(comb2bufL) / sizeof(float)) comb2indexL = 0;
bufout = comb3bufL[comb3indexL];
sum += bufout;
comb3filterL = bufout * combdamp2 + comb3filterL * combdamp1;
comb3bufL[comb3indexL] = input + comb3filterL * combfeeback;
comb3bufL[comb3indexL] = inputL + comb3filterL * combfeeback;
if (++comb3indexL >= sizeof(comb3bufL) / sizeof(float)) comb3indexL = 0;
bufout = comb4bufL[comb4indexL];
sum += bufout;
comb4filterL = bufout * combdamp2 + comb4filterL * combdamp1;
comb4bufL[comb4indexL] = input + comb4filterL * combfeeback;
comb4bufL[comb4indexL] = inputL + comb4filterL * combfeeback;
if (++comb4indexL >= sizeof(comb4bufL) / sizeof(float)) comb4indexL = 0;
bufout = comb5bufL[comb5indexL];
sum += bufout;
comb5filterL = bufout * combdamp2 + comb5filterL * combdamp1;
comb5bufL[comb5indexL] = input + comb5filterL * combfeeback;
comb5bufL[comb5indexL] = inputL + comb5filterL * combfeeback;
if (++comb5indexL >= sizeof(comb5bufL) / sizeof(float)) comb5indexL = 0;
bufout = comb6bufL[comb6indexL];
sum += bufout;
comb6filterL = bufout * combdamp2 + comb6filterL * combdamp1;
comb6bufL[comb6indexL] = input + comb6filterL * combfeeback;
comb6bufL[comb6indexL] = inputL + comb6filterL * combfeeback;
if (++comb6indexL >= sizeof(comb6bufL) / sizeof(float)) comb6indexL = 0;
bufout = comb7bufL[comb7indexL];
sum += bufout;
comb7filterL = bufout * combdamp2 + comb7filterL * combdamp1;
comb7bufL[comb7indexL] = input + comb7filterL * combfeeback;
comb7bufL[comb7indexL] = inputL + comb7filterL * combfeeback;
if (++comb7indexL >= sizeof(comb7bufL) / sizeof(float)) comb7indexL = 0;
bufout = comb8bufL[comb8indexL];
sum += bufout;
comb8filterL = bufout * combdamp2 + comb8filterL * combdamp1;
comb8bufL[comb8indexL] = input + comb8filterL * combfeeback;
comb8bufL[comb8indexL] = inputL + comb8filterL * combfeeback;
if (++comb8indexL >= sizeof(comb8bufL) / sizeof(float)) comb8indexL = 0;
//outputL = sat16(sum * 31457, 17);
@ -400,49 +406,49 @@ void AudioEffectFreeverbStereoFloat::update()
bufout = comb1bufR[comb1indexR];
sum += bufout;
comb1filterR = bufout * combdamp2 + comb1filterR * combdamp1;
comb1bufR[comb1indexR] = input + comb1filterR * combfeeback;
comb1bufR[comb1indexR] = inputR + comb1filterR * combfeeback;
if (++comb1indexR >= sizeof(comb1bufR) / sizeof(float)) comb1indexR = 0;
bufout = comb2bufR[comb2indexR];
sum += bufout;
comb2filterR = bufout * combdamp2 + comb2filterR * combdamp1;
comb2bufR[comb2indexR] = input + comb2filterR * combfeeback;
comb2bufR[comb2indexR] = inputR + comb2filterR * combfeeback;
if (++comb2indexR >= sizeof(comb2bufR) / sizeof(float)) comb2indexR = 0;
bufout = comb3bufR[comb3indexR];
sum += bufout;
comb3filterR = bufout * combdamp2 + comb3filterR * combdamp1;
comb3bufR[comb3indexR] = input + comb3filterR * combfeeback;
comb3bufR[comb3indexR] = inputR + comb3filterR * combfeeback;
if (++comb3indexR >= sizeof(comb3bufR) / sizeof(float)) comb3indexR = 0;
bufout = comb4bufR[comb4indexR];
sum += bufout;
comb4filterR = bufout * combdamp2 + comb4filterR * combdamp1;
comb4bufR[comb4indexR] = input + comb4filterR * combfeeback;
comb4bufR[comb4indexR] = inputR + comb4filterR * combfeeback;
if (++comb4indexR >= sizeof(comb4bufR) / sizeof(float)) comb4indexR = 0;
bufout = comb5bufR[comb5indexR];
sum += bufout;
comb5filterR = bufout * combdamp2 + comb5filterR * combdamp1;
comb5bufR[comb5indexR] = input + comb5filterR * combfeeback;
comb5bufR[comb5indexR] = inputR + comb5filterR * combfeeback;
if (++comb5indexR >= sizeof(comb5bufR) / sizeof(float)) comb5indexR = 0;
bufout = comb6bufR[comb6indexR];
sum += bufout;
comb6filterR = bufout * combdamp2 + comb6filterR * combdamp1;
comb6bufR[comb6indexR] = input + comb6filterR * combfeeback;
comb6bufR[comb6indexR] = inputR + comb6filterR * combfeeback;
if (++comb6indexR >= sizeof(comb6bufR) / sizeof(float)) comb6indexR = 0;
bufout = comb7bufR[comb7indexR];
sum += bufout;
comb7filterR = bufout * combdamp2 + comb7filterR * combdamp1;
comb7bufR[comb7indexR] = input + comb7filterR * combfeeback;
comb7bufR[comb7indexR] = inputR + comb7filterR * combfeeback;
if (++comb7indexR >= sizeof(comb7bufR) / sizeof(float)) comb7indexR = 0;
bufout = comb8bufR[comb8indexR];
sum += bufout;
comb8filterR = bufout * combdamp2 + comb8filterR * combdamp1;
comb8bufR[comb8indexR] = input + comb8filterR * combfeeback;
comb8bufR[comb8indexR] = inputR + comb8filterR * combfeeback;
if (++comb8indexR >= sizeof(comb8bufR) / sizeof(float)) comb8indexR = 0;
//outputR = sat16(sum * 31457, 17);
@ -500,7 +506,8 @@ void AudioEffectFreeverbStereoFloat::update()
transmit(outblockR, 1);
release(outblockL);
release(outblockR);
if (block != &zeroblock) release((audio_block_t *)block);
if (blockL != &zeroblock) release((audio_block_t *)blockL);
if (blockR != &zeroblock) release((audio_block_t *)blockR);
#elif defined(KINETISL)
audio_block_t *block;

@ -116,7 +116,7 @@ class AudioEffectFreeverbStereoFloat : public AudioStream
__enable_irq();
}
private:
audio_block_t *inputQueueArray[1];
audio_block_t *inputQueueArray[2];
float comb1bufL[1116];
float comb2bufL[1188];
float comb3bufL[1277];

Loading…
Cancel
Save