annotate projects/basic_libpd/m_pd.h @ 269:ac8eb07afcf5

Oxygen text added to each render.cpp file for the default projects. Text includes project explanation from Wiki, edited in places. Empty project added as a default project. Doxyfile updated. Each of the project locations added to INPUT configuration option. Consider just watching the whole project file so all new projects are automatically pulled through.
author Robert Jack <robert.h.jack@gmail.com>
date Tue, 17 May 2016 15:40:16 +0100
parents af211ee57867
children
rev   line source
giuliomoro@230 1 /* Copyright (c) 1997-1999 Miller Puckette.
giuliomoro@230 2 * For information on usage and redistribution, and for a DISCLAIMER OF ALL
giuliomoro@230 3 * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
giuliomoro@230 4
giuliomoro@230 5 #ifndef __m_pd_h_
giuliomoro@230 6
giuliomoro@230 7 #if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
giuliomoro@230 8 extern "C" {
giuliomoro@230 9 #endif
giuliomoro@230 10
giuliomoro@230 11 #define PD_MAJOR_VERSION 0
giuliomoro@230 12 #define PD_MINOR_VERSION 46
giuliomoro@230 13 #define PD_BUGFIX_VERSION 6
giuliomoro@230 14 #define PD_TEST_VERSION ""
giuliomoro@230 15 extern int pd_compatibilitylevel; /* e.g., 43 for pd 0.43 compatibility */
giuliomoro@230 16
giuliomoro@230 17 /* old name for "MSW" flag -- we have to take it for the sake of many old
giuliomoro@230 18 "nmakefiles" for externs, which will define NT and not MSW */
giuliomoro@230 19 #if defined(NT) && !defined(MSW)
giuliomoro@230 20 #define MSW
giuliomoro@230 21 #endif
giuliomoro@230 22
giuliomoro@230 23 /* These pragmas are only used for MSVC, not MinGW or Cygwin <hans@at.or.at> */
giuliomoro@230 24 #ifdef _MSC_VER
giuliomoro@230 25 /* #pragma warning( disable : 4091 ) */
giuliomoro@230 26 #pragma warning( disable : 4305 ) /* uncast const double to float */
giuliomoro@230 27 #pragma warning( disable : 4244 ) /* uncast float/int conversion etc. */
giuliomoro@230 28 #pragma warning( disable : 4101 ) /* unused automatic variables */
giuliomoro@230 29 #endif /* _MSC_VER */
giuliomoro@230 30
giuliomoro@230 31 /* the external storage class is "extern" in UNIX; in MSW it's ugly. */
giuliomoro@230 32 #ifdef _WIN32
giuliomoro@230 33 #ifdef PD_INTERNAL
giuliomoro@230 34 #define EXTERN __declspec(dllexport) extern
giuliomoro@230 35 #else
giuliomoro@230 36 #define EXTERN __declspec(dllimport) extern
giuliomoro@230 37 #endif /* PD_INTERNAL */
giuliomoro@230 38 #else
giuliomoro@230 39 #define EXTERN extern
giuliomoro@230 40 #endif /* _WIN32 */
giuliomoro@230 41
giuliomoro@230 42 /* and depending on the compiler, hidden data structures are
giuliomoro@230 43 declared differently: */
giuliomoro@230 44 #if defined( __GNUC__) || defined( __BORLANDC__ ) || defined( __MWERKS__ )
giuliomoro@230 45 #define EXTERN_STRUCT struct
giuliomoro@230 46 #else
giuliomoro@230 47 #define EXTERN_STRUCT extern struct
giuliomoro@230 48 #endif
giuliomoro@230 49
giuliomoro@230 50 /* Define some attributes, specific to the compiler */
giuliomoro@230 51 #if defined(__GNUC__)
giuliomoro@230 52 #define ATTRIBUTE_FORMAT_PRINTF(a, b) __attribute__ ((format (printf, a, b)))
giuliomoro@230 53 #else
giuliomoro@230 54 #define ATTRIBUTE_FORMAT_PRINTF(a, b)
giuliomoro@230 55 #endif
giuliomoro@230 56
giuliomoro@230 57 #if !defined(_SIZE_T) && !defined(_SIZE_T_)
giuliomoro@230 58 #include <stddef.h> /* just for size_t -- how lame! */
giuliomoro@230 59 #endif
giuliomoro@230 60
giuliomoro@230 61 /* Microsoft Visual Studio is not C99, it does not provide stdint.h */
giuliomoro@230 62 #ifdef _MSC_VER
giuliomoro@230 63 typedef signed __int8 int8_t;
giuliomoro@230 64 typedef signed __int16 int16_t;
giuliomoro@230 65 typedef signed __int32 int32_t;
giuliomoro@230 66 typedef signed __int64 int64_t;
giuliomoro@230 67 typedef unsigned __int8 uint8_t;
giuliomoro@230 68 typedef unsigned __int16 uint16_t;
giuliomoro@230 69 typedef unsigned __int32 uint32_t;
giuliomoro@230 70 typedef unsigned __int64 uint64_t;
giuliomoro@230 71 #else
giuliomoro@230 72 # include <stdint.h>
giuliomoro@230 73 #endif
giuliomoro@230 74
giuliomoro@230 75 /* for FILE, needed by sys_fopen() and sys_fclose() only */
giuliomoro@230 76 #include <stdio.h>
giuliomoro@230 77
giuliomoro@230 78 #define MAXPDSTRING 1000 /* use this for anything you want */
giuliomoro@230 79 #define MAXPDARG 5 /* max number of args we can typecheck today */
giuliomoro@230 80
giuliomoro@230 81 /* signed and unsigned integer types the size of a pointer: */
giuliomoro@230 82 #if !defined(PD_LONGINTTYPE)
giuliomoro@230 83 #define PD_LONGINTTYPE long
giuliomoro@230 84 #endif
giuliomoro@230 85
giuliomoro@230 86 #if !defined(PD_FLOATSIZE)
giuliomoro@230 87 /* normally, our floats (t_float, t_sample,...) are 32bit */
giuliomoro@230 88 # define PD_FLOATSIZE 32
giuliomoro@230 89 #endif
giuliomoro@230 90
giuliomoro@230 91 #if PD_FLOATSIZE == 32
giuliomoro@230 92 # define PD_FLOATTYPE float
giuliomoro@230 93 /* an unsigned int of the same size as FLOATTYPE: */
giuliomoro@230 94 # define PD_FLOATUINTTYPE unsigned int
giuliomoro@230 95
giuliomoro@230 96 #elif PD_FLOATSIZE == 64
giuliomoro@230 97 # define PD_FLOATTYPE double
giuliomoro@230 98 # define PD_FLOATUINTTYPE unsigned long
giuliomoro@230 99 #else
giuliomoro@230 100 # error invalid FLOATSIZE: must be 32 or 64
giuliomoro@230 101 #endif
giuliomoro@230 102
giuliomoro@230 103 typedef PD_LONGINTTYPE t_int; /* pointer-size integer */
giuliomoro@230 104 typedef PD_FLOATTYPE t_float; /* a float type at most the same size */
giuliomoro@230 105 typedef PD_FLOATTYPE t_floatarg; /* float type for function calls */
giuliomoro@230 106
giuliomoro@230 107 typedef struct _symbol
giuliomoro@230 108 {
giuliomoro@230 109 char *s_name;
giuliomoro@230 110 struct _class **s_thing;
giuliomoro@230 111 struct _symbol *s_next;
giuliomoro@230 112 } t_symbol;
giuliomoro@230 113
giuliomoro@230 114 EXTERN_STRUCT _array;
giuliomoro@230 115 #define t_array struct _array /* g_canvas.h */
giuliomoro@230 116
giuliomoro@230 117 /* pointers to glist and array elements go through a "stub" which sticks
giuliomoro@230 118 around after the glist or array is freed. The stub itself is deleted when
giuliomoro@230 119 both the glist/array is gone and the refcount is zero, ensuring that no
giuliomoro@230 120 gpointers are pointing here. */
giuliomoro@230 121
giuliomoro@230 122 #define GP_NONE 0 /* the stub points nowhere (has been cut off) */
giuliomoro@230 123 #define GP_GLIST 1 /* the stub points to a glist element */
giuliomoro@230 124 #define GP_ARRAY 2 /* ... or array */
giuliomoro@230 125
giuliomoro@230 126 typedef struct _gstub
giuliomoro@230 127 {
giuliomoro@230 128 union
giuliomoro@230 129 {
giuliomoro@230 130 struct _glist *gs_glist; /* glist we're in */
giuliomoro@230 131 struct _array *gs_array; /* array we're in */
giuliomoro@230 132 } gs_un;
giuliomoro@230 133 int gs_which; /* GP_GLIST/GP_ARRAY */
giuliomoro@230 134 int gs_refcount; /* number of gpointers pointing here */
giuliomoro@230 135 } t_gstub;
giuliomoro@230 136
giuliomoro@230 137 typedef struct _gpointer /* pointer to a gobj in a glist */
giuliomoro@230 138 {
giuliomoro@230 139 union
giuliomoro@230 140 {
giuliomoro@230 141 struct _scalar *gp_scalar; /* scalar we're in (if glist) */
giuliomoro@230 142 union word *gp_w; /* raw data (if array) */
giuliomoro@230 143 } gp_un;
giuliomoro@230 144 int gp_valid; /* number which must match gpointee */
giuliomoro@230 145 t_gstub *gp_stub; /* stub which points to glist/array */
giuliomoro@230 146 } t_gpointer;
giuliomoro@230 147
giuliomoro@230 148 typedef union word
giuliomoro@230 149 {
giuliomoro@230 150 t_float w_float;
giuliomoro@230 151 t_symbol *w_symbol;
giuliomoro@230 152 t_gpointer *w_gpointer;
giuliomoro@230 153 t_array *w_array;
giuliomoro@230 154 struct _binbuf *w_binbuf;
giuliomoro@230 155 int w_index;
giuliomoro@230 156 } t_word;
giuliomoro@230 157
giuliomoro@230 158 typedef enum
giuliomoro@230 159 {
giuliomoro@230 160 A_NULL,
giuliomoro@230 161 A_FLOAT,
giuliomoro@230 162 A_SYMBOL,
giuliomoro@230 163 A_POINTER,
giuliomoro@230 164 A_SEMI,
giuliomoro@230 165 A_COMMA,
giuliomoro@230 166 A_DEFFLOAT,
giuliomoro@230 167 A_DEFSYM,
giuliomoro@230 168 A_DOLLAR,
giuliomoro@230 169 A_DOLLSYM,
giuliomoro@230 170 A_GIMME,
giuliomoro@230 171 A_CANT
giuliomoro@230 172 } t_atomtype;
giuliomoro@230 173
giuliomoro@230 174 #define A_DEFSYMBOL A_DEFSYM /* better name for this */
giuliomoro@230 175
giuliomoro@230 176 typedef struct _atom
giuliomoro@230 177 {
giuliomoro@230 178 t_atomtype a_type;
giuliomoro@230 179 union word a_w;
giuliomoro@230 180 } t_atom;
giuliomoro@230 181
giuliomoro@230 182 EXTERN_STRUCT _class;
giuliomoro@230 183 #define t_class struct _class
giuliomoro@230 184
giuliomoro@230 185 EXTERN_STRUCT _outlet;
giuliomoro@230 186 #define t_outlet struct _outlet
giuliomoro@230 187
giuliomoro@230 188 EXTERN_STRUCT _inlet;
giuliomoro@230 189 #define t_inlet struct _inlet
giuliomoro@230 190
giuliomoro@230 191 EXTERN_STRUCT _binbuf;
giuliomoro@230 192 #define t_binbuf struct _binbuf
giuliomoro@230 193
giuliomoro@230 194 EXTERN_STRUCT _clock;
giuliomoro@230 195 #define t_clock struct _clock
giuliomoro@230 196
giuliomoro@230 197 EXTERN_STRUCT _outconnect;
giuliomoro@230 198 #define t_outconnect struct _outconnect
giuliomoro@230 199
giuliomoro@230 200 EXTERN_STRUCT _glist;
giuliomoro@230 201 #define t_glist struct _glist
giuliomoro@230 202 #define t_canvas struct _glist /* LATER lose this */
giuliomoro@230 203
giuliomoro@230 204 typedef t_class *t_pd; /* pure datum: nothing but a class pointer */
giuliomoro@230 205
giuliomoro@230 206 typedef struct _gobj /* a graphical object */
giuliomoro@230 207 {
giuliomoro@230 208 t_pd g_pd; /* pure datum header (class) */
giuliomoro@230 209 struct _gobj *g_next; /* next in list */
giuliomoro@230 210 } t_gobj;
giuliomoro@230 211
giuliomoro@230 212 typedef struct _scalar /* a graphical object holding data */
giuliomoro@230 213 {
giuliomoro@230 214 t_gobj sc_gobj; /* header for graphical object */
giuliomoro@230 215 t_symbol *sc_template; /* template name (LATER replace with pointer) */
giuliomoro@230 216 t_word sc_vec[1]; /* indeterminate-length array of words */
giuliomoro@230 217 } t_scalar;
giuliomoro@230 218
giuliomoro@230 219 typedef struct _text /* patchable object - graphical, with text */
giuliomoro@230 220 {
giuliomoro@230 221 t_gobj te_g; /* header for graphical object */
giuliomoro@230 222 t_binbuf *te_binbuf; /* holder for the text */
giuliomoro@230 223 t_outlet *te_outlet; /* linked list of outlets */
giuliomoro@230 224 t_inlet *te_inlet; /* linked list of inlets */
giuliomoro@230 225 short te_xpix; /* x&y location (within the toplevel) */
giuliomoro@230 226 short te_ypix;
giuliomoro@230 227 short te_width; /* requested width in chars, 0 if auto */
giuliomoro@230 228 unsigned int te_type:2; /* from defs below */
giuliomoro@230 229 } t_text;
giuliomoro@230 230
giuliomoro@230 231 #define T_TEXT 0 /* just a textual comment */
giuliomoro@230 232 #define T_OBJECT 1 /* a MAX style patchable object */
giuliomoro@230 233 #define T_MESSAGE 2 /* a MAX stype message */
giuliomoro@230 234 #define T_ATOM 3 /* a cell to display a number or symbol */
giuliomoro@230 235
giuliomoro@230 236 #define te_pd te_g.g_pd
giuliomoro@230 237
giuliomoro@230 238 /* t_object is synonym for t_text (LATER unify them) */
giuliomoro@230 239
giuliomoro@230 240 typedef struct _text t_object;
giuliomoro@230 241
giuliomoro@230 242 #define ob_outlet te_outlet
giuliomoro@230 243 #define ob_inlet te_inlet
giuliomoro@230 244 #define ob_binbuf te_binbuf
giuliomoro@230 245 #define ob_pd te_g.g_pd
giuliomoro@230 246 #define ob_g te_g
giuliomoro@230 247
giuliomoro@230 248 typedef void (*t_method)(void);
giuliomoro@230 249 typedef void *(*t_newmethod)( void);
giuliomoro@230 250
giuliomoro@230 251 /* in ARM 64 a varargs prototype generates a different function call sequence
giuliomoro@230 252 from a fixed one, so in that special case we make a more restrictive
giuliomoro@230 253 definition for t_gotfn. This will break some code in the "chaos" package
giuliomoro@230 254 in Pd extended. (that code will run incorrectly anyhow so why not catch it
giuliomoro@230 255 at compile time anyhow.) */
giuliomoro@230 256 #if defined(__APPLE__) && defined(__aarch64__)
giuliomoro@230 257 typedef void (*t_gotfn)(void *x);
giuliomoro@230 258 #else
giuliomoro@230 259 typedef void (*t_gotfn)(void *x, ...);
giuliomoro@230 260 #endif
giuliomoro@230 261
giuliomoro@230 262 /* ---------------- pre-defined objects and symbols --------------*/
giuliomoro@230 263 EXTERN t_pd pd_objectmaker; /* factory for creating "object" boxes */
giuliomoro@230 264 EXTERN t_pd pd_canvasmaker; /* factory for creating canvases */
giuliomoro@230 265 EXTERN t_symbol s_pointer;
giuliomoro@230 266 EXTERN t_symbol s_float;
giuliomoro@230 267 EXTERN t_symbol s_symbol;
giuliomoro@230 268 EXTERN t_symbol s_bang;
giuliomoro@230 269 EXTERN t_symbol s_list;
giuliomoro@230 270 EXTERN t_symbol s_anything;
giuliomoro@230 271 EXTERN t_symbol s_signal;
giuliomoro@230 272 EXTERN t_symbol s__N;
giuliomoro@230 273 EXTERN t_symbol s__X;
giuliomoro@230 274 EXTERN t_symbol s_x;
giuliomoro@230 275 EXTERN t_symbol s_y;
giuliomoro@230 276 EXTERN t_symbol s_;
giuliomoro@230 277
giuliomoro@230 278 /* --------- prototypes from the central message system ----------- */
giuliomoro@230 279 EXTERN void pd_typedmess(t_pd *x, t_symbol *s, int argc, t_atom *argv);
giuliomoro@230 280 EXTERN void pd_forwardmess(t_pd *x, int argc, t_atom *argv);
giuliomoro@230 281 EXTERN t_symbol *gensym(const char *s);
giuliomoro@230 282 EXTERN t_gotfn getfn(t_pd *x, t_symbol *s);
giuliomoro@230 283 EXTERN t_gotfn zgetfn(t_pd *x, t_symbol *s);
giuliomoro@230 284 EXTERN void nullfn(void);
giuliomoro@230 285 EXTERN void pd_vmess(t_pd *x, t_symbol *s, char *fmt, ...);
giuliomoro@230 286
giuliomoro@230 287 /* the following macrose are for sending non-type-checkable mesages, i.e.,
giuliomoro@230 288 using function lookup but circumventing type checking on arguments. Only
giuliomoro@230 289 use for internal messaging protected by A_CANT so that the message can't
giuliomoro@230 290 be generated at patch level. */
giuliomoro@230 291 #define mess0(x, s) ((*getfn((x), (s)))((x)))
giuliomoro@230 292 typedef void (*t_gotfn1)(void *x, void *arg1);
giuliomoro@230 293 #define mess1(x, s, a) ((*(t_gotfn1)getfn((x), (s)))((x), (a)))
giuliomoro@230 294 typedef void (*t_gotfn2)(void *x, void *arg1, void *arg2);
giuliomoro@230 295 #define mess2(x, s, a,b) ((*(t_gotfn2)getfn((x), (s)))((x), (a),(b)))
giuliomoro@230 296 typedef void (*t_gotfn3)(void *x, void *arg1, void *arg2, void *arg3);
giuliomoro@230 297 #define mess3(x, s, a,b,c) ((*(t_gotfn3)getfn((x), (s)))((x), (a),(b),(c)))
giuliomoro@230 298 typedef void (*t_gotfn4)(void *x,
giuliomoro@230 299 void *arg1, void *arg2, void *arg3, void *arg4);
giuliomoro@230 300 #define mess4(x, s, a,b,c,d) \
giuliomoro@230 301 ((*(t_gotfn4)getfn((x), (s)))((x), (a),(b),(c),(d)))
giuliomoro@230 302 typedef void (*t_gotfn5)(void *x,
giuliomoro@230 303 void *arg1, void *arg2, void *arg3, void *arg4, void *arg5);
giuliomoro@230 304 #define mess5(x, s, a,b,c,d,e) \
giuliomoro@230 305 ((*(t_gotfn5)getfn((x), (s)))((x), (a),(b),(c),(d),(e)))
giuliomoro@230 306
giuliomoro@230 307 EXTERN void obj_list(t_object *x, t_symbol *s, int argc, t_atom *argv);
giuliomoro@230 308 EXTERN t_pd *pd_newest(void);
giuliomoro@230 309
giuliomoro@230 310 /* --------------- memory management -------------------- */
giuliomoro@230 311 EXTERN void *getbytes(size_t nbytes);
giuliomoro@230 312 EXTERN void *getzbytes(size_t nbytes);
giuliomoro@230 313 EXTERN void *copybytes(void *src, size_t nbytes);
giuliomoro@230 314 EXTERN void freebytes(void *x, size_t nbytes);
giuliomoro@230 315 EXTERN void *resizebytes(void *x, size_t oldsize, size_t newsize);
giuliomoro@230 316
giuliomoro@230 317 /* -------------------- atoms ----------------------------- */
giuliomoro@230 318
giuliomoro@230 319 #define SETSEMI(atom) ((atom)->a_type = A_SEMI, (atom)->a_w.w_index = 0)
giuliomoro@230 320 #define SETCOMMA(atom) ((atom)->a_type = A_COMMA, (atom)->a_w.w_index = 0)
giuliomoro@230 321 #define SETPOINTER(atom, gp) ((atom)->a_type = A_POINTER, \
giuliomoro@230 322 (atom)->a_w.w_gpointer = (gp))
giuliomoro@230 323 #define SETFLOAT(atom, f) ((atom)->a_type = A_FLOAT, (atom)->a_w.w_float = (f))
giuliomoro@230 324 #define SETSYMBOL(atom, s) ((atom)->a_type = A_SYMBOL, \
giuliomoro@230 325 (atom)->a_w.w_symbol = (s))
giuliomoro@230 326 #define SETDOLLAR(atom, n) ((atom)->a_type = A_DOLLAR, \
giuliomoro@230 327 (atom)->a_w.w_index = (n))
giuliomoro@230 328 #define SETDOLLSYM(atom, s) ((atom)->a_type = A_DOLLSYM, \
giuliomoro@230 329 (atom)->a_w.w_symbol= (s))
giuliomoro@230 330
giuliomoro@230 331 EXTERN t_float atom_getfloat(t_atom *a);
giuliomoro@230 332 EXTERN t_int atom_getint(t_atom *a);
giuliomoro@230 333 EXTERN t_symbol *atom_getsymbol(t_atom *a);
giuliomoro@230 334 EXTERN t_symbol *atom_gensym(t_atom *a);
giuliomoro@230 335 EXTERN t_float atom_getfloatarg(int which, int argc, t_atom *argv);
giuliomoro@230 336 EXTERN t_int atom_getintarg(int which, int argc, t_atom *argv);
giuliomoro@230 337 EXTERN t_symbol *atom_getsymbolarg(int which, int argc, t_atom *argv);
giuliomoro@230 338
giuliomoro@230 339 EXTERN void atom_string(t_atom *a, char *buf, unsigned int bufsize);
giuliomoro@230 340
giuliomoro@230 341 /* ------------------ binbufs --------------- */
giuliomoro@230 342
giuliomoro@230 343 EXTERN t_binbuf *binbuf_new(void);
giuliomoro@230 344 EXTERN void binbuf_free(t_binbuf *x);
giuliomoro@230 345 EXTERN t_binbuf *binbuf_duplicate(t_binbuf *y);
giuliomoro@230 346
giuliomoro@230 347 EXTERN void binbuf_text(t_binbuf *x, char *text, size_t size);
giuliomoro@230 348 EXTERN void binbuf_gettext(t_binbuf *x, char **bufp, int *lengthp);
giuliomoro@230 349 EXTERN void binbuf_clear(t_binbuf *x);
giuliomoro@230 350 EXTERN void binbuf_add(t_binbuf *x, int argc, t_atom *argv);
giuliomoro@230 351 EXTERN void binbuf_addv(t_binbuf *x, char *fmt, ...);
giuliomoro@230 352 EXTERN void binbuf_addbinbuf(t_binbuf *x, t_binbuf *y);
giuliomoro@230 353 EXTERN void binbuf_addsemi(t_binbuf *x);
giuliomoro@230 354 EXTERN void binbuf_restore(t_binbuf *x, int argc, t_atom *argv);
giuliomoro@230 355 EXTERN void binbuf_print(t_binbuf *x);
giuliomoro@230 356 EXTERN int binbuf_getnatom(t_binbuf *x);
giuliomoro@230 357 EXTERN t_atom *binbuf_getvec(t_binbuf *x);
giuliomoro@230 358 EXTERN int binbuf_resize(t_binbuf *x, int newsize);
giuliomoro@230 359 EXTERN void binbuf_eval(t_binbuf *x, t_pd *target, int argc, t_atom *argv);
giuliomoro@230 360 EXTERN int binbuf_read(t_binbuf *b, char *filename, char *dirname,
giuliomoro@230 361 int crflag);
giuliomoro@230 362 EXTERN int binbuf_read_via_canvas(t_binbuf *b, char *filename, t_canvas *canvas,
giuliomoro@230 363 int crflag);
giuliomoro@230 364 EXTERN int binbuf_read_via_path(t_binbuf *b, char *filename, char *dirname,
giuliomoro@230 365 int crflag);
giuliomoro@230 366 EXTERN int binbuf_write(t_binbuf *x, char *filename, char *dir,
giuliomoro@230 367 int crflag);
giuliomoro@230 368 EXTERN void binbuf_evalfile(t_symbol *name, t_symbol *dir);
giuliomoro@230 369 EXTERN t_symbol *binbuf_realizedollsym(t_symbol *s, int ac, t_atom *av,
giuliomoro@230 370 int tonew);
giuliomoro@230 371
giuliomoro@230 372 /* ------------------ clocks --------------- */
giuliomoro@230 373
giuliomoro@230 374 EXTERN t_clock *clock_new(void *owner, t_method fn);
giuliomoro@230 375 EXTERN void clock_set(t_clock *x, double systime);
giuliomoro@230 376 EXTERN void clock_delay(t_clock *x, double delaytime);
giuliomoro@230 377 EXTERN void clock_unset(t_clock *x);
giuliomoro@230 378 EXTERN void clock_setunit(t_clock *x, double timeunit, int sampflag);
giuliomoro@230 379 EXTERN double clock_getlogicaltime(void);
giuliomoro@230 380 EXTERN double clock_getsystime(void); /* OBSOLETE; use clock_getlogicaltime() */
giuliomoro@230 381 EXTERN double clock_gettimesince(double prevsystime);
giuliomoro@230 382 EXTERN double clock_gettimesincewithunits(double prevsystime,
giuliomoro@230 383 double units, int sampflag);
giuliomoro@230 384 EXTERN double clock_getsystimeafter(double delaytime);
giuliomoro@230 385 EXTERN void clock_free(t_clock *x);
giuliomoro@230 386
giuliomoro@230 387 /* ----------------- pure data ---------------- */
giuliomoro@230 388 EXTERN t_pd *pd_new(t_class *cls);
giuliomoro@230 389 EXTERN void pd_free(t_pd *x);
giuliomoro@230 390 EXTERN void pd_bind(t_pd *x, t_symbol *s);
giuliomoro@230 391 EXTERN void pd_unbind(t_pd *x, t_symbol *s);
giuliomoro@230 392 EXTERN t_pd *pd_findbyclass(t_symbol *s, t_class *c);
giuliomoro@230 393 EXTERN void pd_pushsym(t_pd *x);
giuliomoro@230 394 EXTERN void pd_popsym(t_pd *x);
giuliomoro@230 395 EXTERN t_symbol *pd_getfilename(void);
giuliomoro@230 396 EXTERN t_symbol *pd_getdirname(void);
giuliomoro@230 397 EXTERN void pd_bang(t_pd *x);
giuliomoro@230 398 EXTERN void pd_pointer(t_pd *x, t_gpointer *gp);
giuliomoro@230 399 EXTERN void pd_float(t_pd *x, t_float f);
giuliomoro@230 400 EXTERN void pd_symbol(t_pd *x, t_symbol *s);
giuliomoro@230 401 EXTERN void pd_list(t_pd *x, t_symbol *s, int argc, t_atom *argv);
giuliomoro@230 402 EXTERN void pd_anything(t_pd *x, t_symbol *s, int argc, t_atom *argv);
giuliomoro@230 403 #define pd_class(x) (*(x))
giuliomoro@230 404
giuliomoro@230 405 /* ----------------- pointers ---------------- */
giuliomoro@230 406 EXTERN void gpointer_init(t_gpointer *gp);
giuliomoro@230 407 EXTERN void gpointer_copy(const t_gpointer *gpfrom, t_gpointer *gpto);
giuliomoro@230 408 EXTERN void gpointer_unset(t_gpointer *gp);
giuliomoro@230 409 EXTERN int gpointer_check(const t_gpointer *gp, int headok);
giuliomoro@230 410
giuliomoro@230 411 /* ----------------- patchable "objects" -------------- */
giuliomoro@230 412 EXTERN t_inlet *inlet_new(t_object *owner, t_pd *dest, t_symbol *s1,
giuliomoro@230 413 t_symbol *s2);
giuliomoro@230 414 EXTERN t_inlet *pointerinlet_new(t_object *owner, t_gpointer *gp);
giuliomoro@230 415 EXTERN t_inlet *floatinlet_new(t_object *owner, t_float *fp);
giuliomoro@230 416 EXTERN t_inlet *symbolinlet_new(t_object *owner, t_symbol **sp);
giuliomoro@230 417 EXTERN t_inlet *signalinlet_new(t_object *owner, t_float f);
giuliomoro@230 418 EXTERN void inlet_free(t_inlet *x);
giuliomoro@230 419
giuliomoro@230 420 EXTERN t_outlet *outlet_new(t_object *owner, t_symbol *s);
giuliomoro@230 421 EXTERN void outlet_bang(t_outlet *x);
giuliomoro@230 422 EXTERN void outlet_pointer(t_outlet *x, t_gpointer *gp);
giuliomoro@230 423 EXTERN void outlet_float(t_outlet *x, t_float f);
giuliomoro@230 424 EXTERN void outlet_symbol(t_outlet *x, t_symbol *s);
giuliomoro@230 425 EXTERN void outlet_list(t_outlet *x, t_symbol *s, int argc, t_atom *argv);
giuliomoro@230 426 EXTERN void outlet_anything(t_outlet *x, t_symbol *s, int argc, t_atom *argv);
giuliomoro@230 427 EXTERN t_symbol *outlet_getsymbol(t_outlet *x);
giuliomoro@230 428 EXTERN void outlet_free(t_outlet *x);
giuliomoro@230 429 EXTERN t_object *pd_checkobject(t_pd *x);
giuliomoro@230 430
giuliomoro@230 431
giuliomoro@230 432 /* -------------------- canvases -------------- */
giuliomoro@230 433
giuliomoro@230 434 EXTERN void glob_setfilename(void *dummy, t_symbol *name, t_symbol *dir);
giuliomoro@230 435
giuliomoro@230 436 EXTERN void canvas_setargs(int argc, t_atom *argv);
giuliomoro@230 437 EXTERN void canvas_getargs(int *argcp, t_atom **argvp);
giuliomoro@230 438 EXTERN t_symbol *canvas_getcurrentdir(void);
giuliomoro@230 439 EXTERN t_glist *canvas_getcurrent(void);
giuliomoro@230 440 EXTERN void canvas_makefilename(t_glist *c, char *file,
giuliomoro@230 441 char *result,int resultsize);
giuliomoro@230 442 EXTERN t_symbol *canvas_getdir(t_glist *x);
giuliomoro@230 443 EXTERN char sys_font[]; /* default typeface set in s_main.c */
giuliomoro@230 444 EXTERN char sys_fontweight[]; /* default font weight set in s_main.c */
giuliomoro@230 445 EXTERN int sys_fontwidth(int fontsize);
giuliomoro@230 446 EXTERN int sys_fontheight(int fontsize);
giuliomoro@230 447 EXTERN void canvas_dataproperties(t_glist *x, t_scalar *sc, t_binbuf *b);
giuliomoro@230 448 EXTERN int canvas_open(t_canvas *x, const char *name, const char *ext,
giuliomoro@230 449 char *dirresult, char **nameresult, unsigned int size, int bin);
giuliomoro@230 450
giuliomoro@230 451 /* ---------------- widget behaviors ---------------------- */
giuliomoro@230 452
giuliomoro@230 453 EXTERN_STRUCT _widgetbehavior;
giuliomoro@230 454 #define t_widgetbehavior struct _widgetbehavior
giuliomoro@230 455
giuliomoro@230 456 EXTERN_STRUCT _parentwidgetbehavior;
giuliomoro@230 457 #define t_parentwidgetbehavior struct _parentwidgetbehavior
giuliomoro@230 458 EXTERN t_parentwidgetbehavior *pd_getparentwidget(t_pd *x);
giuliomoro@230 459
giuliomoro@230 460 /* -------------------- classes -------------- */
giuliomoro@230 461
giuliomoro@230 462 #define CLASS_DEFAULT 0 /* flags for new classes below */
giuliomoro@230 463 #define CLASS_PD 1
giuliomoro@230 464 #define CLASS_GOBJ 2
giuliomoro@230 465 #define CLASS_PATCHABLE 3
giuliomoro@230 466 #define CLASS_NOINLET 8
giuliomoro@230 467
giuliomoro@230 468 #define CLASS_TYPEMASK 3
giuliomoro@230 469
giuliomoro@230 470
giuliomoro@230 471 EXTERN t_class *class_new(t_symbol *name, t_newmethod newmethod,
giuliomoro@230 472 t_method freemethod, size_t size, int flags, t_atomtype arg1, ...);
giuliomoro@230 473 EXTERN void class_addcreator(t_newmethod newmethod, t_symbol *s,
giuliomoro@230 474 t_atomtype type1, ...);
giuliomoro@230 475 EXTERN void class_addmethod(t_class *c, t_method fn, t_symbol *sel,
giuliomoro@230 476 t_atomtype arg1, ...);
giuliomoro@230 477 EXTERN void class_addbang(t_class *c, t_method fn);
giuliomoro@230 478 EXTERN void class_addpointer(t_class *c, t_method fn);
giuliomoro@230 479 EXTERN void class_doaddfloat(t_class *c, t_method fn);
giuliomoro@230 480 EXTERN void class_addsymbol(t_class *c, t_method fn);
giuliomoro@230 481 EXTERN void class_addlist(t_class *c, t_method fn);
giuliomoro@230 482 EXTERN void class_addanything(t_class *c, t_method fn);
giuliomoro@230 483 EXTERN void class_sethelpsymbol(t_class *c, t_symbol *s);
giuliomoro@230 484 EXTERN void class_setwidget(t_class *c, t_widgetbehavior *w);
giuliomoro@230 485 EXTERN void class_setparentwidget(t_class *c, t_parentwidgetbehavior *w);
giuliomoro@230 486 EXTERN t_parentwidgetbehavior *class_parentwidget(t_class *c);
giuliomoro@230 487 EXTERN char *class_getname(t_class *c);
giuliomoro@230 488 EXTERN char *class_gethelpname(t_class *c);
giuliomoro@230 489 EXTERN char *class_gethelpdir(t_class *c);
giuliomoro@230 490 EXTERN void class_setdrawcommand(t_class *c);
giuliomoro@230 491 EXTERN int class_isdrawcommand(t_class *c);
giuliomoro@230 492 EXTERN void class_domainsignalin(t_class *c, int onset);
giuliomoro@230 493 EXTERN void class_set_extern_dir(t_symbol *s);
giuliomoro@230 494 #define CLASS_MAINSIGNALIN(c, type, field) \
giuliomoro@230 495 class_domainsignalin(c, (char *)(&((type *)0)->field) - (char *)0)
giuliomoro@230 496
giuliomoro@230 497 /* prototype for functions to save Pd's to a binbuf */
giuliomoro@230 498 typedef void (*t_savefn)(t_gobj *x, t_binbuf *b);
giuliomoro@230 499 EXTERN void class_setsavefn(t_class *c, t_savefn f);
giuliomoro@230 500 EXTERN t_savefn class_getsavefn(t_class *c);
giuliomoro@230 501 EXTERN void obj_saveformat(t_object *x, t_binbuf *bb); /* add format to bb */
giuliomoro@230 502
giuliomoro@230 503 /* prototype for functions to open properties dialogs */
giuliomoro@230 504 typedef void (*t_propertiesfn)(t_gobj *x, struct _glist *glist);
giuliomoro@230 505 EXTERN void class_setpropertiesfn(t_class *c, t_propertiesfn f);
giuliomoro@230 506 EXTERN t_propertiesfn class_getpropertiesfn(t_class *c);
giuliomoro@230 507
giuliomoro@230 508 #ifndef PD_CLASS_DEF
giuliomoro@230 509 #define class_addbang(x, y) class_addbang((x), (t_method)(y))
giuliomoro@230 510 #define class_addpointer(x, y) class_addpointer((x), (t_method)(y))
giuliomoro@230 511 #define class_addfloat(x, y) class_doaddfloat((x), (t_method)(y))
giuliomoro@230 512 #define class_addsymbol(x, y) class_addsymbol((x), (t_method)(y))
giuliomoro@230 513 #define class_addlist(x, y) class_addlist((x), (t_method)(y))
giuliomoro@230 514 #define class_addanything(x, y) class_addanything((x), (t_method)(y))
giuliomoro@230 515 #endif
giuliomoro@230 516
giuliomoro@230 517 /* ------------ printing --------------------------------- */
giuliomoro@230 518 EXTERN void post(const char *fmt, ...);
giuliomoro@230 519 EXTERN void startpost(const char *fmt, ...);
giuliomoro@230 520 EXTERN void poststring(const char *s);
giuliomoro@230 521 EXTERN void postfloat(t_floatarg f);
giuliomoro@230 522 EXTERN void postatom(int argc, t_atom *argv);
giuliomoro@230 523 EXTERN void endpost(void);
giuliomoro@230 524 EXTERN void error(const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
giuliomoro@230 525 EXTERN void verbose(int level, const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(2, 3);
giuliomoro@230 526 EXTERN void bug(const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
giuliomoro@230 527 EXTERN void pd_error(void *object, const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(2, 3);
giuliomoro@230 528 EXTERN void logpost(const void *object, const int level, const char *fmt, ...)
giuliomoro@230 529 ATTRIBUTE_FORMAT_PRINTF(3, 4);
giuliomoro@230 530 EXTERN void sys_logerror(const char *object, const char *s);
giuliomoro@230 531 EXTERN void sys_unixerror(const char *object);
giuliomoro@230 532 EXTERN void sys_ouch(void);
giuliomoro@230 533
giuliomoro@230 534
giuliomoro@230 535 /* ------------ system interface routines ------------------- */
giuliomoro@230 536 EXTERN int sys_isreadablefile(const char *name);
giuliomoro@230 537 EXTERN int sys_isabsolutepath(const char *dir);
giuliomoro@230 538 EXTERN void sys_bashfilename(const char *from, char *to);
giuliomoro@230 539 EXTERN void sys_unbashfilename(const char *from, char *to);
giuliomoro@230 540 EXTERN int open_via_path(const char *dir, const char *name, const char *ext,
giuliomoro@230 541 char *dirresult, char **nameresult, unsigned int size, int bin);
giuliomoro@230 542 EXTERN int sched_geteventno(void);
giuliomoro@230 543 EXTERN double sys_getrealtime(void);
giuliomoro@230 544 EXTERN int (*sys_idlehook)(void); /* hook to add idle time computation */
giuliomoro@230 545
giuliomoro@230 546 /* Win32's open()/fopen() do not handle UTF-8 filenames so we need
giuliomoro@230 547 * these internal versions that handle UTF-8 filenames the same across
giuliomoro@230 548 * all platforms. They are recommended for use in external
giuliomoro@230 549 * objectclasses as well so they work with Unicode filenames on Windows */
giuliomoro@230 550 EXTERN int sys_open(const char *path, int oflag, ...);
giuliomoro@230 551 EXTERN int sys_close(int fd);
giuliomoro@230 552 EXTERN FILE *sys_fopen(const char *filename, const char *mode);
giuliomoro@230 553 EXTERN int sys_fclose(FILE *stream);
giuliomoro@230 554
giuliomoro@230 555 /* ------------ threading ------------------- */
giuliomoro@230 556 EXTERN void sys_lock(void);
giuliomoro@230 557 EXTERN void sys_unlock(void);
giuliomoro@230 558 EXTERN int sys_trylock(void);
giuliomoro@230 559
giuliomoro@230 560
giuliomoro@230 561 /* --------------- signals ----------------------------------- */
giuliomoro@230 562
giuliomoro@230 563 typedef PD_FLOATTYPE t_sample;
giuliomoro@230 564 typedef union _sampleint_union {
giuliomoro@230 565 t_sample f;
giuliomoro@230 566 PD_FLOATUINTTYPE i;
giuliomoro@230 567 } t_sampleint_union;
giuliomoro@230 568 #define MAXLOGSIG 32
giuliomoro@230 569 #define MAXSIGSIZE (1 << MAXLOGSIG)
giuliomoro@230 570
giuliomoro@230 571 typedef struct _signal
giuliomoro@230 572 {
giuliomoro@230 573 int s_n; /* number of points in the array */
giuliomoro@230 574 t_sample *s_vec; /* the array */
giuliomoro@230 575 t_float s_sr; /* sample rate */
giuliomoro@230 576 int s_refcount; /* number of times used */
giuliomoro@230 577 int s_isborrowed; /* whether we're going to borrow our array */
giuliomoro@230 578 struct _signal *s_borrowedfrom; /* signal to borrow it from */
giuliomoro@230 579 struct _signal *s_nextfree; /* next in freelist */
giuliomoro@230 580 struct _signal *s_nextused; /* next in used list */
giuliomoro@230 581 int s_vecsize; /* allocated size of array in points */
giuliomoro@230 582 } t_signal;
giuliomoro@230 583
giuliomoro@230 584 typedef t_int *(*t_perfroutine)(t_int *args);
giuliomoro@230 585
giuliomoro@230 586 EXTERN t_int *plus_perform(t_int *args);
giuliomoro@230 587 EXTERN t_int *zero_perform(t_int *args);
giuliomoro@230 588 EXTERN t_int *copy_perform(t_int *args);
giuliomoro@230 589
giuliomoro@230 590 EXTERN void dsp_add_plus(t_sample *in1, t_sample *in2, t_sample *out, int n);
giuliomoro@230 591 EXTERN void dsp_add_copy(t_sample *in, t_sample *out, int n);
giuliomoro@230 592 EXTERN void dsp_add_scalarcopy(t_float *in, t_sample *out, int n);
giuliomoro@230 593 EXTERN void dsp_add_zero(t_sample *out, int n);
giuliomoro@230 594
giuliomoro@230 595 EXTERN int sys_getblksize(void);
giuliomoro@230 596 EXTERN t_float sys_getsr(void);
giuliomoro@230 597 EXTERN int sys_get_inchannels(void);
giuliomoro@230 598 EXTERN int sys_get_outchannels(void);
giuliomoro@230 599
giuliomoro@230 600 EXTERN void dsp_add(t_perfroutine f, int n, ...);
giuliomoro@230 601 EXTERN void dsp_addv(t_perfroutine f, int n, t_int *vec);
giuliomoro@230 602 EXTERN void pd_fft(t_float *buf, int npoints, int inverse);
giuliomoro@230 603 EXTERN int ilog2(int n);
giuliomoro@230 604
giuliomoro@230 605 EXTERN void mayer_fht(t_sample *fz, int n);
giuliomoro@230 606 EXTERN void mayer_fft(int n, t_sample *real, t_sample *imag);
giuliomoro@230 607 EXTERN void mayer_ifft(int n, t_sample *real, t_sample *imag);
giuliomoro@230 608 EXTERN void mayer_realfft(int n, t_sample *real);
giuliomoro@230 609 EXTERN void mayer_realifft(int n, t_sample *real);
giuliomoro@230 610
giuliomoro@230 611 EXTERN float *cos_table;
giuliomoro@230 612 #define LOGCOSTABSIZE 9
giuliomoro@230 613 #define COSTABSIZE (1<<LOGCOSTABSIZE)
giuliomoro@230 614
giuliomoro@230 615 EXTERN int canvas_suspend_dsp(void);
giuliomoro@230 616 EXTERN void canvas_resume_dsp(int oldstate);
giuliomoro@230 617 EXTERN void canvas_update_dsp(void);
giuliomoro@230 618 EXTERN int canvas_dspstate;
giuliomoro@230 619
giuliomoro@230 620 /* up/downsampling */
giuliomoro@230 621 typedef struct _resample
giuliomoro@230 622 {
giuliomoro@230 623 int method; /* up/downsampling method ID */
giuliomoro@230 624
giuliomoro@230 625 int downsample; /* downsampling factor */
giuliomoro@230 626 int upsample; /* upsampling factor */
giuliomoro@230 627
giuliomoro@230 628 t_sample *s_vec; /* here we hold the resampled data */
giuliomoro@230 629 int s_n;
giuliomoro@230 630
giuliomoro@230 631 t_sample *coeffs; /* coefficients for filtering... */
giuliomoro@230 632 int coefsize;
giuliomoro@230 633
giuliomoro@230 634 t_sample *buffer; /* buffer for filtering */
giuliomoro@230 635 int bufsize;
giuliomoro@230 636 } t_resample;
giuliomoro@230 637
giuliomoro@230 638 EXTERN void resample_init(t_resample *x);
giuliomoro@230 639 EXTERN void resample_free(t_resample *x);
giuliomoro@230 640
giuliomoro@230 641 EXTERN void resample_dsp(t_resample *x, t_sample *in, int insize, t_sample *out, int outsize, int method);
giuliomoro@230 642 EXTERN void resamplefrom_dsp(t_resample *x, t_sample *in, int insize, int outsize, int method);
giuliomoro@230 643 EXTERN void resampleto_dsp(t_resample *x, t_sample *out, int insize, int outsize, int method);
giuliomoro@230 644
giuliomoro@230 645 /* ----------------------- utility functions for signals -------------- */
giuliomoro@230 646 EXTERN t_float mtof(t_float);
giuliomoro@230 647 EXTERN t_float ftom(t_float);
giuliomoro@230 648 EXTERN t_float rmstodb(t_float);
giuliomoro@230 649 EXTERN t_float powtodb(t_float);
giuliomoro@230 650 EXTERN t_float dbtorms(t_float);
giuliomoro@230 651 EXTERN t_float dbtopow(t_float);
giuliomoro@230 652
giuliomoro@230 653 EXTERN t_float q8_sqrt(t_float);
giuliomoro@230 654 EXTERN t_float q8_rsqrt(t_float);
giuliomoro@230 655 #ifndef N32
giuliomoro@230 656 EXTERN t_float qsqrt(t_float); /* old names kept for extern compatibility */
giuliomoro@230 657 EXTERN t_float qrsqrt(t_float);
giuliomoro@230 658 #endif
giuliomoro@230 659 /* --------------------- data --------------------------------- */
giuliomoro@230 660
giuliomoro@230 661 /* graphical arrays */
giuliomoro@230 662 EXTERN_STRUCT _garray;
giuliomoro@230 663 #define t_garray struct _garray
giuliomoro@230 664
giuliomoro@230 665 EXTERN t_class *garray_class;
giuliomoro@230 666 EXTERN int garray_getfloatarray(t_garray *x, int *size, t_float **vec);
giuliomoro@230 667 EXTERN int garray_getfloatwords(t_garray *x, int *size, t_word **vec);
giuliomoro@230 668 EXTERN void garray_redraw(t_garray *x);
giuliomoro@230 669 EXTERN int garray_npoints(t_garray *x);
giuliomoro@230 670 EXTERN char *garray_vec(t_garray *x);
giuliomoro@230 671 EXTERN void garray_resize(t_garray *x, t_floatarg f); /* avoid; use this: */
giuliomoro@230 672 EXTERN void garray_resize_long(t_garray *x, long n); /* better version */
giuliomoro@230 673 EXTERN void garray_usedindsp(t_garray *x);
giuliomoro@230 674 EXTERN void garray_setsaveit(t_garray *x, int saveit);
giuliomoro@230 675 EXTERN t_glist *garray_getglist(t_garray *x);
giuliomoro@230 676 EXTERN t_array *garray_getarray(t_garray *x);
giuliomoro@230 677 EXTERN t_class *scalar_class;
giuliomoro@230 678
giuliomoro@230 679 EXTERN t_float *value_get(t_symbol *s);
giuliomoro@230 680 EXTERN void value_release(t_symbol *s);
giuliomoro@230 681 EXTERN int value_getfloat(t_symbol *s, t_float *f);
giuliomoro@230 682 EXTERN int value_setfloat(t_symbol *s, t_float f);
giuliomoro@230 683
giuliomoro@230 684 /* ------- GUI interface - functions to send strings to TK --------- */
giuliomoro@230 685 typedef void (*t_guicallbackfn)(t_gobj *client, t_glist *glist);
giuliomoro@230 686
giuliomoro@230 687 EXTERN void sys_vgui(char *fmt, ...);
giuliomoro@230 688 EXTERN void sys_gui(char *s);
giuliomoro@230 689 EXTERN void sys_pretendguibytes(int n);
giuliomoro@230 690 EXTERN void sys_queuegui(void *client, t_glist *glist, t_guicallbackfn f);
giuliomoro@230 691 EXTERN void sys_unqueuegui(void *client);
giuliomoro@230 692 /* dialog window creation and destruction */
giuliomoro@230 693 EXTERN void gfxstub_new(t_pd *owner, void *key, const char *cmd);
giuliomoro@230 694 EXTERN void gfxstub_deleteforkey(void *key);
giuliomoro@230 695
giuliomoro@230 696 extern t_class *glob_pdobject; /* object to send "pd" messages */
giuliomoro@230 697
giuliomoro@230 698 /*------------- Max 0.26 compatibility --------------------*/
giuliomoro@230 699
giuliomoro@230 700 /* the following reflects the new way classes are laid out, with the class
giuliomoro@230 701 pointing to the messlist and not vice versa. Externs shouldn't feel it. */
giuliomoro@230 702 typedef t_class *t_externclass;
giuliomoro@230 703
giuliomoro@230 704 EXTERN void c_extern(t_externclass *cls, t_newmethod newroutine,
giuliomoro@230 705 t_method freeroutine, t_symbol *name, size_t size, int tiny, \
giuliomoro@230 706 t_atomtype arg1, ...);
giuliomoro@230 707 EXTERN void c_addmess(t_method fn, t_symbol *sel, t_atomtype arg1, ...);
giuliomoro@230 708
giuliomoro@230 709 #define t_getbytes getbytes
giuliomoro@230 710 #define t_freebytes freebytes
giuliomoro@230 711 #define t_resizebytes resizebytes
giuliomoro@230 712 #define typedmess pd_typedmess
giuliomoro@230 713 #define vmess pd_vmess
giuliomoro@230 714
giuliomoro@230 715 /* A definition to help gui objects straddle 0.34-0.35 changes. If this is
giuliomoro@230 716 defined, there is a "te_xpix" field in objects, not a "te_xpos" as before: */
giuliomoro@230 717
giuliomoro@230 718 #define PD_USE_TE_XPIX
giuliomoro@230 719
giuliomoro@230 720 #ifndef _MSC_VER /* Microoft compiler can't handle "inline" function/macros */
giuliomoro@230 721 #if defined(__i386__) || defined(__x86_64__) || defined(__arm__)
giuliomoro@230 722 /* a test for NANs and denormals. Should only be necessary on i386. */
giuliomoro@230 723 # if PD_FLOATSIZE == 32
giuliomoro@230 724 static inline int PD_BADFLOAT(t_sample f) {
giuliomoro@230 725 t_sampleint_union u;
giuliomoro@230 726 u.f=f;
giuliomoro@230 727 return ((u.i & 0x7f800000)==0) || ((u.i&0x7f800000)==0x7f800000);
giuliomoro@230 728 }
giuliomoro@230 729 /* more stringent test: anything not between 1e-19 and 1e19 in absolute val */
giuliomoro@230 730 static inline int PD_BIGORSMALL(t_sample f) {
giuliomoro@230 731 t_sampleint_union u;
giuliomoro@230 732 u.f=f;
giuliomoro@230 733 return ((u.i & 0x60000000)==0) || ((u.i & 0x60000000)==0x60000000);
giuliomoro@230 734 }
giuliomoro@230 735 # else
giuliomoro@230 736 # warning 64bit mode: BIGORSMALL not implemented yet
giuliomoro@230 737 # define PD_BADFLOAT(f) 0
giuliomoro@230 738 # define PD_BIGORSMALL(f) 0
giuliomoro@230 739 # endif
giuliomoro@230 740 #else
giuliomoro@230 741 # define PD_BADFLOAT(f) 0
giuliomoro@230 742 # define PD_BIGORSMALL(f) 0
giuliomoro@230 743 #endif
giuliomoro@230 744 #else /* _MSC_VER */
giuliomoro@230 745 #define PD_BADFLOAT(f) ((((*(unsigned int*)&(f))&0x7f800000)==0) || \
giuliomoro@230 746 (((*(unsigned int*)&(f))&0x7f800000)==0x7f800000))
giuliomoro@230 747 /* more stringent test: anything not between 1e-19 and 1e19 in absolute val */
giuliomoro@230 748 #define PD_BIGORSMALL(f) ((((*(unsigned int*)&(f))&0x60000000)==0) || \
giuliomoro@230 749 (((*(unsigned int*)&(f))&0x60000000)==0x60000000))
giuliomoro@230 750 #endif /* _MSC_VER */
giuliomoro@230 751 /* get version number at run time */
giuliomoro@230 752 EXTERN void sys_getversion(int *major, int *minor, int *bugfix);
giuliomoro@230 753
giuliomoro@230 754 EXTERN_STRUCT _pdinstance;
giuliomoro@230 755 #define t_pdinstance struct _pdinstance /* m_imp.h */
giuliomoro@230 756
giuliomoro@230 757 /* m_pd.c */
giuliomoro@230 758
giuliomoro@230 759 EXTERN t_pdinstance *pdinstance_new( void);
giuliomoro@230 760 EXTERN void pd_setinstance(t_pdinstance *x);
giuliomoro@230 761 EXTERN void pdinstance_free(t_pdinstance *x);
giuliomoro@230 762 EXTERN t_canvas *pd_getcanvaslist(void);
giuliomoro@230 763 EXTERN int pd_getdspstate(void);
giuliomoro@230 764
giuliomoro@230 765 #if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
giuliomoro@230 766 }
giuliomoro@230 767 #endif
giuliomoro@230 768
giuliomoro@230 769 #define __m_pd_h_
giuliomoro@230 770 #endif /* __m_pd_h_ */