semi-working MSVC support

i gave up on gcc, it kept producing segfaults.
This commit is contained in:
Connor Olding 2015-12-06 09:49:12 -08:00
parent 156dcd2233
commit 398a72ef13
18 changed files with 348 additions and 151 deletions

33
build.bat Executable file
View File

@ -0,0 +1,33 @@
@ECHO OFF
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat"
cd bin
set vst=../../../src/vstsdk2.4/
set vst2x=%vst%public.sdk/source/vst2.x/
set vstdef=%vst%public.sdk/samples/vst2.x/win/vstplug.def
set vst_c=/LD /I"%vst%"
set vst_ld=/DEF:"%vstdef%"
set vstsrc=%vst2x%audioeffect.cpp %vst2x%audioeffectx.cpp %vst2x%vstplugmain.cpp
set wall=/Wall /wd4100 /wd4668 /wd4820 /wd4514 /wd4365 /wd4711 /wd4996
REM the warning disabled below is function-not-inlined
set common_c=/I"../" /I"../include/" %wall% /wd4710
set release_c=%common_c% /O2 /Oy- /GL /EHsc /fp:fast /analyze- /nologo
set release_ld=
call:compile delay_test
call:compile eq
call:compile eq_const
call:compile eq_const_T420
REM call:compile eq_const_T420_svf
call:compile level
call:compile mugi4
call:compile noise
call:compile tube
goto:eof
:compile
set crap=%~1
cscript ..\util\generate.vbs %crap%
cl %release_c% %vst_c% ../crap/vst/%crap%.cpp %vstsrc% /link %release_ld% %vst_ld% /OUT:"vst/crap_%crap%.dll"
goto:eof

View File

@ -72,12 +72,12 @@ struct channel {
struct Crap_delay_test
:public AdjustAll<Crap> {
static constexpr ulong id = 0xDEDEDEDE;
static constexpr char label[] = "crap_delay_test";
static constexpr char name[] = "crap sample delay test";
static constexpr char author[] = "Connor Olding";
static constexpr char copyright[] = "MIT";
static constexpr ulong parameters = 0;
static const ulong id = 0xDEDEDEDE;
static const char *label;
static const char *name;
static const char *author;
static const char *copyright;
static const ulong parameters = 0;
channel c_L, c_R;
@ -100,8 +100,8 @@ struct Crap_delay_test
ulong count)
{
for (ulong i = 0; i < count; i++) {
out_L[i] = c_L.process(in_L[i]);
out_R[i] = c_R.process(in_R[i]);
out_L[i] = (float)c_L.process(in_L[i]);
out_R[i] = (float)c_R.process(in_R[i]);
}
}
@ -131,7 +131,7 @@ struct Crap_delay_test
}
};
constexpr char Crap_delay_test::label[];
constexpr char Crap_delay_test::name[];
constexpr char Crap_delay_test::author[];
constexpr char Crap_delay_test::copyright[];
const char *Crap_delay_test::label = "crap_delay_test";
const char *Crap_delay_test::name = "crap sample delay test";
const char *Crap_delay_test::author = "Connor Olding";
const char *Crap_delay_test::copyright = "MIT";

View File

@ -9,14 +9,14 @@
struct Crap_eq
:public AdjustAll<Buffer2<Crap>> {
static constexpr ulong id = 0x000CAFED;
static constexpr char label[] = "crap_eq";
static constexpr char name[] = "crap Parametric Equalizer";
static constexpr char author[] = "Connor Olding";
static constexpr char copyright[] = "MIT";
static const ulong bands = 4;
static constexpr ulong bands = 4;
static constexpr ulong parameters = bands*3;
static const ulong id = 0x000CAFED;
static const char *label;
static const char *name;
static const char *author;
static const char *copyright;
static const ulong parameters = bands*3;
biquad filters_L[bands];
biquad filters_R[bands];
@ -88,7 +88,7 @@ struct Crap_eq
}
};
constexpr char Crap_eq::label[];
constexpr char Crap_eq::name[];
constexpr char Crap_eq::author[];
constexpr char Crap_eq::copyright[];
const char *Crap_eq::label = "crap_eq";
const char *Crap_eq::name = "crap Parametric Equalizer";
const char *Crap_eq::author = "Connor Olding";
const char *Crap_eq::copyright = "MIT";

View File

