Commit f78d0b9c authored by Jaromír Mikeš's avatar Jaromír Mikeš

Imported Upstream version 0.9.24

parent b5052dac
......@@ -75,18 +75,14 @@ AmpVTS::setratio (int r)
over8.reset();
}
template <yield_func_t yield>
void
AmpVTS::cycle (uint frames)
{
int r = 2 << (int) getport(0);
setratio(r);
if (r == 8)
subcycle<yield> (frames, over8);
else if (r == 4)
subcycle<yield> (frames, over4);
else
subcycle<yield> (frames, over2);
if (r == 8) subcycle (frames, over8);
else if (r == 4) subcycle (frames, over4);
else subcycle (frames, over2);
}
/* saturating function selection */
......@@ -96,7 +92,7 @@ AmpVTS::cycle (uint frames)
/* rough correction for tonestack model gain differences */
static float tsgain[] = {.639, 1.290, .534, 1.008, .542, .936, .605, 1.146, .211};
template <yield_func_t yield, class Over>
template <class Over>
void
AmpVTS::subcycle (uint frames, Over & over)
{
......@@ -170,7 +166,7 @@ AmpVTS::subcycle (uint frames, Over & over)
a *= makeup;
yield (d, i, a, adding_gain);
d[i] = a;
}
s+=n;d+=n;
......
......@@ -29,8 +29,8 @@
#define AMP_H
#include "dsp/util.h"
#include "dsp/OnePole.h"
#include "dsp/BiQuad.h"
#include "dsp/IIR1.h"
#include "dsp/IIR2.h"
#include "dsp/Oversampler.h"
......@@ -50,8 +50,8 @@ class AmpVTS
DSP::Oversampler<4,32> over4;
DSP::Oversampler<8,64> over8;
DSP::BiQuad<sample_t> lp, biaslp;
DSP::OnePoleHP<sample_t> hp1, dc1, dc2; /* dc blockers */
DSP::IIR2<sample_t> lp, biaslp;
DSP::HP1<sample_t> hp1, dc1, dc2; /* dc blockers */
int model;
DSP::ToneStack tonestack;
......@@ -61,17 +61,14 @@ class AmpVTS
void setratio (int r);
template <yield_func_t F> void cycle (uint frames);
template <yield_func_t F, class Over> void subcycle (uint frames, Over & over);
void cycle (uint frames);
template <class Over> void subcycle (uint frames, Over & over);
public:
static PortInfo port_info[];
void init();
void activate();
void run (uint n) { cycle<store_func> (n); }
void run_adding (uint n) { cycle<adding_func> (n); }
};
#endif /* AMP_H */
......@@ -66,9 +66,8 @@ AutoFilter::activate()
smoothenv.reset();
}
template <yield_func_t F>
void
AutoFilter::one_cycle (uint frames)
AutoFilter::cycle (uint frames)
{
div_t qr = div (frames, blocksize);
int blocks = qr.quot;
......@@ -126,14 +125,14 @@ AutoFilter::one_cycle (uint frames)
svf1.set_f_Q (fmod, Q);
double g = 1.8;
for (uint i = 0; i < n; ++i)
F (d, i, svf1.process<DSP::Polynomial::tanh>(s[i]+normal,g), adding_gain);
d[i] = svf1.process<DSP::Polynomial::tanh>(s[i]+normal,g);
}
else if (svf == 2)
{
svf2.set_f_Q (fmod, Q);
double g = .84*(1-Q) + .21;
for (uint i = 0; i < n; ++i)
F (d, i, svf2.process<DSP::Polynomial::tanh>(s[i]+normal,g), adding_gain);
d[i] = svf2.process<DSP::Polynomial::tanh>(s[i]+normal,g);
}
s += n;
......@@ -155,13 +154,14 @@ AutoFilter::port_info [] =
{ "filter", CTRL_IN | GROUP, {DEFAULT_1 | INTEGER, 0, 1},
"{0:'breathy',1:'fat'}", },
/* 2 */
{ "f (Hz)", CTRL_IN | GROUP, {LOG | DEFAULT_HIGH, 20, 2801} },
{ "f (Hz)", CTRL_IN | GROUP, {LOG | DEFAULT_HIGH, 20, 3400} },
{ "Q", CTRL_IN, {DEFAULT_LOW, 0, 1} },
/* 4 */
{ "depth", CTRL_IN | GROUP, {DEFAULT_1, 0, 1} },
{ "lfo/env", CTRL_IN, {DEFAULT_LOW, 0, 1} },
{ "rate", CTRL_IN | GROUP, {DEFAULT_LOW, 0, 1} },
{ "x/z", CTRL_IN, {DEFAULT_1, 0, 1} },
/* 8 */
{ "in", AUDIO_IN},
{ "out", AUDIO_OUT}
......
......@@ -35,8 +35,8 @@
#include "dsp/Roessler.h"
#include "dsp/RMS.h"
#include "dsp/BiQuad.h"
#include "dsp/OnePole.h"
#include "dsp/IIR2.h"
#include "dsp/IIR1.h"
class AutoFilter
: public Plugin
......@@ -52,20 +52,17 @@ class AutoFilter
DSP::Lorenz lorenz;
/* rms calculation and smoothing */
DSP::OnePoleHP<sample_t> hp;
DSP::HP1<sample_t> hp;
DSP::RMS<128> rms;
DSP::BiQuad<sample_t> smoothenv;
DSP::IIR2<sample_t> smoothenv;
template <yield_func_t F> void one_cycle (uint frames);
void cycle (uint frames);
public:
static PortInfo port_info [];
void init();
void activate();
void run (uint n) { one_cycle<store_func> (n); }
void run_adding (uint n) { one_cycle<adding_func> (n); }
};
#endif /* _AUTO_FILTER_H_ */
0.9.24
* documentation updates including switch to 48k for all spectra
* "twin" and "stanford" tonestack models swap places
* ChorusI feedback changed to interpolation, softens zipper noise on t changes
* use vestigial FPTruncateMode only on pre-SSE2 hardware
* 4x128 oversampling option removed from Compress plugins
* state port displaying current gain reduction on Compress plugins
* _latency port for parallel Eq
* Saturate fade-in bug eliminated
* Noisegate hysteresis interval lengthened
* Click sounds "stick" brightened and "beep" shortened
* run_adding() removed, reducing binary size by 30 % and compile time similarly
* JVRev tail modified, low-passed
* all ports reordered to consistent ctrl i/o audio i/o order
* Eq4p crossfade reimplemented as equal-power squared cosine, smoother now
* EqFA4p added
* non-SSE v4f_shuffle surrogate fixed
(fixes Eq4p on ARM, reported by Jens Dreske)
* dropped 44.1 kHz ToneStackLT
* OnePole header renamed IIR1, filters renamed LP1 and HP1
* BiQuad header and filter renamed IIR2, SIMD *4f filters renamed *v4
* CabinetIII (less demanding loudspeaker emulation resurrected again)
* ChorusI port ranges and defaults adjusted
* Compress parameter mappings and defaults adjusted
0.9.23
* ChorusI hp filter denormal protection added
......
/*
CabIII.cc
Copyright 2002-14 Tim Goetze <tim@quitte.de>
http://quitte.de/dsp/
Loudspeaker cabinet emulation through IIR filtering.
*/
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA or point your web browser to http://www.gnu.org.
*/
#include "basics.h"
#include "dsp/RBJ.h"
#include "Cabinet.h"
#include "Descriptor.h"
#include "CabIIIModels.h"
void
CabinetIII::init()
{
models = fs > 46000 ? allmodels : allmodels + CabIIIModels;
h = 0;
model = -1;
}
void
CabinetIII::switch_model (int m)
{
model = m;
if (fs > 46000) m += CabIIIModels;
m %= (2*CabIIIModels);
a = models[m].a;
b = models[m].b;
gain = models[m].gain*db2lin(getport(2));
memset(x, 0, sizeof(x));
memset(y, 0, sizeof(y));
}
void
CabinetIII::activate()
{
/* ensure model switch at next run() */
model = -1;
}
void
CabinetIII::cycle (uint frames)
{
int m = (int) getport(0) + CabIIIModels*((int) getport(1));
if (m != model) switch_model (m);
sample_t g = models[model].gain*db2lin (getport(2));
double gf = pow (g/gain, 1/(double) frames);
sample_t * s = ports[3];
sample_t * d = ports[4];
for (uint i = 0; i < frames; ++i)
{
register cabinet_float acc = s[i] + normal;
x[h] = acc;
acc *= a[0];
for(int j=1, z=h-1; j<32; --z,++j)
{
z &= 31;
acc += a[j]*x[z];
acc += b[j]*y[z];
}
y[h] = acc;
d[i] = gain*acc;
h = (h+1) & 31;
gain *= gf;
}
}
/* //////////////////////////////////////////////////////////////////////// */
PortInfo
CabinetIII::port_info [] =
{
{ "model", CTRL_IN, {INTEGER | DEFAULT_1, 0, CabIIIModels-1}, CabIIIModelDict },
{ "alt", CTRL_IN, {INTEGER | DEFAULT_0, 0, 1}, "{0:'off',1:'on',}" },
{ "gain (dB)", CTRL_IN | GROUP, {DEFAULT_0, -24, 24} },
{ "in", INPUT | AUDIO },
{ "out", OUTPUT | AUDIO }
};
/* //////////////////////////////////////////////////////////////////////// */
template <> void
Descriptor<CabinetIII>::setup()
{
Label = "CabinetIII";
Name = CAPS "CabinetIII - Simplistic loudspeaker cabinet emulation";
Maker = "Tim Goetze <tim@quitte.de>";
Copyright = "2002-14";
/* fill port info and vtable */
autogen();
}
This diff is collapsed.
This diff is collapsed.
/*
Cabinet.cc
CabIV.cc
Copyright 2002-12 Tim Goetze <tim@quitte.de>
Copyright 2002-14 Tim Goetze <tim@quitte.de>
http://quitte.de/dsp/
Loudspeaker cabinet emulation through IIR/FIR filtering.
*/
/*
This program is free software; you can redistribute it and/or
......@@ -29,211 +31,6 @@
#include "Cabinet.h"
#include "Descriptor.h"
#include "CabIIModels.h"
void
CabinetII::init()
{
if (fs < 46000)
models = models44100;
else if (fs < 72000)
models = models48000;
else if (fs < 92000)
models = models88200;
else
models = models96000;
h = 0;
model = 0;
}
void
CabinetII::switch_model (int m)
{
model = m;
n = models[m].n;
a = models[m].a;
b = models[m].b;
gain = models[m].gain * db2lin (getport(2));
memset (x, 0, sizeof (x));
memset (y, 0, sizeof (y));
}
void
CabinetII::activate()
{
switch_model ((int) getport(1));
}
template <yield_func_t F>
void
CabinetII::cycle (uint frames)
{
sample_t * s = ports[0];
int m = (int) getport (1);
if (m != model) switch_model (m);
sample_t g = models[model].gain * db2lin (getport(2));
double gf = pow (g / gain, 1 / (double) frames);
sample_t * d = ports[3];
for (uint i = 0; i < frames; ++i)
{
register cabinet_float out = s[i] + normal;
x[h] = out;
out *= a[0];
for (int j = 1, z = h - 1; j < n; --z, ++j)
{
z &= 31;
out += a[j] * x[z];
out += b[j] * y[z];
}
y[h] = out;
h = (h + 1) & 31;
F (d, i, gain * out, adding_gain);
gain *= gf;
}
}
/* //////////////////////////////////////////////////////////////////////// */
PortInfo
CabinetII::port_info [] =
{
{
"in",
INPUT | AUDIO,
{BOUNDED, -1, 1}
}, {
"model",
CTRL_IN,
{INTEGER | DEFAULT_1, 0, 7},
"{1:'unmatched A', 2:'unmatched B', 3:'supertramp', \
4:'little wing 68', 5:'martial', 6:'mega wookie', 7:'pro sr',}"
}, {
"gain (dB)",
CTRL_IN | GROUP,
{DEFAULT_0, -24, 24}
}, {
"out",
OUTPUT | AUDIO,
{0}
}
};
/* //////////////////////////////////////////////////////////////////////// */
template <> void
Descriptor<CabinetII>::setup()
{
Label = "CabinetII";
Name = CAPS "CabinetII - Simplistic loudspeaker cabinet emulation";
Maker = "Tim Goetze <tim@quitte.de>";
Copyright = "2002-12";
/* fill port info and vtable */
autogen();
}
/* //////////////////////////////////////////////////////////////////////// */
#include "CabIIIModels.h"
void
CabinetIII::init()
{
model = -1;
}
void
CabinetIII::switch_model (int m)
{
model = m;
if (model < 0) return;
gain = CabIIIModels[m].gain;
bank.set_a (1, CabIIIModels[m].a1);
bank.set_a (2, CabIIIModels[m].a2);
bank.set_b (1, CabIIIModels[m].b1);
bank.set_b (2, CabIIIModels[m].b2);
bank.reset();
fir.set_kernel (CabIIIModels[m].fir);
fir.reset();
}
void
CabinetIII::activate()
{
switch_model ((int) getport(1));
}
template <yield_func_t F>
void
CabinetIII::cycle (uint frames)
{
sample_t * s = ports[0];
int m = (int) getport (1);
if (m != model) switch_model (m);
sample_t * d = ports[3];
double g = gain * db2lin (getport(2));
for (uint i = 0; i < frames; ++i)
{
sample_t x = s[i];
/* process */
x = g*x + normal;
v4f_t a = (v4f_t) {x,x,x,x};
a = bank.process_no_a0 (a);
x = v4f_sum(a + fir.process(x));
F (d, i, x, adding_gain);
}
}
/* //////////////////////////////////////////////////////////////////////// */
PortInfo
CabinetIII::port_info [] =
{
{ "in", INPUT | AUDIO },
{ "model", CTRL_IN, {INTEGER | DEFAULT_1, 0, 2},
"{0:'wookie A', 1:'wookie B', 2:'wookie C'}" },
{ "gain (dB)", CTRL_IN | GROUP, {DEFAULT_0, -24, 24} },
{ "out", OUTPUT | AUDIO }
};
template <> void
Descriptor<CabinetIII>::setup()
{
Label = "CabinetIII";
Name = CAPS "CabinetIII - Idealised loudspeaker cabinet emulation";
Maker = "Tim Goetze <tim@quitte.de>";
Copyright = "2012-13";
/* fill port info and vtable */
autogen();
}
/* //////////////////////////////////////////////////////////////////////// */
#include "CabIV_64_128.h"
void
......@@ -274,36 +71,31 @@ CabinetIV::switch_model (int m)
void
CabinetIV::activate()
{
switch_model ((int) getport(1));
switch_model ((int) getport(0));
remain = 0;
}
template <yield_func_t F>
void
CabinetIV::cycle (uint frames)
{
static DSP::NoOversampler over1;
if (over == 1)
cycle<F,DSP::NoOversampler,1>(frames,over1);
else if (over == 2)
cycle<F,DSP::Oversampler<2,32>,2>(frames,over2);
else if (over == 4)
cycle<F,DSP::Oversampler<4,64>,4>(frames,over4);
if (over == 1) subcycle<DSP::NoOversampler,1>(frames,over1);
else if (over == 2) subcycle<DSP::Oversampler<2,32>,2>(frames,over2);
else if (over == 4) subcycle<DSP::Oversampler<4,64>,4>(frames,over4);
}
template <yield_func_t F, class O, int Ratio>
template <class O, int Ratio>
void
CabinetIV::cycle (uint frames, O & Over)
CabinetIV::subcycle (uint frames, O & Over)
{
sample_t * s = ports[0];
int m = (int) getport (1);
int m = (int) getport (0);
if (m != model) switch_model (m);
double g = gain * db2lin (getport(1));
sample_t * s = ports[2];
sample_t * d = ports[3];
double g = gain * db2lin (getport(2));
uint n;
/* now we have to jump through some hoops to support odd block sizes
......@@ -321,7 +113,7 @@ CabinetIV::cycle (uint frames, O & Over)
{
Over.downstore(s[i]);
sample_t x = Over.uppad(i+Ratio-remain);
F (d, i, x, adding_gain);
d[i] = x;
}
remain -= n;
......@@ -349,13 +141,13 @@ CabinetIV::cycle (uint frames, O & Over)
x = v4f_sum(a + fir.process(x));
x = Over.upsample (x);
F (d, i, x, adding_gain);
d[i] = x;
for (int o=1; o < Ratio; ++o)
{
Over.downstore(s[++i]);
x = Over.uppad(o);
F (d, i, x, adding_gain);
d[i] = x;
}
}
......@@ -374,7 +166,7 @@ CabinetIV::cycle (uint frames, O & Over)
x = v4f_sum(a + fir.process(x));
x = Over.upsample (x);
F (d, i, x, adding_gain);
d[i] = x;
n = 1+min(frames,remain);
......@@ -383,7 +175,7 @@ CabinetIV::cycle (uint frames, O & Over)
{
Over.downstore(s[++i]);
x = Over.uppad(o);
F (d, i, x, adding_gain);
d[i] = x;
}
}
......@@ -392,9 +184,10 @@ CabinetIV::cycle (uint frames, O & Over)
PortInfo
CabinetIV::port_info [] =
{
{ "in", INPUT | AUDIO },
{ "model", CTRL_IN, {INTEGER | DEFAULT_MID, 0, NCabIVModels-1}, CabIVModelDict },
{ "gain (dB)", CTRL_IN | GROUP, {DEFAULT_0, -24, 24} },
{ "in", INPUT | AUDIO },
{ "out", OUTPUT | AUDIO }
};
......
/*
Cabinet.h
Copyright 2002-13 Tim Goetze <tim@quitte.de>
Copyright 2002-14 Tim Goetze <tim@quitte.de>
http://quitte.de/dsp/
CabinetII - 32nd order IIR filters modeled after existing impulse responses
for 44.1 / 48 / 88.2 / 96 kHz sample rates, switched at runtime.
CabinetIV - IIR/FIR combination filters for cabinet emulation, following
Bank's parfilt approach, see
Bank's parfilt approach (warped Prony), see
Balázs Bank,
"Direct Design of Parallel Second-Order Filters for Instrument Body Modeling",
......@@ -38,53 +35,41 @@
#define CABINET_H
#include "dsp/util.h"
#include "dsp/BiQuad.h"
#include "dsp/Oversampler.h"
#include "dsp/v4f.h"
#include "dsp/v4f_FIR.h"
#include "dsp/v4f_BiQuad.h"
#include "dsp/v4f_IIR2.h"
typedef double cabinet_float;
typedef struct {
int n;
sample_t gain;
cabinet_float a[32], b[32];
float gain;
} Model32;
/* Second version with 32nd order filters precalculated for
* 44.1 / 48 / 88.2 / 96 kHz sample rates */
class CabinetII
class CabinetIII
: public Plugin
{
public:
sample_t gain;
static Model32 models44100 [];
static Model32 models48000 [];
static Model32 models88200 [];
static Model32 models96000 [];
static Model32 allmodels[];
Model32 * models;
int model;
void switch_model (int m);
int n, h;
int h;
cabinet_float * a, * b;
cabinet_float x[32], y[32];
template <yield_func_t F>
void cycle (uint frames);
void cycle (uint frames);
public:
static PortInfo port_info [];
void init();
void activate();
void run (uint n) { cycle<store_func> (n); }
void run_adding (uint n) { cycle<adding_func> (n); }
};
/* /////////////////////////////////////////////////////////////////////// */
......@@ -97,36 +82,6 @@ class ParModel {
float fir[FIR];
};
class CabinetIII
: public Plugin
{
public:
enum {
N = 128/4, /* number of bands/4 */
FIR = 128 /* FIR filter taps */
};
int model;