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 PARAMETERS (BANDS*3)
|
||||
|
||||
|
@ -14,69 +9,20 @@
|
|||
#include "util.hpp"
|
||||
#include "param.hpp"
|
||||
#include "Crap.hpp"
|
||||
#include "Buffer2.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
|
||||
:public Unconstructive<
|
||||
AdjustAll<
|
||||
Buffer2<Crap>
|
||||
>
|
||||
> {
|
||||
:public AdjustAll<Buffer2<Crap>> {
|
||||
static constexpr ulong id = 0x000CAFED;
|
||||
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_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
|
||||
~Crap() {}
|
||||
|
||||
virtual inline void
|
||||
construct() = 0;
|
||||
|
||||
virtual inline void
|
||||
destruct() = 0;
|
||||
|
||||
virtual void
|
||||
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>
|
||||
struct NoParams : public virtual Mixin {
|
||||
// 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->crap = new CrapPlug();
|
||||
plug->crap->construct();
|
||||
#if (PARAMETERS > 0)
|
||||
memcpy(plug->params, global_params, sizeof(param)*PARAMETERS);
|
||||
plug->crap->adjust(plug->params, fs);
|
||||
|
@ -92,7 +91,6 @@ static void
|
|||
plug_destruct(LADSPA_Handle instance)
|
||||
{
|
||||
plug_t *plug = (plug_t *)instance;
|
||||
plug->crap->destruct();
|
||||
delete plug->crap;
|
||||
free(plug);
|
||||
}
|
||||
|
@ -117,13 +115,15 @@ plug_process(LADSPA_Handle instance, unsigned long count)
|
|||
count);
|
||||
}
|
||||
|
||||
static const LADSPA_Descriptor plug_desc = {
|
||||
.UniqueID = ID,
|
||||
.Label = LABEL,
|
||||
TEMPLATE static constexpr
|
||||
LADSPA_Descriptor gen_desc() {
|
||||
return LADSPA_Descriptor {
|
||||
.UniqueID = T::id,
|
||||
.Label = T::label,
|
||||
.Properties = 0,
|
||||
.Name = NAME,
|
||||
.Maker = AUTHOR,
|
||||
.Copyright = COPYRIGHT,
|
||||
.Name = T::name,
|
||||
.Maker = T::author,
|
||||
.Copyright = T::copyright,
|
||||
.PortCount = PCOUNT,
|
||||
.PortDescriptors = p_descs,
|
||||
.PortRangeHints = p_hints,
|
||||
|
@ -137,14 +137,19 @@ static const LADSPA_Descriptor plug_desc = {
|
|||
.run = plug_process,
|
||||
.run_adding = NULL,
|
||||
.set_run_adding_gain = NULL
|
||||
};
|
||||
}
|
||||
|
||||
static constexpr LADSPA_Descriptor plug_descs[] = {
|
||||
gen_desc<CrapPlug>()
|
||||
};
|
||||
|
||||
const LADSPA_Descriptor *
|
||||
ladspa_descriptor(unsigned long index)
|
||||
{
|
||||
if (index != 0)
|
||||
if (index >= sizeof(plug_descs)/sizeof(plug_descs[0]))
|
||||
return NULL;
|
||||
return &plug_desc;
|
||||
return plug_descs + index;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Add table
Reference in a new issue