pd-windowing_0.1/0000755000076500007650000000000011466353543012532 5ustar hanshanspd-windowing_0.1/kaiser~-help.pd0000644000076500007650000000461311466353476015472 0ustar hanshans#N canvas 256 141 557 517 10; #X obj 4 479 cnv 15 550 20 empty \$0-pddp.cnv.footer empty 20 12 0 14 -228856 -66577 0; #X obj 4 -17 cnv 15 550 40 empty \$0-pddp.cnv.header kaiser~ 3 12 0 18 -204280 -1 0; #X obj 3 239 cnv 3 550 3 empty \$0-pddp.cnv.inlets inlets 15 12 0 13 -228856 -1 0; #X obj 3 319 cnv 3 550 3 empty \$0-pddp.cnv.outlets outlet 15 12 0 13 -228856 -1 0; #X obj 3 359 cnv 3 550 3 empty \$0-pddp.cnv.more_info more_info 15 12 0 13 -228856 -1 0; #X obj 72 259 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X text 168 40 formula:; #X obj 97 126 hsl 71 15 -1 1 0 0 empty empty empty -2 -6 0 10 -262144 -1 -1 7000 1; #X msg 94 106 1; #X obj 94 86 loadbang; #X obj 102 365 pddp/pddplink http://en.wikipedia.org/wiki/Window_function -text wikipedia: window functions; #X obj 438 -14 import windowing; #X msg 36 154 \; pd dsp 1; #X text 21 125 height --->; #X obj 127 149 sig~ 1; #N canvas 0 0 450 300 graph3 0; #X array \$0-kaiser 64 float 0; #X coords 0 1 63 -1 200 140 1; #X restore 326 65 graph; #X text 103 396 Windowing functions are used with FFTs. These transform the signal block-by-block into a spectral representation whose resolution in both the frequency and time domains are proportional to their size (as a power-of-two in PD). The different windows have different characteristics in terms of stopband attenuation and noise bandwidth.; #X text 102 258 SIGNAL: the height (amplitude) of the window is controlled by the signal on its inlet.; #X obj 197 126 hsl 81 15 1 240 1 0 empty empty empty -2 -6 0 10 -262144 -1 -1 3361 1; #X floatatom 192 145 5 0 0 0 - - -; #X obj 127 172 kaiser~; #X obj 127 198 tabsend~ \$0-kaiser; #X obj 435 6 pddp/pddplink http://wiki.puredata.info/en/kaiser~ -text pdpedia: kaiser~; #X text 169 84 modified Bessel function; #X text 169 70 where Io is 0th order; #X text 168 55 Io(a*sqrt(1-x^2))/Io(a); #X text 103 327 SIGNAL: a kaiser (exponential decay) window with size=dsp blocksize; #X msg 121 106 10; #X obj 102 379 pddp/pddplink http://en.wikipedia.org/wiki/Kaiser_window -text wikipedia: kaiser window; #X text 102 284 FLOAT: the narrowness of the kaiser window is controlled by floats in the inlet; #X text 15 6 description: generates a kaiser window for each dsp block ; #X connect 7 0 14 0; #X connect 8 0 7 0; #X connect 9 0 8 0; #X connect 9 0 27 0; #X connect 14 0 20 0; #X connect 18 0 19 0; #X connect 19 0 20 0; #X connect 20 0 21 0; #X connect 27 0 18 0; pd-windowing_0.1/blackman~-help.pd0000644000076500007650000000413411466353476015762 0ustar hanshans#N canvas 256 141 561 517 10; #X obj 4 479 cnv 15 550 20 empty \$0-pddp.cnv.footer empty 20 12 0 14 -228856 -66577 0; #X obj 4 -17 cnv 15 550 40 empty \$0-pddp.cnv.header blackman~ 3 12 0 18 -204280 -1 0; #X obj 3 239 cnv 3 550 3 empty \$0-pddp.cnv.inlets inlets 15 12 0 13 -228856 -1 0; #X obj 3 299 cnv 3 550 3 empty \$0-pddp.cnv.outlets outlet 15 12 0 13 -228856 -1 0; #X obj 3 359 cnv 3 550 3 empty \$0-pddp.cnv.more_info more_info 15 12 0 13 -228856 -1 0; #X obj 72 259 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X text 168 40 formula:; #X obj 97 86 hsl 71 15 -1 1 0 0 empty empty empty -2 -6 0 10 -262144 -1 -1 7000 1; #X msg 94 66 1; #X obj 94 46 loadbang; #X obj 102 365 pddp/pddplink http://en.wikipedia.org/wiki/Window_function -text wikipedia: window functions; #X obj 438 -14 import windowing; #X msg 36 154 \; pd dsp 1; #X text 21 85 height --->; #X text 15 6 description: generates a blackman window for each dsp block; #X obj 127 109 sig~ 1; #X obj 127 132 blackman~; #N canvas 0 0 450 300 graph3 0; #X array \$0-blackman 64 float 0; #X coords 0 1 63 -1 200 140 1; #X restore 326 65 graph; #X text 168 70 0.8*cos(2*pi*x); #X text 168 55 0.42+(0.5*cos(pi*x))+; #X obj 102 380 pddp/pddplink http://mathworld.wolfram.com/BlackmanFunction.html -text mathworld link; #X text 103 317 SIGNAL: a blackman window with size=dsp blocksize; #X obj 435 6 pddp/pddplink http://wiki.puredata.info/en/blackman~ -text pdpedia: blackman~; #X text 102 394 Windowing functions are used with FFTs. These transform the signal block-by-block into a spectral representation whose resolution in both the frequency and time domains are proportional to their size (as a power-of-two in PD). The different windows have different characteristics in terms of stopband attenuation and noise bandwidth.; #X text 102 258 SIGNAL: the height (amplitude) of the window is controlled by the signal on its inlet.; #X obj 127 158 tabsend~ \$0-blackman; #X obj 73 319 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X connect 7 0 15 0; #X connect 8 0 7 0; #X connect 9 0 8 0; #X connect 15 0 16 0; #X connect 16 0 25 0; pd-windowing_0.1/mconf.h0000644000076500007650000001254311466353476014017 0ustar hanshans/* mconf.h * * Common include file for math routines * * * * SYNOPSIS: * * #include "mconf.h" * * * * DESCRIPTION: * * This file contains definitions for error codes that are * passed to the common error handling routine mtherr() * (which see). * * The file also includes a conditional assembly definition * for the type of computer arithmetic (IEEE, DEC, Motorola * IEEE, or UNKnown). * * For Digital Equipment PDP-11 and VAX computers, certain * IBM systems, and others that use numbers with a 56-bit * significand, the symbol DEC should be defined. In this * mode, most floating point constants are given as arrays * of octal integers to eliminate decimal to binary conversion * errors that might be introduced by the compiler. * * For little-endian computers, such as IBM PC, that follow the * IEEE Standard for Binary Floating Point Arithmetic (ANSI/IEEE * Std 754-1985), the symbol IBMPC should be defined. These * numbers have 53-bit significands. In this mode, constants * are provided as arrays of hexadecimal 16 bit integers. * * Big-endian IEEE format is denoted MIEEE. On some RISC * systems such as Sun SPARC, double precision constants * must be stored on 8-byte address boundaries. Since integer * arrays may be aligned differently, the MIEEE configuration * may fail on such machines. * * To accommodate other types of computer arithmetic, all * constants are also provided in a normal decimal radix * which one can hope are correctly converted to a suitable * format by the available C language compiler. To invoke * this mode, define the symbol UNK. * * An important difference among these modes is a predefined * set of machine arithmetic constants for each. The numbers * MACHEP (the machine roundoff error), MAXNUM (largest number * represented), and several other parameters are preset by * the configuration symbol. Check the file const.c to * ensure that these values are correct for your computer. * * Configurations NANS, INFINITIES, MINUSZERO, and DENORMAL * may fail on many systems. Verify that they are supposed * to work on your computer. */ /* Cephes Math Library Release 2.3: June, 1995 Copyright 1984, 1987, 1989, 1995 by Stephen L. Moshier */ /* Define if the `long double' type works. */ #define HAVE_LONG_DOUBLE 1 /* Define as the return type of signal handlers (int or void). */ #define RETSIGTYPE void /* Define if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Define if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ /* #undef WORDS_BIGENDIAN */ /* Define if floating point words are bigendian. */ /* #undef FLOAT_WORDS_BIGENDIAN */ /* The number of bytes in a int. */ #define SIZEOF_INT 4 /* Define if you have the header file. */ #define HAVE_STRING_H 1 /* Name of package */ #define PACKAGE "cephes" /* Version number of package */ #define VERSION "2.7" /* Constant definitions for math error conditions */ #ifndef _WIN32 #define DOMAIN 1 /* argument domain error */ #define SING 2 /* argument singularity */ #define OVERFLOW 3 /* overflow range error */ #define UNDERFLOW 4 /* underflow range error */ #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 { double r; double i; } cmplx; #ifdef HAVE_LONG_DOUBLE /* Long double complex numeral. */ typedef struct { long double r; long double i; } cmplxl; #endif #endif /* Type of computer arithmetic */ /* PDP-11, Pro350, VAX: */ /* #define DEC 1 */ /* Intel IEEE, low order words come first: */ /* #define IBMPC 1 */ /* Motorola IEEE, high order words come first * (Sun 680x0 workstation): */ /* #define MIEEE 1 */ /* UNKnown arithmetic, invokes coefficients given in * normal decimal format. Beware of range boundary * problems (MACHEP, MAXLOG, etc. in const.c) and * roundoff problems in pow.c: * (Sun SPARCstation) */ #define UNK 1 /* If you define UNK, then be sure to set BIGENDIAN properly. */ #ifdef FLOAT_WORDS_BIGENDIAN #define BIGENDIAN 1 #else #define BIGENDIAN 0 #endif /* Define this `volatile' if your compiler thinks * that floating point arithmetic obeys the associative * and distributive laws. It will defeat some optimizations * (but probably not enough of them). * * #define VOLATILE volatile */ #define VOLATILE /* For 12-byte long doubles on an i386, pad a 16-bit short 0 * to the end of real constants initialized by integer arrays. * * #define XPD 0, * * Otherwise, the type is 10 bytes long and XPD should be * defined blank (e.g., Microsoft C). * * #define XPD */ #define XPD 0, /* Define to support tiny denormal numbers, else undefine. */ #define DENORMAL 1 /* Define to ask for infinity support, else undefine. */ #define INFINITIES 1 /* Define to ask for support of numbers that are Not-a-Number, else undefine. This may automatically define INFINITIES in some files. */ #define NANS 1 /* Define to distinguish between -0.0 and +0.0. */ #define MINUSZERO 1 /* Define 1 for ANSI C atan2() function See atan.c and clog.c. */ #define ANSIC 1 /* Get ANSI function prototypes, if you want them. */ #if 1 /* #ifdef __STDC__ */ #define ANSIPROT 1 int mtherr ( char *, int ); #else int mtherr(); #endif /* Variable for error reporting. See mtherr.c. */ extern int merror; pd-windowing_0.1/lanczos~.c0000644000076500007650000000535111466353476014556 0ustar hanshans/* lanczos~ - lanczos windowing function for Pure Data ** ** Copyright (C) 2002 Joseph A. Sarlo ** ** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** jsarlo@mambo.peabody.jhu.edu */ #include "m_pd.h" #include #include #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; typedef struct _lanczos { t_object x_obj; int x_blocksize; float *x_table; } t_lanczos; static t_int* lanczos_perform(t_int *w) { t_lanczos *x = (t_lanczos *)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); int i; if (x->x_blocksize != n) { if (x->x_blocksize < n) { x->x_table = realloc(x->x_table, n * sizeof(float)); } x->x_blocksize = n; fillLanczos(x->x_table, x->x_blocksize); } for (i = 0; i < n; i++) { *out++ = *(in++) * x->x_table[i]; } return (w + 5); } static void lanczos_dsp(t_lanczos *x, t_signal **sp) { dsp_add(lanczos_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } static void* lanczos_new(void) { t_lanczos *x = (t_lanczos *)pd_new(lanczos_class); x->x_blocksize = DEFBLOCKSIZE; x->x_table = malloc(x->x_blocksize * sizeof(float)); fillLanczos(x->x_table, x->x_blocksize); outlet_new(&x->x_obj, gensym("signal")); return (x); } static void lanczos_free(t_lanczos *x) { free(x->x_table); } void lanczos_tilde_setup(void) { lanczos_class = class_new(gensym("lanczos~"), (t_newmethod)lanczos_new, (t_method)lanczos_free, sizeof(t_lanczos), 0, A_DEFFLOAT, 0); class_addmethod(lanczos_class, nullfn, gensym("signal"), 0); class_addmethod(lanczos_class, (t_method)lanczos_dsp, gensym("dsp"), 0); } pd-windowing_0.1/bartlett~-help.pd0000644000076500007650000000406711466353476016040 0ustar hanshans#N canvas 256 141 557 517 10; #X obj 4 479 cnv 15 550 20 empty \$0-pddp.cnv.footer empty 20 12 0 14 -228856 -66577 0; #X obj 4 -17 cnv 15 550 40 empty \$0-pddp.cnv.header bartlett~ 3 12 0 18 -204280 -1 0; #X obj 3 239 cnv 3 550 3 empty \$0-pddp.cnv.inlets inlets 15 12 0 13 -228856 -1 0; #X obj 3 299 cnv 3 550 3 empty \$0-pddp.cnv.outlets outlet 15 12 0 13 -228856 -1 0; #X obj 3 359 cnv 3 550 3 empty \$0-pddp.cnv.more_info more_info 15 12 0 13 -228856 -1 0; #X obj 72 259 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X text 168 40 formula:; #X obj 97 86 hsl 71 15 -1 1 0 0 empty empty empty -2 -6 0 10 -262144 -1 -1 7000 1; #X msg 94 66 1; #X obj 94 46 loadbang; #X obj 102 365 pddp/pddplink http://en.wikipedia.org/wiki/Window_function -text wikipedia: window functions; #X obj 438 -14 import windowing; #X msg 36 154 \; pd dsp 1; #X text 21 85 height --->; #X obj 127 109 sig~ 1; #N canvas 0 0 450 300 graph3 0; #X array \$0-bartlett 64 float 0; #X coords 0 1 63 -1 200 140 1; #X restore 326 65 graph; #X text 102 394 Windowing functions are used with FFTs. These transform the signal block-by-block into a spectral representation whose resolution in both the frequency and time domains are proportional to their size (as a power-of-two in PD). The different windows have different characteristics in terms of stopband attenuation and noise bandwidth.; #X text 102 258 SIGNAL: the height (amplitude) of the window is controlled by the signal on its inlet.; #X obj 127 158 tabsend~ \$0-bartlett; #X obj 127 132 bartlett~; #X text 169 53 1-x^2; #X text 103 317 SIGNAL: a bartlett (triangle) window with size=dsp blocksize; #X obj 102 380 pddp/pddplink http://mathworld.wolfram.com/BartlettFunction.html -text mathworld link; #X obj 435 6 pddp/pddplink http://wiki.puredata.info/en/bartlett~ -text pdpedia: bartlett~; #X text 15 6 description: generates a bartlett window for each dsp block; #X obj 72 319 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X connect 7 0 14 0; #X connect 8 0 7 0; #X connect 9 0 8 0; #X connect 14 0 19 0; #X connect 19 0 18 0; pd-windowing_0.1/blackman~.c0000644000076500007650000000535111466353476014655 0ustar hanshans/* blackman~ - blackman windowing function for Pure Data ** ** Copyright (C) 2002 Joseph A. Sarlo ** ** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** jsarlo@mambo.peabody.jhu.edu */ #include "m_pd.h" #include #include #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; typedef struct _blackman { t_object x_obj; int x_blocksize; float *x_table; } t_blackman; static t_int* blackman_perform(t_int *w) { t_blackman *x = (t_blackman *)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); int i; if (x->x_blocksize != n) { if (x->x_blocksize < n) { x->x_table = realloc(x->x_table, n * sizeof(float)); } x->x_blocksize = n; fillBlackman(x->x_table, x->x_blocksize); } for (i = 0; i < n; i++) { *out++ = *(in++) * x->x_table[i]; } return (w + 5); } static void blackman_dsp(t_blackman *x, t_signal **sp) { dsp_add(blackman_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } static void* blackman_new(void) { t_blackman *x = (t_blackman *)pd_new(blackman_class); x->x_blocksize = DEFBLOCKSIZE; x->x_table = malloc(x->x_blocksize * sizeof(float)); fillBlackman(x->x_table, x->x_blocksize); outlet_new(&x->x_obj, gensym("signal")); return (x); } static void blackman_free(t_blackman *x) { free(x->x_table); } void blackman_tilde_setup(void) { blackman_class = class_new(gensym("blackman~"), (t_newmethod)blackman_new, (t_method)blackman_free, sizeof(t_blackman), 0, A_DEFFLOAT, 0); class_addmethod(blackman_class, nullfn, gensym("signal"), 0); class_addmethod(blackman_class, (t_method)blackman_dsp, gensym("dsp"), 0); } pd-windowing_0.1/cosine~-help.pd0000644000076500007650000000405411466353476015473 0ustar hanshans#N canvas 230 69 567 494 10; #X obj 4 454 cnv 15 550 20 empty \$0-pddp.cnv.footer empty 20 12 0 14 -228856 -66577 0; #X obj 4 -17 cnv 15 550 40 empty \$0-pddp.cnv.header cosine~ 3 12 0 18 -204280 -1 0; #X obj 3 239 cnv 3 550 3 empty \$0-pddp.cnv.inlets inlets 15 12 0 13 -228856 -1 0; #X obj 3 299 cnv 3 550 3 empty \$0-pddp.cnv.outlets outlet 15 12 0 13 -228856 -1 0; #X obj 3 359 cnv 3 550 3 empty \$0-pddp.cnv.more_info more_info 15 12 0 13 -228856 -1 0; #X obj 72 259 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X text 168 40 formula:; #X floatatom 170 104 5 0 0 0 - - -; #X obj 97 86 hsl 71 15 -1 1 0 0 empty empty empty -2 -6 0 10 -262144 -1 -1 7000 1; #X msg 94 66 1; #X obj 94 46 loadbang; #X obj 102 363 pddp/pddplink http://en.wikipedia.org/wiki/Window_function -text wikipedia: window functions; #X obj 438 -14 import windowing; #X msg 36 154 \; pd dsp 1; #X text 21 85 height --->; #X text 103 377 Windowing functions are used with FFTs. These transform the signal block-by-block into a spectral representation whose resolution in both the frequency and time domains are proportional to their size (as a power-of-two in PD). The different windows have different characteristics in terms of stopband attenuation and noise bandwidth.; #X obj 170 122 sig~ 1; #X obj 170 143 cosine~; #N canvas 0 0 450 300 graph5 0; #X array \$0-cosine 64 float 0; #X coords 0 1 63 -1 200 140 1; #X restore 301 55 graph; #X text 169 52 cos(pi*x/2); #X text 15 6 description: generates a cosine window for each dsp block ; #X obj 435 6 pddp/pddplink http://wiki.puredata.info/en/cosine~ -text pdpedia: cosine~; #X obj 170 169 tabsend~ \$0-cosine; #X obj 72 319 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X text 102 258 SIGNAL: the height (amplitude) of the window is controled by the signal on its inlet.; #X text 103 317 SIGNAL: a cosine (otherwise known as a sine - actually it's half a sine) window with size=dsp blocksize; #X connect 7 0 16 0; #X connect 8 0 7 0; #X connect 9 0 8 0; #X connect 10 0 9 0; #X connect 16 0 17 0; #X connect 17 0 22 0; pd-windowing_0.1/connes~-help.pd0000644000076500007650000000427111466353476015501 0ustar hanshans#N canvas 230 69 553 535 10; #X obj 4 484 cnv 15 550 20 empty \$0-pddp.cnv.footer empty 20 12 0 14 -228856 -66577 0; #X obj 4 -17 cnv 15 550 40 empty \$0-pddp.cnv.header connes~ 3 12 0 18 -204280 -1 0; #X obj 3 239 cnv 3 550 3 empty \$0-pddp.cnv.inlets inlets 15 12 0 13 -228856 -1 0; #X obj 3 299 cnv 3 550 3 empty \$0-pddp.cnv.outlets outlet 15 12 0 13 -228856 -1 0; #X obj 3 359 cnv 3 550 3 empty \$0-pddp.cnv.more_info more_info 15 12 0 13 -228856 -1 0; #X obj 72 259 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X text 168 40 formula:; #X floatatom 170 104 5 0 0 0 - - -; #X obj 97 86 hsl 71 15 -1 1 0 0 empty empty empty -2 -6 0 10 -262144 -1 -1 7000 1; #X msg 94 66 1; #X obj 94 46 loadbang; #X obj 102 363 pddp/pddplink http://en.wikipedia.org/wiki/Window_function -text wikipedia: window functions; #X obj 438 -14 import windowing; #X msg 36 154 \; pd dsp 1; #X text 21 85 height --->; #X text 103 407 Windowing functions are used with FFTs. These transform the signal block-by-block into a spectral representation whose resolution in both the frequency and time domains are proportional to their size (as a power-of-two in PD). The different windows have different characteristics in terms of stopband attenuation and noise bandwidth.; #X obj 170 122 sig~ 1; #N canvas 0 0 450 300 graph5 0; #X array \$0-connes 64 float 0; #X coords 0 1 63 -1 200 140 1; #X restore 301 55 graph; #X text 169 52 cos(pi*x/2); #X obj 72 319 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X obj 170 169 tabsend~ \$0-connes; #X obj 170 143 connes~; #X text 102 258 SIGNAL: the height (amplitude) of the window is controlled by the signal on its inlet.; #X text 103 317 SIGNAL: a connes window with size=dsp blocksize; #X obj 102 392 pddp/pddplink http://mathworld.wolfram.com/ConnesFunction.html -text mathworld link; #X obj 102 377 pddp/pddplink http://en.wikipedia.org/wiki/Connes -text wikipedia: Alain Connes; #X obj 435 6 pddp/pddplink http://wiki.puredata.info/en/connes~ -text pdpedia: connes~; #X text 15 6 description: generates a connes window for each dsp block ; #X connect 7 0 16 0; #X connect 8 0 7 0; #X connect 9 0 8 0; #X connect 10 0 9 0; #X connect 16 0 21 0; #X connect 21 0 20 0; pd-windowing_0.1/bartlett~.c0000644000076500007650000000520011466353476014717 0ustar hanshans/* bartlett~ - bartlett windowing function for Pure Data ** ** Copyright (C) 2002 Joseph A. Sarlo ** ** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** jsarlo@mambo.peabody.jhu.edu */ #include "m_pd.h" #include #include #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; typedef struct _bartlett { t_object x_obj; int x_blocksize; float *x_table; } t_bartlett; static t_int* bartlett_perform(t_int *w) { t_bartlett *x = (t_bartlett *)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); int i; if (x->x_blocksize != n) { if (x->x_blocksize < n) { x->x_table = realloc(x->x_table, n * sizeof(float)); } x->x_blocksize = n; fillBartlett(x->x_table, x->x_blocksize); } for (i = 0; i < n; i++) { *out++ = *(in++) * x->x_table[i]; } return (w + 5); } static void bartlett_dsp(t_bartlett *x, t_signal **sp) { dsp_add(bartlett_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } static void* bartlett_new(void) { t_bartlett *x = (t_bartlett *)pd_new(bartlett_class); x->x_blocksize = DEFBLOCKSIZE; x->x_table = malloc(x->x_blocksize * sizeof(float)); fillBartlett(x->x_table, x->x_blocksize); outlet_new(&x->x_obj, gensym("signal")); return (x); } static void bartlett_free(t_bartlett *x) { free(x->x_table); } void bartlett_tilde_setup(void) { bartlett_class = class_new(gensym("bartlett~"), (t_newmethod)bartlett_new, (t_method)bartlett_free, sizeof(t_bartlett), 0, A_DEFFLOAT, 0); class_addmethod(bartlett_class, nullfn, gensym("signal"), 0); class_addmethod(bartlett_class, (t_method)bartlett_dsp, gensym("dsp"), 0); } pd-windowing_0.1/README.txt0000644000076500007650000000075211466353476014241 0ustar hanshansPorvides: hammimng~, hanning~, blackman~, cosine~, connes~, bartlett~, welch~, lanczos~, gaussian~, and kaiser~ Usage: Windows inlet signal on each DSP block and sends to outlet gaussian~ takes one optional argument (standard deviation) May be set by float in left inlet kaiser~ takes one option argument (alpha) May be set by float in left inlet See windowing.pd To build: Linux: make windowing_linux Windows: nmake windowing_nt pd-windowing_0.1/cosine~.c0000644000076500007650000000520411466353476014362 0ustar hanshans/* cosine~ - cosine windowing function for Pure Data ** ** Copyright (C) 2002 Joseph A. Sarlo ** ** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** jsarlo@mambo.peabody.jhu.edu */ #include "m_pd.h" #include #include #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; typedef struct _cosine { t_object x_obj; int x_blocksize; float *x_table; } t_cosine; static t_int* cosine_perform(t_int *w) { t_cosine *x = (t_cosine *)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); int i; if (x->x_blocksize != n) { if (x->x_blocksize < n) { x->x_table = realloc(x->x_table, n * sizeof(float)); } x->x_blocksize = n; fillCosine(x->x_table, x->x_blocksize); } for (i = 0; i < n; i++) { *out++ = *(in++) * x->x_table[i]; } return (w + 5); } static void cosine_dsp(t_cosine *x, t_signal **sp) { dsp_add(cosine_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } static void* cosine_new(void) { t_cosine *x = (t_cosine *)pd_new(cosine_class); x->x_blocksize = DEFBLOCKSIZE; x->x_table = malloc(x->x_blocksize * sizeof(float)); fillCosine(x->x_table, x->x_blocksize); outlet_new(&x->x_obj, gensym("signal")); return (x); } static void cosine_free(t_cosine *x) { free(x->x_table); } void cosine_tilde_setup(void) { cosine_class = class_new(gensym("cosine~"), (t_newmethod)cosine_new, (t_method)cosine_free, sizeof(t_cosine), 0, A_DEFFLOAT, 0); class_addmethod(cosine_class, nullfn, gensym("signal"), 0); class_addmethod(cosine_class, (t_method)cosine_dsp, gensym("dsp"), 0); } pd-windowing_0.1/hanning~.c0000644000076500007650000000525311466353476014530 0ustar hanshans/* hanning~ - hanning windowing function for Pure Data ** ** Copyright (C) 2002 Joseph A. Sarlo ** ** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** jsarlo@mambo.peabody.jhu.edu */ #include "m_pd.h" #include #include #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; typedef struct _hanning { t_object x_obj; int x_blocksize; float *x_table; } t_hanning; static t_int* hanning_perform(t_int *w) { t_hanning *x = (t_hanning *)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); int i; if (x->x_blocksize != n) { if (x->x_blocksize < n) { x->x_table = realloc(x->x_table, n * sizeof(float)); } x->x_blocksize = n; fillHanning(x->x_table, x->x_blocksize); } for (i = 0; i < n; i++) { *out++ = *(in++) * x->x_table[i]; } return (w + 5); } static void hanning_dsp(t_hanning *x, t_signal **sp) { dsp_add(hanning_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } static void* hanning_new(void) { t_hanning *x = (t_hanning *)pd_new(hanning_class); x->x_blocksize = DEFBLOCKSIZE; x->x_table = malloc(x->x_blocksize * sizeof(float)); fillHanning(x->x_table, x->x_blocksize); outlet_new(&x->x_obj, gensym("signal")); return (x); } static void hanning_free(t_hanning *x) { free(x->x_table); } void hanning_tilde_setup(void) { hanning_class = class_new(gensym("hanning~"), (t_newmethod)hanning_new, (t_method)hanning_free, sizeof(t_hanning), 0, A_DEFFLOAT, 0); class_addmethod(hanning_class, nullfn, gensym("signal"), 0); class_addmethod(hanning_class, (t_method)hanning_dsp, gensym("dsp"), 0); } pd-windowing_0.1/hamming~-help.pd0000644000076500007650000000434111466353476015632 0ustar hanshans#N canvas 256 141 559 514 10; #X obj 4 477 cnv 15 550 20 empty \$0-pddp.cnv.footer empty 20 12 0 14 -228856 -66577 0; #X obj 4 -17 cnv 15 550 40 empty \$0-pddp.cnv.header hamming~ 3 12 0 18 -204280 -1 0; #X obj 3 239 cnv 3 550 3 empty \$0-pddp.cnv.inlets inlets 15 12 0 13 -228856 -1 0; #X obj 3 299 cnv 3 550 3 empty \$0-pddp.cnv.outlets outlet 15 12 0 13 -228856 -1 0; #X obj 3 359 cnv 3 550 3 empty \$0-pddp.cnv.more_info more_info 15 12 0 13 -228856 -1 0; #X obj 72 259 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X text 168 40 formula:; #X floatatom 170 104 5 0 0 0 - - -; #X obj 97 86 hsl 71 15 -1 1 0 0 empty empty empty -2 -6 0 10 -262144 -1 -1 7000 1; #X msg 94 66 1; #X obj 94 46 loadbang; #X obj 102 364 pddp/pddplink http://en.wikipedia.org/wiki/Window_function -text wikipedia: window functions; #X obj 438 -14 import windowing; #X msg 36 154 \; pd dsp 1; #X text 21 85 height --->; #X text 15 6 description: generates a hamming window for each dsp block ; #X obj 435 6 pddp/pddplink http://wiki.puredata.info/en/hamming~ -text pdpedia: hamming~; #X obj 170 122 sig~ 1; #X obj 170 146 hamming~; #N canvas 0 0 450 300 graph2 0; #X array \$0-hamming 64 float 0; #X coords 0 1 63 -1 200 140 1; #X restore 334 60 graph; #X text 167 53 0.54+0.46*(cos(pi*x)); #X obj 102 377 pddp/pddplink http://en.wikipedia.org/wiki/Hamming -text wikipedia: Richard Hamming; #X obj 102 390 pddp/pddplink http://mathworld.wolfram.com/HammingFunction.html -text mathworld link; #X text 102 402 Windowing functions are used with FFTs. These transform the signal block-by-block into a spectral representation whose resolution in both the frequency and time domains are proportional to their size (as a power-of-two in PD). The different windows have different characteristics in terms of stopband attenuation and noise bandwidth.; #X text 103 317 SIGNAL: a hamming (raised cosine) window with size=dsp blocksize; #X obj 170 171 tabsend~ \$0-hamming; #X obj 72 319 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X text 102 258 SIGNAL: the height (amplitude) of the window is controlled by the signal on its inlet.; #X connect 7 0 17 0; #X connect 8 0 7 0; #X connect 9 0 8 0; #X connect 10 0 9 0; #X connect 17 0 18 0; #X connect 18 0 25 0; pd-windowing_0.1/hamming~.c0000644000076500007650000000525511466353476014530 0ustar hanshans/* hamming~ - hamming windowing function for Pure Data ** ** Copyright (C) 2002 Joseph A. Sarlo ** ** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** jsarlo@mambo.peabody.jhu.edu */ #include "m_pd.h" #include #include #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; typedef struct _hamming { t_object x_obj; int x_blocksize; float *x_table; } t_hamming; static t_int* hamming_perform(t_int *w) { t_hamming *x = (t_hamming *)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); int i; if (x->x_blocksize != n) { if (x->x_blocksize < n) { x->x_table = realloc(x->x_table, n * sizeof(float)); } x->x_blocksize = n; fillHamming(x->x_table, x->x_blocksize); } for (i = 0; i < n; i++) { *out++ = *(in++) * x->x_table[i]; } return (w + 5); } static void hamming_dsp(t_hamming *x, t_signal **sp) { dsp_add(hamming_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } static void* hamming_new(void) { t_hamming *x = (t_hamming *)pd_new(hamming_class); x->x_blocksize = DEFBLOCKSIZE; x->x_table = malloc(x->x_blocksize * sizeof(float)); fillHamming(x->x_table, x->x_blocksize); outlet_new(&x->x_obj, gensym("signal")); return (x); } static void hamming_free(t_hamming *x) { free(x->x_table); } void hamming_tilde_setup(void) { hamming_class = class_new(gensym("hamming~"), (t_newmethod)hamming_new, (t_method)hamming_free, sizeof(t_hamming), 0, A_DEFFLOAT, 0); class_addmethod(hamming_class, nullfn, gensym("signal"), 0); class_addmethod(hamming_class, (t_method)hamming_dsp, gensym("dsp"), 0); } pd-windowing_0.1/hanning~-help.pd0000644000076500007650000000434111466353476015634 0ustar hanshans#N canvas 283 199 561 515 10; #X obj 4 474 cnv 15 550 20 empty \$0-pddp.cnv.footer empty 20 12 0 14 -228856 -66577 0; #X obj 4 -17 cnv 15 550 40 empty \$0-pddp.cnv.header hanning~ 3 12 0 18 -204280 -1 0; #X obj 3 239 cnv 3 550 3 empty \$0-pddp.cnv.inlets inlets 15 12 0 13 -228856 -1 0; #X obj 3 299 cnv 3 550 3 empty \$0-pddp.cnv.outlets outlet 15 12 0 13 -228856 -1 0; #X obj 3 359 cnv 3 550 3 empty \$0-pddp.cnv.more_info more_info 15 12 0 13 -228856 -1 0; #X obj 72 259 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X obj 170 141 hanning~; #N canvas 0 0 450 300 graph1 0; #X array \$0-hanning 64 float 0; #X coords 0 1 63 -1 200 140 1; #X restore 302 54 graph; #X text 168 53 0.5*(1+cos(pi*x)); #X obj 170 121 sig~ 1; #X text 168 40 formula:; #X floatatom 170 104 5 0 0 0 - - -; #X obj 97 86 hsl 71 15 -1 1 0 0 empty empty empty -2 -6 0 10 -262144 -1 -1 7000 1; #X msg 94 66 1; #X obj 94 46 loadbang; #X obj 435 6 pddp/pddplink http://wiki.puredata.info/en/hanning~ -text pdpedia: hanning~; #X obj 102 376 pddp/pddplink http://en.wikipedia.org/wiki/Hanning -text wikipedia: hanning function; #X obj 102 389 pddp/pddplink http://mathworld.wolfram.com/HanningFunction.html -text mathworld link; #X obj 102 363 pddp/pddplink http://en.wikipedia.org/wiki/Window_function -text wikipedia: window functions; #X obj 438 -14 import windowing; #X text 103 317 SIGNAL: a hanning (inverted cosine) window with size=dsp blocksize; #X msg 36 154 \; pd dsp 1; #X text 21 85 height --->; #X text 15 6 description: generates a hanning window for each dsp block ; #X text 102 402 Windowing functions are used with FFTs. These transform the signal block-by-block into a spectral representation whose resolution in both the frequency and time domains are proportional to their size (as a power-of-two in PD). The different windows have different characteristics in terms of stopband attenuation and noise bandwidth.; #X obj 170 167 tabsend~ \$0-hanning; #X text 102 258 SIGNAL: the height (amplitude) of the window is controled by the signal on its inlet.; #X obj 72 319 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X connect 6 0 25 0; #X connect 9 0 6 0; #X connect 11 0 9 0; #X connect 12 0 11 0; #X connect 13 0 12 0; #X connect 14 0 13 0; pd-windowing_0.1/gaussian~-help.pd0000644000076500007650000000475611466353476016036 0ustar hanshans#N canvas 256 141 559 517 10; #X obj 4 479 cnv 15 550 20 empty \$0-pddp.cnv.footer empty 20 12 0 14 -228856 -66577 0; #X obj 4 -17 cnv 15 550 40 empty \$0-pddp.cnv.header gaussian~ 3 12 0 18 -204280 -1 0; #X obj 3 239 cnv 3 550 3 empty \$0-pddp.cnv.inlets inlets 15 12 0 13 -228856 -1 0; #X obj 3 319 cnv 3 550 3 empty \$0-pddp.cnv.outlets outlet 15 12 0 13 -228856 -1 0; #X obj 3 359 cnv 3 550 3 empty \$0-pddp.cnv.more_info more_info 15 12 0 13 -228856 -1 0; #X obj 72 259 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X text 168 40 formula:; #X obj 97 86 hsl 71 15 -1 1 0 0 empty empty empty -2 -6 0 10 -262144 -1 -1 7000 1; #X msg 94 66 1; #X obj 94 46 loadbang; #X obj 102 365 pddp/pddplink http://en.wikipedia.org/wiki/Window_function -text wikipedia: window functions; #X obj 438 -14 import windowing; #X msg 36 154 \; pd dsp 1; #X text 21 85 height --->; #X obj 127 109 sig~ 1; #N canvas 0 0 450 300 graph3 0; #X array \$0-gaussian 64 float 0; #X coords 0 1 63 -1 200 140 1; #X restore 326 65 graph; #X text 103 405 Windowing functions are used with FFTs. These transform the signal block-by-block into a spectral representation whose resolution in both the frequency and time domains are proportional to their size (as a power-of-two in PD). The different windows have different characteristics in terms of stopband attenuation and noise bandwidth.; #X text 102 258 SIGNAL: the height (amplitude) of the window is controlled by the signal on its inlet.; #X text 15 6 description: generates a gaussian window for each dsp block; #X obj 435 6 pddp/pddplink http://wiki.puredata.info/en/gaussian~ -text pdpedia: gaussian~; #X obj 127 132 gaussian~; #X obj 127 158 tabsend~ \$0-gaussian; #X text 103 327 SIGNAL: a gaussian window with size=dsp blocksize; #X obj 197 86 hsl 71 15 0 2 0 0 empty empty empty -2 -6 0 10 -262144 -1 -1 1750 1; #X floatatom 192 105 5 0 0 0 - - -; #X msg 121 66 0.5; #X text 102 284 FLOAT: the width of the gaussian distribution curve is controlled by floats in the inlet; #X text 169 54 2^(-(x/d)^2); #X obj 102 378 pddp/pddplink http://en.wikipedia.org/wiki/Gaussian_function -text wikipedia: gaussian function; #X obj 102 392 pddp/pddplink http://mathworld.wolfram.com/GaussianFunction.html -text mathworld link; #X obj 73 326 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X connect 7 0 14 0; #X connect 8 0 7 0; #X connect 9 0 8 0; #X connect 9 0 25 0; #X connect 14 0 20 0; #X connect 20 0 21 0; #X connect 23 0 24 0; #X connect 24 0 20 0; #X connect 25 0 23 0; pd-windowing_0.1/welch~.c0000644000076500007650000000501611466353476014205 0ustar hanshans/* welch~ - welch windowing function for Pure Data ** ** Copyright (C) 2002 Joseph A. Sarlo ** ** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** jsarlo@mambo.peabody.jhu.edu */ #include "m_pd.h" #include #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; typedef struct _welch { t_object x_obj; int x_blocksize; float *x_table; } t_welch; static t_int* welch_perform(t_int *w) { t_welch *x = (t_welch *)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); int i; if (x->x_blocksize != n) { if (x->x_blocksize < n) { x->x_table = realloc(x->x_table, n * sizeof(float)); } x->x_blocksize = n; fillWelch(x->x_table, x->x_blocksize); } for (i = 0; i < n; i++) { *out++ = *(in++) * x->x_table[i]; } return (w + 5); } static void welch_dsp(t_welch *x, t_signal **sp) { dsp_add(welch_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } static void* welch_new(void) { t_welch *x = (t_welch *)pd_new(welch_class); x->x_blocksize = DEFBLOCKSIZE; x->x_table = malloc(x->x_blocksize * sizeof(float)); fillWelch(x->x_table, x->x_blocksize); outlet_new(&x->x_obj, gensym("signal")); return (x); } static void welch_free(t_welch *x) { free(x->x_table); } void welch_tilde_setup(void) { welch_class = class_new(gensym("welch~"), (t_newmethod)welch_new, (t_method)welch_free, sizeof(t_welch), 0, A_DEFFLOAT, 0); class_addmethod(welch_class, nullfn, gensym("signal"), 0); class_addmethod(welch_class, (t_method)welch_dsp, gensym("dsp"), 0); } pd-windowing_0.1/windowing-meta.pd0000644000076500007650000000042411466353476016015 0ustar hanshans#N canvas 10 10 200 200 10; #N canvas 20 20 420 300 META 0; #X text 10 10 META this is a prototype of a libdir meta file; #X text 10 10 NAME windowing; #X text 10 10 AUTHOR Joe Sarlo; #X text 10 10 LICENSE GPLv2 or later; #X text 10 110 VERSION 0.1; #X restore 10 10 pd META; pd-windowing_0.1/lanczos~-help.pd0000644000076500007650000000372211466353476015665 0ustar hanshans#N canvas 256 141 560 517 10; #X obj 4 479 cnv 15 550 20 empty \$0-pddp.cnv.footer empty 20 12 0 14 -228856 -66577 0; #X obj 4 -17 cnv 15 550 40 empty \$0-pddp.cnv.header lanczos~ 3 12 0 18 -204280 -1 0; #X obj 3 239 cnv 3 550 3 empty \$0-pddp.cnv.inlets inlets 15 12 0 13 -228856 -1 0; #X obj 3 299 cnv 3 550 3 empty \$0-pddp.cnv.outlets outlet 15 12 0 13 -228856 -1 0; #X obj 3 359 cnv 3 550 3 empty \$0-pddp.cnv.more_info more_info 15 12 0 13 -228856 -1 0; #X obj 72 259 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X text 168 40 formula:; #X obj 97 86 hsl 71 15 -1 1 0 0 empty empty empty -2 -6 0 10 -262144 -1 -1 7000 1; #X msg 94 66 1; #X obj 94 46 loadbang; #X obj 102 365 pddp/pddplink http://en.wikipedia.org/wiki/Window_function -text wikipedia: window functions; #X obj 438 -14 import windowing; #X msg 36 154 \; pd dsp 1; #X text 21 85 height --->; #X obj 127 109 sig~ 1; #N canvas 0 0 450 300 graph3 0; #X array \$0-lanczos 64 float 0; #X coords 0 1 63 -1 200 140 1; #X restore 326 65 graph; #X text 102 380 Windowing functions are used with FFTs. These transform the signal block-by-block into a spectral representation whose resolution in both the frequency and time domains are proportional to their size (as a power-of-two in PD). The different windows have different characteristics in terms of stopband attenuation and noise bandwidth.; #X text 102 258 SIGNAL: the height (amplitude) of the window is controlled by the signal on its inlet.; #X text 169 52 sin(pi*x)/(pi*x); #X text 15 6 description: generates a lanczos window for each dsp block ; #X obj 435 6 pddp/pddplink http://wiki.puredata.info/en/lanczos~ -text pdpedia: lanczos~; #X obj 127 158 tabsend~ \$0-lanczos; #X text 103 317 SIGNAL: a lanczos (sinc) window with size=dsp blocksize ; #X obj 127 132 lanczos~; #X obj 72 319 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X connect 7 0 14 0; #X connect 8 0 7 0; #X connect 9 0 8 0; #X connect 14 0 23 0; #X connect 23 0 21 0; pd-windowing_0.1/LICENSE.txt0000644000076500007650000003574511466353476014400 0ustar hanshansGNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS pd-windowing_0.1/Makefile0000644000076500007650000002407011466353476014202 0ustar hanshans## Pd library template version 1.0.1 # For instructions on how to use this template, see: # http://puredata.info/docs/developer/MakefileTemplate LIBRARY_NAME = windowing # add your .c source files, one object per file, to the SOURCES # variable, help files will be included automatically SOURCES = bartlett~.c blackman~.c connes~.c cosine~.c gaussian~.c hamming~.c hanning~.c kaiser~.c lanczos~.c welch~.c # list all pd objects (i.e. myobject.pd) files here, and their helpfiles will # be included automatically PDOBJECTS = # example patches and related files, in the 'examples' subfolder EXAMPLES = # manuals and related files, in the 'manual' subfolder MANUAL = # if you want to include any other files in the source and binary tarballs, # list them here. This can be anything from header files, test patches, # documentation, etc. README.txt and LICENSE.txt are required and therefore # automatically included EXTRA_DIST = mconf.h #------------------------------------------------------------------------------# # # things you might need to edit if you are using other C libraries # #------------------------------------------------------------------------------# CFLAGS = -DPD -I$(PD_PATH)/src -Wall -W -g LDFLAGS = LIBS = #------------------------------------------------------------------------------# # # you shouldn't need to edit anything below here, if we did it right :) # #------------------------------------------------------------------------------# # get library version from meta file LIBRARY_VERSION = $(shell sed -n 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' $(LIBRARY_NAME)-meta.pd) # where Pd lives PD_PATH = ../../pd # where to install the library prefix = /usr/local libdir = $(prefix)/lib pkglibdir = $(libdir)/pd-externals objectsdir = $(pkglibdir) INSTALL = install INSTALL_FILE = $(INSTALL) -p -m 644 INSTALL_DIR = $(INSTALL) -p -m 755 -d ALLSOURCES := $(SOURCES) $(SOURCES_android) $(SOURCES_cygwin) $(SOURCES_macosx) \ $(SOURCES_iphoneos) $(SOURCES_linux) $(SOURCES_windows) DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION) ORIGDIR=pd-$(LIBRARY_NAME)_$(LIBRARY_VERSION) UNAME := $(shell uname -s) ifeq ($(UNAME),Darwin) CPU := $(shell uname -p) ifeq ($(CPU),arm) # iPhone/iPod Touch SOURCES += $(SOURCES_iphoneos) EXTENSION = pd_darwin OS = iphoneos IPHONE_BASE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin CC=$(IPHONE_BASE)/gcc CPP=$(IPHONE_BASE)/cpp CXX=$(IPHONE_BASE)/g++ ISYSROOT = -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk IPHONE_CFLAGS = -miphoneos-version-min=3.0 $(ISYSROOT) -arch armv6 OPT_CFLAGS = -fast -funroll-loops -fomit-frame-pointer CFLAGS := $(IPHONE_CFLAGS) $(OPT_CFLAGS) $(CFLAGS) \ -I/Applications/Pd-extended.app/Contents/Resources/include LDFLAGS += -arch armv6 -bundle -undefined dynamic_lookup $(ISYSROOT) LIBS += -lc STRIP = strip -x DISTBINDIR=$(DISTDIR)-$(OS) else # Mac OS X SOURCES += $(SOURCES_macosx) EXTENSION = pd_darwin OS = macosx OPT_CFLAGS = -ftree-vectorize -ftree-vectorizer-verbose=2 -fast # build universal 32-bit on 10.4 and 32/64 on newer ifeq ($(shell uname -r | sed 's|\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*|\1|'), 8) FAT_FLAGS = -arch ppc -arch i386 -mmacosx-version-min=10.4 else FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4 SOURCES += $(SOURCES_iphoneos) endif CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include \ -I/Applications/Pd-extended.app/Contents/Resources/include LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib # if the 'pd' binary exists, check the linking against it to aid with stripping LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd) LIBS += -lc STRIP = strip -x DISTBINDIR=$(DISTDIR)-$(OS) # install into ~/Library/Pd on Mac OS X since /usr/local isn't used much pkglibdir=$(HOME)/Library/Pd endif endif ifeq ($(UNAME),Linux) CPU := $(shell uname -m) SOURCES += $(SOURCES_linux) EXTENSION = pd_linux OS = linux OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer CFLAGS += -fPIC LDFLAGS += -Wl,--export-dynamic -shared -fPIC LIBS += -lc STRIP = strip --strip-unneeded -R .note -R .comment DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m) endif ifeq (CYGWIN,$(findstring CYGWIN,$(UNAME))) CPU := $(shell uname -m) SOURCES += $(SOURCES_cygwin) EXTENSION = dll OS = cygwin OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer CFLAGS += LDFLAGS += -Wl,--export-dynamic -shared -L$(PD_PATH)/src LIBS += -lc -lpd STRIP = strip --strip-unneeded -R .note -R .comment DISTBINDIR=$(DISTDIR)-$(OS) endif ifeq (MINGW,$(findstring MINGW,$(UNAME))) CPU := $(shell uname -m) SOURCES += $(SOURCES_windows) EXTENSION = dll OS = windows OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer CFLAGS += -mms-bitfields LDFLAGS += -s -shared -Wl,--enable-auto-import LIBS += -L$(PD_PATH)/src -L$(PD_PATH)/bin -L$(PD_PATH)/obj -lpd -lwsock32 -lkernel32 -luser32 -lgdi32 STRIP = strip --strip-unneeded -R .note -R .comment DISTBINDIR=$(DISTDIR)-$(OS) endif # in case somebody manually set the HELPPATCHES above HELPPATCHES ?= $(SOURCES:.c=-help.pd) $(PDOBJECTS:.pd=-help.pd) CFLAGS += $(OPT_CFLAGS) .PHONY = install libdir_install single_install install-doc install-exec install-examples install-manual clean dist etags $(LIBRARY_NAME) all: $(SOURCES:.c=.$(EXTENSION)) %.o: %.c $(CC) $(CFLAGS) -o "$*.o" -c "$*.c" %.$(EXTENSION): %.o $(CC) $(LDFLAGS) -o "$*.$(EXTENSION)" "$*.o" $(LIBS) chmod a-x "$*.$(EXTENSION)" # this links everything into a single binary file $(LIBRARY_NAME): $(SOURCES:.c=.o) $(LIBRARY_NAME).o $(CC) $(LDFLAGS) -o $(LIBRARY_NAME).$(EXTENSION) $(SOURCES:.c=.o) $(LIBRARY_NAME).o $(LIBS) chmod a-x $(LIBRARY_NAME).$(EXTENSION) install: libdir_install # The meta and help files are explicitly installed to make sure they are # actually there. Those files are not optional, then need to be there. libdir_install: $(SOURCES:.c=.$(EXTENSION)) install-doc install-examples install-manual $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) $(INSTALL_FILE) $(LIBRARY_NAME)-meta.pd \ $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) test -z "$(strip $(SOURCES))" || (\ $(INSTALL_FILE) $(SOURCES:.c=.$(EXTENSION)) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) && \ $(STRIP) $(addprefix $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/,$(SOURCES:.c=.$(EXTENSION)))) test -z "$(strip $(PDOBJECTS))" || \ $(INSTALL_FILE) $(PDOBJECTS) \ $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) # install library linked as single binary single_install: $(LIBRARY_NAME) install-doc install-exec $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) $(INSTALL_FILE) $(LIBRARY_NAME).$(EXTENSION) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) $(STRIP) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/$(LIBRARY_NAME).$(EXTENSION) install-doc: $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) test -z "$(strip $(SOURCES) $(PDOBJECTS))" || \ $(INSTALL_FILE) $(HELPPATCHES) \ $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) $(INSTALL_FILE) README.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/README.txt $(INSTALL_FILE) LICENSE.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/LICENSE.txt install-examples: test -z "$(strip $(EXAMPLES))" || \ $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples && \ for file in $(EXAMPLES); do \ $(INSTALL_FILE) examples/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples; \ done install-manual: test -z "$(strip $(MANUAL))" || \ $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual && \ for file in $(MANUAL); do \ $(INSTALL_FILE) manual/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual; \ done clean: -rm -f -- $(SOURCES:.c=.o) $(SOURCES_LIB:.c=.o) -rm -f -- $(SOURCES:.c=.$(EXTENSION)) -rm -f -- $(LIBRARY_NAME).o -rm -f -- $(LIBRARY_NAME).$(EXTENSION) distclean: clean -rm -f -- $(DISTBINDIR).tar.gz -rm -rf -- $(DISTBINDIR) -rm -f -- $(DISTDIR).tar.gz -rm -rf -- $(DISTDIR) -rm -f -- $(ORIGDIR).tar.gz -rm -rf -- $(ORIGDIR) $(DISTBINDIR): $(INSTALL_DIR) $(DISTBINDIR) libdir: all $(DISTBINDIR) $(INSTALL_FILE) $(LIBRARY_NAME)-meta.pd $(DISTBINDIR) $(INSTALL_FILE) $(SOURCES) $(DISTBINDIR) $(INSTALL_FILE) $(HELPPATCHES) $(DISTBINDIR) test -z "$(strip $(EXTRA_DIST))" || \ $(INSTALL_FILE) $(EXTRA_DIST) $(DISTBINDIR) # tar --exclude-vcs -czpf $(DISTBINDIR).tar.gz $(DISTBINDIR) $(DISTDIR): $(INSTALL_DIR) $(DISTDIR) $(ORIGDIR): $(INSTALL_DIR) $(ORIGDIR) dist: $(DISTDIR) $(INSTALL_FILE) Makefile $(DISTDIR) $(INSTALL_FILE) README.txt $(DISTDIR) $(INSTALL_FILE) LICENSE.txt $(DISTDIR) $(INSTALL_FILE) $(LIBRARY_NAME)-meta.pd $(DISTDIR) test -z "$(strip $(ALLSOURCES))" || \ $(INSTALL_FILE) $(ALLSOURCES) $(DISTDIR) test -z "$(strip $(PDOBJECTS))" || \ $(INSTALL_FILE) $(PDOBJECTS) $(DISTDIR) test -z "$(strip $(HELPPATCHES))" || \ $(INSTALL_FILE) $(HELPPATCHES) $(DISTDIR) test -z "$(strip $(EXTRA_DIST))" || \ $(INSTALL_FILE) $(EXTRA_DIST) $(DISTDIR) test -z "$(strip $(EXAMPLES))" || \ $(INSTALL_DIR) $(DISTDIR)/examples && \ for file in $(EXAMPLES); do \ $(INSTALL_FILE) examples/$$file $(DISTDIR)/examples; \ done test -z "$(strip $(MANUAL))" || \ $(INSTALL_DIR) $(DISTDIR)/manual && \ for file in $(MANUAL); do \ $(INSTALL_FILE) manual/$$file $(DISTDIR)/manual; \ done tar --exclude-vcs -czpf $(DISTDIR).tar.gz $(DISTDIR) # make a Debian source package dpkg-source: debclean make distclean dist mv $(DISTDIR) $(ORIGDIR) tar --exclude-vcs -czpf ../$(ORIGDIR).orig.tar.gz $(ORIGDIR) rm -f -- $(DISTDIR).tar.gz rm -rf -- $(DISTDIR) $(ORIGDIR) cd .. && dpkg-source -b $(LIBRARY_NAME) etags: etags *.h $(SOURCES) ../../pd/src/*.[ch] /usr/include/*.h /usr/include/*/*.h showsetup: @echo "PD_PATH: $(PD_PATH)" @echo "objectsdir: $(objectsdir)" @echo "LIBRARY_NAME: $(LIBRARY_NAME)" @echo "LIBRARY_VERSION: $(LIBRARY_VERSION)" @echo "SOURCES: $(SOURCES)" @echo "PDOBJECTS: $(PDOBJECTS)" @echo "ALLSOURCES: $(ALLSOURCES)" @echo "UNAME: $(UNAME)" @echo "CPU: $(CPU)" @echo "pkglibdir: $(pkglibdir)" @echo "DISTDIR: $(DISTDIR)" @echo "ORIGDIR: $(ORIGDIR)" pd-windowing_0.1/connes~.c0000644000076500007650000000510711466353476014371 0ustar hanshans/* connes~ - connes windowing function for Pure Data ** ** Copyright (C) 2002 Joseph A. Sarlo ** ** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** jsarlo@mambo.peabody.jhu.edu */ #include "m_pd.h" #include #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; typedef struct _connes { t_object x_obj; int x_blocksize; float *x_table; } t_connes; static t_int* connes_perform(t_int *w) { t_connes *x = (t_connes *)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); int i; if (x->x_blocksize != n) { if (x->x_blocksize < n) { x->x_table = realloc(x->x_table, n * sizeof(float)); } x->x_blocksize = n; fillConnes(x->x_table, x->x_blocksize); } for (i = 0; i < n; i++) { *out++ = *(in++) * x->x_table[i]; } return (w + 5); } static void connes_dsp(t_connes *x, t_signal **sp) { dsp_add(connes_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } static void* connes_new(void) { t_connes *x = (t_connes *)pd_new(connes_class); x->x_blocksize = DEFBLOCKSIZE; x->x_table = malloc(x->x_blocksize * sizeof(float)); fillConnes(x->x_table, x->x_blocksize); outlet_new(&x->x_obj, gensym("signal")); return (x); } static void connes_free(t_connes *x) { free(x->x_table); } void connes_tilde_setup(void) { connes_class = class_new(gensym("connes~"), (t_newmethod)connes_new, (t_method)connes_free, sizeof(t_connes), 0, A_DEFFLOAT, 0); class_addmethod(connes_class, nullfn, gensym("signal"), 0); class_addmethod(connes_class, (t_method)connes_dsp, gensym("dsp"), 0); } pd-windowing_0.1/welch~-help.pd0000644000076500007650000000421011466353476015307 0ustar hanshans#N canvas 256 141 560 517 10; #X obj 4 479 cnv 15 550 20 empty \$0-pddp.cnv.footer empty 20 12 0 14 -228856 -66577 0; #X obj 4 -17 cnv 15 550 40 empty \$0-pddp.cnv.header welch~ 3 12 0 18 -204280 -1 0; #X obj 3 239 cnv 3 550 3 empty \$0-pddp.cnv.inlets inlets 15 12 0 13 -228856 -1 0; #X obj 3 299 cnv 3 550 3 empty \$0-pddp.cnv.outlets outlet 15 12 0 13 -228856 -1 0; #X obj 3 359 cnv 3 550 3 empty \$0-pddp.cnv.more_info more_info 15 12 0 13 -228856 -1 0; #X obj 72 259 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X text 168 40 formula:; #X obj 97 86 hsl 71 15 -1 1 0 0 empty empty empty -2 -6 0 10 -262144 -1 -1 7000 1; #X msg 94 66 1; #X obj 94 46 loadbang; #X obj 102 365 pddp/pddplink http://en.wikipedia.org/wiki/Window_function -text wikipedia: window functions; #X obj 438 -14 import windowing; #X msg 36 154 \; pd dsp 1; #X text 21 85 height --->; #X obj 127 109 sig~ 1; #N canvas 0 0 450 300 graph3 0; #X array \$0-welch 64 float 0; #X coords 0 1 63 -1 200 140 1; #X restore 326 65 graph; #X text 102 406 Windowing functions are used with FFTs. These transform the signal block-by-block into a spectral representation whose resolution in both the frequency and time domains are proportional to their size (as a power-of-two in PD). The different windows have different characteristics in terms of stopband attenuation and noise bandwidth.; #X text 102 258 SIGNAL: the height (amplitude) of the window is controlled by the signal on its inlet.; #X obj 127 158 tabsend~ \$0-welch; #X obj 127 132 welch~; #X text 169 53 1-abs(x); #X obj 102 379 pddp/pddplink http://en.wikipedia.org/wiki/Welch_method -text wikipedia: Welch's method; #X obj 102 392 pddp/pddplink http://mathworld.wolfram.com/WelchApodizationFunction.html -text mathworld link; #X text 103 317 SIGNAL: a welch window with size=dsp blocksize; #X text 15 6 description: generates a welch window for each dsp block ; #X obj 435 6 pddp/pddplink http://wiki.puredata.info/en/welch~ -text pdpedia: welch~; #X obj 73 319 cnv 17 3 30 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 -162280 0; #X connect 7 0 14 0; #X connect 8 0 7 0; #X connect 9 0 8 0; #X connect 14 0 19 0; #X connect 19 0 18 0; pd-windowing_0.1/gaussian~.c0000644000076500007650000000632711466353476014723 0ustar hanshans/* gaussian~ - gaussian windowing function for Pure Data ** ** Copyright (C) 2002 Joseph A. Sarlo ** ** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** jsarlo@mambo.peabody.jhu.edu */ #include "m_pd.h" #include #include #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; typedef struct _gaussian { t_object x_obj; int x_blocksize; float *x_table; float x_delta; } t_gaussian; static t_int* gaussian_perform(t_int *w) { t_gaussian *x = (t_gaussian *)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); int i; if (x->x_blocksize != n) { if (x->x_blocksize < n) { x->x_table = realloc(x->x_table, n * sizeof(float)); } x->x_blocksize = n; fillGaussian(x->x_table, x->x_blocksize, x->x_delta); } for (i = 0; i < n; i++) { *out++ = *(in++) * x->x_table[i]; } return (w + 5); } static void gaussian_dsp(t_gaussian *x, t_signal **sp) { dsp_add(gaussian_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } static void gaussian_float(t_gaussian *x, t_float delta) { if (delta != 0) { x->x_delta = delta; fillGaussian(x->x_table, x->x_blocksize, x->x_delta); } } static void* gaussian_new(float delta) { t_gaussian *x = (t_gaussian *)pd_new(gaussian_class); x->x_blocksize = DEFBLOCKSIZE; if (delta == 0) { x->x_delta = DEFDELTA; } else { x->x_delta = delta; } x->x_table = malloc(x->x_blocksize * sizeof(float)); fillGaussian(x->x_table, x->x_blocksize, x->x_delta); outlet_new(&x->x_obj, gensym("signal")); return (x); } static void gaussian_free(t_gaussian *x) { free(x->x_table); } void gaussian_tilde_setup(void) { gaussian_class = class_new(gensym("gaussian~"), (t_newmethod)gaussian_new, (t_method)gaussian_free, sizeof(t_gaussian), 0, A_DEFFLOAT, 0); class_addmethod(gaussian_class, nullfn, gensym("signal"), 0); class_addmethod(gaussian_class, (t_method)gaussian_dsp, gensym("dsp"), 0); class_addfloat(gaussian_class, (t_method)gaussian_float); } pd-windowing_0.1/kaiser~.c0000644000076500007650000003002211466353476014354 0ustar hanshans/* kaiser~ - kaiser windowing function for Pure Data ** ** Copyright (C) 2002 Joseph A. Sarlo ** ** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** jsarlo@mambo.peabody.jhu.edu */ #include "m_pd.h" #include "mconf.h" #include #include #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; typedef struct _kaiser { t_object x_obj; int x_blocksize; float *x_table; float x_alpha; } t_kaiser; static t_int* kaiser_perform(t_int *w) { t_kaiser *x = (t_kaiser *)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); int i; if (x->x_blocksize != n) { if (x->x_blocksize < n) { x->x_table = realloc(x->x_table, n * sizeof(float)); } x->x_blocksize = n; fillKaiser(x->x_table, x->x_blocksize, x->x_alpha); } for (i = 0; i < n; i++) { *out++ = *(in++) * x->x_table[i]; } return (w + 5); } static void kaiser_dsp(t_kaiser *x, t_signal **sp) { dsp_add(kaiser_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } static void kaiser_float(t_kaiser *x, t_float alpha) { x->x_alpha = alpha; fillKaiser(x->x_table, x->x_blocksize, x->x_alpha); } static void* kaiser_new(float alpha) { t_kaiser *x = (t_kaiser *)pd_new(kaiser_class); x->x_blocksize = DEFBLOCKSIZE; if (alpha == 0) { x->x_alpha = DEFALPHA; } else { x->x_alpha = alpha; } x->x_table = malloc(x->x_blocksize * sizeof(float)); fillKaiser(x->x_table, x->x_blocksize, x->x_alpha); outlet_new(&x->x_obj, gensym("signal")); return (x); } static void kaiser_free(t_kaiser *x) { free(x->x_table); } void kaiser_tilde_setup(void) { kaiser_class = class_new(gensym("kaiser~"), (t_newmethod)kaiser_new, (t_method)kaiser_free, sizeof(t_kaiser), 0, A_DEFFLOAT, 0); class_addmethod(kaiser_class, nullfn, gensym("signal"), 0); class_addmethod(kaiser_class, (t_method)kaiser_dsp, gensym("dsp"), 0); 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) ); }