| 1 | /* |
| 2 | pd~.c - embed a Pd process within Pd or Max. |
| 3 | |
| 4 | Copyright 2008 Miller Puckette |
| 5 | BSD license; see README.txt in this distribution for details. |
| 6 | */ |
| 7 | |
| 8 | /* this is here so that we don't have to do anything in the MACOS tool |
| 9 | chain to define MSP. I'm sure it's easy but life's too short to waste |
| 10 | learning XCode. */ |
| 11 | #if !defined(PDcxx . . $ `<built-in>:475:9`!) && !defined(MSP) |
| 12 | #define MSP |
| 13 | #endif |
| 14 | |
| 15 | #ifdef _WIN32 |
| 16 | #include <io.h> |
| 17 | #include <fcntl.h> |
| 18 | #include <process.h> |
| 19 | #include <windows.h> |
| 20 | typedef int socklen_t; |
| 21 | #else |
| 22 | #include <string.h> |
| 23 | #include <unistd.h> |
| 24 | #include <stdlib.h> |
| 25 | #include <errno.h> |
| 26 | #include <ctype.h> |
| 27 | #include <sys/wait.h> |
| 28 | #include <fcntl.h> |
| 29 | #include <signal.h> |
| 30 | #endif |
| 31 | #include <sys/types.h> |
| 32 | #include <sys/stat.h> |
| 33 | #include <stdio.h> |
| 34 | |
| 35 | #ifdef _MSC_VER |
| 36 | #pragma warning (disable: 4305 4244) |
| 37 | #define stat _stat |
| 38 | #endif |
| 39 | |
| 40 | #ifdef _WIN32 |
| 41 | # define PIPE(p) _pipe(p, 65536, O_BINARY | O_NOINHERIT) |
| 42 | #else |
| 43 | # define PIPEcxx . . $ `extra/pd~/pd~.c:43:10`!(p) pipe(p) |
| 44 | #endif |
| 45 | |
| 46 | |
| 47 | #ifdef MSP |
| 48 | #include "ext.h" |
| 49 | #include "z_dsp.h" |
| 50 | #include "math.h" |
| 51 | #include "ext_mess.h" |
| 52 | #include "ext_support.h" |
| 53 | #include "ext_proto.h" |
| 54 | #include "ext_obex.h" |
| 55 | |
| 56 | typedef float t_float; |
| 57 | typedef float t_pdsample; |
| 58 | #define PD_FLOATSIZE 32 |
| 59 | #define w_symbol w_sym |
| 60 | #define A_SYMBOL A_SYM |
| 61 | #define PDERROR error( |
| 62 | void *pd_tilde_class; |
| 63 | #define MAXPDSTRING 4096 |
| 64 | #define DEFDACBLKSIZE 64 |
| 65 | |
| 66 | typedef struct _binbuf |
| 67 | { |
| 68 | int b_n; |
| 69 | t_atom *b_vec; |
| 70 | } t_binbuf; |
| 71 | #define SETSEMI(atom) ((atom)->a_type = A_SEMI, (atom)->a_w.w_long = 0) |
| 72 | #define SETCOMMA(atom) ((atom)->a_type = A_COMMA, (atom)->a_w.w_long = 0) |
| 73 | #define SETFLOAT(atom, f) ((atom)->a_type = A_FLOAT, (atom)->a_w.w_float = (f)) |
| 74 | #define SETSYMBOL(atom, s) ((atom)->a_type = A_SYMBOL, \ |
| 75 | (atom)->a_w.w_symbol = (s)) |
| 76 | |
| 77 | void critical_enter(int z); |
| 78 | void critical_exit(int z); |
| 79 | |
| 80 | #else /* not MSP */ |
| 81 | #define t_pdsamplecxx . . $ `extra/pd~/pd~.c:81:9`! t_sample |
| 82 | #endif /* MSP */ |
| 83 | |
| 84 | #ifdef PDcxx . . $ `<built-in>:475:9`! |
| 85 | #include "m_pd.h"cxx . . $ `<file>/src/m_pd.h`/ |
| 86 | #include "s_stuff.h"cxx . . $ `<file>/src/s_stuff.h`/ |
| 87 | static t_classcxx . . $ `src/m_pd.h:244:9`! *pd_tilde_classcxx . . $ pd_tilde_class.; |
| 88 | #define PDERRORcxx . . $ `extra/pd~/pd~.c:88:9`! pd_error(x, |
| 89 | #else |
| 90 | #ifdef _MSC_VER |
| 91 | /* Sorry, MSP! */ |
| 92 | #define pd_snprintf _snprintf |
| 93 | #else |
| 94 | #define pd_snprintf snprintf |
| 95 | #endif |
| 96 | #endif |
| 97 | |
| 98 | #if defined(__x86_64__cxx . . $ `<built-in>:373:9`!) || defined(_M_X64) |
| 99 | # define ARCHEXTcxx . . $ `extra/pd~/pd~.c:99:10`! "amd64" |
| 100 | #elif defined(__i386__) || defined(_M_IX86) |
| 101 | # define ARCHEXT "i386" |
| 102 | #elif defined(__arm__) |
| 103 | # define ARCHEXT "arm" |
| 104 | #elif defined(__aarch64__) |
| 105 | # define ARCHEXT "arm64" |
| 106 | #elif defined(__ppc__) |
| 107 | # define ARCHEXT "ppc" |
| 108 | #endif |
| 109 | |
| 110 | #ifdef ARCHEXTcxx . . $ `extra/pd~/pd~.c:99:10`! |
| 111 | #define ARCHDLLEXTcxx . . $ `extra/pd~/pd~.c:111:9`!(prefix) prefix ARCHEXTcxx . . $ `extra/pd~/pd~.c:99:10`! , |
| 112 | #else |
| 113 | #define ARCHDLLEXT(prefix) |
| 114 | #endif |
| 115 | |
| 116 | |
| 117 | static const char *pd_tilde_dllextentcxx . . $ pd_tilde_dllextent.[] = { |
| 118 | #if defined(__linux__cxx . . $ `<built-in>:399:9`!) || defined(__FreeBSD_kernel__) || defined(__GNU__) |
| 119 | ARCHDLLEXTcxx . . $ `extra/pd~/pd~.c:111:9`!(".l_") |
| 120 | ".pd_linux", |
| 121 | #elif defined(__APPLE__) |
| 122 | ARCHDLLEXT(".d_") |
| 123 | ".d_fat", |
| 124 | ".pd_darwin", |
| 125 | #elif defined(_WIN32) || defined(__CYGWIN__) |
| 126 | ARCHDLLEXT(".m_") |
| 127 | #endif |
| 128 | /* and some generic extensions */ |
| 129 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 130 | ".dll", |
| 131 | #else |
| 132 | ".so", |
| 133 | #endif |
| 134 | 0}; |
| 135 | |
| 136 | |
| 137 | static const char **get_dllextentcxx . . $ get_dllextent(5435fb1d25b36c11).(void) |
| 138 | { |
| 139 | #if PDcxx . . $ `<built-in>:475:9`! |
| 140 | const char**dllextent = sys_get_dllextensionscxx . . $ sys_get_dllextensions(5435fb1d25b36c11).(); |
| 141 | if(dllextent && *dllextent) |
| 142 | return dllextent; |
| 143 | #endif |
| 144 | return pd_tilde_dllextentcxx . . $ pd_tilde_dllextent.; |
| 145 | } |
| 146 | |
| 147 | |
| 148 | #include "binarymsg.c"cxx . . $ `<file>/extra/pd~/binarymsg.c`/ |
| 149 | |
| 150 | /* ------------------------ pd_tilde~ ----------------------------- */ |
| 151 | |
| 152 | #define MSGBUFSIZEcxx . . $ `extra/pd~/pd~.c:152:9`! 65536 |
| 153 | |
| 154 | typedef struct _pd_tildecxx . . $ _pd_tilde# |
| 155 | { |
| 156 | #ifdef PDcxx . . $ `<built-in>:475:9`! |
| 157 | t_objectcxx . . $ t_object# x_objcxx . . $ _pd_tilde#x_obj.; |
| 158 | t_clockcxx . . $ `src/m_pd.h:256:9`! *x_clockcxx . . $ _pd_tilde#x_clock.; |
| 159 | t_outletcxx . . $ `src/m_pd.h:247:9`! *x_outlet1cxx . . $ _pd_tilde#x_outlet1.; /* for messages back from subproc */ |
| 160 | t_canvascxx . . $ `src/m_pd.h:263:9`! *x_canvascxx . . $ _pd_tilde#x_canvas.; |
| 161 | #endif /* PD */ |
| 162 | #ifdef MSP |
| 163 | t_pxobject x_obj; |
| 164 | void *x_outlet1; |
| 165 | void *x_clock; |
| 166 | int x_clockisset; |
| 167 | t_pdsample *x_sampbuf; |
| 168 | #endif /* MSP */ |
| 169 | FILEcxx . . $ FILE# *x_infdcxx . . $ _pd_tilde#x_infd.; |
| 170 | FILEcxx . . $ FILE# *x_outfdcxx . . $ _pd_tilde#x_outfd.; |
| 171 | t_binbufcxx . . $ `src/m_pd.h:253:9`! *x_binbufcxx . . $ _pd_tilde#x_binbuf.; |
| 172 | int x_childpidcxx . . $ _pd_tilde#x_childpid.; |
| 173 | int x_ninsigcxx . . $ _pd_tilde#x_ninsig.; |
| 174 | int x_noutsigcxx . . $ _pd_tilde#x_noutsig.; |
| 175 | int x_fifocxx . . $ _pd_tilde#x_fifo.; |
| 176 | int x_binarycxx . . $ _pd_tilde#x_binary.; |
| 177 | t_floatcxx . . $ t_float# x_srcxx . . $ _pd_tilde#x_sr.; |
| 178 | t_symbolcxx . . $ t_symbol# *x_pddircxx . . $ _pd_tilde#x_pddir.; |
| 179 | t_symbolcxx . . $ t_symbol# *x_schedlibdircxx . . $ _pd_tilde#x_schedlibdir.; |
| 180 | t_pdsamplecxx . . $ `extra/pd~/pd~.c:81:9`! **x_insigcxx . . $ _pd_tilde#x_insig.; |
| 181 | t_pdsamplecxx . . $ `extra/pd~/pd~.c:81:9`! **x_outsigcxx . . $ _pd_tilde#x_outsig.; |
| 182 | int x_blksizecxx . . $ _pd_tilde#x_blksize.; |
| 183 | } t_pd_tildecxx . . $ t_pd_tilde#; |
| 184 | |
| 185 | #ifdef MSP |
| 186 | static void *pd_tilde_new(t_symbol *s, long ac, t_atom *av); |
| 187 | static void pd_tilde_dsp64(t_pd_tilde *x, t_object *dsp64, short *count, |
| 188 | double samplerate, long maxvectorsize, long flags); |
| 189 | void pd_tilde_assist(t_pd_tilde *x, void *b, long m, long a, char *s); |
| 190 | static void pd_tilde_free(t_pd_tilde *x); |
| 191 | void pd_tilde_setup(void); |
| 192 | void ext_main( void *r); |
| 193 | void pd_tilde_minvel_set(t_pd_tilde *x, void *attr, long ac, t_atom *av); |
| 194 | |
| 195 | #define binbuf_new pdbinbuf_new |
| 196 | #undef binbuf_free |
| 197 | #define binbuf_free pdbinbuf_free |
| 198 | #define binbuf_clear pdbinbuf_clear |
| 199 | #define binbuf_resize pdbinbuf_resize |
| 200 | #define binbuf_add pdbinbuf_add |
| 201 | #define binbuf_text pdbinbuf_text |
| 202 | #define binbuf_getnatom pdbinbuf_getnatom |
| 203 | #define binbuf_getvec pdbinbuf_getvec |
| 204 | |
| 205 | t_binbuf *binbuf_new(void) |
| 206 | { |
| 207 | t_binbuf *x = (t_binbuf *)t_getbytes(sizeof(*x)); |
| 208 | x->b_n = 0; |
| 209 | x->b_vec = t_getbytes(0); |
| 210 | return (x); |
| 211 | } |
| 212 | |
| 213 | void binbuf_free(t_binbuf *x) |
| 214 | { |
| 215 | t_freebytes(x->b_vec, x->b_n * sizeof(*x->b_vec)); |
| 216 | t_freebytes(x, sizeof(*x)); |
| 217 | } |
| 218 | |
| 219 | void binbuf_clear(t_binbuf *x) |
| 220 | { |
| 221 | x->b_vec = t_resizebytes((char *)x->b_vec, x->b_n * sizeof(*x->b_vec), 0); |
| 222 | x->b_n = 0; |
| 223 | } |
| 224 | |
| 225 | int binbuf_resize(t_binbuf *x, int newsize) |
| 226 | { |
| 227 | t_atom *new = (t_atom *)t_resizebytes((char *)x->b_vec, |
| 228 | x->b_n * sizeof(*x->b_vec), newsize * sizeof(*x->b_vec)); |
| 229 | if (new) |
| 230 | x->b_vec = new, x->b_n = newsize; |
| 231 | return (new != 0); |
| 232 | } |
| 233 | |
| 234 | void binbuf_add(t_binbuf *x, int argc, const t_atom *argv) |
| 235 | { |
| 236 | int previoussize = x->b_n; |
| 237 | int newsize = previoussize + argc, i; |
| 238 | t_atom *ap; |
| 239 | |
| 240 | if (!binbuf_resize(x, newsize)) |
| 241 | { |
| 242 | PDERROR "binbuf_addmessage: out of space"); |
| 243 | return; |
| 244 | } |
| 245 | for (ap = x->b_vec + previoussize, i = argc; i--; ap++) |
| 246 | *ap = *(argv++); |
| 247 | } |
| 248 | |
| 249 | /* convert text to a binbuf */ |
| 250 | void binbuf_text(t_binbuf *x, const char *text, size_t size) |
| 251 | { |
| 252 | char buf[MAXPDSTRING+1], *bufp, *ebuf = buf+MAXPDSTRING; |
| 253 | const char *textp = text, *etext = text+size; |
| 254 | t_atom *ap; |
| 255 | int nalloc = 16, natom = 0; |
| 256 | binbuf_clear(x); |
| 257 | if (!binbuf_resize(x, nalloc)) return; |
| 258 | ap = x->b_vec; |
| 259 | while (1) |
| 260 | { |
| 261 | |
| 262 | /* skip leading space */ |
| 263 | while ((textp != etext) && (*textp == ' ' || *textp == '\n' |
| 264 | || *textp == '\r' || *textp == '\t')) |
| 265 | textp++; |
| 266 | if (textp == etext) break; |
| 267 | if (*textp == ';') SETSEMI(ap), textp++; |
| 268 | else if (*textp == ',') SETCOMMA(ap), textp++; |
| 269 | else |
| 270 | { |
| 271 | /* it's an atom other than a comma or semi */ |
| 272 | char c; |
| 273 | int floatstate = 0, slash = 0, lastslash = 0, dollar = 0; |
| 274 | bufp = buf; |
| 275 | do |
| 276 | { |
| 277 | c = *bufp = *textp++; |
| 278 | lastslash = slash; |
| 279 | slash = (c == '\\'); |
| 280 | |
| 281 | if (floatstate >= 0) |
| 282 | { |
| 283 | int digit = (c >= '0' && c <= '9'), |
| 284 | dot = (c == '.'), minus = (c == '-'), |
| 285 | plusminus = (minus || (c == '+')), |
| 286 | expon = (c == 'e' || c == 'E'); |
| 287 | if (floatstate == 0) /* beginning */ |
| 288 | { |
| 289 | if (minus) floatstate = 1; |
| 290 | else if (digit) floatstate = 2; |
| 291 | else if (dot) floatstate = 3; |
| 292 | else floatstate = -1; |
| 293 | } |
| 294 | else if (floatstate == 1) /* got minus */ |
| 295 | { |
| 296 | if (digit) floatstate = 2; |
| 297 | else if (dot) floatstate = 3; |
| 298 | else floatstate = -1; |
| 299 | } |
| 300 | else if (floatstate == 2) /* got digits */ |
| 301 | { |
| 302 | if (dot) floatstate = 4; |
| 303 | else if (expon) floatstate = 6; |
| 304 | else if (!digit) floatstate = -1; |
| 305 | } |
| 306 | else if (floatstate == 3) /* got '.' without digits */ |
| 307 | { |
| 308 | if (digit) floatstate = 5; |
| 309 | else floatstate = -1; |
| 310 | } |
| 311 | else if (floatstate == 4) /* got '.' after digits */ |
| 312 | { |
| 313 | if (digit) floatstate = 5; |
| 314 | else if (expon) floatstate = 6; |
| 315 | else floatstate = -1; |
| 316 | } |
| 317 | else if (floatstate == 5) /* got digits after . */ |
| 318 | { |
| 319 | if (expon) floatstate = 6; |
| 320 | else if (!digit) floatstate = -1; |
| 321 | } |
| 322 | else if (floatstate == 6) /* got 'e' */ |
| 323 | { |
| 324 | if (plusminus) floatstate = 7; |
| 325 | else if (digit) floatstate = 8; |
| 326 | else floatstate = -1; |
| 327 | } |
| 328 | else if (floatstate == 7) /* got plus or minus */ |
| 329 | { |
| 330 | if (digit) floatstate = 8; |
| 331 | else floatstate = -1; |
| 332 | } |
| 333 | else if (floatstate == 8) /* got digits */ |
| 334 | { |
| 335 | if (!digit) floatstate = -1; |
| 336 | } |
| 337 | } |
| 338 | if (!lastslash && c == '$' && (textp != etext && |
| 339 | textp[0] >= '0' && textp[0] <= '9')) |
| 340 | dollar = 1; |
| 341 | if (!slash) bufp++; |
| 342 | else if (lastslash) |
| 343 | { |
| 344 | bufp++; |
| 345 | slash = 0; |
| 346 | } |
| 347 | } |
| 348 | while (textp != etext && bufp != ebuf && |
| 349 | (slash || (*textp != ' ' && *textp != '\n' && *textp != '\r' |
| 350 | && *textp != '\t' &&*textp != ',' && *textp != ';'))); |
| 351 | *bufp = 0; |
| 352 | if (floatstate == 2 || floatstate == 4 || floatstate == 5 || |
| 353 | floatstate == 8) |
| 354 | SETFLOAT(ap, atof(buf)); |
| 355 | /* LATER try to figure out how to mix "$" and "\$" correctly; |
| 356 | here, the backslashes were already stripped so we assume all |
| 357 | "$" chars are real dollars. In fact, we only know at least one |
| 358 | was. */ |
| 359 | else if (dollar) |
| 360 | { |
| 361 | if (buf[0] != '$') |
| 362 | dollar = 0; |
| 363 | for (bufp = buf+1; *bufp; bufp++) |
| 364 | if (*bufp < '0' || *bufp > '9') |
| 365 | dollar = 0; |
| 366 | SETFLOAT(ap, 0); |
| 367 | } |
| 368 | else SETSYMBOL(ap, gensym(buf)); |
| 369 | } |
| 370 | ap++; |
| 371 | natom++; |
| 372 | if (natom == nalloc) |
| 373 | { |
| 374 | if (!binbuf_resize(x, nalloc*2)) break; |
| 375 | nalloc = nalloc * 2; |
| 376 | ap = x->b_vec + natom; |
| 377 | } |
| 378 | if (textp == etext) break; |
| 379 | } |
| 380 | /* reallocate the vector to exactly the right size */ |
| 381 | binbuf_resize(x, natom); |
| 382 | } |
| 383 | |
| 384 | int binbuf_getnatom(const t_binbuf *x) |
| 385 | { |
| 386 | return (x->b_n); |
| 387 | } |
| 388 | |
| 389 | t_atom *binbuf_getvec(const t_binbuf *x) |
| 390 | { |
| 391 | return (x->b_vec); |
| 392 | } |
| 393 | void sys_bashfilename(char *tmpbuf, char *outbuf) |
| 394 | { |
| 395 | strcpy(outbuf, tmpbuf); |
| 396 | } |
| 397 | |
| 398 | #if 0 /* stuff for debugging */ |
| 399 | static FILE *barf_fd; |
| 400 | |
| 401 | void barf(const char *s) |
| 402 | { |
| 403 | if (!barf_fd) |
| 404 | barf_fd = fopen("/tmp/foo.txt", "w"); |
| 405 | if (barf_fd) |
| 406 | { |
| 407 | fprintf(barf_fd, "%s\n", s); |
| 408 | fflush(barf_fd); |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | void barf1(const char *s, int n1) |
| 413 | { |
| 414 | char buf2[1000]; |
| 415 | sprintf(buf2, s, n1); |
| 416 | barf(buf2); |
| 417 | } |
| 418 | |
| 419 | |
| 420 | void barf2(const char *s, int n1, int n2) |
| 421 | { |
| 422 | char buf2[1000]; |
| 423 | sprintf(buf2, s, n1, n2); |
| 424 | barf(buf2); |
| 425 | } |
| 426 | |
| 427 | #ifdef getc /* if debugging is on, copy all getc() output to /tmp/foo.txt */ |
| 428 | #undef getc |
| 429 | #endif |
| 430 | |
| 431 | int barf_getc(FILE *fd) |
| 432 | { |
| 433 | int poodle = getc(fd); |
| 434 | #if 0 |
| 435 | if (poodle < 0) |
| 436 | barf("barf_getc oops"); |
| 437 | else |
| 438 | { |
| 439 | if (!barf_fd) |
| 440 | barf_fd = fopen("/tmp/foo.txt", "w"); |
| 441 | if (barf_fd) |
| 442 | putc(poodle, barf_fd); |
| 443 | } |
| 444 | #endif |
| 445 | return (poodle); |
| 446 | } |
| 447 | |
| 448 | #define getc barf_getc |
| 449 | |
| 450 | #endif /* debugging */ |
| 451 | |
| 452 | #endif /* MAX */ |
| 453 | |
| 454 | static void pd_tilde_closecxx . . $ pd_tilde_close(2c157e4e29f4c94c).(t_pd_tildecxx . . $ t_pd_tilde# *x) |
| 455 | { |
| 456 | #ifdef _WIN32 |
| 457 | int termstat; |
| 458 | #endif |
| 459 | FILEcxx . . $ FILE# *infd = x->x_infdcxx . . $ _pd_tilde#x_infd., *outfd = x->x_outfdcxx . . $ _pd_tilde#x_outfd.; |
| 460 | x->x_infdcxx . . $ _pd_tilde#x_infd. = x->x_outfdcxx . . $ _pd_tilde#x_outfd. = 0; |
| 461 | if (outfd) |
| 462 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(outfd); |
| 463 | if (infd) |
| 464 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(infd); |
| 465 | if (x->x_childpidcxx . . $ _pd_tilde#x_childpid. > 0) |
| 466 | #ifdef _WIN32 |
| 467 | _cwait(&termstat, x->x_childpid, WAIT_CHILD); |
| 468 | #else |
| 469 | waitpidcxx . . $ waitpid(1df93256b606fe1f).(x->x_childpidcxx . . $ _pd_tilde#x_childpid., 0, 0); |
| 470 | #endif |
| 471 | binbuf_clearcxx . . $ binbuf_clear(e38d44570b85fc22).(x->x_binbufcxx . . $ _pd_tilde#x_binbuf.); |
| 472 | x->x_infdcxx . . $ _pd_tilde#x_infd. = x->x_outfdcxx . . $ _pd_tilde#x_outfd. = 0; |
| 473 | x->x_childpidcxx . . $ _pd_tilde#x_childpid. = -1; |
| 474 | } |
| 475 | |
| 476 | static int pd_tilde_readmessagescxx . . $ pd_tilde_readmessages(f737e017d0c88331).(t_pd_tildecxx . . $ t_pd_tilde# *x, FILEcxx . . $ FILE# *infd) |
| 477 | { |
| 478 | t_atomcxx . . $ t_atom# at; |
| 479 | if (x->x_binarycxx . . $ _pd_tilde#x_binary.) |
| 480 | { |
| 481 | int nonempty = 0; |
| 482 | while (1) |
| 483 | { |
| 484 | if (!pd_tilde_getatomcxx . . $ pd_tilde_getatom(badff60e2a3e117a).(&at, infd)) |
| 485 | return 0; |
| 486 | if (!nonempty && at.a_typecxx . . $ _atom#a_type. == A_SEMIcxx . . $ A_SEMI.) |
| 487 | break; |
| 488 | nonempty = (at.a_typecxx . . $ _atom#a_type. != A_SEMIcxx . . $ A_SEMI.); |
| 489 | binbuf_addcxx . . $ binbuf_add(80738d835459133).(x->x_binbufcxx . . $ _pd_tilde#x_binbuf., 1, &at); |
| 490 | } |
| 491 | } |
| 492 | else /* ASCII */ |
| 493 | { |
| 494 | t_binbufcxx . . $ `src/m_pd.h:253:9`! *tmpb = binbuf_newcxx . . $ binbuf_new(f904d73faf2754e9).(); |
| 495 | while (1) |
| 496 | { |
| 497 | char msgbuf[MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!]; |
| 498 | int c, infill = 0, n; |
| 499 | t_atomcxx . . $ t_atom# *vec; |
| 500 | while (isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!((c = getc(infd))) && c != EOFcxx . . $ `<external>/232824719582829767/stdio.h:105:9`!) |
| 501 | ; |
| 502 | if (c == EOFcxx . . $ `<external>/232824719582829767/stdio.h:105:9`!) |
| 503 | return 0; |
| 504 | do |
| 505 | msgbuf[infill++] = c; |
| 506 | while (!isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!((c = getc(infd))) && c != ';' && c != EOFcxx . . $ `<external>/232824719582829767/stdio.h:105:9`! |
| 507 | && infill < MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!-1) ; |
| 508 | if (c == ';' && infill < MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!-1) |
| 509 | msgbuf[infill++] = c; |
| 510 | binbuf_textcxx . . $ binbuf_text(bcb3fc6130d71256).(tmpb, msgbuf, infill); |
| 511 | n = binbuf_getnatomcxx . . $ binbuf_getnatom(7381d28fc432400c).(tmpb); |
| 512 | vec = binbuf_getveccxx . . $ binbuf_getvec(ec9d8f9604fe4c84).(tmpb); |
| 513 | binbuf_addcxx . . $ binbuf_add(80738d835459133).(x->x_binbufcxx . . $ _pd_tilde#x_binbuf., n, vec); |
| 514 | if (!n) |
| 515 | { |
| 516 | postcxx . . $ post(326aeb464d16410c).("bug: pd~"); |
| 517 | break; /* shouldn't happen */ |
| 518 | } |
| 519 | if (vec[0].a_typecxx . . $ _atom#a_type. == A_SEMIcxx . . $ A_SEMI.) |
| 520 | break; |
| 521 | } |
| 522 | binbuf_freecxx . . $ binbuf_free(e38d44570b85fc22).(tmpb); |
| 523 | } |
| 524 | #ifdef MAX |
| 525 | /* in Max, since control and DSP may be asynchronous, we might |
| 526 | already be set. If so, re-setting can just delay things further. */ |
| 527 | if (!x->x_clockisset) |
| 528 | { |
| 529 | x->x_clockisset = 1; |
| 530 | clock_delay(x->x_clock, 0); |
| 531 | } |
| 532 | #else |
| 533 | clock_delaycxx . . $ clock_delay(cf603c4af67bb09).(x->x_clockcxx . . $ _pd_tilde#x_clock., 0); |
| 534 | #endif |
| 535 | return (1); |
| 536 | } |
| 537 | |
| 538 | #define FIXEDARGcxx . . $ `extra/pd~/pd~.c:538:9`! 13 |
| 539 | #define MAXARGcxx . . $ `extra/pd~/pd~.c:539:9`! 100 |
| 540 | #ifdef _WIN32 |
| 541 | #define EXTENT ".exe" |
| 542 | #else |
| 543 | #define EXTENTcxx . . $ `extra/pd~/pd~.c:543:9`! "" |
| 544 | #endif |
| 545 | |
| 546 | /* only call this if we're not already running (x->x_infd = 0, etc.) */ |
| 547 | static void pd_tilde_dostartcxx . . $ pd_tilde_dostart(8236d19f281334fa).(t_pd_tildecxx . . $ t_pd_tilde# *x, const char *pddir, |
| 548 | const char *schedlibdir, const char *patchdir_c, int argc, t_atomcxx . . $ t_atom# *argv, |
| 549 | int ninsig, int noutsig, int fifo, t_floatcxx . . $ t_float# samplerate) |
| 550 | { |
| 551 | int i, pid, pipe1[2], pipe2[2]; |
| 552 | FILEcxx . . $ FILE# *infd, *outfd; |
| 553 | char cmdbuf[MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!], pdexecbuf[MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!], schedbuf[MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!], |
| 554 | tmpbuf[MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!], patchdir[MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!]; |
| 555 | char *execargv[FIXEDARGcxx . . $ `extra/pd~/pd~.c:538:9`!+MAXARGcxx . . $ `extra/pd~/pd~.c:539:9`!+1], ninsigstr[20], noutsigstr[20], |
| 556 | sampleratestr[40]; |
| 557 | const char**dllextent; |
| 558 | struct statcxx . . $ stat# statbuf; |
| 559 | x->x_childpidcxx . . $ _pd_tilde#x_childpid. = -1; |
| 560 | if (argc > MAXARGcxx . . $ `extra/pd~/pd~.c:539:9`!) |
| 561 | { |
| 562 | postcxx . . $ post(326aeb464d16410c).("pd~: args truncated to %d items", MAXARGcxx . . $ `extra/pd~/pd~.c:539:9`!); |
| 563 | argc = MAXARGcxx . . $ `extra/pd~/pd~.c:539:9`!; |
| 564 | } |
| 565 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(ninsigstr, "%d", ninsig); |
| 566 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(noutsigstr, "%d", noutsig); |
| 567 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(sampleratestr, "%f", (float)samplerate); |
| 568 | pd_snprintfcxx . . $ pd_snprintf(ea502d73e74c754c).(tmpbuf, MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!, "%s/bin/pd" EXTENTcxx . . $ `extra/pd~/pd~.c:543:9`!, pddir); |
| 569 | sys_bashfilenamecxx . . $ sys_bashfilename(611124a97efc52dd).(tmpbuf, pdexecbuf); |
| 570 | if (statcxx . . $ stat(a9cd1e23e96f423c).(pdexecbuf, &statbuf) < 0) |
| 571 | { |
| 572 | pd_snprintfcxx . . $ pd_snprintf(ea502d73e74c754c).(tmpbuf, MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!, "%s/../../../bin/pd" EXTENTcxx . . $ `extra/pd~/pd~.c:543:9`!, pddir); |
| 573 | sys_bashfilenamecxx . . $ sys_bashfilename(611124a97efc52dd).(tmpbuf, pdexecbuf); |
| 574 | if (statcxx . . $ stat(a9cd1e23e96f423c).(pdexecbuf, &statbuf) < 0) |
| 575 | { |
| 576 | pd_snprintfcxx . . $ pd_snprintf(ea502d73e74c754c).(tmpbuf, MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!, "%s/pd" EXTENTcxx . . $ `extra/pd~/pd~.c:543:9`!, pddir); |
| 577 | sys_bashfilenamecxx . . $ sys_bashfilename(611124a97efc52dd).(tmpbuf, pdexecbuf); |
| 578 | if (statcxx . . $ stat(a9cd1e23e96f423c).(pdexecbuf, &statbuf) < 0) |
| 579 | { |
| 580 | PDERRORcxx . . $ `extra/pd~/pd~.c:88:9`! "pd~: can't stat %s", pdexecbuf); |
| 581 | goto fail1; |
| 582 | } |
| 583 | } |
| 584 | } |
| 585 | /* check that the scheduler dynamic linkable exists w either suffix */ |
| 586 | for(dllextent=get_dllextentcxx . . $ get_dllextent(5435fb1d25b36c11).(); *dllextent; dllextent++) |
| 587 | { |
| 588 | pd_snprintfcxx . . $ pd_snprintf(ea502d73e74c754c).(tmpbuf, MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!, "%s/pdsched%s", schedlibdir, *dllextent); |
| 589 | sys_bashfilenamecxx . . $ sys_bashfilename(611124a97efc52dd).(tmpbuf, schedbuf); |
| 590 | if (statcxx . . $ stat(a9cd1e23e96f423c).(schedbuf, &statbuf) >= 0) |
| 591 | goto gotone; |
| 592 | } |
| 593 | PDERRORcxx . . $ `extra/pd~/pd~.c:88:9`! "pd~: can't stat %s", schedbuf); |
| 594 | goto fail1; |
| 595 | |
| 596 | gotone: |
| 597 | /* but the sub-process wants the scheduler name without the suffix */ |
| 598 | pd_snprintfcxx . . $ pd_snprintf(ea502d73e74c754c).(tmpbuf, MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!, "%s/pdsched", schedlibdir); |
| 599 | sys_bashfilenamecxx . . $ sys_bashfilename(611124a97efc52dd).(tmpbuf, schedbuf); |
| 600 | /* was: pd_snprintf(cmdbuf, MAXPDSTRING, |
| 601 | "'%s' -schedlib '%s'/pdsched -path '%s' -inchannels %d -outchannels %d -r \ |
| 602 | %g %s\n", |
| 603 | pdexecbuf, schedlibdir, patchdir, ninsig, noutsig, samplerate, pdargs); |
| 604 | */ |
| 605 | pd_snprintfcxx . . $ pd_snprintf(ea502d73e74c754c).(cmdbuf, MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!, "%s", pdexecbuf); |
| 606 | #ifdef _WIN32 |
| 607 | /* _spawnv wants the command without quotes as in cmdbuf above; |
| 608 | but in the argument vector paths must be quoted if they contain |
| 609 | whitespace */ |
| 610 | if (strchr(pdexecbuf, ' ') && *pdexecbuf != '"' && *pdexecbuf != '\'') |
| 611 | { |
| 612 | if (pd_snprintf(tmpbuf, MAXPDSTRING, "\"%s\"", pdexecbuf) >= 0) |
| 613 | pd_snprintf(pdexecbuf, MAXPDSTRING, "%s", tmpbuf); |
| 614 | } |
| 615 | if (strchr(schedbuf, ' ') && *schedbuf != '"' && *schedbuf != '\'') |
| 616 | { |
| 617 | if (pd_snprintf(tmpbuf, MAXPDSTRING, "\"%s\"", schedbuf) >= 0) |
| 618 | pd_snprintf(schedbuf, MAXPDSTRING, "%s", tmpbuf); |
| 619 | } |
| 620 | if (strchr(patchdir_c, ' ') && *patchdir_c != '"' && *patchdir_c != '\'') |
| 621 | pd_snprintf(patchdir, MAXPDSTRING, "\"%s\"", patchdir_c); |
| 622 | else |
| 623 | #endif /* _WIN32 */ |
| 624 | pd_snprintfcxx . . $ pd_snprintf(ea502d73e74c754c).(patchdir, MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!, "%s", patchdir_c); |
| 625 | |
| 626 | execargv[0] = pdexecbuf; |
| 627 | execargv[1] = "-schedlib"; |
| 628 | execargv[2] = schedbuf; |
| 629 | execargv[3] = "-extraflags"; |
| 630 | execargv[4] = (x->x_binarycxx . . $ _pd_tilde#x_binary. ? "b" : "a"); |
| 631 | execargv[5] = "-path"; |
| 632 | execargv[6] = patchdir; |
| 633 | execargv[7] = "-inchannels"; |
| 634 | execargv[8] = ninsigstr; |
| 635 | execargv[9] = "-outchannels"; |
| 636 | execargv[10] = noutsigstr; |
| 637 | execargv[11] = "-r"; |
| 638 | execargv[12] = sampleratestr; |
| 639 | |
| 640 | /* convert atom arguments to strings (temporarily allocating space) */ |
| 641 | for (i = 0; i < argc; i++) |
| 642 | { |
| 643 | #ifdef PDcxx . . $ `<built-in>:475:9`! |
| 644 | if (argv[i].a_typecxx . . $ _atom#a_type. == A_SYMBOLcxx . . $ A_SYMBOL.) |
| 645 | pd_snprintfcxx . . $ pd_snprintf(ea502d73e74c754c).(tmpbuf, MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!, "%s", argv[i].a_wcxx . . $ _atom#a_w..w_symbolcxx . . $ word#w_symbol.->s_namecxx . . $ _symbol#s_name.); |
| 646 | else if (argv[i].a_typecxx . . $ _atom#a_type. == A_FLOATcxx . . $ A_FLOAT.) |
| 647 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(tmpbuf, "%f", (float)argv[i].a_wcxx . . $ _atom#a_w..w_floatcxx . . $ word#w_float.); |
| 648 | #endif |
| 649 | #ifdef MSP |
| 650 | /* because Mac pathnames sometimes have an evil preceding |
| 651 | colon character, we test for and silently eat them */ |
| 652 | if (argv[i].a_type == A_SYM) |
| 653 | strncpy(tmpbuf, (*argv[i].a_w.w_sym->s_name == ':'? |
| 654 | argv[i].a_w.w_sym->s_name+1 : argv[i].a_w.w_sym->s_name), |
| 655 | MAXPDSTRING-3); |
| 656 | else if (argv[i].a_type == A_LONG) |
| 657 | sprintf(tmpbuf, "%ld", (long)argv[i].a_w.w_long); |
| 658 | else if (argv[i].a_type == A_FLOAT) |
| 659 | sprintf(tmpbuf, "%f", (float)argv[i].a_w.w_float); |
| 660 | #endif |
| 661 | #ifdef _WIN32 |
| 662 | /* and now, for Windows (whether Max or Pd), spaces need quotes */ |
| 663 | if (strchr(tmpbuf, ' ') && *tmpbuf != '"' && *tmpbuf != '\'') |
| 664 | { |
| 665 | char nutherbuf[MAXPDSTRING]; |
| 666 | pd_snprintf(nutherbuf, MAXPDSTRING, "\"%s\"", tmpbuf); |
| 667 | pd_snprintf(tmpbuf, MAXPDSTRING, "%s", nutherbuf); |
| 668 | } |
| 669 | #endif /* _WIN32 */ |
| 670 | execargv[FIXEDARGcxx . . $ `extra/pd~/pd~.c:538:9`!+i] = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(strlencxx . . $ strlen(751346f8406fd082).(tmpbuf) + 1); |
| 671 | strcpycxx . . $ strcpy(b7b3a83273496486).(execargv[FIXEDARGcxx . . $ `extra/pd~/pd~.c:538:9`!+i], tmpbuf); |
| 672 | } |
| 673 | execargv[argc+FIXEDARGcxx . . $ `extra/pd~/pd~.c:538:9`!] = 0; |
| 674 | #if 0 |
| 675 | for (i = 0; i < argc+FIXEDARG; i++) |
| 676 | post("arg %d = %s", i, execargv[i]); |
| 677 | #endif |
| 678 | if (PIPEcxx . . $ `extra/pd~/pd~.c:43:10`!(pipe1) < 0) |
| 679 | { |
| 680 | PDERRORcxx . . $ `extra/pd~/pd~.c:88:9`! "pd~: can't create pipe"); |
| 681 | goto fail1; |
| 682 | } |
| 683 | if (PIPEcxx . . $ `extra/pd~/pd~.c:43:10`!(pipe2) < 0) |
| 684 | { |
| 685 | PDERRORcxx . . $ `extra/pd~/pd~.c:88:9`! "pd~: can't create pipe"); |
| 686 | goto fail2; |
| 687 | } |
| 688 | #ifdef _WIN32 |
| 689 | { |
| 690 | int stdinwas = _dup(0), stdoutwas = _dup(1); |
| 691 | if (pipe2[1] == 0) |
| 692 | pipe2[1] = _dup(pipe2[1]); |
| 693 | if (pipe1[0] != 0) |
| 694 | _dup2(pipe1[0], 0); |
| 695 | if (pipe2[1] != 1) |
| 696 | _dup2(pipe2[1], 1); |
| 697 | pid = _spawnv(P_NOWAIT, cmdbuf, (const char * const *)execargv); |
| 698 | if (pid < 0) |
| 699 | { |
| 700 | post("%s: couldn't start subprocess (%s)\n", execargv[0], |
| 701 | strerror(errno)); |
| 702 | goto fail1; |
| 703 | } |
| 704 | _dup2(stdinwas, 0); |
| 705 | _dup2(stdoutwas, 1); |
| 706 | _close(stdinwas); |
| 707 | _close(stdoutwas); |
| 708 | } |
| 709 | #else /* _WIN32 */ |
| 710 | if ((pid = forkcxx . . $ fork(b126dc7c1de90089).()) < 0) |
| 711 | { |
| 712 | PDERRORcxx . . $ `extra/pd~/pd~.c:88:9`! "pd~: can't fork"); |
| 713 | goto fail3; |
| 714 | } |
| 715 | else if (pid == 0) |
| 716 | { |
| 717 | /* child process */ |
| 718 | /* the first dup2 below would bash pipe2[1] if it happens to be |
| 719 | zero so in that case renumber it */ |
| 720 | if (pipe2[1] == 0) |
| 721 | pipe2[1] = dupcxx . . $ dup(7864480464b09eea).(pipe2[1]); |
| 722 | if (pipe1[0] != 0) |
| 723 | { |
| 724 | dup2cxx . . $ dup2(9b79fb6aee4c0440).(pipe1[0], 0); |
| 725 | closecxx . . $ close(7864480464b09eea).(pipe1[0]); |
| 726 | } |
| 727 | if (pipe2[1] != 1) |
| 728 | { |
| 729 | dup2cxx . . $ dup2(9b79fb6aee4c0440).(pipe2[1], 1); |
| 730 | closecxx . . $ close(7864480464b09eea).(pipe2[1]); |
| 731 | } |
| 732 | if (pipe1[1] >= 2) |
| 733 | closecxx . . $ close(7864480464b09eea).(pipe1[1]); |
| 734 | if (pipe2[0] >= 2) |
| 735 | closecxx . . $ close(7864480464b09eea).(pipe2[0]); |
| 736 | execvcxx . . $ execv(8a4102a9cf05ffcd).(cmdbuf, execargv); |
| 737 | _exitcxx . . $ _exit(3ca292c338df9bb3).(1); |
| 738 | } |
| 739 | for (i=FIXEDARGcxx . . $ `extra/pd~/pd~.c:538:9`!; execargv[i]; i++) |
| 740 | freecxx . . $ free(5d22bdacc48458e8).(execargv[i]); |
| 741 | |
| 742 | #endif /* _WIN32 */ |
| 743 | /* done with fork/exec or spawn; parent continues here */ |
| 744 | closecxx . . $ close(7864480464b09eea).(pipe1[0]); |
| 745 | closecxx . . $ close(7864480464b09eea).(pipe2[1]); |
| 746 | #ifndef _WIN32 /* this was done in windows via the O_NOINHERIT flag */ |
| 747 | fcntlcxx . . $ fcntl(cac4efb70f20a0fb).(pipe1[1], F_SETFDcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:167:9`!, FD_CLOEXECcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:219:9`!); |
| 748 | fcntlcxx . . $ fcntl(cac4efb70f20a0fb).(pipe2[0], F_SETFDcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:167:9`!, FD_CLOEXECcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:219:9`!); |
| 749 | #endif |
| 750 | outfd = fdopencxx . . $ fdopen(8f4e2d7350ebd077).(pipe1[1], "w"); |
| 751 | infd = fdopencxx . . $ fdopen(8f4e2d7350ebd077).(pipe2[0], "r"); |
| 752 | x->x_childpidcxx . . $ _pd_tilde#x_childpid. = pid; |
| 753 | for (i = 0; i < fifo; i++) |
| 754 | if (x->x_binarycxx . . $ _pd_tilde#x_binary.) |
| 755 | { |
| 756 | pd_tilde_putsemicxx . . $ pd_tilde_putsemi(8d4262d45fc644ab).(outfd); |
| 757 | pd_tilde_putfloatcxx . . $ pd_tilde_putfloat(bbac51b3ec643997).(0, outfd); |
| 758 | pd_tilde_putsemicxx . . $ pd_tilde_putsemi(8d4262d45fc644ab).(outfd); |
| 759 | } |
| 760 | else fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(outfd, "%s", ";\n0;\n"); |
| 761 | |
| 762 | fflushcxx . . $ fflush(89bc1efcdac0ca22).(outfd); |
| 763 | binbuf_clearcxx . . $ binbuf_clear(e38d44570b85fc22).(x->x_binbufcxx . . $ _pd_tilde#x_binbuf.); |
| 764 | pd_tilde_readmessagescxx . . $ pd_tilde_readmessages(f737e017d0c88331).(x, infd); |
| 765 | x->x_outfdcxx . . $ _pd_tilde#x_outfd. = outfd; |
| 766 | x->x_infdcxx . . $ _pd_tilde#x_infd. = infd; |
| 767 | return; |
| 768 | #ifndef _WIN32 |
| 769 | fail3: |
| 770 | closecxx . . $ close(7864480464b09eea).(pipe2[0]); |
| 771 | closecxx . . $ close(7864480464b09eea).(pipe2[1]); |
| 772 | if (x->x_childpidcxx . . $ _pd_tilde#x_childpid. > 0) |
| 773 | waitpidcxx . . $ waitpid(1df93256b606fe1f).(x->x_childpidcxx . . $ _pd_tilde#x_childpid., 0, 0); |
| 774 | #endif |
| 775 | fail2: |
| 776 | closecxx . . $ close(7864480464b09eea).(pipe1[0]); |
| 777 | closecxx . . $ close(7864480464b09eea).(pipe1[1]); |
| 778 | fail1: |
| 779 | x->x_infdcxx . . $ _pd_tilde#x_infd. = x->x_outfdcxx . . $ _pd_tilde#x_outfd. = 0; |
| 780 | x->x_childpidcxx . . $ _pd_tilde#x_childpid. = -1; |
| 781 | postcxx . . $ post(326aeb464d16410c).("pd~ startup failed"); |
| 782 | return; |
| 783 | } |
| 784 | |
| 785 | /* #define TOSSIN */ |
| 786 | #ifdef TOSSIN |
| 787 | #include <sys/select.h> |
| 788 | |
| 789 | void pd_empty(int infd) |
| 790 | { |
| 791 | char buf[10000]; |
| 792 | fd_set readset, writeset, exceptset; |
| 793 | FD_ZERO(&writeset); |
| 794 | FD_ZERO(&readset); |
| 795 | FD_ZERO(&exceptset); |
| 796 | FD_SET(infd, &readset); |
| 797 | if (select(infd+1, &readset, &writeset, &exceptset, 0) >= 0 && |
| 798 | FD_ISSET(infd, &readset)) |
| 799 | read(infd, buf, 10000); |
| 800 | } |
| 801 | #endif |
| 802 | |
| 803 | static int nperfedcxx . . $ nperfed. = 0; |
| 804 | |
| 805 | static void pd_tilde_doperfcxx . . $ pd_tilde_doperf(2c157e4e29f4c94c).(t_pd_tildecxx . . $ t_pd_tilde# *x) |
| 806 | { |
| 807 | int n = x->x_blksizecxx . . $ _pd_tilde#x_blksize., i, j, nsigs, numbuffill = 0, c; |
| 808 | char numbuf[80]; |
| 809 | if (n > DEFDACBLKSIZEcxx . . $ `src/s_stuff.h:93:9`!) |
| 810 | n = DEFDACBLKSIZEcxx . . $ `src/s_stuff.h:93:9`!; |
| 811 | #ifdef MAX |
| 812 | critical_enter(0); |
| 813 | #endif |
| 814 | if (!x->x_infdcxx . . $ _pd_tilde#x_infd.) |
| 815 | goto zeroit; |
| 816 | if (x->x_binarycxx . . $ _pd_tilde#x_binary.) |
| 817 | { |
| 818 | pd_tilde_putsemicxx . . $ pd_tilde_putsemi(8d4262d45fc644ab).(x->x_outfdcxx . . $ _pd_tilde#x_outfd.); |
| 819 | if (!x->x_ninsigcxx . . $ _pd_tilde#x_ninsig.) |
| 820 | pd_tilde_putfloatcxx . . $ pd_tilde_putfloat(bbac51b3ec643997).(0, x->x_outfdcxx . . $ _pd_tilde#x_outfd.); |
| 821 | else for (i = 0; i < x->x_ninsigcxx . . $ _pd_tilde#x_ninsig.; i++) |
| 822 | { |
| 823 | t_pdsamplecxx . . $ `extra/pd~/pd~.c:81:9`! *fp = x->x_insigcxx . . $ _pd_tilde#x_insig.[i]; |
| 824 | for (j = 0; j < n; j++) |
| 825 | pd_tilde_putfloatcxx . . $ pd_tilde_putfloat(bbac51b3ec643997).(*fp++, x->x_outfdcxx . . $ _pd_tilde#x_outfd.); |
| 826 | for (; j < DEFDACBLKSIZEcxx . . $ `src/s_stuff.h:93:9`!; j++) |
| 827 | pd_tilde_putfloatcxx . . $ pd_tilde_putfloat(bbac51b3ec643997).(0, x->x_outfdcxx . . $ _pd_tilde#x_outfd.); |
| 828 | } |
| 829 | pd_tilde_putsemicxx . . $ pd_tilde_putsemi(8d4262d45fc644ab).(x->x_outfdcxx . . $ _pd_tilde#x_outfd.); |
| 830 | } |
| 831 | else |
| 832 | { |
| 833 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(x->x_outfdcxx . . $ _pd_tilde#x_outfd., ";\n"); |
| 834 | if (!x->x_ninsigcxx . . $ _pd_tilde#x_ninsig.) |
| 835 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(x->x_outfdcxx . . $ _pd_tilde#x_outfd., "0\n"); |
| 836 | else for (i = 0; i < x->x_ninsigcxx . . $ _pd_tilde#x_ninsig.; i++) |
| 837 | { |
| 838 | t_pdsamplecxx . . $ `extra/pd~/pd~.c:81:9`! *fp = x->x_insigcxx . . $ _pd_tilde#x_insig.[i]; |
| 839 | for (j = 0; j < n; j++) |
| 840 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(x->x_outfdcxx . . $ _pd_tilde#x_outfd., "%g\n", *fp++); |
| 841 | for (; j < DEFDACBLKSIZEcxx . . $ `src/s_stuff.h:93:9`!; j++) |
| 842 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(x->x_outfdcxx . . $ _pd_tilde#x_outfd., "0\n"); |
| 843 | } |
| 844 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(x->x_outfdcxx . . $ _pd_tilde#x_outfd., ";\n"); |
| 845 | } |
| 846 | fflushcxx . . $ fflush(89bc1efcdac0ca22).(x->x_outfdcxx . . $ _pd_tilde#x_outfd.); |
| 847 | nsigs = j = 0; |
| 848 | if (x->x_binarycxx . . $ _pd_tilde#x_binary.) |
| 849 | { |
| 850 | while (1) |
| 851 | { |
| 852 | t_atomcxx . . $ t_atom# at; |
| 853 | if (!pd_tilde_getatomcxx . . $ pd_tilde_getatom(badff60e2a3e117a).(&at, x->x_infdcxx . . $ _pd_tilde#x_infd.)) |
| 854 | { |
| 855 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!) |
| 856 | PDERRORcxx . . $ `extra/pd~/pd~.c:88:9`! "pd~: %s", strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 857 | else PDERRORcxx . . $ `extra/pd~/pd~.c:88:9`! "pd~: subprocess exited"); |
| 858 | pd_tilde_closecxx . . $ pd_tilde_close(2c157e4e29f4c94c).(x); |
| 859 | goto zeroit; |
| 860 | } |
| 861 | if (at.a_typecxx . . $ _atom#a_type. == A_SEMIcxx . . $ A_SEMI.) |
| 862 | break; |
| 863 | else if (at.a_typecxx . . $ _atom#a_type. == A_FLOATcxx . . $ A_FLOAT.) |
| 864 | { |
| 865 | if (nsigs < x->x_noutsigcxx . . $ _pd_tilde#x_noutsig.) |
| 866 | x->x_outsigcxx . . $ _pd_tilde#x_outsig.[nsigs][j] = at.a_wcxx . . $ _atom#a_w..w_floatcxx . . $ word#w_float.; |
| 867 | if (++j >= DEFDACBLKSIZEcxx . . $ `src/s_stuff.h:93:9`!) |
| 868 | j = 0, nsigs++; |
| 869 | } |
| 870 | else PDERRORcxx . . $ `extra/pd~/pd~.c:88:9`! "pd~: subprocess returned malformed audio"); |
| 871 | } |
| 872 | } |
| 873 | else |
| 874 | { |
| 875 | while (1) |
| 876 | { |
| 877 | while (1) |
| 878 | { |
| 879 | c = getccxx . . $ getc(89bc1efcdac0ca22).(x->x_infdcxx . . $ _pd_tilde#x_infd.); |
| 880 | if (c == EOFcxx . . $ `<external>/232824719582829767/stdio.h:105:9`!) |
| 881 | { |
| 882 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!) |
| 883 | PDERRORcxx . . $ `extra/pd~/pd~.c:88:9`! "pd~: %s", strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 884 | else PDERRORcxx . . $ `extra/pd~/pd~.c:88:9`! "pd~: subprocess exited"); |
| 885 | pd_tilde_closecxx . . $ pd_tilde_close(2c157e4e29f4c94c).(x); |
| 886 | goto zeroit; |
| 887 | } |
| 888 | else if (!isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(c) && c != ';') |
| 889 | { |
| 890 | if (numbuffill < (80-1)) |
| 891 | numbuf[numbuffill++] = c; |
| 892 | } |
| 893 | else |
| 894 | { |
| 895 | t_pdsamplecxx . . $ `extra/pd~/pd~.c:81:9`! z; |
| 896 | if (numbuffill) |
| 897 | { |
| 898 | numbuf[numbuffill] = 0; |
| 899 | #if PD_FLOATSIZEcxx . . $ `src/m_pd.h:146:10`! == 32 |
| 900 | if (sscanfcxx . . $ sscanf(5e8a2c12db2ea735).(numbuf, "%f", &z) < 1) |
| 901 | #else |
| 902 | if (sscanf(numbuf, "%lf", &z) < 1) |
| 903 | #endif |
| 904 | continue; |
| 905 | if (nsigs < x->x_noutsigcxx . . $ _pd_tilde#x_noutsig.) |
| 906 | x->x_outsigcxx . . $ _pd_tilde#x_outsig.[nsigs][j] = z; |
| 907 | if (++j >= DEFDACBLKSIZEcxx . . $ `src/s_stuff.h:93:9`!) |
| 908 | j = 0, nsigs++; |
| 909 | } |
| 910 | numbuffill = 0; |
| 911 | break; |
| 912 | } |
| 913 | } |
| 914 | /* message terminated */ |
| 915 | if (c == ';') |
| 916 | break; |
| 917 | } |
| 918 | } |
| 919 | if (nsigs < x->x_noutsigcxx . . $ _pd_tilde#x_noutsig.) |
| 920 | postcxx . . $ post(326aeb464d16410c).("pd~: short audio signals (sigs %d, fragment %d)", nsigs, j); |
| 921 | for (; nsigs < x->x_noutsigcxx . . $ _pd_tilde#x_noutsig.; nsigs++, j = 0) |
| 922 | { |
| 923 | for (; j < x->x_blksizecxx . . $ _pd_tilde#x_blksize.; j++) |
| 924 | x->x_outsigcxx . . $ _pd_tilde#x_outsig.[nsigs][j] = 0; |
| 925 | } |
| 926 | if (!pd_tilde_readmessagescxx . . $ pd_tilde_readmessages(f737e017d0c88331).(x, x->x_infdcxx . . $ _pd_tilde#x_infd.)) |
| 927 | { |
| 928 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!) |
| 929 | PDERRORcxx . . $ `extra/pd~/pd~.c:88:9`! "pd~: %s", strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 930 | else PDERRORcxx . . $ `extra/pd~/pd~.c:88:9`! "pd~: subprocess exited"); |
| 931 | pd_tilde_closecxx . . $ pd_tilde_close(2c157e4e29f4c94c).(x); |
| 932 | } |
| 933 | #ifdef MAX |
| 934 | critical_exit(0); |
| 935 | #endif |
| 936 | return; |
| 937 | zeroit: |
| 938 | #ifdef MAX |
| 939 | critical_exit(0); |
| 940 | #endif |
| 941 | for (i = 0; i < x->x_noutsigcxx . . $ _pd_tilde#x_noutsig.; i++) |
| 942 | { |
| 943 | for (j = 0; j < x->x_blksizecxx . . $ _pd_tilde#x_blksize.; j++) |
| 944 | x->x_outsigcxx . . $ _pd_tilde#x_outsig.[i][j] = 0; |
| 945 | } |
| 946 | } |
| 947 | |
| 948 | static void pd_tilde_pdtildecxx . . $ pd_tilde_pdtilde(99b38e06a4606529).(t_pd_tildecxx . . $ t_pd_tilde# *x, t_symbolcxx . . $ t_symbol# *s, |
| 949 | int argc, t_atomcxx . . $ t_atom# *argv) |
| 950 | { |
| 951 | t_symbolcxx . . $ t_symbol# *sel = ((argc > 0 && argv->a_typecxx . . $ _atom#a_type. == A_SYMBOLcxx . . $ A_SYMBOL.) ? |
| 952 | argv->a_wcxx . . $ _atom#a_w..w_symbolcxx . . $ word#w_symbol. : gensymcxx . . $ gensym(4ae2805c5eec037c).("?")), *schedlibdir; |
| 953 | const char *patchdir; |
| 954 | |
| 955 | if (sel == gensymcxx . . $ gensym(4ae2805c5eec037c).("start")) |
| 956 | { |
| 957 | char pdargstring[MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!]; |
| 958 | #ifdef MAX |
| 959 | critical_enter(0); |
| 960 | #endif |
| 961 | if (x->x_infdcxx . . $ _pd_tilde#x_infd.) |
| 962 | pd_tilde_closecxx . . $ pd_tilde_close(2c157e4e29f4c94c).(x); |
| 963 | #ifdef MAX |
| 964 | critical_exit(0); |
| 965 | #endif |
| 966 | pdargstring[0] = 0; |
| 967 | argc--; argv++; |
| 968 | #ifdef PDcxx . . $ `<built-in>:475:9`! |
| 969 | patchdir = canvas_getdircxx . . $ canvas_getdir(b493342e22c29ae3).(x->x_canvascxx . . $ _pd_tilde#x_canvas.)->s_namecxx . . $ _symbol#s_name.; |
| 970 | #endif |
| 971 | #ifdef MSP |
| 972 | patchdir = "."; |
| 973 | #endif |
| 974 | schedlibdir = x->x_schedlibdircxx . . $ _pd_tilde#x_schedlibdir.; |
| 975 | if (schedlibdir == gensymcxx . . $ gensym(4ae2805c5eec037c).(".") && x->x_pddircxx . . $ _pd_tilde#x_pddir. != gensymcxx . . $ gensym(4ae2805c5eec037c).(".")) |
| 976 | { |
| 977 | const char *pds = x->x_pddircxx . . $ _pd_tilde#x_pddir.->s_namecxx . . $ _symbol#s_name.; |
| 978 | char scheddirstring[MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!]; |
| 979 | int l = strlencxx . . $ strlen(751346f8406fd082).(pds); |
| 980 | if (l >= 4 && (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(pds+l-3, "bin") || !strcmpcxx . . $ strcmp(5ae29d726ae57f88).(pds+l-4, "bin/"))) |
| 981 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(scheddirstring, MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!, "%s/../extra/pd~", pds); |
| 982 | else snprintfcxx . . $ snprintf(ea502d73e74c754c).(scheddirstring, MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!, "%s/extra/pd~", pds); |
| 983 | schedlibdir = gensymcxx . . $ gensym(4ae2805c5eec037c).(scheddirstring); |
| 984 | } |
| 985 | pd_tilde_dostartcxx . . $ pd_tilde_dostart(8236d19f281334fa).(x, x->x_pddircxx . . $ _pd_tilde#x_pddir.->s_namecxx . . $ _symbol#s_name., schedlibdir->s_namecxx . . $ _symbol#s_name., |
| 986 | patchdir, argc, argv, x->x_ninsigcxx . . $ _pd_tilde#x_ninsig., x->x_noutsigcxx . . $ _pd_tilde#x_noutsig., x->x_fifocxx . . $ _pd_tilde#x_fifo., |
| 987 | x->x_srcxx . . $ _pd_tilde#x_sr.); |
| 988 | } |
| 989 | else if (sel == gensymcxx . . $ gensym(4ae2805c5eec037c).("stop")) |
| 990 | { |
| 991 | #ifdef MAX |
| 992 | critical_enter(0); |
| 993 | #endif |
| 994 | if (x->x_infdcxx . . $ _pd_tilde#x_infd.) |
| 995 | pd_tilde_closecxx . . $ pd_tilde_close(2c157e4e29f4c94c).(x); |
| 996 | #ifdef MAX |
| 997 | critical_exit(0); |
| 998 | #endif |
| 999 | } |
| 1000 | else if (sel == gensymcxx . . $ gensym(4ae2805c5eec037c).("pddir")) |
| 1001 | { |
| 1002 | if ((argc > 1) && argv[1].a_typecxx . . $ _atom#a_type. == A_SYMBOLcxx . . $ A_SYMBOL.) |
| 1003 | { |
| 1004 | t_symbolcxx . . $ t_symbol# *sym = argv[1].a_wcxx . . $ _atom#a_w..w_symbolcxx . . $ word#w_symbol.; |
| 1005 | #ifdef MSP |
| 1006 | if (sym->s_name[0] == ':') |
| 1007 | sym = gensym(s->s_name+1); |
| 1008 | #endif |
| 1009 | x->x_pddircxx . . $ _pd_tilde#x_pddir. = sym; |
| 1010 | } |
| 1011 | else PDERRORcxx . . $ `extra/pd~/pd~.c:88:9`! "pd~ pddir: needs symbol argument"); |
| 1012 | } |
| 1013 | else if (sel == gensymcxx . . $ gensym(4ae2805c5eec037c).("vis")) |
| 1014 | { |
| 1015 | if ((argc > 1) && argv[1].a_typecxx . . $ _atom#a_type. == A_FLOATcxx . . $ A_FLOAT.) |
| 1016 | { |
| 1017 | int onoff = (argv[1].a_wcxx . . $ _atom#a_w..w_floatcxx . . $ word#w_float. != 0); |
| 1018 | if (onoff) |
| 1019 | vmesscxx . . $ `src/m_pd.h:911:9`!(&x->x_objcxx . . $ _pd_tilde#x_obj..te_pdcxx . . $ `src/m_pd.h:299:9`!, gensymcxx . . $ gensym(4ae2805c5eec037c).("pd"), "ss", sel, x->x_pddircxx . . $ _pd_tilde#x_pddir.); |
| 1020 | else vmesscxx . . $ `src/m_pd.h:911:9`!(&x->x_objcxx . . $ _pd_tilde#x_obj..te_pdcxx . . $ `src/m_pd.h:299:9`!, gensymcxx . . $ gensym(4ae2805c5eec037c).("pd"), "s", sel); |
| 1021 | } |
| 1022 | else PDERRORcxx . . $ `extra/pd~/pd~.c:88:9`! "pd~ vis: needs float argument"); |
| 1023 | } |
| 1024 | else PDERRORcxx . . $ `extra/pd~/pd~.c:88:9`! "pd~: unknown control message: %s", sel->s_namecxx . . $ _symbol#s_name.); |
| 1025 | } |
| 1026 | |
| 1027 | static void pd_tilde_freecxx . . $ pd_tilde_free(2c157e4e29f4c94c).(t_pd_tildecxx . . $ t_pd_tilde# *x) |
| 1028 | { |
| 1029 | pd_tilde_closecxx . . $ pd_tilde_close(2c157e4e29f4c94c).(x); |
| 1030 | clock_freecxx . . $ clock_free(f74906b9b1337f0c).(x->x_clockcxx . . $ _pd_tilde#x_clock.); |
| 1031 | t_freebytescxx . . $ `src/m_pd.h:908:9`!(x->x_insigcxx . . $ _pd_tilde#x_insig., x->x_ninsigcxx . . $ _pd_tilde#x_ninsig. * sizeof(*x->x_insigcxx . . $ _pd_tilde#x_insig.)); |
| 1032 | t_freebytescxx . . $ `src/m_pd.h:908:9`!(x->x_outsigcxx . . $ _pd_tilde#x_outsig., x->x_noutsigcxx . . $ _pd_tilde#x_noutsig. * sizeof(*x->x_outsigcxx . . $ _pd_tilde#x_outsig.)); |
| 1033 | #ifdef MSP |
| 1034 | if (x->x_sampbuf) |
| 1035 | free(x->x_sampbuf); |
| 1036 | dsp_free((t_pxobject *)x); |
| 1037 | #endif |
| 1038 | } |
| 1039 | |
| 1040 | /* -------------------------- Pd glue ------------------------- */ |
| 1041 | #ifdef PDcxx . . $ `<built-in>:475:9`! |
| 1042 | |
| 1043 | static t_intcxx . . $ t_int# *pd_tilde_performcxx . . $ pd_tilde_perform(b718b19f711df6a2).(t_intcxx . . $ t_int# *w) |
| 1044 | { |
| 1045 | t_pd_tildecxx . . $ t_pd_tilde# *x = (t_pd_tildecxx . . $ t_pd_tilde# *)(w[1]); |
| 1046 | pd_tilde_doperfcxx . . $ pd_tilde_doperf(2c157e4e29f4c94c).(x); |
| 1047 | return (w+2); |
| 1048 | } |
| 1049 | |
| 1050 | static void pd_tilde_dspcxx . . $ pd_tilde_dsp(6efeb84b6176a4b).(t_pd_tildecxx . . $ t_pd_tilde# *x, t_signalcxx . . $ t_signal# **sp) |
| 1051 | { |
| 1052 | int i; |
| 1053 | t_pdsamplecxx . . $ `extra/pd~/pd~.c:81:9`! **g; |
| 1054 | |
| 1055 | x->x_blksizecxx . . $ _pd_tilde#x_blksize. = (x->x_ninsigcxx . . $ _pd_tilde#x_ninsig. || x->x_noutsigcxx . . $ _pd_tilde#x_noutsig. ? sp[0]->s_ncxx . . $ _signal#$anonymous_type_4#s_n. : 1); |
| 1056 | for (i = 0, g = x->x_insigcxx . . $ _pd_tilde#x_insig.; i < x->x_ninsigcxx . . $ _pd_tilde#x_ninsig.; i++, g++) |
| 1057 | *g = (*(sp++))->s_veccxx . . $ _signal#s_vec.; |
| 1058 | /* if there were no input signals Pd still provided us with one, |
| 1059 | which we ignore: */ |
| 1060 | if (!x->x_ninsigcxx . . $ _pd_tilde#x_ninsig.) |
| 1061 | sp++; |
| 1062 | for (i = 0, g = x->x_outsigcxx . . $ _pd_tilde#x_outsig.; i < x->x_noutsigcxx . . $ _pd_tilde#x_noutsig.; i++, g++) |
| 1063 | *g = (*(sp++))->s_veccxx . . $ _signal#s_vec.; |
| 1064 | dsp_addcxx . . $ dsp_add(e4a1289ea3423628).(pd_tilde_performcxx . . $ pd_tilde_perform(b718b19f711df6a2)., 1, x); |
| 1065 | } |
| 1066 | |
| 1067 | static void pd_tilde_tickcxx . . $ pd_tilde_tick(2c157e4e29f4c94c).(t_pd_tildecxx . . $ t_pd_tilde# *x) |
| 1068 | { |
| 1069 | int messstart = 0, i, n; |
| 1070 | t_atomcxx . . $ t_atom# *vec; |
| 1071 | /* binbuf_print(b); */ |
| 1072 | n = binbuf_getnatomcxx . . $ binbuf_getnatom(7381d28fc432400c).(x->x_binbufcxx . . $ _pd_tilde#x_binbuf.); |
| 1073 | vec = binbuf_getveccxx . . $ binbuf_getvec(ec9d8f9604fe4c84).(x->x_binbufcxx . . $ _pd_tilde#x_binbuf.); |
| 1074 | for (i = 0; i < n; i++) |
| 1075 | { |
| 1076 | if (vec[i].a_typecxx . . $ _atom#a_type. == A_SEMIcxx . . $ A_SEMI.) |
| 1077 | { |
| 1078 | if (i > messstart && vec[messstart].a_typecxx . . $ _atom#a_type. == A_SYMBOLcxx . . $ A_SYMBOL.) |
| 1079 | outlet_anythingcxx . . $ outlet_anything(64d0a05027bba77b).(x->x_outlet1cxx . . $ _pd_tilde#x_outlet1., vec[messstart].a_wcxx . . $ _atom#a_w..w_symbolcxx . . $ word#w_symbol., |
| 1080 | i-(messstart+1), vec+(messstart+1)); |
| 1081 | else if (i > messstart) |
| 1082 | outlet_listcxx . . $ outlet_list(64d0a05027bba77b).(x->x_outlet1cxx . . $ _pd_tilde#x_outlet1., 0, i-messstart, vec+messstart); |
| 1083 | messstart = i+1; |
| 1084 | } |
| 1085 | } |
| 1086 | binbuf_clearcxx . . $ binbuf_clear(e38d44570b85fc22).(x->x_binbufcxx . . $ _pd_tilde#x_binbuf.); |
| 1087 | } |
| 1088 | |
| 1089 | static void pd_tilde_anythingcxx . . $ pd_tilde_anything(99b38e06a4606529).(t_pd_tildecxx . . $ t_pd_tilde# *x, t_symbolcxx . . $ t_symbol# *s, |
| 1090 | int argc, t_atomcxx . . $ t_atom# *argv) |
| 1091 | { |
| 1092 | char msgbuf[MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!]; |
| 1093 | if (!x->x_outfdcxx . . $ _pd_tilde#x_outfd.) |
| 1094 | return; |
| 1095 | if (x->x_binarycxx . . $ _pd_tilde#x_binary.) |
| 1096 | { |
| 1097 | pd_tilde_putsymbolcxx . . $ pd_tilde_putsymbol(1c66aa0a437df16e).(s, x->x_outfdcxx . . $ _pd_tilde#x_outfd.); |
| 1098 | for (; argc--; argv++) |
| 1099 | { |
| 1100 | if (argv->a_typecxx . . $ _atom#a_type. == A_FLOATcxx . . $ A_FLOAT.) |
| 1101 | pd_tilde_putfloatcxx . . $ pd_tilde_putfloat(bbac51b3ec643997).(argv->a_wcxx . . $ _atom#a_w..w_floatcxx . . $ word#w_float., x->x_outfdcxx . . $ _pd_tilde#x_outfd.); |
| 1102 | else if (argv->a_typecxx . . $ _atom#a_type. == A_SYMBOLcxx . . $ A_SYMBOL.) |
| 1103 | pd_tilde_putsymbolcxx . . $ pd_tilde_putsymbol(1c66aa0a437df16e).(argv->a_wcxx . . $ _atom#a_w..w_symbolcxx . . $ word#w_symbol., x->x_outfdcxx . . $ _pd_tilde#x_outfd.); |
| 1104 | } |
| 1105 | putccxx . . $ putc(b1cd03d6c470d1bd).(A_SEMIcxx . . $ A_SEMI., x->x_outfdcxx . . $ _pd_tilde#x_outfd.); |
| 1106 | } |
| 1107 | else |
| 1108 | { |
| 1109 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(x->x_outfdcxx . . $ _pd_tilde#x_outfd., "%s ", s->s_namecxx . . $ _symbol#s_name.); |
| 1110 | while (argc--) |
| 1111 | { |
| 1112 | atom_stringcxx . . $ atom_string(6a24dcb48dbba0f7).(argv++, msgbuf, MAXPDSTRINGcxx . . $ `src/m_pd.h:132:9`!); |
| 1113 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(x->x_outfdcxx . . $ _pd_tilde#x_outfd., "%s ", msgbuf); |
| 1114 | } |
| 1115 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(x->x_outfdcxx . . $ _pd_tilde#x_outfd., ";\n"); |
| 1116 | } |
| 1117 | } |
| 1118 | |
| 1119 | static void *pd_tilde_newcxx . . $ pd_tilde_new(27379d620b24126e).(t_symbolcxx . . $ t_symbol# *s, int argc, t_atomcxx . . $ t_atom# *argv) |
| 1120 | { |
| 1121 | t_pd_tildecxx . . $ t_pd_tilde# *x = (t_pd_tildecxx . . $ t_pd_tilde# *)pd_newcxx . . $ pd_new(80ba20735813b70c).(pd_tilde_classcxx . . $ pd_tilde_class.); |
| 1122 | int ninsig = 2, noutsig = 2, j, fifo = 5, binary = 1; |
| 1123 | t_floatcxx . . $ t_float# sr = sys_getsrcxx . . $ sys_getsr(9b8c9e39889c762c).(); |
| 1124 | t_pdsamplecxx . . $ `extra/pd~/pd~.c:81:9`! **g; |
| 1125 | t_symbolcxx . . $ t_symbol# *pddir = sys_libdircxx . . $ sys_libdir., |
| 1126 | *scheddir = gensymcxx . . $ gensym(4ae2805c5eec037c).(class_gethelpdircxx . . $ class_gethelpdir(55d747a56e5d7296).(pd_tilde_classcxx . . $ pd_tilde_class.)); |
| 1127 | while (argc > 0) |
| 1128 | { |
| 1129 | t_symbolcxx . . $ t_symbol# *firstarg = atom_getsymbolargcxx . . $ atom_getsymbolarg(1f18606b17d8115f).(0, argc, argv); |
| 1130 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(firstarg->s_namecxx . . $ _symbol#s_name., "-sr") && argc > 1) |
| 1131 | { |
| 1132 | sr = atom_getfloatargcxx . . $ atom_getfloatarg(d71582eab24134e3).(1, argc, argv); |
| 1133 | argc -= 2; argv += 2; |
| 1134 | } |
| 1135 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(firstarg->s_namecxx . . $ _symbol#s_name., "-ninsig") && argc > 1) |
| 1136 | { |
| 1137 | ninsig = atom_getfloatargcxx . . $ atom_getfloatarg(d71582eab24134e3).(1, argc, argv); |
| 1138 | argc -= 2; argv += 2; |
| 1139 | } |
| 1140 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(firstarg->s_namecxx . . $ _symbol#s_name., "-noutsig") && argc > 1) |
| 1141 | { |
| 1142 | noutsig = atom_getfloatargcxx . . $ atom_getfloatarg(d71582eab24134e3).(1, argc, argv); |
| 1143 | argc -= 2; argv += 2; |
| 1144 | } |
| 1145 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(firstarg->s_namecxx . . $ _symbol#s_name., "-fifo") && argc > 1) |
| 1146 | { |
| 1147 | fifo = atom_getfloatargcxx . . $ atom_getfloatarg(d71582eab24134e3).(1, argc, argv); |
| 1148 | argc -= 2; argv += 2; |
| 1149 | } |
| 1150 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(firstarg->s_namecxx . . $ _symbol#s_name., "-pddir") && argc > 1) |
| 1151 | { |
| 1152 | pddir = atom_getsymbolargcxx . . $ atom_getsymbolarg(1f18606b17d8115f).(1, argc, argv); |
| 1153 | argc -= 2; argv += 2; |
| 1154 | } |
| 1155 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(firstarg->s_namecxx . . $ _symbol#s_name., "-scheddir") && argc > 1) |
| 1156 | { |
| 1157 | scheddir = atom_getsymbolargcxx . . $ atom_getsymbolarg(1f18606b17d8115f).(1, argc, argv); |
| 1158 | argc -= 2; argv += 2; |
| 1159 | } |
| 1160 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(firstarg->s_namecxx . . $ _symbol#s_name., "-ascii")) |
| 1161 | { |
| 1162 | binary = 0; |
| 1163 | argc--; argv++; |
| 1164 | } |
| 1165 | else break; |
| 1166 | } |
| 1167 | |
| 1168 | if (argc) |
| 1169 | { |
| 1170 | pd_errorcxx . . $ pd_error(a36a41508f37f5fe).(x, |
| 1171 | "usage: pd~ [-sr #] [-ninsig #] [-noutsig #] [-fifo #] [-pddir <>]"); |
| 1172 | postcxx . . $ post(326aeb464d16410c).( |
| 1173 | "... [-scheddir <>]"); |
| 1174 | } |
| 1175 | |
| 1176 | x->x_clockcxx . . $ _pd_tilde#x_clock. = clock_newcxx . . $ clock_new(f0935e5d70b2358d).(x, (t_methodcxx . . $ t_method#)pd_tilde_tickcxx . . $ pd_tilde_tick(2c157e4e29f4c94c).); |
| 1177 | x->x_insigcxx . . $ _pd_tilde#x_insig. = (t_pdsamplecxx . . $ `extra/pd~/pd~.c:81:9`! **)t_getbytescxx . . $ `src/m_pd.h:907:9`!(ninsig * sizeof(*x->x_insigcxx . . $ _pd_tilde#x_insig.)); |
| 1178 | x->x_outsigcxx . . $ _pd_tilde#x_outsig. = (t_pdsamplecxx . . $ `extra/pd~/pd~.c:81:9`! **)t_getbytescxx . . $ `src/m_pd.h:907:9`!(noutsig * sizeof(*x->x_outsigcxx . . $ _pd_tilde#x_outsig.)); |
| 1179 | x->x_ninsigcxx . . $ _pd_tilde#x_ninsig. = ninsig; |
| 1180 | x->x_noutsigcxx . . $ _pd_tilde#x_noutsig. = noutsig; |
| 1181 | x->x_blksizecxx . . $ _pd_tilde#x_blksize. = DEFDACBLKSIZEcxx . . $ `src/s_stuff.h:93:9`!; |
| 1182 | x->x_fifocxx . . $ _pd_tilde#x_fifo. = fifo; |
| 1183 | x->x_srcxx . . $ _pd_tilde#x_sr. = sr; |
| 1184 | x->x_pddircxx . . $ _pd_tilde#x_pddir. = pddir; |
| 1185 | x->x_schedlibdircxx . . $ _pd_tilde#x_schedlibdir. = scheddir; |
| 1186 | x->x_infdcxx . . $ _pd_tilde#x_infd. = 0; |
| 1187 | x->x_outfdcxx . . $ _pd_tilde#x_outfd. = 0; |
| 1188 | x->x_childpidcxx . . $ _pd_tilde#x_childpid. = -1; |
| 1189 | x->x_canvascxx . . $ _pd_tilde#x_canvas. = canvas_getcurrentcxx . . $ canvas_getcurrent(ed6be57a7b9c657d).(); |
| 1190 | x->x_binbufcxx . . $ _pd_tilde#x_binbuf. = binbuf_newcxx . . $ binbuf_new(f904d73faf2754e9).(); |
| 1191 | x->x_binarycxx . . $ _pd_tilde#x_binary. = binary; |
| 1192 | for (j = 1, g = x->x_insigcxx . . $ _pd_tilde#x_insig.; j < ninsig; j++, g++) |
| 1193 | inlet_newcxx . . $ inlet_new(f7c422074f48ed43).(&x->x_objcxx . . $ _pd_tilde#x_obj., &x->x_objcxx . . $ _pd_tilde#x_obj..ob_pdcxx . . $ `src/m_pd.h:308:9`!, &s_signalcxx . . $ s_signal., &s_signalcxx . . $ s_signal.); |
| 1194 | x->x_outlet1cxx . . $ _pd_tilde#x_outlet1. = outlet_newcxx . . $ outlet_new(6f53423cb691805d).(&x->x_objcxx . . $ _pd_tilde#x_obj., 0); |
| 1195 | for (j = 0, g = x->x_outsigcxx . . $ _pd_tilde#x_outsig.; j < noutsig; j++, g++) |
| 1196 | outlet_newcxx . . $ outlet_new(6f53423cb691805d).(&x->x_objcxx . . $ _pd_tilde#x_obj., &s_signalcxx . . $ s_signal.); |
| 1197 | #ifndef _WIN32 |
| 1198 | signalcxx . . $ signal(c2d516773f91faf8).(SIGPIPEcxx . . $ `<external>/11773118241360591791/signum-generic.h:60:9`!, SIG_IGNcxx . . $ `<external>/11773118241360591791/signum-generic.h:30:9`!); |
| 1199 | #endif |
| 1200 | return (x); |
| 1201 | } |
| 1202 | |
| 1203 | void pd_tilde_setupcxx . . $ pd_tilde_setup(49f6e7a06ebc5aa8).(void) |
| 1204 | { |
| 1205 | pd_tilde_classcxx . . $ pd_tilde_class. = class_newcxx . . $ class_new(577f793ddd58a527).(gensymcxx . . $ gensym(4ae2805c5eec037c).("pd~"), (t_newmethodcxx . . $ t_newmethod#)pd_tilde_newcxx . . $ pd_tilde_new(27379d620b24126e)., |
| 1206 | (t_methodcxx . . $ t_method#)pd_tilde_freecxx . . $ pd_tilde_free(2c157e4e29f4c94c)., sizeof(t_pd_tildecxx . . $ t_pd_tilde#), 0, A_GIMMEcxx . . $ A_GIMME., 0); |
| 1207 | class_addmethodcxx . . $ class_addmethod(57d2d79994ee8ccc).(pd_tilde_classcxx . . $ pd_tilde_class., nullfncxx . . $ nullfn(49f6e7a06ebc5aa8)., gensymcxx . . $ gensym(4ae2805c5eec037c).("signal"), 0); |
| 1208 | class_addmethodcxx . . $ class_addmethod(57d2d79994ee8ccc).(pd_tilde_classcxx . . $ pd_tilde_class., (t_methodcxx . . $ t_method#)pd_tilde_dspcxx . . $ pd_tilde_dsp(6efeb84b6176a4b)., gensymcxx . . $ gensym(4ae2805c5eec037c).("dsp"), |
| 1209 | A_CANTcxx . . $ A_CANT., 0); |
| 1210 | class_addmethodcxx . . $ class_addmethod(57d2d79994ee8ccc).(pd_tilde_classcxx . . $ pd_tilde_class., (t_methodcxx . . $ t_method#)pd_tilde_pdtildecxx . . $ pd_tilde_pdtilde(99b38e06a4606529)., gensymcxx . . $ gensym(4ae2805c5eec037c).("pd~"), |
| 1211 | A_GIMMEcxx . . $ A_GIMME., 0); |
| 1212 | class_addanythingcxx . . $ `src/m_pd.h:625:9`!(pd_tilde_class, pd_tilde_anything); |
| 1213 | postcxx . . $ post(326aeb464d16410c).("pd~ version 0.54"); |
| 1214 | } |
| 1215 | #endif |
| 1216 | |
| 1217 | /* -------------------------- Max/MSP glue ------------------------- */ |
| 1218 | #ifdef MSP |
| 1219 | |
| 1220 | static void pd_tilde_perf64(t_pd_tilde *x, t_object *dsp64, |
| 1221 | double **ins, long numins, double **outs, long numouts, |
| 1222 | long sampleframes, long flags, void *userparam) |
| 1223 | { |
| 1224 | int i, j, nin = (numins < x->x_ninsig ? numins : x->x_ninsig), |
| 1225 | nout = (numouts < x->x_noutsig ? numouts : x->x_noutsig); |
| 1226 | |
| 1227 | if (sampleframes > DEFDACBLKSIZE) |
| 1228 | sampleframes = DEFDACBLKSIZE; /* LATER iterate through them */ |
| 1229 | x->x_blksize = sampleframes; |
| 1230 | |
| 1231 | for (i = 0; i < nin; i++) |
| 1232 | for (j = 0; j < sampleframes; j++) |
| 1233 | x->x_insig[i][j] = ins[i][j]; |
| 1234 | for (; i < x->x_ninsig; i++) |
| 1235 | for (j = 0; j < sampleframes; j++) |
| 1236 | x->x_insig[i][j] = 0; |
| 1237 | pd_tilde_doperf(x); |
| 1238 | for (i = 0; i < nout; i++) |
| 1239 | for (j = 0; j < sampleframes; j++) |
| 1240 | outs[i][j] = x->x_outsig[i][j]; |
| 1241 | for (; i < numouts; i++) |
| 1242 | for (j = 0; j < sampleframes; j++) |
| 1243 | outs[i][j] = 0; |
| 1244 | nperfed++; |
| 1245 | } |
| 1246 | |
| 1247 | static void pd_tilde_dsp64(t_pd_tilde *x, t_object *dsp64, |
| 1248 | short *count, double samplerate, long maxvectorsize, long flags) |
| 1249 | { |
| 1250 | int i; |
| 1251 | t_pdsample *sp; |
| 1252 | |
| 1253 | if (x->x_sampbuf) |
| 1254 | free(x->x_sampbuf); |
| 1255 | x->x_sampbuf = malloc((x->x_ninsig + x->x_noutsig) * |
| 1256 | DEFDACBLKSIZE * sizeof(t_pdsample)); |
| 1257 | for (i = 0, sp = x->x_sampbuf; i < x->x_ninsig; i++) |
| 1258 | x->x_insig[i] = sp, sp += DEFDACBLKSIZE; |
| 1259 | for (i = 0; i < x->x_noutsig; i++) |
| 1260 | x->x_outsig[i] = sp, sp += DEFDACBLKSIZE; |
| 1261 | object_method(dsp64, gensym("dsp_add64"), x, pd_tilde_perf64, 0, 0); |
| 1262 | } |
| 1263 | |
| 1264 | static void pd_tilde_tick(t_pd_tilde *x) |
| 1265 | { |
| 1266 | int messstart = 0, i, n = 0; |
| 1267 | t_atom *vec; |
| 1268 | t_binbuf *b; |
| 1269 | |
| 1270 | critical_enter(0); |
| 1271 | b = x->x_binbuf; |
| 1272 | x->x_binbuf = binbuf_new(); |
| 1273 | critical_exit(0); |
| 1274 | n = binbuf_getnatom(b); |
| 1275 | vec = binbuf_getvec(b); |
| 1276 | for (i = 0; i < n; i++) |
| 1277 | { |
| 1278 | if (vec[i].a_type == A_SEMI) |
| 1279 | { |
| 1280 | if (i > messstart) |
| 1281 | { |
| 1282 | if (vec[messstart].a_type == A_SYM) |
| 1283 | outlet_anything(x->x_outlet1, vec[messstart].a_w.w_sym, |
| 1284 | i-messstart-1, vec+(messstart+1)); |
| 1285 | else if (vec[messstart].a_type == A_FLOAT && i == messstart+1) |
| 1286 | outlet_float(x->x_outlet1, vec[messstart].a_w.w_float); |
| 1287 | else if (vec[messstart].a_type == A_LONG && i == messstart+1) |
| 1288 | outlet_int(x->x_outlet1, vec[messstart].a_w.w_long); |
| 1289 | else outlet_list(x->x_outlet1, gensym("list"), |
| 1290 | i-messstart, vec+(messstart)); |
| 1291 | } |
| 1292 | messstart = i+1; |
| 1293 | } |
| 1294 | } |
| 1295 | binbuf_free(b); |
| 1296 | x->x_clockisset = 0; |
| 1297 | } |
| 1298 | |
| 1299 | static void pd_tilde_anything(t_pd_tilde *x, t_symbol *s, long ac, t_atom *av) |
| 1300 | { |
| 1301 | if (!x->x_outfd) |
| 1302 | return; |
| 1303 | if (x->x_binary) |
| 1304 | { |
| 1305 | critical_enter(0); |
| 1306 | pd_tilde_putsymbol(s, x->x_outfd); |
| 1307 | while (ac--) |
| 1308 | { |
| 1309 | switch (av->a_type) |
| 1310 | { |
| 1311 | case A_FLOAT: |
| 1312 | pd_tilde_putfloat(av->a_w.w_float, x->x_outfd); |
| 1313 | break; |
| 1314 | case A_LONG: |
| 1315 | pd_tilde_putfloat(av->a_w.w_long, x->x_outfd); |
| 1316 | break; |
| 1317 | case A_SYM: |
| 1318 | pd_tilde_putsymbol(av->a_w.w_sym, x->x_outfd); |
| 1319 | break; |
| 1320 | } |
| 1321 | av++; |
| 1322 | } |
| 1323 | pd_tilde_putsemi(x->x_outfd); |
| 1324 | critical_exit(0); |
| 1325 | } |
| 1326 | else |
| 1327 | { |
| 1328 | char msgbuf[MAXPDSTRING], *sp, *ep = msgbuf+MAXPDSTRING; |
| 1329 | msgbuf[0] = 0; |
| 1330 | strncpy(msgbuf, s->s_name, MAXPDSTRING); |
| 1331 | msgbuf[MAXPDSTRING-1] = 0; |
| 1332 | sp = msgbuf + strlen(msgbuf); |
| 1333 | while (ac--) |
| 1334 | { |
| 1335 | if (sp < ep-1) |
| 1336 | sp[0] = ' ', sp[1] = 0, sp++; |
| 1337 | if (sp < ep - 80) |
| 1338 | { |
| 1339 | if (av->a_type == A_SYM && strlen(av->a_w.w_sym->s_name) |
| 1340 | < ep - sp-20) |
| 1341 | strcpy(sp, av->a_w.w_sym->s_name); |
| 1342 | else if (av->a_type == A_LONG) |
| 1343 | sprintf(sp, "%ld" , (long)av->a_w.w_long); |
| 1344 | else if (av->a_type == A_FLOAT) |
| 1345 | sprintf(sp, "%g" , (t_float)av->a_w.w_float); |
| 1346 | } |
| 1347 | sp += strlen(sp); |
| 1348 | av++; |
| 1349 | } |
| 1350 | critical_enter(0); |
| 1351 | fprintf(x->x_outfd, "%s;\n", msgbuf); |
| 1352 | critical_exit(0); |
| 1353 | } |
| 1354 | } |
| 1355 | |
| 1356 | void ext_main( void *r) |
| 1357 | { |
| 1358 | t_class *c; |
| 1359 | |
| 1360 | c = class_new("pd~", (method)pd_tilde_new, (method)pd_tilde_free, |
| 1361 | sizeof(t_pd_tilde), (method)0L, A_GIMME, 0); |
| 1362 | |
| 1363 | class_addmethod(c, (method)pd_tilde_dsp64, "dsp64", A_CANT, 0); |
| 1364 | class_addmethod(c, (method)pd_tilde_assist, "assist", A_CANT, 0); |
| 1365 | class_addmethod(c, (method)pd_tilde_pdtilde, "pd~", A_GIMME, 0); |
| 1366 | class_addmethod(c, (method)pd_tilde_anything, "anything", A_GIMME, 0); |
| 1367 | class_dspinit(c); |
| 1368 | |
| 1369 | class_register(CLASS_BOX, c); |
| 1370 | pd_tilde_class = c; |
| 1371 | post("pd~ version 0.54"); |
| 1372 | } |
| 1373 | |
| 1374 | static void *pd_tilde_new(t_symbol *s, long ac, t_atom *av) |
| 1375 | { |
| 1376 | int ninsig = 2, noutsig = 2, fifo = 5, binary = 1, j; |
| 1377 | t_float sr = sys_getsr(); |
| 1378 | t_symbol *pddir = gensym("."), *scheddir = gensym("."); |
| 1379 | t_pd_tilde *x; |
| 1380 | |
| 1381 | if ((x = (t_pd_tilde *)object_alloc(pd_tilde_class))) |
| 1382 | { |
| 1383 | while (ac > 0 && av[0].a_type == A_SYM) |
| 1384 | { |
| 1385 | const char *flag = av[0].a_w.w_sym->s_name; |
| 1386 | if (!strcmp(flag, "-sr") && ac > 1) |
| 1387 | { |
| 1388 | sr = (av[1].a_type == A_FLOAT ? av[1].a_w.w_float : |
| 1389 | (av[1].a_type == A_LONG ? av[1].a_w.w_long : 0)); |
| 1390 | ac -= 2; av += 2; |
| 1391 | } |
| 1392 | else if (!strcmp(flag, "-ninsig") && ac > 1) |
| 1393 | { |
| 1394 | ninsig = (av[1].a_type == A_FLOAT ? av[1].a_w.w_float : |
| 1395 | (av[1].a_type == A_LONG ? av[1].a_w.w_long : 0)); |
| 1396 | ac -= 2; av += 2; |
| 1397 | } |
| 1398 | else if (!strcmp(flag, "-noutsig") && ac > 1) |
| 1399 | { |
| 1400 | noutsig = (av[1].a_type == A_FLOAT ? av[1].a_w.w_float : |
| 1401 | (av[1].a_type == A_LONG ? av[1].a_w.w_long : 0)); |
| 1402 | ac -= 2; av += 2; |
| 1403 | } |
| 1404 | else if (!strcmp(flag, "-fifo") && ac > 1) |
| 1405 | { |
| 1406 | fifo = (av[1].a_type == A_FLOAT ? av[1].a_w.w_float : |
| 1407 | (av[1].a_type == A_LONG ? av[1].a_w.w_long : 0)); |
| 1408 | ac -= 2; av += 2; |
| 1409 | } |
| 1410 | else if (!strcmp(flag, "-pddir") && ac > 1) |
| 1411 | { |
| 1412 | pddir = (av[1].a_type == A_SYM ? av[1].a_w.w_sym : gensym(".")); |
| 1413 | ac -= 2; av += 2; |
| 1414 | } |
| 1415 | else if (!strcmp(flag, "-scheddir") && ac > 1) |
| 1416 | { |
| 1417 | scheddir = |
| 1418 | (av[1].a_type == A_SYM ? av[1].a_w.w_sym : gensym(".")); |
| 1419 | ac -= 2; av += 2; |
| 1420 | } |
| 1421 | else if (!strcmp(flag, "-ascii")) |
| 1422 | { |
| 1423 | binary = 0; |
| 1424 | ac--; av++; |
| 1425 | } |
| 1426 | else break; |
| 1427 | } |
| 1428 | if (ac) |
| 1429 | post("pd~: warning: ignoring extra arguments"); |
| 1430 | dsp_setup((t_pxobject *)x, ninsig); |
| 1431 | x->x_outlet1 = outlet_new(&x->x_obj, 0); |
| 1432 | for (j = 0; j < noutsig; j++) |
| 1433 | outlet_new((t_pxobject *)x, "signal"); |
| 1434 | x->x_clock = clock_new(x, (method)pd_tilde_tick); |
| 1435 | x->x_insig = (t_pdsample **)t_getbytes(ninsig * sizeof(*x->x_insig)); |
| 1436 | x->x_outsig = (t_pdsample **)t_getbytes(noutsig * sizeof(*x->x_outsig)); |
| 1437 | x->x_ninsig = ninsig; |
| 1438 | x->x_noutsig = noutsig; |
| 1439 | x->x_fifo = fifo; |
| 1440 | x->x_sr = sr; |
| 1441 | x->x_pddir = pddir; |
| 1442 | x->x_schedlibdir = scheddir; |
| 1443 | x->x_infd = 0; |
| 1444 | x->x_outfd = 0; |
| 1445 | x->x_childpid = -1; |
| 1446 | x->x_binbuf = binbuf_new(); |
| 1447 | x->x_clockisset = 0; |
| 1448 | x->x_binary = binary; |
| 1449 | x->x_sampbuf = 0; |
| 1450 | } |
| 1451 | return (x); |
| 1452 | } |
| 1453 | |
| 1454 | void pd_tilde_assist(t_pd_tilde *x, void *b, long m, long a, char *s) |
| 1455 | { |
| 1456 | } |
| 1457 | |
| 1458 | #endif /* MSP */ |