From 7312e58d17e331d71d4f47e21bf15499609bace8 Mon Sep 17 00:00:00 2001 From: dieter kovacic Date: Tue, 9 Jul 2002 12:41:56 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r33, which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/ext13/; revision=34 --- ftos.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 ftos.c (limited to 'ftos.c') diff --git a/ftos.c b/ftos.c new file mode 100644 index 0000000..db64e38 --- /dev/null +++ b/ftos.c @@ -0,0 +1,67 @@ +#include "ext13.h" +#include "m_pd.h" +#include +#include +#include +#include + +#ifdef NT +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* -------------------------- ftos ------------------------------ */ +static t_class *ftos_class; + +typedef struct _ftos +{ + t_object x_obj; + t_symbol *x_s; + t_symbol *x_fmt; + t_float x_f; +} t_ftos; + + +static void *ftos_new(t_floatarg f) +{ + t_ftos *x = (t_ftos *)pd_new(ftos_class); + x->x_f=f; + floatinlet_new(&x->x_obj, &x->x_f); + outlet_new(&x->x_obj,0); + x->x_s = gensym("0"); + return (x); +} + + + +static void ftos_bang(t_ftos *x) +{ + outlet_symbol(x->x_obj.ob_outlet,x->x_s); +} + +static void ftos_float(t_ftos *x, t_float f) +{ + char result[MAXPDSTRING]; + char fmt[MAXPDSTRING]; + char num[MAXPDSTRING]; +/* if (!f){f=2;} */ + sprintf(num,"%d",(int)x->x_f); + strcpy(fmt,"%."); + strcat(fmt,num); + strcat(fmt,"f"); + x->x_fmt = gensym (fmt); + sprintf(result,x->x_fmt->s_name,(float)f); + x->x_s = gensym(result); + ftos_bang(x); +} + + + +void ftos_setup(void) +{ + ftos_class = class_new(gensym("ftos"), (t_newmethod)ftos_new, 0, + sizeof(t_ftos), 0, A_DEFFLOAT, 0); + class_addbang(ftos_class, ftos_bang); + class_addfloat(ftos_class, ftos_float); +/* class_addfloat(ftos_class; ftos_float);*/ +} -- cgit v1.2.1