Update of /cvsroot/pure-data/externals/windowing
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3830/windowing
Modified Files:
bartlett~.c blackman~.c connes~.c cosine~.c gaussian~.c
hamming~.c hanning~.c kaiser~.c lanczos~.c mconf.h welch~.c
Removed Files:
i0.c windowFunctions.c windowFunctions.h windowing.pd
Log Message:
- reorganized files to build easy with Pd-extended.
- updated NT macro to _MSC_VER since those pragmas are for MSVC only
- put each object's "fill" function into that object's .c file,
- added i0.c to the end of kaiser~.c since that's the only one that needs it
- added #define powf pow for _WIN32 and Mac OS X for gaussian~.c since those
platforms don't have single precision pow() by default
--- windowFunctions.c DELETED ---
Index: bartlett~.c
===================================================================
RCS file: /cvsroot/pure-data/externals/windowing/bartlett~.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** bartlett~.c 13 Dec 2007 04:10:52 -0000 1.1
--- bartlett~.c 13 Dec 2007 05:28:54 -0000 1.2
***************
*** 21,32 ****
#include "m_pd.h"
- #include "windowFunctions.h"
#include <stdlib.h>
! #ifdef NT
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
#define DEFBLOCKSIZE 64
static t_class *bartlett_class;
--- 21,44 ----
#include "m_pd.h"
#include <stdlib.h>
! #include <math.h>
!
! #ifdef _MSC_VER
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
+
#define DEFBLOCKSIZE 64
+ void fillBartlett(float *vec, int n) {
+ int i;
+ float xShift = (float)n / 2;
+ float x;
+ for (i = 0; i < n; i++) {
+ x = (i - xShift) / xShift;
+ vec[i] = (float)(1 - fabs(x));
+ }
+ }
+
static t_class *bartlett_class;
Index: lanczos~.c
===================================================================
RCS file: /cvsroot/pure-data/externals/windowing/lanczos~.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** lanczos~.c 13 Dec 2007 04:10:52 -0000 1.1
--- lanczos~.c 13 Dec 2007 05:28:54 -0000 1.2
***************
*** 21,32 ****
#include "m_pd.h"
- #include "windowFunctions.h"
#include <stdlib.h>
! #ifdef NT
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
#define DEFBLOCKSIZE 64
static t_class *lanczos_class;
--- 21,53 ----
#include "m_pd.h"
#include <stdlib.h>
! #include <math.h>
!
! #ifdef _WIN32
! #define M_PI 3.14159265358979323846
! #endif
!
! #ifdef _MSC_VER
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
+
#define DEFBLOCKSIZE 64
+ void fillLanczos(float *vec, int n) {
+ int i;
+ float xShift = (float)n / 2;
+ float x;
+ for (i = 0; i < n; i++) {
+ x = (i - xShift) / xShift;
+ if (x == 0) {
+ vec[i] = 1;
+ }
+ else {
+ vec[i] = (float)(sin(M_PI * x) / (M_PI * x));
+ }
+ }
+ }
+
static t_class *lanczos_class;
--- windowFunctions.h DELETED ---
Index: mconf.h
===================================================================
RCS file: /cvsroot/pure-data/externals/windowing/mconf.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** mconf.h 13 Dec 2007 04:10:52 -0000 1.1
--- mconf.h 13 Dec 2007 05:28:54 -0000 1.2
***************
*** 100,108 ****
#define TLOSS 5 /* total loss of precision */
#define PLOSS 6 /* partial loss of precision */
! #endif
#define EDOM 33
#define ERANGE 34
/* Complex numeral. */
typedef struct
{
--- 100,109 ----
#define TLOSS 5 /* total loss of precision */
#define PLOSS 6 /* partial loss of precision */
! #endif
#define EDOM 33
#define ERANGE 34
/* Complex numeral. */
+ #if 0
typedef struct
{
***************
*** 119,123 ****
} cmplxl;
#endif
!
/* Type of computer arithmetic */
--- 120,124 ----
} cmplxl;
#endif
! #endif
/* Type of computer arithmetic */
Index: cosine~.c
===================================================================
RCS file: /cvsroot/pure-data/externals/windowing/cosine~.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** cosine~.c 13 Dec 2007 04:10:52 -0000 1.1
--- cosine~.c 13 Dec 2007 05:28:54 -0000 1.2
***************
*** 21,32 ****
#include "m_pd.h"
- #include "windowFunctions.h"
#include <stdlib.h>
! #ifdef NT
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
#define DEFBLOCKSIZE 64
static t_class *cosine_class;
--- 21,48 ----
#include "m_pd.h"
#include <stdlib.h>
! #include <math.h>
!
! #ifdef _WIN32
! #define M_PI 3.14159265358979323846
! #endif
!
! #ifdef _MSC_VER
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
+
#define DEFBLOCKSIZE 64
+ void fillCosine(float *vec, int n) {
+ int i;
+ float xShift = (float)n / 2;
+ float x;
+ for (i = 0; i < n; i++) {
+ x = (i - xShift) / xShift;
+ vec[i] = (float)cos(M_PI * x / 2);
+ }
+ }
+
static t_class *cosine_class;
--- i0.c DELETED ---
Index: blackman~.c
===================================================================
RCS file: /cvsroot/pure-data/externals/windowing/blackman~.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** blackman~.c 13 Dec 2007 04:10:52 -0000 1.1
--- blackman~.c 13 Dec 2007 05:28:54 -0000 1.2
***************
*** 21,32 ****
#include "m_pd.h"
- #include "windowFunctions.h"
#include <stdlib.h>
! #ifdef NT
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
#define DEFBLOCKSIZE 64
static t_class *blackman_class;
--- 21,48 ----
#include "m_pd.h"
#include <stdlib.h>
! #include <math.h>
!
! #ifdef _WIN32
! #define M_PI 3.14159265358979323846
! #endif
!
! #ifdef _MSC_VER
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
+
#define DEFBLOCKSIZE 64
+ void fillBlackman(float *vec, int n) {
+ int i;
+ float xShift = (float)n / 2;
+ float x;
+ for (i = 0; i < n; i++) {
+ x = (i - xShift) / xShift;
+ vec[i] = (float)(0.42 + (0.5 * cos(M_PI * x)) + (0.08 * cos (2 * M_PI * x)));
+ }
+ }
+
static t_class *blackman_class;
Index: connes~.c
===================================================================
RCS file: /cvsroot/pure-data/externals/windowing/connes~.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** connes~.c 13 Dec 2007 04:10:52 -0000 1.1
--- connes~.c 13 Dec 2007 05:28:54 -0000 1.2
***************
*** 21,32 ****
#include "m_pd.h"
- #include "windowFunctions.h"
#include <stdlib.h>
! #ifdef NT
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
#define DEFBLOCKSIZE 64
static t_class *connes_class;
--- 21,43 ----
#include "m_pd.h"
#include <stdlib.h>
!
! #ifdef _MSC_VER
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
+
#define DEFBLOCKSIZE 64
+ void fillConnes(float *vec, int n) {
+ int i;
+ float xShift = (float)n / 2;
+ float x;
+ for (i = 0; i < n; i++) {
+ x = (i - xShift) / xShift;
+ vec[i] = (float)((1 - (x * x)) * (1 - (x * x)));
+ }
+ }
+
static t_class *connes_class;
Index: hamming~.c
===================================================================
RCS file: /cvsroot/pure-data/externals/windowing/hamming~.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** hamming~.c 13 Dec 2007 04:10:52 -0000 1.1
--- hamming~.c 13 Dec 2007 05:28:54 -0000 1.2
***************
*** 21,32 ****
#include "m_pd.h"
- #include "windowFunctions.h"
#include <stdlib.h>
! #ifdef NT
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
#define DEFBLOCKSIZE 64
static t_class *hamming_class;
--- 21,48 ----
#include "m_pd.h"
#include <stdlib.h>
! #include <math.h>
!
! #ifdef _WIN32
! #define M_PI 3.14159265358979323846
! #endif
!
! #ifdef _MSC_VER
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
+
#define DEFBLOCKSIZE 64
+ void fillHamming(float *vec, int n) {
+ int i;
+ float xShift = (float)n / 2;
+ float x;
+ for (i = 0; i < n; i++) {
+ x = (i - xShift) / xShift;
+ vec[i] = (float)(0.54 + 0.46 * cos(M_PI * x));
+ }
+ }
+
static t_class *hamming_class;
Index: welch~.c
===================================================================
RCS file: /cvsroot/pure-data/externals/windowing/welch~.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** welch~.c 13 Dec 2007 04:10:52 -0000 1.1
--- welch~.c 13 Dec 2007 05:28:54 -0000 1.2
***************
*** 21,32 ****
#include "m_pd.h"
- #include "windowFunctions.h"
#include <stdlib.h>
! #ifdef NT
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
#define DEFBLOCKSIZE 64
static t_class *welch_class;
--- 21,43 ----
#include "m_pd.h"
#include <stdlib.h>
!
! #ifdef _MSC_VER
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
+
#define DEFBLOCKSIZE 64
+ void fillWelch(float *vec, int n) {
+ int i;
+ float xShift = (float)n / 2;
+ float x;
+ for (i = 0; i < n; i++) {
+ x = (i - xShift) / xShift;
+ vec[i] = 1 - (x * x);
+ }
+ }
+
static t_class *welch_class;
Index: hanning~.c
===================================================================
RCS file: /cvsroot/pure-data/externals/windowing/hanning~.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** hanning~.c 13 Dec 2007 04:10:52 -0000 1.1
--- hanning~.c 13 Dec 2007 05:28:54 -0000 1.2
***************
*** 21,32 ****
#include "m_pd.h"
- #include "windowFunctions.h"
#include <stdlib.h>
! #ifdef NT
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
#define DEFBLOCKSIZE 64
static t_class *hanning_class;
--- 21,48 ----
#include "m_pd.h"
#include <stdlib.h>
! #include <math.h>
!
! #ifdef _WIN32
! #define M_PI 3.14159265358979323846
! #endif
!
! #ifdef _MSC_VER
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
+
#define DEFBLOCKSIZE 64
+ void fillHanning(float *vec, int n) {
+ int i;
+ float xShift = (float)n / 2;
+ float x;
+ for (i = 0; i < n; i++) {
+ x = (i - xShift) / xShift;
+ vec[i] = (float)(0.5 * (1 + cos(M_PI * x)));
+ }
+ }
+
static t_class *hanning_class;
--- windowing.pd DELETED ---
Index: kaiser~.c
===================================================================
RCS file: /cvsroot/pure-data/externals/windowing/kaiser~.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** kaiser~.c 13 Dec 2007 04:10:52 -0000 1.1
--- kaiser~.c 13 Dec 2007 05:28:54 -0000 1.2
***************
*** 21,33 ****
#include "m_pd.h"
! #include "windowFunctions.h"
#include <stdlib.h>
! #ifdef NT
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
#define DEFALPHA 10
#define DEFBLOCKSIZE 64
static t_class *kaiser_class;
--- 21,49 ----
#include "m_pd.h"
! #include "mconf.h"
#include <stdlib.h>
! #include <math.h>
!
! #ifdef _MSC_VER
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
+
#define DEFALPHA 10
#define DEFBLOCKSIZE 64
+ double i0(double x);
+ double i0e(double x);
+
+ void fillKaiser(float *vec, int n, float alpha) {
+ int i;
+ float xShift = (float)n / 2;
+ float x;
+ for (i = 0; i < n; i++) {
+ x = (i - xShift) / xShift;
+ vec[i] = (float)(i0(alpha * sqrt(1 - (x * x))) / i0(alpha));
+ }
+ }
+
static t_class *kaiser_class;
***************
*** 98,99 ****
--- 114,527 ----
class_addfloat(kaiser_class, (t_method)kaiser_float);
}
+
+
+
+
+ /* originally from i0.c
+ *
+ * Modified Bessel function of order zero
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, i0();
+ *
+ * y = i0( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns modified Bessel function of order zero of the
+ * argument.
+ *
+ * The function is defined as i0(x) = j0( ix ).
+ *
+ * The range is partitioned into the two intervals [0,8] and
+ * (8, infinity). Chebyshev polynomial expansions are employed
+ * in each interval.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ * Relative error:
+ * arithmetic domain # trials peak rms
+ * DEC 0,30 6000 8.2e-17 1.9e-17
+ * IEEE 0,30 30000 5.8e-16 1.4e-16
+ *
+ */
+ /* i0e.c
+ *
+ * Modified Bessel function of order zero,
+ * exponentially scaled
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, i0e();
+ *
+ * y = i0e( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns exponentially scaled modified Bessel function
+ * of order zero of the argument.
+ *
+ * The function is defined as i0e(x) = exp(-|x|) j0( ix ).
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ * Relative error:
+ * arithmetic domain # trials peak rms
+ * IEEE 0,30 30000 5.4e-16 1.2e-16
+ * See i0().
+ *
+ */
+
+ /* i0.c */
+
+
+ /*
+ Cephes Math Library Release 2.8: June, 2000
+ Copyright 1984, 1987, 2000 by Stephen L. Moshier
+ */
+
+ #include "mconf.h"
+
+ /* Chebyshev coefficients for exp(-x) I0(x)
+ * in the interval [0,8].
+ *
+ * lim(x->0){ exp(-x) I0(x) } = 1.
+ */
+
+ #ifdef UNK
+ static double A[] =
+ {
+ -4.41534164647933937950E-18,
+ 3.33079451882223809783E-17,
+ -2.43127984654795469359E-16,
+ 1.71539128555513303061E-15,
+ -1.16853328779934516808E-14,
+ 7.67618549860493561688E-14,
+ -4.85644678311192946090E-13,
+ 2.95505266312963983461E-12,
+ -1.72682629144155570723E-11,
+ 9.67580903537323691224E-11,
+ -5.18979560163526290666E-10,
+ 2.65982372468238665035E-9,
+ -1.30002500998624804212E-8,
+ 6.04699502254191894932E-8,
+ -2.67079385394061173391E-7,
+ 1.11738753912010371815E-6,
+ -4.41673835845875056359E-6,
+ 1.64484480707288970893E-5,
+ -5.75419501008210370398E-5,
+ 1.88502885095841655729E-4,
+ -5.76375574538582365885E-4,
+ 1.63947561694133579842E-3,
+ -4.32430999505057594430E-3,
+ 1.05464603945949983183E-2,
+ -2.37374148058994688156E-2,
+ 4.93052842396707084878E-2,
+ -9.49010970480476444210E-2,
+ 1.71620901522208775349E-1,
+ -3.04682672343198398683E-1,
+ 6.76795274409476084995E-1
+ };
+ #endif
+
+ #ifdef DEC
+ static unsigned short A[] = {
+ 0121642,0162671,0004646,0103567,
+ 0022431,0115424,0135755,0026104,
+ 0123214,0023533,0110365,0156635,
+ 0023767,0033304,0117662,0172716,
+ 0124522,0100426,0012277,0157531,
+ 0025254,0155062,0054461,0030465,
+ 0126010,0131143,0013560,0153604,
+ 0026517,0170577,0006336,0114437,
+ 0127227,0162253,0152243,0052734,
+ 0027724,0142766,0061641,0160200,
+ 0130416,0123760,0116564,0125262,
+ 0031066,0144035,0021246,0054641,
+ 0131537,0053664,0060131,0102530,
+ 0032201,0155664,0165153,0020652,
+ 0132617,0061434,0074423,0176145,
+ 0033225,0174444,0136147,0122542,
+ 0133624,0031576,0056453,0020470,
+ 0034211,0175305,0172321,0041314,
+ 0134561,0054462,0147040,0165315,
+ 0035105,0124333,0120203,0162532,
+ 0135427,0013750,0174257,0055221,
+ 0035726,0161654,0050220,0100162,
+ 0136215,0131361,0000325,0041110,
+ 0036454,0145417,0117357,0017352,
+ 0136702,0072367,0104415,0133574,
+ 0037111,0172126,0072505,0014544,
+ 0137302,0055601,0120550,0033523,
+ 0037457,0136543,0136544,0043002,
+ 0137633,0177536,0001276,0066150,
+ 0040055,0041164,0100655,0010521
+ };
+ #endif
+
+ #ifdef IBMPC
+ static unsigned short A[] = {
+ 0xd0ef,0x2134,0x5cb7,0xbc54,
+ 0xa589,0x977d,0x3362,0x3c83,
+ 0xbbb4,0x721e,0x84eb,0xbcb1,
+ 0x5eba,0x93f6,0xe6d8,0x3cde,
+ 0xfbeb,0xc297,0x5022,0xbd0a,
+ 0x2627,0x4b26,0x9b46,0x3d35,
+ 0x1af0,0x62ee,0x164c,0xbd61,
+ 0xd324,0xe19b,0xfe2f,0x3d89,
+ 0x6abc,0x7a94,0xfc95,0xbdb2,
+ 0x3c10,0xcc74,0x98be,0x3dda,
+ 0x9556,0x13ae,0xd4fe,0xbe01,
+ 0xcb34,0xa454,0xd903,0x3e26,
+ 0x30ab,0x8c0b,0xeaf6,0xbe4b,
+ 0x6435,0x9d4d,0x3b76,0x3e70,
+ 0x7f8d,0x8f22,0xec63,0xbe91,
+ 0xf4ac,0x978c,0xbf24,0x3eb2,
+ 0x6427,0xcba5,0x866f,0xbed2,
+ 0x2859,0xbe9a,0x3f58,0x3ef1,
+ 0x1d5a,0x59c4,0x2b26,0xbf0e,
+ 0x7cab,0x7410,0xb51b,0x3f28,
+ 0xeb52,0x1f15,0xe2fd,0xbf42,
+ 0x100e,0x8a12,0xdc75,0x3f5a,
+ 0xa849,0x201a,0xb65e,0xbf71,
+ 0xe3dd,0xf3dd,0x9961,0x3f85,
+ 0xb6f0,0xf121,0x4e9e,0xbf98,
+ 0xa32d,0xcea8,0x3e8a,0x3fa9,
+ 0x06ea,0x342d,0x4b70,0xbfb8,
+ 0x88c0,0x77ac,0xf7ac,0x3fc5,
+ 0xcd8d,0xc057,0x7feb,0xbfd3,
+ 0xa22a,0x9035,0xa84e,0x3fe5,
+ };
+ #endif
+
+ #ifdef MIEEE
+ static unsigned short A[] = {
+ 0xbc54,0x5cb7,0x2134,0xd0ef,
+ 0x3c83,0x3362,0x977d,0xa589,
+ 0xbcb1,0x84eb,0x721e,0xbbb4,
+ 0x3cde,0xe6d8,0x93f6,0x5eba,
+ 0xbd0a,0x5022,0xc297,0xfbeb,
+ 0x3d35,0x9b46,0x4b26,0x2627,
+ 0xbd61,0x164c,0x62ee,0x1af0,
+ 0x3d89,0xfe2f,0xe19b,0xd324,
+ 0xbdb2,0xfc95,0x7a94,0x6abc,
+ 0x3dda,0x98be,0xcc74,0x3c10,
+ 0xbe01,0xd4fe,0x13ae,0x9556,
+ 0x3e26,0xd903,0xa454,0xcb34,
+ 0xbe4b,0xeaf6,0x8c0b,0x30ab,
+ 0x3e70,0x3b76,0x9d4d,0x6435,
+ 0xbe91,0xec63,0x8f22,0x7f8d,
+ 0x3eb2,0xbf24,0x978c,0xf4ac,
+ 0xbed2,0x866f,0xcba5,0x6427,
+ 0x3ef1,0x3f58,0xbe9a,0x2859,
+ 0xbf0e,0x2b26,0x59c4,0x1d5a,
+ 0x3f28,0xb51b,0x7410,0x7cab,
+ 0xbf42,0xe2fd,0x1f15,0xeb52,
+ 0x3f5a,0xdc75,0x8a12,0x100e,
+ 0xbf71,0xb65e,0x201a,0xa849,
+ 0x3f85,0x9961,0xf3dd,0xe3dd,
+ 0xbf98,0x4e9e,0xf121,0xb6f0,
+ 0x3fa9,0x3e8a,0xcea8,0xa32d,
+ 0xbfb8,0x4b70,0x342d,0x06ea,
+ 0x3fc5,0xf7ac,0x77ac,0x88c0,
+ 0xbfd3,0x7feb,0xc057,0xcd8d,
+ 0x3fe5,0xa84e,0x9035,0xa22a
+ };
+ #endif
+
+
+ /* Chebyshev coefficients for exp(-x) sqrt(x) I0(x)
+ * in the inverted interval [8,infinity].
+ *
+ * lim(x->inf){ exp(-x) sqrt(x) I0(x) } = 1/sqrt(2pi).
+ */
+
+ #ifdef UNK
+ static double B[] =
+ {
+ -7.23318048787475395456E-18,
+ -4.83050448594418207126E-18,
+ 4.46562142029675999901E-17,
+ 3.46122286769746109310E-17,
+ -2.82762398051658348494E-16,
+ -3.42548561967721913462E-16,
+ 1.77256013305652638360E-15,
+ 3.81168066935262242075E-15,
+ -9.55484669882830764870E-15,
+ -4.15056934728722208663E-14,
+ 1.54008621752140982691E-14,
+ 3.85277838274214270114E-13,
+ 7.18012445138366623367E-13,
+ -1.79417853150680611778E-12,
+ -1.32158118404477131188E-11,
+ -3.14991652796324136454E-11,
+ 1.18891471078464383424E-11,
+ 4.94060238822496958910E-10,
+ 3.39623202570838634515E-9,
+ 2.26666899049817806459E-8,
+ 2.04891858946906374183E-7,
+ 2.89137052083475648297E-6,
+ 6.88975834691682398426E-5,
+ 3.36911647825569408990E-3,
+ 8.04490411014108831608E-1
+ };
+ #endif
+
+ #ifdef DEC
+ static unsigned short B[] = {
+ 0122005,0066672,0123124,0054311,
+ 0121662,0033323,0030214,0104602,
+ 0022515,0170300,0113314,0020413,
+ 0022437,0117350,0035402,0007146,
+ 0123243,0000135,0057220,0177435,
+ 0123305,0073476,0144106,0170702,
+ 0023777,0071755,0017527,0154373,
+ 0024211,0052214,0102247,0033270,
+ 0124454,0017763,0171453,0012322,
+ 0125072,0166316,0075505,0154616,
+ 0024612,0133770,0065376,0025045,
+ 0025730,0162143,0056036,0001632,
+ 0026112,0015077,0150464,0063542,
+ 0126374,0101030,0014274,0065457,
+ 0127150,0077271,0125763,0157617,
+ 0127412,0104350,0040713,0120445,
+ 0027121,0023765,0057500,0001165,
+ 0030407,0147146,0003643,0075644,
+ 0031151,0061445,0044422,0156065,
+ 0031702,0132224,0003266,0125551,
+ 0032534,0000076,0147153,0005555,
+ 0033502,0004536,0004016,0026055,
+ 0034620,0076433,0142314,0171215,
+ 0036134,0146145,0013454,0101104,
+ 0040115,0171425,0062500,0047133
+ };
+ #endif
+
+ #ifdef IBMPC
+ static unsigned short B[] = {
+ 0x8b19,0x54ca,0xadb7,0xbc60,
+ 0x9130,0x6611,0x46da,0xbc56,
+ 0x8421,0x12d9,0xbe18,0x3c89,
+ 0x41cd,0x0760,0xf3dd,0x3c83,
+ 0x1fe4,0xabd2,0x600b,0xbcb4,
+ 0xde38,0xd908,0xaee7,0xbcb8,
+ 0xfb1f,0xa3ea,0xee7d,0x3cdf,
+ 0xe6d7,0x9094,0x2a91,0x3cf1,
+ 0x629a,0x7e65,0x83fe,0xbd05,
+ 0xbb32,0xcf68,0x5d99,0xbd27,
+ 0xc545,0x0d5f,0x56ff,0x3d11,
+ 0xc073,0x6b83,0x1c8c,0x3d5b,
+ 0x8cec,0xfa26,0x4347,0x3d69,
+ 0x8d66,0x0317,0x9043,0xbd7f,
+ 0x7bf2,0x357e,0x0fd7,0xbdad,
+ 0x7425,0x0839,0x511d,0xbdc1,
+ 0x004f,0xabe8,0x24fe,0x3daa,
+ 0x6f75,0xc0f4,0xf9cc,0x3e00,
+ 0x5b87,0xa922,0x2c64,0x3e2d,
+ 0xd56d,0x80d6,0x5692,0x3e58,
+ 0x616e,0xd9cd,0x8007,0x3e8b,
+ 0xc586,0xc101,0x412b,0x3ec8,
+ 0x9e52,0x7899,0x0fa3,0x3f12,
+ 0x9049,0xa2e5,0x998c,0x3f6b,
+ 0x09cb,0xaca8,0xbe62,0x3fe9
+ };
+ #endif
+
+ #ifdef MIEEE
+ static unsigned short B[] = {
+ 0xbc60,0xadb7,0x54ca,0x8b19,
+ 0xbc56,0x46da,0x6611,0x9130,
+ 0x3c89,0xbe18,0x12d9,0x8421,
+ 0x3c83,0xf3dd,0x0760,0x41cd,
+ 0xbcb4,0x600b,0xabd2,0x1fe4,
+ 0xbcb8,0xaee7,0xd908,0xde38,
+ 0x3cdf,0xee7d,0xa3ea,0xfb1f,
+ 0x3cf1,0x2a91,0x9094,0xe6d7,
+ 0xbd05,0x83fe,0x7e65,0x629a,
+ 0xbd27,0x5d99,0xcf68,0xbb32,
+ 0x3d11,0x56ff,0x0d5f,0xc545,
+ 0x3d5b,0x1c8c,0x6b83,0xc073,
+ 0x3d69,0x4347,0xfa26,0x8cec,
+ 0xbd7f,0x9043,0x0317,0x8d66,
+ 0xbdad,0x0fd7,0x357e,0x7bf2,
+ 0xbdc1,0x511d,0x0839,0x7425,
+ 0x3daa,0x24fe,0xabe8,0x004f,
+ 0x3e00,0xf9cc,0xc0f4,0x6f75,
+ 0x3e2d,0x2c64,0xa922,0x5b87,
+ 0x3e58,0x5692,0x80d6,0xd56d,
+ 0x3e8b,0x8007,0xd9cd,0x616e,
+ 0x3ec8,0x412b,0xc101,0xc586,
+ 0x3f12,0x0fa3,0x7899,0x9e52,
+ 0x3f6b,0x998c,0xa2e5,0x9049,
+ 0x3fe9,0xbe62,0xaca8,0x09cb
+ };
+ #endif
+
+ double chbevl(double x, double array[], int n)
+ {
+ double b0, b1, b2, *p;
+ int i;
+
+ p = array;
+ b0 = *p++;
+ b1 = 0.0;
+ i = n - 1;
+
+ do
+ {
+ b2 = b1;
+ b1 = b0;
+ b0 = x * b1 - b2 + *p++;
+ }
+ while( --i );
+
+ return( 0.5*(b0-b2) );
+ }
+
+ double i0(double x)
+ {
+ double y;
+
+ if( x < 0 )
+ x = -x;
+ if( x <= 8.0 )
+ {
+ y = (x/2.0) - 2.0;
+ return( exp(x) * chbevl( y, A, 30 ) );
+ }
+
+ return( exp(x) * chbevl( 32.0/x - 2.0, B, 25 ) / sqrt(x) );
+
+ }
+
+
+
+
+ double i0e(double x)
+ {
+ double y;
+
+ if( x < 0 )
+ x = -x;
+ if( x <= 8.0 )
+ {
+ y = (x/2.0) - 2.0;
+ return( chbevl( y, A, 30 ) );
+ }
+
+ return( chbevl( 32.0/x - 2.0, B, 25 ) / sqrt(x) );
+
+ }
Index: gaussian~.c
===================================================================
RCS file: /cvsroot/pure-data/externals/windowing/gaussian~.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** gaussian~.c 13 Dec 2007 04:10:52 -0000 1.1
--- gaussian~.c 13 Dec 2007 05:28:54 -0000 1.2
***************
*** 21,33 ****
#include "m_pd.h"
- #include "windowFunctions.h"
#include <stdlib.h>
! #ifdef NT
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
#define DEFDELTA 0.5
#define DEFBLOCKSIZE 64
static t_class *gaussian_class;
--- 21,53 ----
#include "m_pd.h"
#include <stdlib.h>
! #include <math.h>
!
! #ifdef _MSC_VER
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
+
#define DEFDELTA 0.5
#define DEFBLOCKSIZE 64
+ /* MSW and OSX don't appear to have single-precision ANSI math */
+ #if defined(_WIN32) || defined(__APPLE__)
+ #define powf pow
+ #endif
+
+ void fillGaussian(float *vec, int n, float delta) {
+ int i;
+ float xShift = (float)n / 2;
+ float x;
+ if (delta == 0) {
+ delta = 1;
+ }
+ for (i = 0; i < n; i++) {
+ x = (i - xShift) / xShift;
+ vec[i] = (float)(pow(2, (-1 * (x / delta) * (x / delta))));
+ }
+ }
+
static t_class *gaussian_class;