bump eq; factor out process funcs
This commit is contained in:
parent
4022d11349
commit
8e7dde59f6
3 changed files with 58 additions and 70 deletions
46
crap/eq.h
46
crap/eq.h
|
@ -1,9 +1,6 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "param.h"
|
||||
|
||||
#define BANDS 4
|
||||
|
||||
#define ID 0x000CAFED
|
||||
|
@ -13,44 +10,29 @@
|
|||
#define COPYRIGHT "MIT"
|
||||
#define PARAMETERS (BANDS*3)
|
||||
|
||||
#define BLOCK_SIZE 256
|
||||
|
||||
#include "util.h"
|
||||
#include "param.h"
|
||||
|
||||
typedef struct {
|
||||
biquad filters[2][BANDS];
|
||||
float fs;
|
||||
} personal;
|
||||
|
||||
INNER double
|
||||
process_one(biquad *filters, double samp)
|
||||
{
|
||||
for (int i = 0; i < BANDS; i++)
|
||||
samp = biquad_run(&filters[i], samp);
|
||||
return samp;
|
||||
}
|
||||
|
||||
INNER void
|
||||
process(personal *data,
|
||||
float *in_L, float *in_R,
|
||||
float *out_L, float *out_R,
|
||||
unsigned long count)
|
||||
{
|
||||
disable_denormals();
|
||||
for (unsigned long pos = 0; pos < count; pos++) {
|
||||
out_L[pos] = process_one(data->filters[0], in_L[pos]);
|
||||
out_R[pos] = process_one(data->filters[1], in_R[pos]);
|
||||
}
|
||||
}
|
||||
|
||||
INNER void
|
||||
static void
|
||||
process_double(personal *data,
|
||||
double *in_L, double *in_R,
|
||||
double *out_L, double *out_R,
|
||||
unsigned long count)
|
||||
{
|
||||
disable_denormals();
|
||||
for (unsigned long pos = 0; pos < count; pos++) {
|
||||
out_L[pos] = process_one(data->filters[0], in_L[pos]);
|
||||
out_R[pos] = process_one(data->filters[1], in_R[pos]);
|
||||
}
|
||||
}
|
||||
#include "process_biquads.h"
|
||||
|
||||
static void
|
||||
process(personal *data,
|
||||
float *in_L, float *in_R,
|
||||
float *out_L, float *out_R,
|
||||
ulong count)
|
||||
#include "process_biquads.h"
|
||||
|
||||
INNER void
|
||||
resume(personal *data)
|
||||
|
|
|
@ -20,45 +20,15 @@ static void
|
|||
process_double(personal *data,
|
||||
double *in_L, double *in_R,
|
||||
double *out_L, double *out_R,
|
||||
unsigned long count)
|
||||
#include "process_biquads.h"
|
||||
|
||||
static void
|
||||
process(personal *data,
|
||||
float *in_L, float *in_R,
|
||||
float *out_L, float *out_R,
|
||||
ulong count)
|
||||
{
|
||||
disable_denormals();
|
||||
|
||||
v2df buf[BLOCK_SIZE];
|
||||
|
||||
biquad *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; i < rem; i++) {
|
||||
buf[i][0] = in_L[i];
|
||||
buf[i][1] = in_R[i];
|
||||
}
|
||||
|
||||
f0 = data->filters[0];
|
||||
f1 = data->filters[1];
|
||||
for (ulong i = 0; i < BANDS; i++) {
|
||||
biquad_run_block_stereo(f0, f1, buf, rem);
|
||||
f0++;
|
||||
f1++;
|
||||
}
|
||||
|
||||
for (ulong i = 0; i < rem; i++) {
|
||||
out_L[i] = buf[i][0];
|
||||
out_R[i] = buf[i][1];
|
||||
}
|
||||
|
||||
in_L += BLOCK_SIZE;
|
||||
in_R += BLOCK_SIZE;
|
||||
out_L += BLOCK_SIZE;
|
||||
out_R += BLOCK_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
#include "process.h"
|
||||
#include "process_biquads.h"
|
||||
|
||||
INNER void
|
||||
construct(personal *data)
|
||||
|
|
36
include/process_biquads.h
Normal file
36
include/process_biquads.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
disable_denormals();
|
||||
|
||||
v2df buf[BLOCK_SIZE];
|
||||
|
||||
biquad *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; i < rem; i++) {
|
||||
buf[i][0] = in_L[i];
|
||||
buf[i][1] = in_R[i];
|
||||
}
|
||||
|
||||
f0 = data->filters[0];
|
||||
f1 = data->filters[1];
|
||||
for (ulong i = 0; i < BANDS; i++) {
|
||||
biquad_run_block_stereo(f0, f1, buf, rem);
|
||||
f0++;
|
||||
f1++;
|
||||
}
|
||||
|
||||
for (ulong i = 0; i < rem; i++) {
|
||||
out_L[i] = buf[i][0];
|
||||
out_R[i] = buf[i][1];
|
||||
}
|
||||
|
||||
in_L += BLOCK_SIZE;
|
||||
in_R += BLOCK_SIZE;
|
||||
out_L += BLOCK_SIZE;
|
||||
out_R += BLOCK_SIZE;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue