Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4194/pd/src
Modified Files: Tag: stable_0_40 d_array.c d_osc.c m_pd.h x_list.c Added Files: Tag: stable_0_40 d_fft_fftsg.c d_fft_fftw.c d_fftsg_h.c Log Message: checking in 0.40-2
Index: x_list.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/x_list.c,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** x_list.c 24 Aug 2006 15:23:52 -0000 1.4 --- x_list.c 19 Jan 2007 04:30:57 -0000 1.4.2.1 *************** *** 411,415 **** int argc, t_atom *argv) { ! outlet_float(x->x_obj.ob_outlet, (float)argc); }
--- 411,415 ---- int argc, t_atom *argv) { ! outlet_float(x->x_obj.ob_outlet, (float)argc+1); }
--- NEW FILE: d_fftsg_h.c --- /* Fast Fourier/Cosine/Sine Transform dimension :one data length :power of 2 decimation :frequency radix :split-radix data :inplace table :not use functions cdft: Complex Discrete Fourier Transform rdft: Real Discrete Fourier Transform ddct: Discrete Cosine Transform ddst: Discrete Sine Transform dfct: Cosine Transform of RDFT (Real Symmetric DFT) dfst: Sine Transform of RDFT (Real Anti-symmetric DFT) function prototypes void cdft(int, int, double *); void rdft(int, int, double *); void ddct(int, int, double *); [...3408 lines suppressed...] }
void dstsub4(int n, double *a) { int m; double wki, wdr, wdi, xr;
wki = WR5000; m = n >> 1; if (m == 2) { wdr = wki * WI2500; wdi = wki * WR2500; xr = wdi * a[3] - wdr * a[1]; a[3] = wdr * a[3] + wdi * a[1]; a[1] = xr; } a[m] *= wki; }
--- NEW FILE: d_fft_fftsg.c --- /****************** begin Pd-specific prologue ***********************/
/* This is the file, "fftsg.c" from the OOURA FFT package. The copyright notice from Ooura's README is:
Copyright: Copyright(C) 1996-2001 Takuya OOURA email: ooura@mmm.t.u-tokyo.ac.jp download: http://momonga.t.u-tokyo.ac.jp/~ooura/fft.html You may use, copy, modify this code for any purpose and without fee. You may distribute this ORIGINAL package.
After the following prologue, the code is exactly Ooura's original, which I believe the above notice permits me to redistribute. See Ooura's website for another, more permissive-sounding copyright notice. -MSP */
/* ---------- Pd interface to OOURA FFT; imitate Mayer API ---------- */ [...3423 lines suppressed...] void dstsub(int n, double *a, int nc, double *c) { int j, k, kk, ks, m; double wkr, wki, xr;
m = n >> 1; ks = nc / n; kk = 0; for (j = 1; j < m; j++) { k = n - j; kk += ks; wkr = c[kk] - c[nc - kk]; wki = c[kk] + c[nc - kk]; xr = wki * a[k] - wkr * a[j]; a[k] = wkr * a[k] + wki * a[j]; a[j] = xr; } a[m] *= c[0]; }
Index: m_pd.h =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_pd.h,v retrieving revision 1.16 retrieving revision 1.16.2.1 diff -C2 -d -r1.16 -r1.16.2.1 *** m_pd.h 9 Oct 2006 04:36:12 -0000 1.16 --- m_pd.h 19 Jan 2007 04:30:57 -0000 1.16.2.1 *************** *** 11,15 **** #define PD_MAJOR_VERSION 0 #define PD_MINOR_VERSION 40 ! #define PD_BUGFIX_VERSION 1 #define PD_TEST_VERSION ""
--- 11,15 ---- #define PD_MAJOR_VERSION 0 #define PD_MINOR_VERSION 40 ! #define PD_BUGFIX_VERSION 2 #define PD_TEST_VERSION ""
Index: d_array.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/d_array.c,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -C2 -d -r1.6 -r1.6.2.1 *** d_array.c 31 Dec 2005 20:55:25 -0000 1.6 --- d_array.c 19 Jan 2007 04:30:57 -0000 1.6.2.1 *************** *** 493,497 **** /******************** tabosc4~ ***********************/
- /* this is all copied from d_osc.c... what include file could this go in? */ #define UNITBIT32 1572864. /* 3*2^19; bit 32 has place value 1 */
--- 493,496 ---- *************** *** 503,507 **** #define LOWOFFSET 1 /* word offset to find LSB */ #define int32 long /* a data type that has 32 bits */ ! #else #ifdef MSW /* little-endian; most significant byte is at highest address */ --- 502,507 ---- #define LOWOFFSET 1 /* word offset to find LSB */ #define int32 long /* a data type that has 32 bits */ ! #endif /* IRIX */ ! #ifdef MSW /* little-endian; most significant byte is at highest address */ *************** *** 509,533 **** #define LOWOFFSET 0 #define int32 long ! #else ! #ifdef __FreeBSD__ #include <machine/endian.h> - #if BYTE_ORDER == LITTLE_ENDIAN - #define HIOFFSET 1 - #define LOWOFFSET 0 - #else - #define HIOFFSET 0 /* word offset to find MSB */ - #define LOWOFFSET 1 /* word offset to find LSB */ - #endif /* BYTE_ORDER */ - #include <sys/types.h> - #define int32 int32_t #endif
! #ifdef __linux__ #include <endian.h> ! #if !defined(__BYTE_ORDER) || !defined(__LITTLE_ENDIAN) #error No byte order defined #endif ! ! #if __BYTE_ORDER == __LITTLE_ENDIAN #define HIOFFSET 1 #define LOWOFFSET 0 --- 509,528 ---- #define LOWOFFSET 0 #define int32 long ! #endif ! ! #if defined(__FreeBSD__) || defined(__APPLE__) #include <machine/endian.h> #endif
! #ifdef __linux__ #include <endian.h> ! #endif ! ! #if defined(__unix__) || defined(__APPLE__) ! #if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN) #error No byte order defined #endif ! ! #if BYTE_ORDER == LITTLE_ENDIAN #define HIOFFSET 1 #define LOWOFFSET 0 *************** *** 536,553 **** #define LOWOFFSET 1 /* word offset to find LSB */ #endif /* __BYTE_ORDER */ - #include <sys/types.h> #define int32 int32_t ! ! #else ! #ifdef __APPLE__ ! #define HIOFFSET 0 /* word offset to find MSB */ ! #define LOWOFFSET 1 /* word offset to find LSB */ ! #define int32 int /* a data type that has 32 bits */ ! ! #endif /* __APPLE__ */ ! #endif /* __linux__ */ ! #endif /* MSW */ ! #endif /* SGI */
union tabfudge --- 531,537 ---- #define LOWOFFSET 1 /* word offset to find LSB */ #endif /* __BYTE_ORDER */ #include <sys/types.h> #define int32 int32_t ! #endif /* __unix__ or __APPLE__*/
union tabfudge
--- NEW FILE: d_fft_fftw.c --- /* Copyright (c) 1997- Miller Puckette and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
/* --------- Pd interface to FFTW library; imitate Mayer API ---------- */
#include "m_pd.h" #ifdef MSW #include <malloc.h> #else #include <alloca.h> #endif
#error oops -- I'm talking to the old fftw. Apparently it's still changing.
#include <fftw.h>
int ilog2(int n);
#define MINFFT 5 #define MAXFFT 30
/* from the FFTW website: fftw_complex in[N], out[N]; fftw_plan p; ... p = fftw_create_plan(N, FFTW_FORWARD, FFTW_ESTIMATE); ... fftw_one(p, in, out); ... fftw_destroy_plan(p);
FFTW_FORWARD or FFTW_BACKWARD, and indicates the direction of the transform you are interested in. Alternatively, you can use the sign of the exponent in the transform, -1 or +1, which corresponds to FFTW_FORWARD or FFTW_BACKWARD respectively. The flags argument is either FFTW_MEASURE
*/
static fftw_plan fftw_pvec[2 * (MAXFFT+1 - MINFFT)];
static fftw_plan fftw_getplan(int n, int dir) { logn = ilog2(n); if (logn < MINFFT || logn > MAXFFT) return (0); int indx = 2*(logn-MINFFT) + inverse); if (!fftw_pvec[indx] fftw_pvec[indx] = fftw_create_plan(N, dir, FFTW_MEASURE); return (fftw_pvec[indx]); }
EXTERN void mayer_fht(float *fz, int n) { post("FHT: not yet implemented"); }
static void mayer_dofft(int n, float *fz1, float *fz2, int dir) { float *inbuf, *outbuf, *fp1, *fp2, *fp3; int i; fftw_plan p = fftw_getplan(n, dir); inbuf = alloca(n * (4 * sizeof(float))); outbuf = inbuf + 2*n; if (!p) return; for (i = 0, fp1 = fz1, fp2 = fz2, fp3 = inbuf; i < n; i++) fp3[0] = *fp1++, fp3[1] = *fp2++, fp3 += 2; fftw_one(p, inbuf, outbuf); for (i = 0, fp1 = fz1, fp2 = fz2, fp3 = outbuf; i < n; i++) *fp1++ = fp3[0], *fp2++ = fp3[1], fp3 += 2; }
EXTERN void mayer_fft(int n, float *fz1, float *fz2) { mayer_dofft(n, fz1, fz2, FFTW_FORWARD); }
EXTERN void mayer_ifft(int n, float *fz1, float *fz2) { mayer_dofft(n, fz1, fz2, FFTW_BACKWARD); }
EXTERN void mayer_realfft(int n, float *fz) { post("rfft: not yet implemented"); }
EXTERN void mayer_realifft(int n, float *fz) { post("rifft: not yet implemented"); }
Index: d_osc.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/d_osc.c,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** d_osc.c 31 Dec 2005 20:55:25 -0000 1.4 --- d_osc.c 19 Jan 2007 04:30:57 -0000 1.4.2.1 *************** *** 31,39 **** #endif
- #ifdef __APPLE__ - #define __BYTE_ORDER BYTE_ORDER - #define __LITTLE_ENDIAN LITTLE_ENDIAN - #endif - #ifdef __linux__ #include <endian.h> --- 31,34 ---- *************** *** 41,49 ****
#if defined(__unix__) || defined(__APPLE__) ! #if !defined(__BYTE_ORDER) || !defined(__LITTLE_ENDIAN) #error No byte order defined #endif
! #if __BYTE_ORDER == __LITTLE_ENDIAN #define HIOFFSET 1 #define LOWOFFSET 0 --- 36,44 ----
#if defined(__unix__) || defined(__APPLE__) ! #if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN) #error No byte order defined #endif
! #if BYTE_ORDER == LITTLE_ENDIAN #define HIOFFSET 1 #define LOWOFFSET 0 *************** *** 56,60 **** #endif /* __unix__ or __APPLE__*/
- union tabfudge { --- 51,54 ---- *************** *** 63,67 **** };
- /* -------------------------- phasor~ ------------------------------ */ static t_class *phasor_class, *scalarphasor_class; --- 57,60 ----