crap/crap/eq_const_T420_svf.hpp

116 lines
3.2 KiB
C++
Raw Normal View History

2015-05-28 16:45:14 -07:00
#define ID (0x0DEFACED+420+1337)
#define LABEL "crap_eq_const_T420_svf"
#define NAME "crap T420 Speaker Compensation (SVF)"
#define AUTHOR "Connor Olding"
#define COPYRIGHT "MIT"
#define PARAMETERS 0
#define BLOCK_SIZE 256
2015-06-06 23:03:04 -07:00
#include <string.h>
#include <stdio.h>
#include <assert.h>
2015-06-06 10:42:14 -07:00
#include "util.hpp"
2015-06-06 17:25:18 -07:00
#include "svf.hpp"
2015-05-28 16:45:14 -07:00
#define BANDS 16
typedef struct {
2015-06-06 17:25:18 -07:00
svf_matrix<v4sf> filters[2][BANDS];
2015-05-28 16:45:14 -07:00
} personal;
2015-06-06 17:25:18 -07:00
TEMPLATE static void
process(personal *data,
T *in_L, T *in_R,
T *out_L, T *out_R,
2015-05-28 16:45:14 -07:00
unsigned long count)
{
disable_denormals();
2015-05-28 16:45:14 -07:00
assert(count % 2 == 0);
v4sf buf_L[BLOCK_SIZE/2];
v4sf buf_R[BLOCK_SIZE/2];
2015-06-06 17:25:18 -07:00
svf_matrix<v4sf> *f0, *f1;
for (ulong pos = 0; pos < count; pos += BLOCK_SIZE) {
ulong rem = BLOCK_SIZE;
if (pos + BLOCK_SIZE > count)
rem = count - pos;
for (ulong i = 0, j = 0; i < rem; i += 2, j++) {
buf_L[j][0] = in_L[i+0];
buf_L[j][1] = in_L[i+1];
buf_R[j][0] = in_R[i+0];
buf_R[j][1] = in_R[i+1];
}
f0 = data->filters[0];
for (ulong i = 0; i < BANDS; i++) {
svf_run_block_mat(f0, buf_L, rem);
f0++;
}
f1 = data->filters[1];
for (ulong i = 0; i < BANDS; i++) {
svf_run_block_mat(f1, buf_R, rem);
f1++;
}
for (ulong i = 0, j = 0; i < rem; i += 2, j++) {
out_L[i+0] = buf_L[j][0];
out_L[i+1] = buf_L[j][1];
out_R[i+0] = buf_R[j][0];
out_R[i+1] = buf_R[j][1];
}
in_L += BLOCK_SIZE;
in_R += BLOCK_SIZE;
out_L += BLOCK_SIZE;
out_R += BLOCK_SIZE;
}
}
2015-05-28 16:45:14 -07:00
INNER void
construct(personal *data)
{}
INNER void
destruct(personal *data)
{}
INNER void
resume(personal *data)
{
2015-06-06 17:25:18 -07:00
svf_matrix<v4sf> *filters = data->filters[0];
for (int i = 0; i < BANDS; i++)
filters[i].memory = v4sf(0);
memcpy(data->filters[1], filters, BANDS*sizeof(svf_matrix<v4sf>));
2015-05-28 16:45:14 -07:00
}
INNER void
pause(personal *data)
{}
INNER void
adjust(personal *data, ulong fs)
{
2015-06-06 17:25:18 -07:00
svf_matrix<v4sf> *filters = data->filters[0];
filters[ 0] = svf_gen_matrix<v4sf>(svf_gen(FILT_PEAKING, 180., 11., 1.40, fs));
filters[ 1] = svf_gen_matrix<v4sf>(svf_gen(FILT_PEAKING, 740., 5.5, 0.70, fs));
filters[ 2] = svf_gen_matrix<v4sf>(svf_gen(FILT_PEAKING, 1220, -12., 0.70, fs));
filters[ 3] = svf_gen_matrix<v4sf>(svf_gen(FILT_PEAKING, 1580, 7.0, 0.25, fs));
filters[ 4] = svf_gen_matrix<v4sf>(svf_gen(FILT_PEAKING, 2080, -2.5, 0.30, fs));
filters[ 5] = svf_gen_matrix<v4sf>(svf_gen(FILT_PEAKING, 2270, 6.0, 0.20, fs));
filters[ 6] = svf_gen_matrix<v4sf>(svf_gen(FILT_PEAKING, 2470, -2.0, 0.18, fs));
filters[ 7] = svf_gen_matrix<v4sf>(svf_gen(FILT_PEAKING, 3700, -5.0, 0.32, fs));
filters[ 8] = svf_gen_matrix<v4sf>(svf_gen(FILT_PEAKING, 6200, -3.5, 0.25, fs));
filters[ 9] = svf_gen_matrix<v4sf>(svf_gen(FILT_PEAKING, 6000, -11., 3.66, fs));
filters[10] = svf_gen_matrix<v4sf>(svf_gen(FILT_HIGHSHELF, 11500, 4.0, 0.40, fs));
filters[11] = svf_gen_matrix<v4sf>(svf_gen(FILT_HIGHPASS, 150, 0.0, 1.00, fs));
filters[12] = svf_gen_matrix<v4sf>(svf_gen(FILT_PEAKING, 1775, -2.0, 0.18, fs));
filters[13] = svf_gen_matrix<v4sf>(svf_gen(FILT_PEAKING, 490, -1.5, 0.23, fs));
filters[14] = svf_gen_matrix<v4sf>(svf_gen(FILT_PEAKING, 3100, 5.0, 0.33, fs));
filters[15] = svf_gen_matrix<v4sf>(svf_gen(FILT_LOWPASS, 14000, 0.0, 0.40, fs));
2015-05-28 16:45:14 -07:00
}