diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2007-12-13 05:28:54 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2007-12-13 05:28:54 +0000 |
commit | c70554786db3e32ce5601b11d29d25db08cb2b37 (patch) | |
tree | 9ef0d1b4f7a54797ae8b8198910ab08c4858326d /gaussian~.c | |
parent | 1979f4b826560ec32ebb77c3c2c0e8506498b162 (diff) |
- reorganized files to build easy with Pd-extended.
- updated NT macro to _MSC_VER since those pragmas are for MSVC only
- put each object's "fill" function into that object's .c file,
- added i0.c to the end of kaiser~.c since that's the only one that needs it
- added #define powf pow for _WIN32 and Mac OS X for gaussian~.c since those
platforms don't have single precision pow() by default
svn path=/trunk/externals/windowing/; revision=9092
Diffstat (limited to 'gaussian~.c')
-rw-r--r-- | gaussian~.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/gaussian~.c b/gaussian~.c index 4716c8e..5ec3c47 100644 --- a/gaussian~.c +++ b/gaussian~.c @@ -20,15 +20,35 @@ */ #include "m_pd.h" -#include "windowFunctions.h" #include <stdlib.h> -#ifdef NT +#include <math.h> + +#ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif + #define DEFDELTA 0.5 #define DEFBLOCKSIZE 64 +/* MSW and OSX don't appear to have single-precision ANSI math */ +#if defined(_WIN32) || defined(__APPLE__) +#define powf pow +#endif + +void fillGaussian(float *vec, int n, float delta) { + int i; + float xShift = (float)n / 2; + float x; + if (delta == 0) { + delta = 1; + } + for (i = 0; i < n; i++) { + x = (i - xShift) / xShift; + vec[i] = (float)(pow(2, (-1 * (x / delta) * (x / delta)))); + } +} + static t_class *gaussian_class; typedef struct _gaussian { |