rewrite delay_test (everything compiles now)
This commit is contained in:
parent
5f6921bf5c
commit
94ee72662b
1 changed files with 72 additions and 63 deletions
|
@ -1,30 +1,17 @@
|
||||||
#define ID 0xDEDEDEDE
|
|
||||||
#define LABEL "crap_delay_test"
|
|
||||||
#define NAME "crap sample delay test"
|
|
||||||
#define AUTHOR "Connor Olding"
|
|
||||||
#define COPYRIGHT "MIT"
|
|
||||||
#define PARAMETERS 0
|
|
||||||
#define DELAY
|
#define DELAY
|
||||||
|
static auto global_delay = 2;
|
||||||
|
|
||||||
#include "util.hpp"
|
#define OVERSAMPLE 4
|
||||||
#include "biquad.hpp"
|
|
||||||
|
|
||||||
static ulong global_delay = 2;
|
// number of taps. coefficients via:
|
||||||
static double oversample = 4;
|
|
||||||
|
|
||||||
// taps. coefficients via:
|
|
||||||
// http://vladgsound.wordpress.com/2013/06/01/iir-based-eq-and-distortions/
|
// http://vladgsound.wordpress.com/2013/06/01/iir-based-eq-and-distortions/
|
||||||
#define UP 19
|
#define UP 19
|
||||||
#define DOWN 5
|
#define DOWN 5
|
||||||
|
|
||||||
typedef struct {
|
#include "util.hpp"
|
||||||
double up[UP], down[DOWN];
|
#include "Param.hpp"
|
||||||
biquad filter;
|
#include "Crap.hpp"
|
||||||
} channel;
|
#include "biquad.hpp"
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
channel c[2];
|
|
||||||
} personal;
|
|
||||||
|
|
||||||
INNER double
|
INNER double
|
||||||
fir_up(double *x, double s)
|
fir_up(double *x, double s)
|
||||||
|
@ -68,56 +55,78 @@ fir_down(double *x, double s)
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
INNER double
|
struct channel {
|
||||||
process_one(channel *c, double s)
|
double up[UP], down[DOWN]; // TODO: dumb in fir_up/fir_down struct
|
||||||
{
|
biquad filter;
|
||||||
s = fir_down(c->down, biquad_run(&c->filter, fir_up(c->up, s)));
|
|
||||||
fir_down(c->down, biquad_run(&c->filter, fir_up(c->up, 0)));
|
|
||||||
fir_down(c->down, biquad_run(&c->filter, fir_up(c->up, 0)));
|
|
||||||
fir_down(c->down, biquad_run(&c->filter, fir_up(c->up, 0)));
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
inline double
|
||||||
INNER void
|
process(double s)
|
||||||
process(personal *data,
|
{
|
||||||
T *in_L, T *in_R,
|
s = fir_down(down, biquad_run(&filter, fir_up(up, s)));
|
||||||
T *out_L, T *out_R,
|
fir_down(down, biquad_run(&filter, fir_up(up, 0)));
|
||||||
ulong count)
|
fir_down(down, biquad_run(&filter, fir_up(up, 0)));
|
||||||
{
|
fir_down(down, biquad_run(&filter, fir_up(up, 0)));
|
||||||
for (ulong pos = 0; pos < count; pos++) {
|
return s;
|
||||||
out_L[pos] = process_one(&data->c[0], in_L[pos]);
|
|
||||||
out_R[pos] = process_one(&data->c[1], in_R[pos]);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
INNER void
|
struct Crap_delay_test
|
||||||
construct(personal *data)
|
: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;
|
||||||
|
|
||||||
INNER void
|
channel c_L, c_R;
|
||||||
destruct(personal *data)
|
|
||||||
{}
|
|
||||||
|
|
||||||
INNER void
|
inline void
|
||||||
resume(personal *data)
|
process(
|
||||||
{}
|
double *in_L, double *in_R,
|
||||||
|
double *out_L, double *out_R,
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
INNER void
|
inline void
|
||||||
pause(personal *data)
|
process(
|
||||||
{}
|
float *in_L, float *in_R,
|
||||||
|
float *out_L, float *out_R,
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
INNER void
|
static inline void
|
||||||
adjust(personal *data, ulong fs)
|
construct_params(Param *params)
|
||||||
{
|
{}
|
||||||
for (int k = 0; k < 2; k++) {
|
|
||||||
channel *c = &data->c[k];
|
inline void
|
||||||
|
resume()
|
||||||
|
{}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
pause()
|
||||||
|
{}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
adjust_all(Param *params)
|
||||||
|
{
|
||||||
for (int i = 0; i < UP; i++)
|
for (int i = 0; i < UP; i++)
|
||||||
c->up[i] = 0;
|
c_L.up[i] = 0;
|
||||||
for (int i = 0; i < DOWN; i++)
|
for (int i = 0; i < DOWN; i++)
|
||||||
c->down[i] = 0;
|
c_L.down[i] = 0;
|
||||||
c->filter = biquad_gen(FILT_PEAKING,
|
c_L.filter = biquad_gen(FILT_PEAKING,
|
||||||
16630, 10, 1, fs*oversample);
|
16630, 10, 1, fs*OVERSAMPLE);
|
||||||
biquad_init(&c->filter);
|
biquad_init(&c_L.filter);
|
||||||
|
c_R = c_L;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue