tube: fix oversampling
the original cascade was missing a first-order filter entirely! N is incremented so the cascade is only second-order filters which allows minimal changes to the code. additionally the output sample is from the last zero-padding for a slightly better phase response.
This commit is contained in:
parent
1b1e4353fb
commit
7545689477
2 changed files with 18 additions and 18 deletions
|
@ -37,8 +37,6 @@ white noise generator. loud, full-range, 0dBFS. don't say i didn't warn you.
|
|||
__crap\_tube (0x50F7BA11)__
|
||||
|
||||
static waveshaper with 4x oversampling, sounds kinda like a tube i guess?
|
||||
be aware that its oversampling currently boosts top-most frequencies by
|
||||
~2dB before attenuating.
|
||||
|
||||
### crap delay test
|
||||
|
||||
|
@ -60,6 +58,7 @@ other targets:
|
|||
|
||||
## TODO
|
||||
|
||||
* spaces-in-paths support in Makefile
|
||||
* rename plugins (fix capitalization consistency and such)
|
||||
* reduce input/output buffers on biquads (shared)
|
||||
* ease up on the preprocessor ifs
|
||||
|
|
33
crap/tube.h
33
crap/tube.h
|
@ -11,7 +11,7 @@
|
|||
#define COPYRIGHT "MIT"
|
||||
#define PARAMETERS 2
|
||||
|
||||
#define HIST_SIZE_2 (2 + 2*10)
|
||||
#define HIST_SIZE_2 (2 + 2*11)
|
||||
#define HIST_SIZE (HIST_SIZE_2*2)
|
||||
|
||||
typedef struct {
|
||||
|
@ -67,21 +67,22 @@ static double
|
|||
oversample(double h[HIST_SIZE_2], double x)
|
||||
{
|
||||
/* designed with <https://coewww.rutgers.edu/~orfanidi/hpeq/>
|
||||
fs = 44100; OS = 4; Gs = -120; f2 = 18248/fs/OS; f2s = 22050/fs/OS;
|
||||
N = hpeqord(-Inf,0,Gs,-6,2*pi*f2s,2*pi*f2,2) % 20.9971490662433
|
||||
fs = 44100; OS = 4; Gs = -120; f2 = 18544/fs/OS; f2s = 22050/fs/OS;
|
||||
N = hpeqord(-Inf,0,Gs,-6,2*pi*f2s,2*pi*f2,2) % 21.9986847697467
|
||||
*/
|
||||
double y;
|
||||
LOWPASS(0, +0.65855672,-0.92949215,-1.56012668,+0.94774797);
|
||||
LOWPASS(1, +0.61716958,-0.85685555,-1.47099672,+0.84848033);
|
||||
LOWPASS(2, +0.56959704,-0.76263107,-1.37527450,+0.75183750);
|
||||
LOWPASS(3, +0.51503506,-0.64652564,-1.27052746,+0.65407194);
|
||||
LOWPASS(4, +0.45328074,-0.50918096,-1.15569311,+0.55307363);
|
||||
LOWPASS(5, +0.38524858,-0.35361043,-1.03185791,+0.44874463);
|
||||
LOWPASS(6, +0.31367929,-0.18703461,-0.90341296,+0.34373693);
|
||||
LOWPASS(7, +0.24382090,-0.02260789,-0.77918770,+0.24422161);
|
||||
LOWPASS(8, +0.18353302,+0.12028336,-0.67260228,+0.15995168);
|
||||
LOWPASS(9, +0.14205849,+0.21898074,-0.59952639,+0.10262410);
|
||||
BQSHIFT(10);
|
||||
LOWPASS( 0,+0.68211844,-0.96291784,-1.54972173,+0.95104078);
|
||||
LOWPASS( 1,+0.64259794,-0.89367078,-1.46615406,+0.85767914);
|
||||
LOWPASS( 2,+0.59754712,-0.80432534,-1.37570293,+0.76647184);
|
||||
LOWPASS( 3,+0.54606830,-0.69425498,-1.27603271,+0.67391434);
|
||||
LOWPASS( 4,+0.48770451,-0.56343052,-1.16582052,+0.57779902);
|
||||
LOWPASS( 5,+0.42283783,-0.41357065,-1.04538942,+0.47749444);
|
||||
LOWPASS( 6,+0.35328311,-0.24971266,-0.91771844,+0.37457200);
|
||||
LOWPASS( 7,+0.28296589,-0.08195448,-0.78962026,+0.27359756);
|
||||
LOWPASS( 8,+0.21832227,+0.07351444,-0.67243388,+0.18259286);
|
||||
LOWPASS( 9,+0.16778186,+0.19566401,-0.58109077,+0.11231849);
|
||||
LOWPASS(10,+0.13979560,+0.26348229,-0.53059324,+0.07366673);
|
||||
BQSHIFT(11);
|
||||
return y;
|
||||
}
|
||||
|
||||
|
@ -101,10 +102,10 @@ process_os(personal *data, double x, int right)
|
|||
#define doit(SAMP) \
|
||||
oversample(h1, process_one(4*oversample(h0, SAMP), \
|
||||
smooth(&data->drive), smooth(&data->wet)))
|
||||
y = doit(x);
|
||||
doit(0);
|
||||
doit(x);
|
||||
doit(0);
|
||||
doit(0);
|
||||
y = doit(0);
|
||||
#undef doit
|
||||
|
||||
return y;
|
||||
|
|
Loading…
Reference in a new issue