@ -8,14 +8,14 @@
struct Crap_eq_const
:public AdjustAll<Buffer2<Crap>> {
static constexpr ulong id = 0x0DEFACED;
static constexpr char label[] = "crap_eq_const";
static constexpr char name[] = "crap Constant Equalizer";
static constexpr char author[] = "Connor Olding";
static constexpr char copyright[] = "MIT";
static const ulong id = 0x0DEFACED;
static const char *label;
static const char *name;
static const char *author;
static const char *copyright;
static const ulong parameters = 0;
static constexpr ulong bands = 12;
static constexpr ulong parameters = 0;
static const ulong bands = 12;
biquad filters_L[bands];
biquad filters_R[bands];
@ -71,7 +71,7 @@ struct Crap_eq_const
}
};
constexpr char Crap_eq_const::label[];
constexpr char Crap_eq_const::name[];
constexpr char Crap_eq_const::author[];
constexpr char Crap_eq_const::copyright[];
const char *Crap_eq_const::label = "crap_eq_const";
const char *Crap_eq_const::name = "crap Constant Equalizer";
const char *Crap_eq_const::author = "Connor Olding";
const char *Crap_eq_const::copyright = "MIT";

View File

@ -8,14 +8,14 @@
struct Crap_eq_const_T420
:public AdjustAll<Buffer2<Crap>> {
static constexpr ulong id = 0x0DEFACED + 420;
static constexpr char label[] = "crap_eq_const_T420";
static constexpr char name[] = "crap T420 Speaker Compensation";
static constexpr char author[] = "Connor Olding";
static constexpr char copyright[] = "MIT";
static const ulong id = 0x0DEFACED + 420;
static const char *label;
static const char *name;
static const char *author;
static const char *copyright;
static const ulong parameters = 0;
static constexpr ulong bands = 16;
static constexpr ulong parameters = 0;
static const ulong bands = 16;
biquad filters_L[bands];
biquad filters_R[bands];
@ -75,7 +75,7 @@ struct Crap_eq_const_T420
}
};
constexpr char Crap_eq_const_T420::label[];
constexpr char Crap_eq_const_T420::name[];
constexpr char Crap_eq_const_T420::author[];
constexpr char Crap_eq_const_T420::copyright[];
const char *Crap_eq_const_T420::label = "crap_eq_const_T420";
const char *Crap_eq_const_T420::name = "crap T420 Speaker Compensation";
const char *Crap_eq_const_T420::author = "Connor Olding";
const char *Crap_eq_const_T420::copyright = "MIT";

View File

@ -10,14 +10,14 @@
struct Crap_eq_const_T420_svf
:public AdjustAll<Buffer4<Crap>> {
static constexpr ulong id = 0x0DEFACED + 420 + 1337;
static constexpr char label[] = "crap_eq_const_T420_svf";
static constexpr char name[] = "crap T420 Speaker Compensation (SVF)";
static constexpr char author[] = "Connor Olding";
static constexpr char copyright[] = "MIT";
static const ulong id = 0x0DEFACED + 420 + 1337;
static const char *label;
static const char *name;
static const char *author;
static const char *copyright;
static const ulong parameters = 0;
static constexpr ulong bands = 16;
static constexpr ulong parameters = 0;
static const ulong bands = 16;
svf_matrix<v4sf> filters_L[bands];
svf_matrix<v4sf> filters_R[bands];
@ -83,7 +83,7 @@ struct Crap_eq_const_T420_svf
}
};
constexpr char Crap_eq_const_T420_svf::label[];
constexpr char Crap_eq_const_T420_svf::name[];
constexpr char Crap_eq_const_T420_svf::author[];
constexpr char Crap_eq_const_T420_svf::copyright[];
const char *Crap_eq_const_T420_svf::label = "crap_eq_const_T420_svf";
const char *Crap_eq_const_T420_svf::name = "crap T420 Speaker Compensation (SVF)";
const char *Crap_eq_const_T420_svf::author = "Connor Olding";
const char *Crap_eq_const_T420_svf::copyright = "MIT";

View File

