diff options
author | Peter D'Hoye <peter.dhoye@gmail.com> | 2009-05-24 21:28:16 +0000 |
---|---|---|
committer | Peter D'Hoye <peter.dhoye@gmail.com> | 2009-05-24 21:28:16 +0000 |
commit | 526b5580dabbfed7cfe5439dc3a90ec727f563c2 (patch) | |
tree | 22b1af92348785daad16714ee5e2b633017e0e48 /apps/plugins/pdbox/PDa/src/d_global.c | |
parent | 4f2dfcc01b260d946044ef2b6af5fe36cb772c8d (diff) | |
download | rockbox-526b5580dabbfed7cfe5439dc3a90ec727f563c2.tar.gz rockbox-526b5580dabbfed7cfe5439dc3a90ec727f563c2.zip |
Cut the files in half and it might work better (note to self: check your tree is really clean before patching)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21070 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/d_global.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/src/d_global.c | 308 |
1 files changed, 0 insertions, 308 deletions
diff --git a/apps/plugins/pdbox/PDa/src/d_global.c b/apps/plugins/pdbox/PDa/src/d_global.c index 2b129ac5f4..893abe1f7d 100644 --- a/apps/plugins/pdbox/PDa/src/d_global.c +++ b/apps/plugins/pdbox/PDa/src/d_global.c | |||
@@ -306,311 +306,3 @@ void d_global_setup(void) | |||
306 | sigthrow_setup(); | 306 | sigthrow_setup(); |
307 | } | 307 | } |
308 | 308 | ||
309 | /* Copyright (c) 1997-1999 Miller Puckette. | ||
310 | * For information on usage and redistribution, and for a DISCLAIMER OF ALL | ||
311 | * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ | ||
312 | |||
313 | /* send~, receive~, throw~, catch~ */ | ||
314 | |||
315 | #include "m_pd.h" | ||
316 | #include <string.h> | ||
317 | |||
318 | #define DEFSENDVS 64 /* LATER get send to get this from canvas */ | ||
319 | |||
320 | /* ----------------------------- send~ ----------------------------- */ | ||
321 | static t_class *sigsend_class; | ||
322 | |||
323 | typedef struct _sigsend | ||
324 | { | ||
325 | t_object x_obj; | ||
326 | t_symbol *x_sym; | ||
327 | int x_n; | ||
328 | t_sample *x_vec; | ||
329 | float x_f; | ||
330 | } t_sigsend; | ||
331 | |||
332 | static void *sigsend_new(t_symbol *s) | ||
333 | { | ||
334 | t_sigsend *x = (t_sigsend *)pd_new(sigsend_class); | ||
335 | pd_bind(&x->x_obj.ob_pd, s); | ||
336 | x->x_sym = s; | ||
337 | x->x_n = DEFSENDVS; | ||
338 | x->x_vec = (t_sample *)getbytes(DEFSENDVS * sizeof(t_sample)); | ||
339 | memset((char *)(x->x_vec), 0, DEFSENDVS * sizeof(t_sample)); | ||
340 | x->x_f = 0; | ||
341 | return (x); | ||
342 | } | ||
343 | |||
344 | static t_int *sigsend_perform(t_int *w) | ||
345 | { | ||
346 | t_sample *in = (t_sample *)(w[1]); | ||
347 | t_sample *out = (t_sample *)(w[2]); | ||
348 | int n = (int)(w[3]); | ||
349 | while (n--) | ||
350 | { | ||
351 | *out = (PD_BIGORSMALL(*in) ? 0 : *in); | ||
352 | out++; | ||
353 | in++; | ||
354 | } | ||
355 | return (w+4); | ||
356 | } | ||
357 | |||
358 | static void sigsend_dsp(t_sigsend *x, t_signal **sp) | ||
359 | { | ||
360 | if (x->x_n == sp[0]->s_n) | ||
361 | dsp_add(sigsend_perform, 3, sp[0]->s_vec, x->x_vec, sp[0]->s_n); | ||
362 | else error("sigsend %s: unexpected vector size", x->x_sym->s_name); | ||
363 | } | ||
364 | |||
365 | static void sigsend_free(t_sigsend *x) | ||
366 | { | ||
367 | pd_unbind(&x->x_obj.ob_pd, x->x_sym); | ||
368 | freebytes(x->x_vec, x->x_n * sizeof(float)); | ||
369 | } | ||
370 | |||
371 | static void sigsend_setup(void) | ||
372 | { | ||
373 | sigsend_class = class_new(gensym("send~"), (t_newmethod)sigsend_new, | ||
374 | (t_method)sigsend_free, sizeof(t_sigsend), 0, A_DEFSYM, 0); | ||
375 | class_addcreator((t_newmethod)sigsend_new, gensym("s~"), A_DEFSYM, 0); | ||
376 | CLASS_MAINSIGNALIN(sigsend_class, t_sigsend, x_f); | ||
377 | class_addmethod(sigsend_class, (t_method)sigsend_dsp, gensym("dsp"), 0); | ||
378 | } | ||
379 | |||
380 | /* ----------------------------- receive~ ----------------------------- */ | ||
381 | static t_class *sigreceive_class; | ||
382 | |||
383 | typedef struct _sigreceive | ||
384 | { | ||
385 | t_object x_obj; | ||
386 | t_symbol *x_sym; | ||
387 | t_sample *x_wherefrom; | ||
388 | int x_n; | ||
389 | } t_sigreceive; | ||
390 | |||
391 | static void *sigreceive_new(t_symbol *s) | ||
392 | { | ||
393 | t_sigreceive *x = (t_sigreceive *)pd_new(sigreceive_class); | ||
394 | x->x_n = DEFSENDVS; /* LATER find our vector size correctly */ | ||
395 | x->x_sym = s; | ||
396 | x->x_wherefrom = 0; | ||
397 | outlet_new(&x->x_obj, &s_signal); | ||
398 | return (x); | ||
399 | } | ||
400 | |||
401 | static t_int *sigreceive_perform(t_int *w) | ||
402 | { | ||
403 | t_sigreceive *x = (t_sigreceive *)(w[1]); | ||
404 | t_sample *out = (t_sample *)(w[2]); | ||
405 | int n = (int)(w[3]); | ||
406 | t_sample *in = x->x_wherefrom; | ||
407 | if (in) | ||
408 | { | ||
409 | while (n--) | ||
410 | *out++ = *in++; | ||
411 | } | ||
412 | else | ||
413 | { | ||
414 | while (n--) | ||
415 | *out++ = 0; | ||
416 | } | ||
417 | return (w+4); | ||
418 | } | ||
419 | |||
420 | static void sigreceive_set(t_sigreceive *x, t_symbol *s) | ||
421 | { | ||
422 | t_sigsend *sender = (t_sigsend *)pd_findbyclass((x->x_sym = s), | ||
423 | sigsend_class); | ||
424 | if (sender) | ||
425 | { | ||
426 | if (sender->x_n == x->x_n) | ||
427 | x->x_wherefrom = sender->x_vec; | ||
428 | else | ||
429 | { | ||
430 | pd_error(x, "receive~ %s: vector size mismatch", x->x_sym->s_name); | ||
431 | x->x_wherefrom = 0; | ||
432 | } | ||
433 | } | ||
434 | else | ||
435 | { | ||
436 | pd_error(x, "receive~ %s: no matching send", x->x_sym->s_name); | ||
437 | x->x_wherefrom = 0; | ||
438 | } | ||
439 | } | ||
440 | |||
441 | static void sigreceive_dsp(t_sigreceive *x, t_signal **sp) | ||
442 | { | ||
443 | if (sp[0]->s_n != x->x_n) | ||
444 | { | ||
445 | pd_error(x, "receive~ %s: vector size mismatch", x->x_sym->s_name); | ||
446 | } | ||
447 | else | ||
448 | { | ||
449 | sigreceive_set(x, x->x_sym); | ||
450 | dsp_add(sigreceive_perform, 3, | ||
451 | x, sp[0]->s_vec, sp[0]->s_n); | ||
452 | } | ||
453 | } | ||
454 | |||
455 | static void sigreceive_setup(void) | ||
456 | { | ||
457 | sigreceive_class = class_new(gensym("receive~"), | ||
458 | (t_newmethod)sigreceive_new, 0, | ||
459 | sizeof(t_sigreceive), 0, A_DEFSYM, 0); | ||
460 | class_addcreator((t_newmethod)sigreceive_new, gensym("r~"), A_DEFSYM, 0); | ||
461 | class_addmethod(sigreceive_class, (t_method)sigreceive_set, gensym("set"), | ||
462 | A_SYMBOL, 0); | ||
463 | class_addmethod(sigreceive_class, (t_method)sigreceive_dsp, gensym("dsp"), | ||
464 | 0); | ||
465 | class_sethelpsymbol(sigreceive_class, gensym("send~")); | ||
466 | } | ||
467 | |||
468 | /* ----------------------------- catch~ ----------------------------- */ | ||
469 | static t_class *sigcatch_class; | ||
470 | |||
471 | typedef struct _sigcatch | ||
472 | { | ||
473 | t_object x_obj; | ||
474 | t_symbol *x_sym; | ||
475 | int x_n; | ||
476 | t_sample *x_vec; | ||
477 | } t_sigcatch; | ||
478 | |||
479 | static void *sigcatch_new(t_symbol *s) | ||
480 | { | ||
481 | t_sigcatch *x = (t_sigcatch *)pd_new(sigcatch_class); | ||
482 | pd_bind(&x->x_obj.ob_pd, s); | ||
483 | x->x_sym = s; | ||
484 | x->x_n = DEFSENDVS; | ||
485 | x->x_vec = (t_sample *)getbytes(DEFSENDVS * sizeof(t_sample)); | ||
486 | memset((char *)(x->x_vec), 0, DEFSENDVS * sizeof(t_sample)); | ||
487 | outlet_new(&x->x_obj, &s_signal); | ||
488 | return (x); | ||
489 | } | ||
490 | |||
491 | static t_int *sigcatch_perform(t_int *w) | ||
492 | { | ||
493 | t_sample *in = (t_sample *)(w[1]); | ||
494 | t_sample *out = (t_sample *)(w[2]); | ||
495 | int n = (int)(w[3]); | ||
496 | while (n--) *out++ = *in, *in++ = 0; | ||
497 | return (w+4); | ||
498 | } | ||
499 | |||
500 | static void sigcatch_dsp(t_sigcatch *x, t_signal **sp) | ||
501 | { | ||
502 | if (x->x_n == sp[0]->s_n) | ||
503 | dsp_add(sigcatch_perform, 3, x->x_vec, sp[0]->s_vec, sp[0]->s_n); | ||
504 | else error("sigcatch %s: unexpected vector size", x->x_sym->s_name); | ||
505 | } | ||
506 | |||
507 | static void sigcatch_free(t_sigcatch *x) | ||
508 | { | ||
509 | pd_unbind(&x->x_obj.ob_pd, x->x_sym); | ||
510 | freebytes(x->x_vec, x->x_n * sizeof(float)); | ||
511 | } | ||
512 | |||
513 | static void sigcatch_setup(void) | ||
514 | { | ||
515 | sigcatch_class = class_new(gensym("catch~"), (t_newmethod)sigcatch_new, | ||
516 | (t_method)sigcatch_free, sizeof(t_sigcatch), CLASS_NOINLET, A_DEFSYM, 0); | ||
517 | class_addmethod(sigcatch_class, (t_method)sigcatch_dsp, gensym("dsp"), 0); | ||
518 | class_sethelpsymbol(sigcatch_class, gensym("throw~")); | ||
519 | } | ||
520 | |||
521 | /* ----------------------------- throw~ ----------------------------- */ | ||
522 | static t_class *sigthrow_class; | ||
523 | |||
524 | typedef struct _sigthrow | ||
525 | { | ||
526 | t_object x_obj; | ||
527 | t_symbol *x_sym; | ||
528 | t_sample *x_whereto; | ||
529 | int x_n; | ||
530 | t_float x_f; | ||
531 | } t_sigthrow; | ||
532 | |||
533 | static void *sigthrow_new(t_symbol *s) | ||
534 | { | ||
535 | t_sigthrow *x = (t_sigthrow *)pd_new(sigthrow_class); | ||
536 | x->x_sym = s; | ||
537 | x->x_whereto = 0; | ||
538 | x->x_n = DEFSENDVS; | ||
539 | x->x_f = 0; | ||
540 | return (x); | ||
541 | } | ||
542 | |||
543 | static t_int *sigthrow_perform(t_int *w) | ||
544 | { | ||
545 | t_sigthrow *x = (t_sigthrow *)(w[1]); | ||
546 | t_sample *in = (t_sample *)(w[2]); | ||
547 | int n = (int)(w[3]); | ||
548 | t_sample *out = x->x_whereto; | ||
549 | if (out) | ||
550 | { | ||
551 | while (n--) | ||
552 | { | ||
553 | *out += (PD_BIGORSMALL(*in) ? 0 : *in); | ||
554 | out++; | ||
555 | in++; | ||
556 | } | ||
557 | } | ||
558 | return (w+4); | ||
559 | } | ||
560 | |||
561 | static void sigthrow_set(t_sigthrow *x, t_symbol *s) | ||
562 | { | ||
563 | t_sigcatch *catcher = (t_sigcatch *)pd_findbyclass((x->x_sym = s), | ||
564 | sigcatch_class); | ||
565 | if (catcher) | ||
566 | { | ||
567 | if (catcher->x_n == x->x_n) | ||
568 | x->x_whereto = catcher->x_vec; | ||
569 | else | ||
570 | { | ||
571 | pd_error(x, "throw~ %s: vector size mismatch", x->x_sym->s_name); | ||
572 | x->x_whereto = 0; | ||
573 | } | ||
574 | } | ||
575 | else | ||
576 | { | ||
577 | pd_error(x, "throw~ %s: no matching catch", x->x_sym->s_name); | ||
578 | x->x_whereto = 0; | ||
579 | } | ||
580 | } | ||
581 | |||
582 | static void sigthrow_dsp(t_sigthrow *x, t_signal **sp) | ||
583 | { | ||
584 | if (sp[0]->s_n != x->x_n) | ||
585 | { | ||
586 | pd_error(x, "throw~ %s: vector size mismatch", x->x_sym->s_name); | ||
587 | } | ||
588 | else | ||
589 | { | ||
590 | sigthrow_set(x, x->x_sym); | ||
591 | dsp_add(sigthrow_perform, 3, | ||
592 | x, sp[0]->s_vec, sp[0]->s_n); | ||
593 | } | ||
594 | } | ||
595 | |||
596 | static void sigthrow_setup(void) | ||
597 | { | ||
598 | sigthrow_class = class_new(gensym("throw~"), (t_newmethod)sigthrow_new, 0, | ||
599 | sizeof(t_sigthrow), 0, A_DEFSYM, 0); | ||
600 | class_addcreator((t_newmethod)sigthrow_new, gensym("r~"), A_DEFSYM, 0); | ||
601 | class_addmethod(sigthrow_class, (t_method)sigthrow_set, gensym("set"), | ||
602 | A_SYMBOL, 0); | ||
603 | CLASS_MAINSIGNALIN(sigthrow_class, t_sigthrow, x_f); | ||
604 | class_addmethod(sigthrow_class, (t_method)sigthrow_dsp, gensym("dsp"), 0); | ||
605 | } | ||
606 | |||
607 | /* ----------------------- global setup routine ---------------- */ | ||
608 | |||
609 | void d_global_setup(void) | ||
610 | { | ||
611 | sigsend_setup(); | ||
612 | sigreceive_setup(); | ||
613 | sigcatch_setup(); | ||
614 | sigthrow_setup(); | ||
615 | } | ||
616 | |||