working svf matricies
This commit is contained in:
parent
79fe905ec5
commit
99c4a214ce
3 changed files with 75 additions and 58 deletions
|
@ -1,5 +1,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#define ID (0x0DEFACED+420+1337)
|
#define ID (0x0DEFACED+420+1337)
|
||||||
#define LABEL "crap_eq_const_T420_svf"
|
#define LABEL "crap_eq_const_T420_svf"
|
||||||
|
@ -14,7 +15,7 @@
|
||||||
|
|
||||||
#define BANDS 16
|
#define BANDS 16
|
||||||
typedef struct {
|
typedef struct {
|
||||||
svf filters[2][BANDS];
|
svf_matrix filters[2][BANDS];
|
||||||
} personal;
|
} personal;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -42,12 +43,12 @@ destruct(personal *data)
|
||||||
INNER void
|
INNER void
|
||||||
resume(personal *data)
|
resume(personal *data)
|
||||||
{
|
{
|
||||||
svf *filters = data->filters[0];
|
svf_matrix *filters = data->filters[0];
|
||||||
for (int i = 0; i < BANDS; i++) {
|
for (int i = 0; i < BANDS; i++) {
|
||||||
filters[i].memory[0] = 0;
|
filters[i].memory[0] = 0;
|
||||||
filters[i].memory[1] = 0;
|
filters[i].memory[1] = 0;
|
||||||
}
|
}
|
||||||
memcpy(data->filters[1], filters, BANDS*sizeof(svf));
|
memcpy(data->filters[1], filters, BANDS*sizeof(svf_matrix));
|
||||||
}
|
}
|
||||||
|
|
||||||
INNER void
|
INNER void
|
||||||
|
@ -57,28 +58,21 @@ pause(personal *data)
|
||||||
INNER void
|
INNER void
|
||||||
adjust(personal *data, ulong fs)
|
adjust(personal *data, ulong fs)
|
||||||
{
|
{
|
||||||
svf *filters = data->filters[0];
|
svf_matrix *filters = data->filters[0];
|
||||||
filters[ 0] = svf_gen(FILT_PEAKING, 180., 11., 1.40, fs);
|
filters[ 0] = svf_gen_matrix(svf_gen(FILT_PEAKING, 180., 11., 1.40, fs));
|
||||||
filters[ 1] = svf_gen(FILT_PEAKING, 740., 5.5, 0.70, fs);
|
filters[ 1] = svf_gen_matrix(svf_gen(FILT_PEAKING, 740., 5.5, 0.70, fs));
|
||||||
filters[ 2] = svf_gen(FILT_PEAKING, 1220, -12., 0.70, fs);
|
filters[ 2] = svf_gen_matrix(svf_gen(FILT_PEAKING, 1220, -12., 0.70, fs));
|
||||||
filters[ 3] = svf_gen(FILT_PEAKING, 1580, 7.0, 0.25, fs);
|
filters[ 3] = svf_gen_matrix(svf_gen(FILT_PEAKING, 1580, 7.0, 0.25, fs));
|
||||||
filters[ 4] = svf_gen(FILT_PEAKING, 2080, -2.5, 0.30, fs);
|
filters[ 4] = svf_gen_matrix(svf_gen(FILT_PEAKING, 2080, -2.5, 0.30, fs));
|
||||||
filters[ 5] = svf_gen(FILT_PEAKING, 2270, 6.0, 0.20, fs);
|
filters[ 5] = svf_gen_matrix(svf_gen(FILT_PEAKING, 2270, 6.0, 0.20, fs));
|
||||||
filters[ 6] = svf_gen(FILT_PEAKING, 2470, -2.0, 0.18, fs);
|
filters[ 6] = svf_gen_matrix(svf_gen(FILT_PEAKING, 2470, -2.0, 0.18, fs));
|
||||||
filters[ 7] = svf_gen(FILT_PEAKING, 3700, -5.0, 0.32, fs);
|
filters[ 7] = svf_gen_matrix(svf_gen(FILT_PEAKING, 3700, -5.0, 0.32, fs));
|
||||||
filters[ 8] = svf_gen(FILT_PEAKING, 6200, -3.5, 0.25, fs);
|
filters[ 8] = svf_gen_matrix(svf_gen(FILT_PEAKING, 6200, -3.5, 0.25, fs));
|
||||||
filters[ 9] = svf_gen(FILT_PEAKING, 6000, -11., 3.66, fs);
|
filters[ 9] = svf_gen_matrix(svf_gen(FILT_PEAKING, 6000, -11., 3.66, fs));
|
||||||
filters[10] = svf_gen(FILT_HIGHSHELF, 11500, 4.0, 0.40, fs);
|
filters[10] = svf_gen_matrix(svf_gen(FILT_HIGHSHELF, 11500, 4.0, 0.40, fs));
|
||||||
filters[11] = svf_gen(FILT_HIGHPASS, 150, 0.0, 1.00, fs);
|
filters[11] = svf_gen_matrix(svf_gen(FILT_HIGHPASS, 150, 0.0, 1.00, fs));
|
||||||
filters[12] = svf_gen(FILT_PEAKING, 1775, -2.0, 0.18, fs);
|
filters[12] = svf_gen_matrix(svf_gen(FILT_PEAKING, 1775, -2.0, 0.18, fs));
|
||||||
filters[13] = svf_gen(FILT_PEAKING, 490, -1.5, 0.23, fs);
|
filters[13] = svf_gen_matrix(svf_gen(FILT_PEAKING, 490, -1.5, 0.23, fs));
|
||||||
filters[14] = svf_gen(FILT_PEAKING, 3100, 5.0, 0.33, fs);
|
filters[14] = svf_gen_matrix(svf_gen(FILT_PEAKING, 3100, 5.0, 0.33, fs));
|
||||||
filters[15] = svf_gen(FILT_LOWPASS, 14000, 0.0, 0.40, fs);
|
filters[15] = svf_gen_matrix(svf_gen(FILT_LOWPASS, 14000, 0.0, 0.40, fs));
|
||||||
/* debugging
|
|
||||||
svf *f = &filters[10];
|
|
||||||
printf("A = [%.8f %.8f]\n", f->A0[0], f->A0[1]);
|
|
||||||
printf(" [%.8f %.8f]\n", f->A1[0], f->A1[1]);
|
|
||||||
printf("B = {%.8f, %.8f}\n", f->B[0], f->B[1]);
|
|
||||||
printf("C = {%.8f, %.8f, %9.7f}\n", f->C[0], f->C[1], f->C[2]);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,35 +1,41 @@
|
||||||
{
|
{
|
||||||
disable_denormals();
|
disable_denormals();
|
||||||
|
|
||||||
float buf_L[BLOCK_SIZE];
|
assert(count % 2 == 0);
|
||||||
float buf_R[BLOCK_SIZE];
|
|
||||||
|
|
||||||
svf *f0, *f1;
|
v4sf buf_L[BLOCK_SIZE/2];
|
||||||
|
v4sf buf_R[BLOCK_SIZE/2];
|
||||||
|
|
||||||
|
svf_matrix *f0, *f1;
|
||||||
|
|
||||||
for (ulong pos = 0; pos < count; pos += BLOCK_SIZE) {
|
for (ulong pos = 0; pos < count; pos += BLOCK_SIZE) {
|
||||||
ulong rem = BLOCK_SIZE;
|
ulong rem = BLOCK_SIZE;
|
||||||
if (pos + BLOCK_SIZE > count)
|
if (pos + BLOCK_SIZE > count)
|
||||||
rem = count - pos;
|
rem = count - pos;
|
||||||
|
|
||||||
for (ulong i = 0; i < rem; i++) {
|
for (ulong i = 0, j = 0; i < rem; i += 2, j++) {
|
||||||
buf_L[i] = in_L[i];
|
buf_L[j][0] = in_L[i+0];
|
||||||
buf_R[i] = in_R[i];
|
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];
|
f0 = data->filters[0];
|
||||||
|
for (ulong i = 0; i < BANDS; i++) {
|
||||||
|
svf_run_block_mat(f0, buf_L, rem);
|
||||||
|
f0++;
|
||||||
|
}
|
||||||
f1 = data->filters[1];
|
f1 = data->filters[1];
|
||||||
for (ulong i = 0; i < BANDS; i++) {
|
for (ulong i = 0; i < BANDS; i++) {
|
||||||
for (ulong j = 0; j < rem; j++)
|
svf_run_block_mat(f1, buf_R, rem);
|
||||||
buf_L[j] = svf_run(f0, buf_L[j]);
|
|
||||||
for (ulong j = 0; j < rem; j++)
|
|
||||||
buf_R[j] = svf_run(f1, buf_R[j]);
|
|
||||||
f0++;
|
|
||||||
f1++;
|
f1++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ulong i = 0; i < rem; i++) {
|
for (ulong i = 0, j = 0; i < rem; i += 2, j++) {
|
||||||
out_L[i] = buf_L[i];
|
out_L[i+0] = buf_L[j][0];
|
||||||
out_R[i] = buf_R[i];
|
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_L += BLOCK_SIZE;
|
||||||
|
|
|
@ -95,17 +95,6 @@ svf_run(svf *s, float x)
|
||||||
static svf_matrix
|
static svf_matrix
|
||||||
svf_gen_matrix(svf s)
|
svf_gen_matrix(svf s)
|
||||||
{
|
{
|
||||||
// note: does not copy memory
|
|
||||||
/*
|
|
||||||
AA = dot(A, A);
|
|
||||||
AB = dot(A, B);
|
|
||||||
CA = dot(C[1:], A);
|
|
||||||
cb = dot(C[1:], B);
|
|
||||||
return [[ C[0], 0, C[1], C[2]],
|
|
||||||
[ cb, C[0], CA[0], CA[1]],
|
|
||||||
[AB[0], B[0], AA[0][0], AA[0][1]],
|
|
||||||
[AB[1], B[1], AA[1][0], AA[1][1]]];
|
|
||||||
*/
|
|
||||||
float AA0[2], AA1[2], AB[2], CA[2], cb;
|
float AA0[2], AA1[2], AB[2], CA[2], cb;
|
||||||
AA0[0] = s.A0[0]*s.A0[0] + s.A0[1]*s.A1[0];
|
AA0[0] = s.A0[0]*s.A0[0] + s.A0[1]*s.A1[0];
|
||||||
AA1[0] = s.A1[0]*s.A0[0] + s.A1[1]*s.A1[0];
|
AA1[0] = s.A1[0]*s.A0[0] + s.A1[1]*s.A1[0];
|
||||||
|
@ -113,8 +102,9 @@ svf_gen_matrix(svf s)
|
||||||
AA1[1] = s.A1[0]*s.A0[1] + s.A1[1]*s.A1[1];
|
AA1[1] = s.A1[0]*s.A0[1] + s.A1[1]*s.A1[1];
|
||||||
AB[0] = s.A0[0]*s.B[0] + s.A0[1]*s.B[1];
|
AB[0] = s.A0[0]*s.B[0] + s.A0[1]*s.B[1];
|
||||||
AB[1] = s.A1[0]*s.B[0] + s.A1[1]*s.B[1];
|
AB[1] = s.A1[0]*s.B[0] + s.A1[1]*s.B[1];
|
||||||
CA[0] = s.A0[0]*s.C[1] + s.A0[1]*s.C[2];
|
CA[0] = s.A0[0]*s.C[1] + s.A1[0]*s.C[2];
|
||||||
CA[1] = s.A1[0]*s.C[1] + s.A1[1]*s.C[2];
|
CA[1] = s.A0[1]*s.C[1] + s.A1[1]*s.C[2];
|
||||||
|
|
||||||
cb = s.C[1]*s.B[0] + s.C[2]*s.B[1];
|
cb = s.C[1]*s.B[0] + s.C[2]*s.B[1];
|
||||||
|
|
||||||
svf_matrix mat;
|
svf_matrix mat;
|
||||||
|
@ -125,3 +115,30 @@ svf_gen_matrix(svf s)
|
||||||
mat.d = (v4sf){ AB[1], s.B[1], AA1[0], AA1[1]};
|
mat.d = (v4sf){ AB[1], s.B[1], AA1[0], AA1[1]};
|
||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INNER void
|
||||||
|
svf_run_block_mat(svf_matrix *restrict mat, v4sf *restrict buf, ulong count)
|
||||||
|
{
|
||||||
|
v4sf t1, t2, t3, t4;
|
||||||
|
v4sf a, b, c, d; // const?
|
||||||
|
a = mat->a;
|
||||||
|
b = mat->b;
|
||||||
|
c = mat->c;
|
||||||
|
d = mat->d;
|
||||||
|
v4sf memory = mat->memory;
|
||||||
|
for (ulong i = 0; i < count/2; i++) {
|
||||||
|
memory[0] = buf[i][0];
|
||||||
|
memory[1] = buf[i][1];
|
||||||
|
t1 = mat->a*memory;
|
||||||
|
t2 = mat->b*memory;
|
||||||
|
t3 = mat->c*memory;
|
||||||
|
t4 = mat->d*memory;
|
||||||
|
memory[0] = t1[0] + t1[1] + t1[2] + t1[3];
|
||||||
|
memory[1] = t2[0] + t2[1] + t2[2] + t2[3];
|
||||||
|
memory[2] = t3[0] + t3[1] + t3[2] + t3[3];
|
||||||
|
memory[3] = t4[0] + t4[1] + t4[2] + t4[3];
|
||||||
|
buf[i][0] = memory[0];
|
||||||
|
buf[i][1] = memory[1];
|
||||||
|
}
|
||||||
|
mat->memory = memory;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue