Update of /cvsroot/pure-data/externals/creb/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13817
Modified Files: ead.c eadsr.c ear.c fdn.c permut.c tabreadmix.c Added Files: extlib_util.h filters.h Log Message: moved headers from externals/creb/include to externals/creb/modules to dramatically simplify build process (I discussed this with Tom, he said he would make the changes to his own source repository, this is just a copy)
Index: tabreadmix.c =================================================================== RCS file: /cvsroot/pure-data/externals/creb/modules/tabreadmix.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tabreadmix.c 12 Apr 2005 06:22:12 -0000 1.2 --- tabreadmix.c 25 May 2006 16:03:20 -0000 1.3 *************** *** 20,24 **** #include <m_pd.h> #include <math.h> ! #include "../include/extlib_util.h"
/******************** tabreadmix~ ***********************/ --- 20,24 ---- #include <m_pd.h> #include <math.h> ! #include "extlib_util.h"
/******************** tabreadmix~ ***********************/
--- NEW FILE: extlib_util.h --- /* * Prototypes for utility functions used in pd externals * Copyright (c) 2000-2003 by Tom Schouten * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef CREB_EXTLIB_UTIL_H #define CREB_EXTLIB_UTIL_H
#include <math.h> #include "m_pd.h"
/* envelope stuff */
/* exponential range for envelopes is 60dB */ #define ENVELOPE_RANGE 0.001f #define ENVELOPE_MAX (1.0f - ENVELOPE_RANGE) #define ENVELOPE_MIN ENVELOPE_RANGE
/* convert milliseconds to 1-p, with p a real pole */ float milliseconds_2_one_minus_realpole(float time);
typedef union { unsigned int i; float f; } t_flint;
/* check if floating point number is denormal */
//#define IS_DENORMAL(f) (((*(unsigned int *)&(f))&0x7f800000) == 0)
#define IS_DENORMAL(f) (((((t_flint)(f)).i) & 0x7f800000) == 0)
#endif /* CREB_EXTLIB_UTIL_H */
Index: eadsr.c =================================================================== RCS file: /cvsroot/pure-data/externals/creb/modules/eadsr.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** eadsr.c 12 Apr 2005 06:22:12 -0000 1.4 --- eadsr.c 25 May 2006 16:03:20 -0000 1.5 *************** *** 20,24 **** #include <m_pd.h> #include <math.h> ! #include "../include/extlib_util.h"
typedef struct eadsrctl --- 20,24 ---- #include <m_pd.h> #include <math.h> ! #include "extlib_util.h"
typedef struct eadsrctl
Index: fdn.c =================================================================== RCS file: /cvsroot/pure-data/externals/creb/modules/fdn.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** fdn.c 31 Dec 2005 19:31:09 -0000 1.5 --- fdn.c 25 May 2006 16:03:20 -0000 1.6 *************** *** 29,33 **** #include <m_pd.h> #include <math.h> ! #include "../include/extlib_util.h"
#include <stdlib.h> --- 29,33 ---- #include <m_pd.h> #include <math.h> ! #include "extlib_util.h"
#include <stdlib.h>
Index: ear.c =================================================================== RCS file: /cvsroot/pure-data/externals/creb/modules/ear.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ear.c 12 Apr 2005 06:22:12 -0000 1.4 --- ear.c 25 May 2006 16:03:20 -0000 1.5 *************** *** 20,24 **** #include <m_pd.h> #include <math.h> ! #include "../include/extlib_util.h"
typedef struct earctl --- 20,24 ---- #include <m_pd.h> #include <math.h> ! #include "extlib_util.h"
typedef struct earctl
--- NEW FILE: filters.h --- /* this file contains a 37th attempt to write a general purpose iir filter toolset */
/* defined as inline functions with call by reference to enable compiler ref/deref optim */
#ifndef CREB_FILTERS_H #define CREB_FILTERS_H
/* the typedef */ #ifndef T #define T float #endif
/* the prototype for a word */ #define P static inline void #define PP static void
/* the 'reference' arguments */ #define A *a #define B *b #define C *c #define D *d #define X *x #define Y *y #define S *s
/* the opcodes */
/* add */ P cadd (T X, T Y, T A, T B, T C, T D) { X = A + C; Y = B + D;} P cadd2 (T A, T B, T C, T D) { A += C; B += D;} P vcadd (T X, T A, T C) { cadd(x,x+1,a,a+1,c,c+1); } P vcadd2 (T A, T C) { cadd2(a,a+1,c,c+1); }
/* mul */ P cmul_r (T X, T A, T B, T C, T D) { X = A * C - B * D;} P cmul_i (T Y, T A, T B, T C, T D) { Y = A * D + B * C;} P cmul (T X, T Y, T A, T B, T C, T D) { cmul_r (x, a, b, c, d); cmul_i (y, a, b, c, d); } P cmul2 (T A, T B, T C, T D) { T x = A; T y = B; cmul (&x, &y, a, b, c, d); A = x; B = y; }
P vcmul (T X, T A, T C) { cmul(x,x+1,a,a+1,c,c+1); } P vcmul2 (T A, T C) { cmul2(a,a+1,c,c+1); }
/* norm */ static inline float vcnorm(T X) { return hypot(x[0], x[1]); }
/* swap */ P vcswap(T Y, T X) { float t[2] = {x[0], x[1]}; x[0] = y[0]; x[1] = y[1]; y[0] = t[0]; y[1] = t[1]; }
/* inverse */ P vcinv(T Y, T X) { float scale = 1.0f / vcnorm(x); y[0] = scale * x[0]; y[1] = scale * x[1]; }
P vcinv1(T X) { float scale = 1.0f / vcnorm(x); x[0] *= scale; x[1] *= scale; }
/* exp */
/* X = exp(Y) */ P vcexp2 (T Y, T X) { T r = exp(x[0]); y[0] = cos (x[1]); y[1] = sin (x[1]); y[0] *= r; y[1] *= r; }
P vcexp1 (T X) { T y[2]; vcexp2(y,x); x[0] = y[0]; x[1] = y[1]; }
/* FILTERS
the transfer function is defined in terms of the "engineering" bilateral z-transform of the discrete impulse response h[n].
H(z) = Sum{n = -inf -> inf} h[n] z^(-n)
a unit delay operating on a singnal S(z) is therefore represented as z^(-1) S(z)
*/
/* biquads */
/* biquad, orthogonal (poles & zeros), real in, out, state, pole, output */ P biq_orth_r (T X, T Y, T S, T A, T C) { Y = X + c[0] * s[0] - c[1] * s[1]; /* mind sign of c[1] */ vcmul2(s, a); S += X; }
/* biquad, orthogonal, complex one-pole, with scaling */
/* complex one pole: (output = s[0] + is[1]): C / (1-A z^(-1)) */
P one_pole_complex (T X, T Y, T S, T A, T C) { vcmul(y, s, a); vcadd2(y, x); s[0] = y[0]; s[1] = y[1]; vcmul(y, s, c); }
/* complex conj two pole: (output = s[0] : (Re(C) - Re(C*Conj(A))) / (1 - A z^(-1)) (1 - Conj(A) z^(-1)) */
P two_pole_complex_conj (T X, T Y, T S, T A, T C) { vcmul2(s, a); s[0] += x[0]; y[0] = s[0] * c[0] - s[1] * c[1]; }
/* support functions for IIR filter design */
/* evaluate pole and allzero TF in z^-1 given the complex zeros/poles: p(z) (or p(z)^-1) = \product (1-z_i z^-1) */ PP eval_zero_poly(float *val, float *arg, float *zeros, int nb_zeros) { int i; float a[2] = {arg[0], arg[1]}; vcinv1(a); val[0] = 1.0f; val[1] = 0.0f; a[0] *= -1; a[1] *= -1; for (i=0; i<nb_zeros; i++){ float t[2]; vcmul(t, a, zeros + 2*i); t[0] += 1.0f; vcmul2(val, t); } }
PP eval_pole_poly(float *val, float *arg, float *poles, int nb_poles) { eval_zero_poly(val, arg, poles, nb_poles); vcinv1(val); }
/* since it's more efficient to store half of the poles for a real impulse response, these functions compute p(z) conj(p(conj(z))) */
PP eval_conj_zero_poly(float *val, float *arg, float *zeros, int nb_zeros) { float t[2]; float a[2] = {arg[0], arg[1]}; eval_zero_poly(t, a, zeros, nb_zeros); a[1] *= -1; eval_zero_poly(val, a, zeros, nb_zeros); val[1] *= -1; vcmul2(val, t); }
PP eval_conj_pole_poly(float *val, float *arg, float *poles, int nb_poles) { eval_conj_zero_poly(val, arg, poles, nb_poles); vcinv1(val); }
PP eval_conj_pole_zero_ratfunc(float *val, float *arg, float *poles, float *zeros, int nb_poles, int nb_zeros) { float t[2]; eval_conj_zero_poly(t, arg, zeros, nb_zeros); eval_conj_pole_poly(val, arg, poles, nb_zeros); vcmul2(val, t); }
/* bandlimited IIR impulse:
* design analog butterworth filter * obtain the partial fraction expansion of the transfer function * determine the state increment as a function of fractional delay of impulse location (sample the impulse response)
*/
#endif /* CREB_FILTERS_H */
Index: permut.c =================================================================== RCS file: /cvsroot/pure-data/externals/creb/modules/permut.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** permut.c 31 Dec 2005 19:31:09 -0000 1.4 --- permut.c 25 May 2006 16:03:20 -0000 1.5 *************** *** 22,26 **** #include <m_pd.h> #include <math.h> ! #include "../include/extlib_util.h" #include <stdlib.h>
--- 22,26 ---- #include <m_pd.h> #include <math.h> ! #include "extlib_util.h" #include <stdlib.h>
Index: ead.c =================================================================== RCS file: /cvsroot/pure-data/externals/creb/modules/ead.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ead.c 12 Apr 2005 06:22:12 -0000 1.4 --- ead.c 25 May 2006 16:03:20 -0000 1.5 *************** *** 20,24 **** #include <m_pd.h> #include <math.h> ! #include "../include/extlib_util.h"
/* pointer to */ --- 20,24 ---- #include <m_pd.h> #include <math.h> ! #include "extlib_util.h"
/* pointer to */