(Audio filters) Cleanups

This commit is contained in:
twinaphex 2015-03-15 06:17:40 +01:00
parent 7a552e61ea
commit 9f088d8e72
4 changed files with 34 additions and 28 deletions

View File

@ -57,12 +57,12 @@ endif
CC := $(compiler) -Wall
CXX := $(subst CC,++,$(compiler)) -std=gnu++0x -Wall
flags := -fPIC $(extra_flags)
flags := -fPIC $(extra_flags) -I../../libretro-common/include
asflags := -fPIC $(extra_flags)
objects :=
ifeq (1,$(use_neon))
ASMFLAGS := -INEON/asm
ASMFLAGS := -INEON/asm
asflags += -mfpu=neon
endif

View File

@ -17,6 +17,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <retro_inline.h>
#include "fft/fft.c"
@ -185,7 +186,7 @@ static void generate_response(fft_complex_t *response,
// Modified Bessel function of first order.
// Check Wiki for mathematical definition ...
static inline double kaiser_besseli0(double x)
static INLINE double kaiser_besseli0(double x)
{
unsigned i;
double sum = 0.0;
@ -211,7 +212,7 @@ static inline double kaiser_besseli0(double x)
return sum;
}
static inline double kaiser_window(double index, double beta)
static INLINE double kaiser_window(double index, double beta)
{
return kaiser_besseli0(beta * sqrt(1 - index * index));
}

View File

@ -25,19 +25,20 @@
#define sqr(a) ((a) * (a))
/* filter types */
enum IIRFilter {
LPF, /* low pass filter */
HPF, /* High pass filter */
BPCSGF,/* band pass filter 1 */
BPZPGF,/* band pass filter 2 */
APF, /* Allpass filter*/
NOTCH, /* Notch Filter */
RIAA_phono, /* RIAA record/tape deemphasis */
PEQ, /* Peaking band EQ filter */
BBOOST, /* Bassboost filter */
LSH, /* Low shelf filter */
HSH, /* High shelf filter */
RIAA_CD /* CD de-emphasis */
enum IIRFilter
{
LPF, /* low pass filter */
HPF, /* High pass filter */
BPCSGF, /* band pass filter 1 */
BPZPGF, /* band pass filter 2 */
APF, /* Allpass filter*/
NOTCH, /* Notch Filter */
RIAA_phono, /* RIAA record/tape deemphasis */
PEQ, /* Peaking band EQ filter */
BBOOST, /* Bassboost filter */
LSH, /* Low shelf filter */
HSH, /* High shelf filter */
RIAA_CD /* CD de-emphasis */
};
struct iir_data
@ -90,8 +91,8 @@ static void iir_process(void *data, struct dspfilter_output *output,
float in_l = out[0];
float in_r = out[1];
float l = (b0 * in_l + b1 * xn1_l + b2 * xn2_l - a1 * yn1_l - a2 * yn2_l) / a0;
float r = (b0 * in_r + b1 * xn1_r + b2 * xn2_r - a1 * yn1_r - a2 * yn2_r) / a0;
float l = (b0 * in_l + b1 * xn1_l + b2 * xn2_l - a1 * yn1_l - a2 * yn2_l) / a0;
float r = (b0 * in_r + b1 * xn1_r + b2 * xn2_r - a1 * yn1_r - a2 * yn2_r) / a0;
xn2_l = xn1_l;
xn1_l = in_l;
@ -140,9 +141,11 @@ static void make_poly_from_roots(
const double *roots, unsigned num_roots, float *poly)
{
unsigned i, j;
poly[0] = 1;
poly[1] = -roots[0];
memset(poly + 2, 0, (num_roots + 1 - 2) * sizeof(*poly));
for (i = 1; i < num_roots; i++)
for (j = num_roots; j > 0; j--)
poly[j] -= poly[j - 1] * roots[i];

View File

@ -18,6 +18,7 @@
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <retro_inline.h>
struct comb
{
@ -30,7 +31,15 @@ struct comb
float damp1, damp2;
};
static inline float comb_process(struct comb *c, float input)
struct allpass
{
float *buffer;
float feedback;
unsigned bufsize;
unsigned bufidx;
};
static INLINE float comb_process(struct comb *c, float input)
{
float output = c->buffer[c->bufidx];
c->filterstore = (output * c->damp2) + (c->filterstore * c->damp1);
@ -44,15 +53,8 @@ static inline float comb_process(struct comb *c, float input)
return output;
}
struct allpass
{
float *buffer;
float feedback;
unsigned bufsize;
unsigned bufidx;
};
static inline float allpass_process(struct allpass *a, float input)
static INLINE float allpass_process(struct allpass *a, float input)
{
float bufout = a->buffer[a->bufidx];
float output = -input + bufout;