Added IIR filter (1-order, 3-order) for filtering LP-filtering the mdulation

signal at 5000 Hz (just for testing).
dev
Holger Wirtz 5 years ago
parent 5c987723d6
commit 84981851fc
  1. 7
      config.h
  2. 52
      effect_modulated_delay.cpp

@ -56,9 +56,10 @@
#define REDUCE_LOUDNESS 0 #define REDUCE_LOUDNESS 0
#define USE_XFADE_DATA 1 #define USE_XFADE_DATA 1
// CHORUS parameters // CHORUS parameters
#define INTERPOLATION_WINDOW_SIZE 21 // use only odd numbers!!! #define INTERPOLATION_WINDOW_SIZE 7 // use only odd numbers!!!
//#define INTERPOLATE_MODE 11 #define INTERPOLATE_MODE 11
#define CHORUS_WAVEFORM WAVEFORM_SINE // WAVEFORM_SINE WAVEFORM_TRIANGLE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE #define FILTER_IIR_ORDER_3 1
#define CHORUS_WAVEFORM WAVEFORM_TRIANGLE // WAVEFORM_SINE WAVEFORM_TRIANGLE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE
#define CHORUS_DELAY_LENGTH_SAMPLES (15*AUDIO_BLOCK_SAMPLES) // one AUDIO_BLOCK_SAMPLES = 2.902ms; you need doubled length, e.g. delay point is 20ms, so you need up to 40ms delay! #define CHORUS_DELAY_LENGTH_SAMPLES (15*AUDIO_BLOCK_SAMPLES) // one AUDIO_BLOCK_SAMPLES = 2.902ms; you need doubled length, e.g. delay point is 20ms, so you need up to 40ms delay!
//************************************************************************************************* //*************************************************************************************************

@ -26,6 +26,7 @@
#include "limits.h" #include "limits.h"
#include "effect_modulated_delay.h" #include "effect_modulated_delay.h"
#include "spline.h" #include "spline.h"
#include "config.h"
/******************************************************************/ /******************************************************************/
@ -99,7 +100,56 @@ void AudioEffectModulatedDelay::update(void)
// Calculate modulation index as a float, for interpolation later. // Calculate modulation index as a float, for interpolation later.
// The index is located around the half of the delay length multiplied by the current amount of the modulator // The index is located around the half of the delay length multiplied by the current amount of the modulator
mod_idx = float(*mp) / SHRT_MAX * float(_delay_length >> 1); /**************************************************************************************************************
Use an IIR filter on the modulation for avoiding aliasing (http://www-users.cs.york.ac.uk/~fisher/mkfilter/) */
#if defined(FILTER_IIR_ORDER_1)
/* Digital filter designed by mkfilter/mkshape/gencode A.J. Fisher
Command line: /www/usr/fisher/helpers/mkfilter -Bu -Lp -o 1 -a 1.1333499558e-01 0.0000000000e+00 -l
Parameters: filtertype = Butterworth
passtype = Lowpass
ripple =
order = 1
samplerate = 44117.64706
corner1 = 5000
corner2 =
adzero =
logmin =
**************************************************************************************************************/
#define NZEROS 1
#define NPOLES 1
#define GAIN 3.688918967e+00
static float xv[NZEROS + 1], yv[NPOLES + 1];
xv[0] = xv[1];
xv[1] = (float(*mp) / SHRT_MAX) / GAIN;
yv[0] = yv[1];
yv[1] = (xv[0] + xv[1]) + (0.4578357460 * yv[0]);
//new_value = yv[1];
mod_idx = yv[1] * float(_delay_length >> 1);
#elif defined(FILTER_IIR_ORDER_3)
/* Digital filter designed by mkfilter/mkshape/gencode A.J. Fisher
Command line: /www/usr/fisher/helpers/mkfilter -Bu -Lp -o 3 -a 1.1333333333e-01 0.0000000000e+00 -l
raw alpha1 = 0.1133333333
raw alpha2 = 0.1133333333
warped alpha1 = 0.1183783855
warped alpha2 = 0.1183783855
gain at dc : mag = 4.028005941e+01 phase = 0.0000000000 pi
gain at centre: mag = 2.848230315e+01 phase = -0.7500000000 pi
gain at hf : mag = 0.000000000e+00
**************************************************************************************************************/
#define NZEROS 3
#define NPOLES 3
#define GAIN 4.028005941e+01
static float xv[NZEROS + 1], yv[NPOLES + 1];
xv[0] = xv[1]; xv[1] = xv[2]; xv[2] = xv[3];
xv[3] = (float(*mp) / SHRT_MAX) / GAIN;
yv[0] = yv[1]; yv[1] = yv[2]; yv[2] = yv[3];
yv[3] = (xv[0] + xv[3]) + 3 * (xv[1] + xv[2])
+ ( 0.2323461955 * yv[0]) + ( -1.0299524229 * yv[1])
+ ( 1.5989967885 * yv[2]);
//new_value = yv[3];
mod_idx = yv[3] * float(_delay_length >> 1);
/************************************************************************/
#endif
mod_fraction = modff(mod_idx, &mod_number); mod_fraction = modff(mod_idx, &mod_number);
#ifdef INTERPOLATE_MODE #ifdef INTERPOLATE_MODE

Loading…
Cancel
Save