work out some defines; refactor
This commit is contained in:
parent
fbea39cfa6
commit
677040782b
4 changed files with 98 additions and 105 deletions
81
crap/eq.hpp
81
crap/eq.hpp
|
@ -1,8 +1,3 @@
|
||||||
#define ID 0x000CAFED
|
|
||||||
#define LABEL "crap_eq"
|
|
||||||
#define NAME "crap Parametric Equalizer"
|
|
||||||
#define AUTHOR "Connor Olding"
|
|
||||||
#define COPYRIGHT "MIT"
|
|
||||||
#define BANDS 4
|
#define BANDS 4
|
||||||
#define PARAMETERS (BANDS*3)
|
#define PARAMETERS (BANDS*3)
|
||||||
|
|
||||||
|
@ -14,69 +9,20 @@
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
#include "param.hpp"
|
#include "param.hpp"
|
||||||
#include "Crap.hpp"
|
#include "Crap.hpp"
|
||||||
|
#include "Buffer2.hpp"
|
||||||
#include "biquad.hpp"
|
#include "biquad.hpp"
|
||||||
|
|
||||||
template<class Mixin>
|
|
||||||
struct Buffer2 : public virtual Mixin {
|
|
||||||
virtual inline void
|
|
||||||
process2(v2df *buf, ulong rem) = 0;
|
|
||||||
|
|
||||||
TEMPLATE void
|
|
||||||
_process(T *in_L, T *in_R, T *out_L, T *out_R, ulong count)
|
|
||||||
{
|
|
||||||
disable_denormals();
|
|
||||||
|
|
||||||
v2df buf[BLOCK_SIZE];
|
|
||||||
|
|
||||||
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];
|
|
||||||
}
|
|
||||||
|
|
||||||
process2(buf, rem);
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
process(
|
|
||||||
double *in_L, double *in_R,
|
|
||||||
double *out_L, double *out_R,
|
|
||||||
ulong count)
|
|
||||||
{
|
|
||||||
_process(in_L, in_R, out_L, out_R, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
process(
|
|
||||||
float *in_L, float *in_R,
|
|
||||||
float *out_L, float *out_R,
|
|
||||||
ulong count)
|
|
||||||
{
|
|
||||||
_process(in_L, in_R, out_L, out_R, count);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Crap_eq
|
struct Crap_eq
|
||||||
:public Unconstructive<
|
:public AdjustAll<Buffer2<Crap>> {
|
||||||
AdjustAll<
|
static constexpr ulong id = 0x000CAFED;
|
||||||
Buffer2<Crap>
|
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 constexpr ulong bands = 4;
|
||||||
|
static constexpr ulong parameters = bands*3;
|
||||||
|
|
||||||
biquad filters_L[BANDS];
|
biquad filters_L[BANDS];
|
||||||
biquad filters_R[BANDS];
|
biquad filters_R[BANDS];
|
||||||
|
|
||||||
|
@ -146,3 +92,8 @@ struct Crap_eq
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constexpr char Crap_eq::label[];
|
||||||
|
constexpr char Crap_eq::name[];
|
||||||
|
constexpr char Crap_eq::author[];
|
||||||
|
constexpr char Crap_eq::copyright[];
|
||||||
|
|
54
include/Buffer2.hpp
Normal file
54
include/Buffer2.hpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
template<class Mixin>
|
||||||
|
struct Buffer2 : public virtual Mixin {
|
||||||
|
virtual inline void
|
||||||
|
process2(v2df *buf, ulong rem) = 0;
|
||||||
|
|
||||||
|
TEMPLATE void
|
||||||
|
_process(T *in_L, T *in_R, T *out_L, T *out_R, ulong count)
|
||||||
|
{
|
||||||
|
disable_denormals();
|
||||||
|
|
||||||
|
v2df buf[BLOCK_SIZE];
|
||||||
|
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
|
||||||
|
process2(buf, rem);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
process(
|
||||||
|
double *in_L, double *in_R,
|
||||||
|
double *out_L, double *out_R,
|
||||||
|
ulong count)
|
||||||
|
{
|
||||||
|
_process(in_L, in_R, out_L, out_R, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
process(
|
||||||
|
float *in_L, float *in_R,
|
||||||
|
float *out_L, float *out_R,
|
||||||
|
ulong count)
|
||||||
|
{
|
||||||
|
_process(in_L, in_R, out_L, out_R, count);
|
||||||
|
}
|
||||||
|
};
|
|
@ -2,12 +2,6 @@ struct Crap {
|
||||||
virtual inline
|
virtual inline
|
||||||
~Crap() {}
|
~Crap() {}
|
||||||
|
|
||||||
virtual inline void
|
|
||||||
construct() = 0;
|
|
||||||
|
|
||||||
virtual inline void
|
|
||||||
destruct() = 0;
|
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
pause() = 0;
|
pause() = 0;
|
||||||
|
|
||||||
|
@ -57,17 +51,6 @@ struct AdjustAll : public virtual Mixin {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Mixin>
|
|
||||||
struct Unconstructive : public virtual Mixin {
|
|
||||||
inline void
|
|
||||||
construct()
|
|
||||||
{};
|
|
||||||
|
|
||||||
inline void
|
|
||||||
destruct()
|
|
||||||
{};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class Mixin>
|
template<class Mixin>
|
||||||
struct NoParams : public virtual Mixin {
|
struct NoParams : public virtual Mixin {
|
||||||
// etc
|
// etc
|
||||||
|
|
|
@ -78,7 +78,6 @@ plug_construct(const LADSPA_Descriptor *descriptor, unsigned long fs)
|
||||||
{
|
{
|
||||||
plug_t *plug = (plug_t *) calloc(1, sizeof(plug_t));
|
plug_t *plug = (plug_t *) calloc(1, sizeof(plug_t));
|
||||||
plug->crap = new CrapPlug();
|
plug->crap = new CrapPlug();
|
||||||
plug->crap->construct();
|
|
||||||
#if (PARAMETERS > 0)
|
#if (PARAMETERS > 0)
|
||||||
memcpy(plug->params, global_params, sizeof(param)*PARAMETERS);
|
memcpy(plug->params, global_params, sizeof(param)*PARAMETERS);
|
||||||
plug->crap->adjust(plug->params, fs);
|
plug->crap->adjust(plug->params, fs);
|
||||||
|
@ -92,7 +91,6 @@ static void
|
||||||
plug_destruct(LADSPA_Handle instance)
|
plug_destruct(LADSPA_Handle instance)
|
||||||
{
|
{
|
||||||
plug_t *plug = (plug_t *)instance;
|
plug_t *plug = (plug_t *)instance;
|
||||||
plug->crap->destruct();
|
|
||||||
delete plug->crap;
|
delete plug->crap;
|
||||||
free(plug);
|
free(plug);
|
||||||
}
|
}
|
||||||
|
@ -117,13 +115,15 @@ plug_process(LADSPA_Handle instance, unsigned long count)
|
||||||
count);
|
count);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const LADSPA_Descriptor plug_desc = {
|
TEMPLATE static constexpr
|
||||||
.UniqueID = ID,
|
LADSPA_Descriptor gen_desc() {
|
||||||
.Label = LABEL,
|
return LADSPA_Descriptor {
|
||||||
|
.UniqueID = T::id,
|
||||||
|
.Label = T::label,
|
||||||
.Properties = 0,
|
.Properties = 0,
|
||||||
.Name = NAME,
|
.Name = T::name,
|
||||||
.Maker = AUTHOR,
|
.Maker = T::author,
|
||||||
.Copyright = COPYRIGHT,
|
.Copyright = T::copyright,
|
||||||
.PortCount = PCOUNT,
|
.PortCount = PCOUNT,
|
||||||
.PortDescriptors = p_descs,
|
.PortDescriptors = p_descs,
|
||||||
.PortRangeHints = p_hints,
|
.PortRangeHints = p_hints,
|
||||||
|
@ -137,14 +137,19 @@ static const LADSPA_Descriptor plug_desc = {
|
||||||
.run = plug_process,
|
.run = plug_process,
|
||||||
.run_adding = NULL,
|
.run_adding = NULL,
|
||||||
.set_run_adding_gain = NULL
|
.set_run_adding_gain = NULL
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static constexpr LADSPA_Descriptor plug_descs[] = {
|
||||||
|
gen_desc<CrapPlug>()
|
||||||
};
|
};
|
||||||
|
|
||||||
const LADSPA_Descriptor *
|
const LADSPA_Descriptor *
|
||||||
ladspa_descriptor(unsigned long index)
|
ladspa_descriptor(unsigned long index)
|
||||||
{
|
{
|
||||||
if (index != 0)
|
if (index >= sizeof(plug_descs)/sizeof(plug_descs[0]))
|
||||||
return NULL;
|
return NULL;
|
||||||
return &plug_desc;
|
return plug_descs + index;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Reference in a new issue