@ -12,7 +12,7 @@ static ulong global_delay = 0;
TEMPLATE
struct Delay {
static constexpr ulong size = 4096;
static const ulong size = 4096;
// needs to be twice the size for a memcpy trick later
T buf[size*2];
@ -28,7 +28,7 @@ struct Delay {
};
inline T
delay(T s)
delay(const T &s)
{
pos--;
if (pos <= 0) {
@ -52,14 +52,13 @@ struct Delay {
struct Crap_level
:public AdjustAll<Buffer2<Crap>> {
static constexpr ulong id = 0xAAAAAAAA;
static constexpr char label[] = "crap_level";
static constexpr char name[] = "crap Leveller";
static constexpr char author[] = "Connor Olding";
static constexpr char copyright[] = "MIT";
static constexpr ulong bands = 2;
static constexpr ulong parameters = 0;
static const ulong id = 0xAAAAAAAA;
static const char *label;
static const char *name;
static const char *author;
static const char *copyright;
static const ulong bands = 2;
static const ulong parameters = 0;
v2df sc[BLOCK_SIZE]; // sidechain
biquad filters_L[bands];
@ -80,7 +79,7 @@ struct Crap_level
~Crap_level()
{
if (window)
free(window);
delete window;
}
inline void
@ -89,20 +88,21 @@ struct Crap_level
biquad *f0, *f1;
f0 = filters_L;
f1 = filters_R;
memcpy(sc, buf, rem*sizeof(v2df));
for (ulong i = 0; i < rem; i++)
sc[i] = buf[i];
for (ulong i = 0; i < bands; i++) {
biquad_run_block_stereo(f0, f1, sc, rem);
f0++;
f1++;
}
double envs[rem];
double envs[BLOCK_SIZE];
for (ulong i = 0; i < rem; i++)
envs[i] = fabs(sc[i][0]) + fabs(sc[i][1]);
for (ulong i = 0; i < rem; i++)
envs[i] *= 0.5;
// MaxFIR
double applied[window_size];
double *applied = new double[window_size];
for (ulong i = 0; i < rem; i++) {
window_delay.delay(envs[i]);
for (ulong j = 0; j < window_size; j++)
@ -112,6 +112,7 @@ struct Crap_level
max_ = fmax(max_, applied[j]);
envs[i] = max_;
}
delete applied;
// Follower
for (ulong i = 0; i < rem; i++) {
@ -119,7 +120,7 @@ struct Crap_level
env = fmax(0.00001, env);
envs[i] = env;
}
double gains[rem];
double gains[BLOCK_SIZE];
for (ulong i = 0; i < rem; i++)
gains[i] = 0.3991 - 0.01769/(envs[i] + 0.044);
for (ulong i = 0; i < rem; i++)
@ -153,7 +154,7 @@ struct Crap_level
construct_params(Param *params)
{}
virtual void
void
adjust_all(Param *params)
{
biquad *f = filters_L;
@ -163,15 +164,15 @@ struct Crap_level
filters_R[i] = filters_L[i];
double window_length = fs*0.010/0.60;
window_size = round(window_length);
lookahead = round(window_length*0.6);
window_size = (ulong) round(window_length);
lookahead = (ulong) round(window_length*0.6);
global_delay = lookahead;
if (window)
free(window);
window = (double *) calloc(window_size, sizeof(double));
delete window;
window = new double[window_size];
for (int i = 0; i < window_size; i++) {
for (ulong i = 0; i < window_size; i++) {
double x = double(i)/window_size;
double y = -(x - 0)*(x - 1)*(x + 0.6)/0.288;
window[i] = y;
@ -184,7 +185,7 @@ struct Crap_level
}
};
constexpr char Crap_level::label[];
constexpr char Crap_level::name[];
constexpr char Crap_level::author[];
constexpr char Crap_level::copyright[];
const char *Crap_level::label = "crap_level";
const char *Crap_level::name = "crap Leveller";
const char *Crap_level::author = "Connor Olding";
const char *Crap_level::copyright = "MIT";

View File

@ -21,10 +21,10 @@ https://aaltodoc.aalto.fi/bitstream/handle/123456789/14420/article6.pdf
#define VT 0.026
#define N 4
#define VT2 T(2.*VT)
#define VT2 2.*VT
TEMPLATE INNER PURE T
tanh2(T x)
tanh2(const T &x)
{
//return T(tanh(x[0]), tanh(x[1]));
T xx = x*x;
@ -47,12 +47,12 @@ struct stage {
v2df sum, sumback, dout;
TEMPLATE inline T
process(freqdata fd, T in)
process(const freqdata &fd, const T &in)
{
T temp = (in + sumback)*VT2*fd.L_p0*fd.g;
T temp = (in + sumback)*T(VT2)*fd.L_p0*fd.g;
T out = temp + sum;
sum += T(2)*temp;
dout = tanh2<T>(out/VT2);
dout = tanh2<T>(out/T(VT2));
sumback = in*fd.L_r1 - dout*fd.L_q0;
return out;
}
@ -64,25 +64,26 @@ struct mugi4 {
v2df sumback1, sumback2, sumback3, sumback4;
v2df drive, feedback;
TEMPLATE inline T
process(T in)
inline v2df
process(const v2df &in_)
{
in *= drive;
v2df in = in_*drive;
T sum = in + sumback1;
T pre = -fd.p0*sum;
s1.process<T>(fd, tanh2<T>(pre/VT2));
s2.process<T>(fd, s1.dout);
s3.process<T>(fd, s2.dout);
T out = s4.process<T>(fd, s3.dout);
v2df sum = in + sumback1;
v2df pre = -fd.p0*sum;
v2df temp = tanh2<v2df>(pre/VT2);
s1.process<v2df>(fd, temp);
s2.process<v2df>(fd, s1.dout);
s3.process<v2df>(fd, s2.dout);
v2df out = s4.process<v2df>(fd, s3.dout);
T back = feedback*out;
v2df back = feedback*out;
sumback1 = fd.r1*in + fd.q0*back + sumback2;
sumback2 = fd.r2*in + fd.q1*back + sumback3;
sumback3 = fd.r3*in + fd.q2*back + sumback4;
sumback4 = fd.r4*in + fd.q3*back;
T compensate = -(feedback + T(1));
v2df compensate = -(feedback + v2df(1));
return out/drive*compensate;
}
@ -99,7 +100,7 @@ struct mugi4 {
double bc4 = -1; //-binomial(N, 4);
// apparently fd_set is used by some stdio implementations, so
#define crap_fd_set(L, R) double L = R; fd.L = (v2df){L, L}
#define crap_fd_set(L, R) double L = R; fd.L = v2df(L, L)
crap_fd_set(g, tan(wc));
double gg1 = g/(g + 1);
double gg1Nk = k*gg1*gg1*gg1*gg1;
@ -124,13 +125,12 @@ struct mugi4 {
struct Crap_mugi4
:public AdjustAll<Buffer2OS2<Crap>> {
static constexpr ulong id = 0xD8D0D8D0;
static constexpr char label[] = "crap_mugi4";
static constexpr char name[] = "crap mugi4 (moog-like)";
static constexpr char author[] = "Connor Olding";
static constexpr char copyright[] = "MIT";
static constexpr ulong parameters = 3;
static const ulong id = 0xD8D0D8D0;
static const char *label;
static const char *name;
static const char *author;
static const char *copyright;
static const ulong parameters = 3;
mugi4 filter;
@ -196,7 +196,7 @@ struct Crap_mugi4
}
};
constexpr char Crap_mugi4::label[];
constexpr char Crap_mugi4::name[];
constexpr char Crap_mugi4::author[];
constexpr char Crap_mugi4::copyright[];
const char *Crap_mugi4::label = "crap_mugi4";
const char *Crap_mugi4::name = "crap mugi4 (moog-like)";
const char *Crap_mugi4::author = "Connor Olding";
const char *Crap_mugi4::copyright = "MIT";

View File

@ -6,12 +6,12 @@
struct Crap_noise
:public AdjustAll<Crap> {
static constexpr ulong id = 0xEC57A71C;
static constexpr char label[] = "crap_noise";
static constexpr char name[] = "crap noise generator";
static constexpr char author[] = "Connor Olding";
static constexpr char copyright[] = "MIT";
static constexpr ulong parameters = 0;
static const ulong id = 0xEC57A71C;
static const char *label;
static const char *name;
static const char *author;
static const char *copyright;
static const ulong parameters = 0;
unsigned int mirand_L, mirand_R;
@ -61,7 +61,7 @@ struct Crap_noise
{}
};
constexpr char Crap_noise::label[];
constexpr char Crap_noise::name[];
constexpr char Crap_noise::author[];
constexpr char Crap_noise::copyright[];
const char *Crap_noise::label = "crap_noise";
const char *Crap_noise::name = "crap noise generator";
const char *Crap_noise::author = "Connor Olding";
const char *Crap_noise::copyright = "MIT";

View File

@ -33,13 +33,13 @@ typedef struct {
namespace Tube {
TEMPLATE INNER CONST T
distort(T x)
distort(const T &x)
{
return (T(27.)*x + T(9.)) / (T(9.)*x*x + T(6.)*x + T(19.)) - T(9./19.);
}
TEMPLATE INNER CONST T
process(T x, T drive, T wet)
process(const T &x, const T &drive, const T &wet)
{
return (distort<T>(x*drive)/drive*T(0.79) - x)*wet + x;
}
@ -47,13 +47,12 @@ namespace Tube {
struct Crap_tube
:public Buffer2OS2<Crap> {
static constexpr ulong id = 0x50F7BA11;
static constexpr char label[] = "crap_tube";
static constexpr char name[] = "crap Tube Distortion";
static constexpr char author[] = "Connor Olding";
static constexpr char copyright[] = "MIT";
static constexpr ulong parameters = 2;
static const ulong id = 0x50F7BA11;
static const char *label;
static const char *name;
static const char *author;
static const char *copyright;
static const ulong parameters = 2;
smoothval drive, wet;
@ -121,7 +120,7 @@ struct Crap_tube
}
};
constexpr char Crap_tube::label[];
constexpr char Crap_tube::name[];
constexpr char Crap_tube::author[];
constexpr char Crap_tube::copyright[];
const char *Crap_tube::label = "crap_tube";
const char *Crap_tube::name = "crap Tube Distortion";
const char *Crap_tube::author = "Connor Olding";
const char *Crap_tube::copyright = "MIT";

View File

@ -23,8 +23,8 @@ struct Buffer2 : public Mixin {
process2(buf, rem);
for (ulong i = 0; i < rem; i++) {
out_L[i] = buf[i][0];
out_R[i] = buf[i][1];
out_L[i] = (T)buf[i][0];
out_R[i] = (T)buf[i][1];
}
in_L += BLOCK_SIZE;

View File

@ -37,8 +37,8 @@ struct Buffer2OS2 : public Mixin {
}
for (ulong i = 0; i < rem; i++) {
out_L[i] = buf[i][0];
out_R[i] = buf[i][1];
out_L[i] = (T)buf[i][0];
out_R[i] = (T)buf[i][1];
}
in_L += BLOCK_SIZE;

View File

@ -19,14 +19,15 @@ design(double cw, double sw,
double num0, double num1, double num2,
double den0, double den1, double den2)
{
return (biquad_interim) {
.b0 = num0* (1 + cw) + num1*sw + num2* (1 - cw),
.b1 = num0*-2*(1 + cw) + num2*2*(1 - cw),
.b2 = num0* (1 + cw) - num1*sw + num2* (1 - cw),
.a0 = den0* (1 + cw) + den1*sw + den2* (1 - cw),
.a1 = den0*-2*(1 + cw) + den2*2*(1 - cw),
.a2 = den0* (1 + cw) - den1*sw + den2* (1 - cw),
const biquad_interim ret = {
num0* (1 + cw) + num1*sw + num2* (1 - cw),
num0*-2*(1 + cw) + num2*2*(1 - cw),
num0* (1 + cw) - num1*sw + num2* (1 - cw),
den0* (1 + cw) + den1*sw + den2* (1 - cw),
den0*-2*(1 + cw) + den2*2*(1 - cw),
den0* (1 + cw) - den1*sw + den2* (1 - cw),
};
return ret;
}
// TODO: rename to biquad_gen_raw, fix up parameters like you did with svf
@ -55,6 +56,8 @@ biquad_gen(filter_t type, double fc, double gain, double bw, double fs)
case FILT_BANDPASS_2: d(0, 1/Q, 0, 1, 1/Q, 1); break;
case FILT_NOTCH: d(1, 0, 1, 1, 1/Q, 1); break;
case FILT_GAIN: d(A, A, A, 1/A, 1/A, 1/A); break;
// TODO: error or something
default: d(1, 1, 1, 1, 1, 1); break;
}
#undef d

View File

@ -17,7 +17,7 @@ struct halfband_t {
};
TEMPLATE INNER void
halfband_a(T a[8], T ao[8], T x0, T x2)
halfband_a(T a[8], T ao[8], const T &x0, const T &x2)
{
a[0] = x2 + (x0 - ao[0])*T(0.006185967461045014);
a[1] = ao[0] + (a[0] - ao[1])*T(0.054230780876613788);
@ -30,7 +30,7 @@ halfband_a(T a[8], T ao[8], T x0, T x2)
}
TEMPLATE INNER void
halfband_b(T b[8], T bo[8], T x1, T x3)
halfband_b(T b[8], T bo[8], const T &x1, const T &x3)
{
b[0] = x3 + (x1 - bo[0])*T(0.024499027624721819);
b[1] = bo[0] + (b[0] - bo[1])*T(0.094283481125726432);
@ -43,7 +43,7 @@ halfband_b(T b[8], T bo[8], T x1, T x3)
}
TEMPLATE INNER T
halfband(halfband_t<T> *h, T x0)
halfband(halfband_t<T> *h, const T &x0)
{
T a[8], b[8];
halfband_a(a, h->ao, x0, h->x2);
@ -59,7 +59,7 @@ halfband(halfband_t<T> *h, T x0)
}
TEMPLATE INNER T
decimate_a(halfband_t<T> *h, T x0)
decimate_a(halfband_t<T> *h, const T &x0)
{
T c[8];
halfband_b(c, h->bo, x0, h->x2);
@ -70,7 +70,7 @@ decimate_a(halfband_t<T> *h, T x0)
}
TEMPLATE INNER T
decimate_b(halfband_t<T> *h, T x0)
decimate_b(halfband_t<T> *h, const T &x0)
{
T c[8];
halfband_a(c, h->ao, x0, h->x2);
@ -82,7 +82,7 @@ decimate_b(halfband_t<T> *h, T x0)
// note: do not zero-stuff! send the input each time.
TEMPLATE INNER T
interpolate_a(halfband_t<T> *h, T x0)
interpolate_a(halfband_t<T> *h, const T &x0)
{
T c[8];
halfband_a(c, h->ao, x0, h->x1);
@ -92,7 +92,7 @@ interpolate_a(halfband_t<T> *h, T x0)
// note: do not zero-stuff! send the input each time.
TEMPLATE INNER T
interpolate_b(halfband_t<T> *h, T x0)
interpolate_b(halfband_t<T> *h, const T &x0)
{
T c[8];
halfband_b(c, h->bo, x0, h->x1);

View File

@ -2,15 +2,27 @@
#include <math.h>
#include <stdint.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#define M_SQRT2 1.41421356237309504880
#define M_SQRT1_2 0.707106781186547524401
#endif
#ifdef __SSE2__
#include <emmintrin.h>
#endif
#define TEMPLATE template<typename T>
#define INNER static inline
#ifdef _MSC_VER
#define PURE
#define CONST
#define RESTRICT
#else
#define PURE __attribute__((pure))
#define CONST __attribute__((const))
#define RESTRICT __restrict__
#endif
typedef unsigned long ulong; // __attribute((aligned(16)));
@ -18,8 +30,12 @@ typedef unsigned long ulong; // __attribute((aligned(16)));
#define BLOCK_SIZE 256
#endif
#ifdef _MSC_VER
#include "vectors_simple.hpp"
#else
#include "Dumber.hpp"
#include "vectors.hpp"
#endif
#ifdef FORCE_SINGLE
#define v2df v2sf

123
include/vectors_simple.hpp Executable file
View File

@ -0,0 +1,123 @@
#include <emmintrin.h>
typedef __m128d _v2df;
typedef __m64 _v2sf;
typedef __m128 _v4sf;
struct v2df {
_v2df v;
v2df()
{}
v2df(double d)
{ v = _mm_set1_pd(d); }
v2df(double d0, double d1)
{ v = _mm_setr_pd(d0,d1); }
friend inline v2df
operator-(const v2df &a)
{ v2df c; c.v =_mm_sub_pd(_mm_setzero_pd(),a.v); return c; }
friend inline v2df
operator+(const v2df &a, const v2df &b)
{ v2df c; c.v = _mm_add_pd(a.v,b.v); return c; }
friend inline v2df
operator-(const v2df &a, const v2df &b)
{ v2df c; c.v = _mm_sub_pd(a.v,b.v); return c; }
friend inline v2df
operator*(const v2df &a, const v2df &b)
{ v2df c; c.v = _mm_mul_pd(a.v,b.v); return c; }
friend inline v2df
operator/(const v2df &a, const v2df &b)
{ v2df c; c.v = _mm_div_pd(a.v,b.v); return c; }
friend inline v2df
sqrt(const v2df &a)
{ v2df c; c.v = _mm_sqrt_pd(a.v); return c; }
friend inline v2df
operator+(double a, const v2df &b)
{ v2df c; c.v = _mm_add_pd(_mm_set1_pd(a),b.v); return c; }
friend inline v2df
operator-(double a, const v2df &b)
{ v2df c; c.v = _mm_sub_pd(_mm_set1_pd(a),b.v); return c; }
friend inline v2df
operator*(double a, const v2df &b)
{ v2df c; c.v = _mm_mul_pd(_mm_set1_pd(a),b.v); return c; }
friend inline v2df
operator/(double a, const v2df &b)
{ v2df c; c.v = _mm_div_pd(_mm_set1_pd(a),b.v); return c; }
inline v2df &
operator+=(const v2df &a)
{ v = _mm_add_pd(v,a.v); return *this; }
inline v2df &
operator-=(const v2df &a)
{ v = _mm_sub_pd(v,a.v); return *this; }
inline v2df &
operator*=(const v2df &a)
{ v = _mm_mul_pd(v,a.v); return *this; }
inline v2df &
operator/=(const v2df &a)
{ v = _mm_div_pd(v,a.v); return *this; }
friend inline v2df
operator&(const v2df &a, const v2df &b)
{ v2df c; c.v = _mm_and_pd(a.v,b.v); return c; }
friend inline v2df
operator|(const v2df &a, const v2df &b)
{ v2df c; c.v = _mm_or_pd(a.v,b.v); return c; }
friend inline v2df
operator^(const v2df &a, const v2df &b)
{ v2df c; c.v = _mm_xor_pd(a.v,b.v); return c; }
friend inline v2df
andnot(const v2df &a, const v2df &b)
{ v2df c; c.v = _mm_andnot_pd(a.v,b.v); return c; }
friend inline v2df
operator<(const v2df &a, const v2df &b)
{ v2df c; c.v = _mm_cmplt_pd(a.v,b.v); return c; }
friend inline v2df
operator>(const v2df &a, const v2df &b)
{ v2df c; c.v = _mm_cmpgt_pd(a.v,b.v); return c; }
friend inline v2df
operator==(const v2df &a, const v2df &b)
{ v2df c; c.v = _mm_cmpeq_pd(a.v,b.v); return c; }
friend inline v2df
operator<(const v2df &a, double b)
{ v2df c; c.v = _mm_cmplt_pd(a.v,_mm_set1_pd(b)); return c; }
friend inline v2df
operator>(const v2df &a, double b)
{ v2df c; c.v = _mm_cmpgt_pd(a.v,_mm_set1_pd(b)); return c; }
friend inline v2df
max(const v2df &a, v2df &b)
{ v2df c; c.v = _mm_max_pd(a.v,b.v); return c; }
inline double &
operator[](int index) {
return ((double *)&v)[index];
}
inline const double &
operator[](int index) const {
return ((double *)&v)[index];
}
};

View File

@ -37,7 +37,7 @@ struct plugin : public AudioEffectX
char programName[kVstMaxProgNameLen];
Param params[CrapPlug::parameters];
Param *params;
Crap *crap;
};
@ -53,6 +53,8 @@ plugin::plugin(audioMasterCallback audioMaster)
: AudioEffectX(audioMaster, 1, CrapPlug::parameters)
{
crap = new CrapPlug();
if (CrapPlug::parameters)
params = new Param[CrapPlug::parameters];
setNumInputs(2);
setNumOutputs(2);
setUniqueID(CrapPlug::id);
@ -65,6 +67,8 @@ plugin::plugin(audioMasterCallback audioMaster)
plugin::~plugin()
{
delete crap;
if (CrapPlug::parameters)
delete[] params;
}
void

18
util/generate.vbs Executable file
View File

@ -0,0 +1,18 @@
Set FSO = CreateObject("Scripting.FileSystemObject")
Name = WScript.Arguments(0)
IPath = "../template/vst.cpp"
OPath = "../crap/vst/"&Name&".cpp"
Inc = "crap/"&Name&".hpp"
Set File = FSO.OpenTextFile(IPath)
Text = File.ReadAll
File.Close
Text = Replace(Text, "//#INCLUDE", "#include """&Inc&"""")
Text = Replace(Text, "//#REDEFINE", "#define CrapPlug Crap_"&Name)
Set File = FSO.CreateTextFile(OPath, True)
File.Write Text
File.Close