From 1a42ee8ec19ddc0d544c7fd854421cefda2309f0 Mon Sep 17 00:00:00 2001 From: Miller Puckette <msp@ucsd.edu> Date: Sat, 17 May 2008 09:49:53 -0700 Subject: [PATCH] Zmoelnig 64-bit float fixes --- doc/1.manual/x5.htm | 9 +++++++++ src/d_fftroutine.c | 22 +++++++++++----------- src/d_math.c | 8 ++++---- src/g_array.c | 5 +++-- src/g_template.c | 12 ++++++------ src/m_pd.h | 18 +++++++++++------- src/s_main.c | 3 ++- 7 files changed, 46 insertions(+), 31 deletions(-) diff --git a/doc/1.manual/x5.htm b/doc/1.manual/x5.htm index 9cccef257..53d6b1d9f 100644 --- a/doc/1.manual/x5.htm +++ b/doc/1.manual/x5.htm @@ -20,6 +20,15 @@ <H3> <A name="s2"> 5.1. release notes </A> </H3> +<P> ------------------ 0.42 --------------------------- + +<P> ".pdrc" loading suppressed if pd is started with "-noprefs". + +<P> Bug fix in pipe object: if sending a list to pipe, it didn't update the +delay time when asked to. + +<P> + <P> ------------------ 0.41-3,4 --------------------------- <P> 2 fixes for PC: no bonk~, and the audio device selection diff --git a/src/d_fftroutine.c b/src/d_fftroutine.c index 4678d38a7..0222a0c00 100644 --- a/src/d_fftroutine.c +++ b/src/d_fftroutine.c @@ -98,7 +98,7 @@ #define FALSE 0 #endif -#define SAMPLE float /* data type used in calculation */ +#define SAMPLE PD_FLOATTYPE /* data type used in calculation */ #define SHORT_SIZE sizeof(short) #define INT_SIZE sizeof(int) @@ -154,8 +154,8 @@ typedef struct Tfft_net { void cfft(int trnsfrm_dir, int npnt, int window, - float *source_buf, int source_form, int source_scale, - float *result_buf, int result_form, int result_scale, int debug); + SAMPLE *source_buf, int source_form, int source_scale, + SAMPLE *result_buf, int result_form, int result_scale, int debug); /*****************************************************************************/ @@ -172,10 +172,10 @@ int power_of_two(int n); void create_hanning(SAMPLE *window, int n, SAMPLE scale); void create_rectangular(SAMPLE *window, int n, SAMPLE scale); void short_to_float(short *short_buf, float *float_buf, int n); -void load_registers(FFT_NET *fft_net, float *buf, int buf_form, +void load_registers(FFT_NET *fft_net, SAMPLE *buf, int buf_form, int buf_scale, int trnsfrm_dir); void compute_fft(FFT_NET *fft_net); -void store_registers(FFT_NET *fft_net, float *buf, int buf_form, +void store_registers(FFT_NET *fft_net, SAMPLE *buf, int buf_form, int buf_scale, int debug); void build_fft_network(FFT_NET *fft_net, int n, int window_type); @@ -184,8 +184,8 @@ void build_fft_network(FFT_NET *fft_net, int n, int window_type); /*****************************************************************************/ void cfft(int trnsfrm_dir, int npnt, int window, - float *source_buf, int source_form, int source_scale, - float *result_buf, int result_form, int result_scale, int debug) + SAMPLE *source_buf, int source_form, int source_scale, + SAMPLE *result_buf, int result_form, int result_scale, int debug) /* modifies: result_buf effects: Computes npnt FFT specified by form, scale, and dir parameters. @@ -471,7 +471,7 @@ void build_fft_network(FFT_NET *fft_net, int n, int window_type) /* REGISTER LOAD AND STORE */ /*****************************************************************************/ -void load_registers(FFT_NET *fft_net, float *buf, int buf_form, +void load_registers(FFT_NET *fft_net, SAMPLE *buf, int buf_form, int buf_scale, int trnsfrm_dir) /* effects: Multiplies the input buffer with the appropriate window and @@ -605,7 +605,7 @@ void load_registers(FFT_NET *fft_net, float *buf, int buf_form, } -void store_registers(FFT_NET *fft_net, float *buf, int buf_form, +void store_registers(FFT_NET *fft_net, SAMPLE *buf, int buf_form, int buf_scale, int debug) /* modifies: buf @@ -989,10 +989,10 @@ void short_to_float(short *short_buf, float *float_buf, int n) /* here's the meat: */ -void pd_fft(float *buf, int npoints, int inverse) +void pd_fft(t_float *buf, int npoints, int inverse) { double renorm; - float *fp, *fp2; + SAMPLE *fp, *fp2; int i; renorm = (inverse ? npoints : 1.); cfft((inverse ? INVERSE : FORWARD), npoints, RECTANGULAR, diff --git a/src/d_math.c b/src/d_math.c index 213b866e5..8c480e37e 100644 --- a/src/d_math.c +++ b/src/d_math.c @@ -97,7 +97,7 @@ static void init_rsqrt(void) /* these are used in externs like "bonk" */ -float q8_rsqrt(float f) +t_float q8_rsqrt(t_float f) { long l = *(long *)(&f); if (f < 0) return (0); @@ -105,7 +105,7 @@ float q8_rsqrt(float f) rsqrt_mantissatab[(l >> 13) & 0x3ff]); } -float q8_sqrt(float f) +t_float q8_sqrt(t_float f) { long l = *(long *)(&f); if (f < 0) return (0); @@ -116,8 +116,8 @@ float q8_sqrt(float f) /* the old names are OK unless we're in IRIX N32 */ #ifndef N32 -float qsqrt(float f) {return (q8_sqrt(f)); } -float qrsqrt(float f) {return (q8_rsqrt(f)); } +t_float qsqrt(t_float f) {return (q8_sqrt(f)); } +t_float qrsqrt(t_float f) {return (q8_rsqrt(f)); } #endif diff --git a/src/g_array.c b/src/g_array.c index 0ebc99fb8..a73c5ba54 100644 --- a/src/g_array.c +++ b/src/g_array.c @@ -1402,13 +1402,14 @@ static void garray_read(t_garray *x, t_symbol *filename) } for (i = 0; i < nelem; i++) { - if (!fscanf(fd, "%f", ((t_float *)(array->a_vec + - elemsize * i) + yonset))) + float f; + if (!fscanf(fd, "%f", &f)) { post("%s: read %d elements into table of size %d", filename->s_name, i, nelem); break; } + else *((t_float *)(array->a_vec + elemsize * i) + yonset) = f; } while (i < nelem) *((t_float *)(array->a_vec + diff --git a/src/g_template.c b/src/g_template.c index 4d66bbed5..aff6f7cb4 100644 --- a/src/g_template.c +++ b/src/g_template.c @@ -721,11 +721,11 @@ struct _fielddesc t_symbol *fd_symbol; /* the field is a constant symbol */ t_symbol *fd_varsym; /* the field is variable and this is the name */ } fd_un; - t_float fd_v1; /* min and max values */ - t_float fd_v2; - t_float fd_screen1; /* min and max screen values */ - t_float fd_screen2; - t_float fd_quantum; /* quantization in value */ + float fd_v1; /* min and max values */ + float fd_v2; + float fd_screen1; /* min and max screen values */ + float fd_screen2; + float fd_quantum; /* quantization in value */ }; static void fielddesc_setfloat_const(t_fielddesc *fd, t_float f) @@ -2225,7 +2225,7 @@ static void drawnumber_key(void *z, t_floatarg fkey) else { /* key entry for a numeric field. This is just a stopgap. */ - t_float newf; + float newf; if (drawnumber_motion_firstkey) sbuf[0] = 0; else sprintf(sbuf, "%g", template_getfloat(drawnumber_motion_template, diff --git a/src/m_pd.h b/src/m_pd.h index 580bac0b8..89f613128 100644 --- a/src/m_pd.h +++ b/src/m_pd.h @@ -55,11 +55,15 @@ extern "C" { #define MAXPDARG 5 /* max number of args we can typecheck today */ /* signed and unsigned integer types the size of a pointer: */ -/* GG: long is the size of a pointer */ -typedef long t_int; - -typedef float t_float; /* a floating-point number at most the same size */ -typedef float t_floatarg; /* floating-point type for function calls */ +#if !defined(PD_LONGINTTYPE) +#define PD_LONGINTTYPE long +#endif +#if !defined(PD_FLOATTYPE) +#define PD_FLOATTYPE float +#endif +typedef PD_LONGINTTYPE t_int; /* pointer-size integer */ +typedef PD_FLOATTYPE t_float; /* a float type at most the same size */ +typedef PD_FLOATTYPE t_floatarg; /* float type for function calls */ typedef struct _symbol { @@ -443,7 +447,7 @@ EXTERN t_propertiesfn class_getpropertiesfn(t_class *c); EXTERN void post(const char *fmt, ...); EXTERN void startpost(const char *fmt, ...); EXTERN void poststring(const char *s); -EXTERN void postfloat(float f); +EXTERN void postfloat(t_floatarg f); EXTERN void postatom(int argc, t_atom *argv); EXTERN void endpost(void); EXTERN void error(const char *fmt, ...); @@ -474,7 +478,7 @@ EXTERN int sys_trylock(void); /* --------------- signals ----------------------------------- */ -typedef float t_sample; +typedef PD_FLOATTYPE t_sample; #define MAXLOGSIG 32 #define MAXSIGSIZE (1 << MAXLOGSIG) diff --git a/src/s_main.c b/src/s_main.c index 877ed41f6..dcc3bed97 100644 --- a/src/s_main.c +++ b/src/s_main.c @@ -282,7 +282,8 @@ int sys_main(int argc, char **argv) if (!noprefs) sys_loadpreferences(); /* load default settings */ #ifndef MSW - sys_rcfile(); /* parse the startup file */ + if (!noprefs) + sys_rcfile(); /* parse the startup file */ #endif if (sys_argparse(argc-1, argv+1)) /* parse cmd line */ return (1); -- GitLab