From 4d8bc9862cac82349421270f22f9206c6b445ec8 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 23 Oct 2004 13:02:05 +0000 Subject: Cleanup svn-id: r15662 --- backends/midi/mt32/synth.cpp | 59 ++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 38 deletions(-) (limited to 'backends/midi') diff --git a/backends/midi/mt32/synth.cpp b/backends/midi/mt32/synth.cpp index eca2cae04e..084919437d 100644 --- a/backends/midi/mt32/synth.cpp +++ b/backends/midi/mt32/synth.cpp @@ -94,52 +94,35 @@ int axtoi(char *str) { return result; } -typedef struct { - unsigned int length; /* size of filter */ - float *history; /* pointer to history in filter */ - float *coef; /* pointer to coefficients of filter */ -} FILTER; - - -#define FILTER_SECTIONS 2 /* 2 filter sections for 24 db/oct filter */ - -typedef struct { - double a0, a1, a2; /* numerator coefficients */ - double b0, b1, b2; /* denominator coefficients */ -} BIQUAD; +struct FILTER { + unsigned int length; // size of filter + float *history; // pointer to history in filter + float *coef; // pointer to coefficients of filter +}; -BIQUAD ProtoCoef[FILTER_SECTIONS]; /* Filter prototype coefficients, - 1 for each filter section */ +#define FILTER_SECTIONS 2 // 2 filter sections for 24 db/oct filter -void prewarp(double *a0, double *a1, double *a2, double fc, double fs); -void bilinear( - double a0, double a1, double a2, /* numerator coefficients */ - double b0, double b1, double b2, /* denominator coefficients */ - double *k, /* overall gain factor */ - double fs, /* sampling rate */ - float *coef); /* pointer to 4 iir coefficients */ +struct BIQUAD { + double a0, a1, a2; // numerator coefficients + double b0, b1, b2; // denominator coefficients +}; +// Filter prototype coefficients, 1 for each filter section +BIQUAD ProtoCoef[FILTER_SECTIONS]; -/* - * ---------------------------------------------------------- - * Pre-warp the coefficients of a numerator or denominator. - * Note that a0 is assumed to be 1, so there is no wrapping - * of it. - * ---------------------------------------------------------- +/** + * Pre-warp the coefficients of a numerator or denominator. Note that a0 is + * assumed to be 1, so there is no wrapping of it. */ -void prewarp( - double *a0, double *a1, double *a2, - double fc, double fs) -{ - double wp, pi; - pi = 4.0 * atan(1.0); - wp = 2.0 * fs * tan(pi * fc / fs); +void prewarp(double *a0, double *a1, double *a2, double fc, double fs) { + double wp; - *a2 = (*a2) / (wp * wp); - *a1 = (*a1) / wp; -} + wp = 2.0 * fs * tan(PI * fc / fs); + *a2 = (*a2) / (wp * wp); + *a1 = (*a1) / wp; +} /* * ---------------------------------------------------------- -- cgit v1.2.3