From c1ae4414d4ac6504992434b949b252c30daf0c48 Mon Sep 17 00:00:00 2001 From: Wincent Balin Date: Thu, 3 Jun 2010 00:39:13 +0000 Subject: pdbox: Source cleanup. Removed unneeded files. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26497 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/pdbox/PDa/extra/OSC-client.h | 189 ---- apps/plugins/pdbox/PDa/extra/OSC.pd | 14 - apps/plugins/pdbox/PDa/extra/OSCroute.c | 628 ----------- apps/plugins/pdbox/PDa/extra/bandpass-help.pd | 18 - apps/plugins/pdbox/PDa/extra/dumpOSC.c | 1000 ----------------- apps/plugins/pdbox/PDa/extra/fatom.h | 486 -------- apps/plugins/pdbox/PDa/extra/gcanvas-help.pd | 9 - apps/plugins/pdbox/PDa/extra/makefile | 34 - apps/plugins/pdbox/PDa/extra/sendOSC.c | 1461 ------------------------- apps/plugins/pdbox/PDa/extra/sformat.h | 56 - apps/plugins/pdbox/PDa/extra/shell.c | 312 ------ apps/plugins/pdbox/PDa/extra/slider.c | 54 - apps/plugins/pdbox/PDa/extra/sliderh.c | 64 -- apps/plugins/pdbox/PDa/extra/test-clip.pd | 14 - apps/plugins/pdbox/PDa/extra/test-vcf.pd | 19 - 15 files changed, 4358 deletions(-) delete mode 100644 apps/plugins/pdbox/PDa/extra/OSC-client.h delete mode 100644 apps/plugins/pdbox/PDa/extra/OSC.pd delete mode 100644 apps/plugins/pdbox/PDa/extra/OSCroute.c delete mode 100644 apps/plugins/pdbox/PDa/extra/bandpass-help.pd delete mode 100644 apps/plugins/pdbox/PDa/extra/dumpOSC.c delete mode 100644 apps/plugins/pdbox/PDa/extra/fatom.h delete mode 100644 apps/plugins/pdbox/PDa/extra/gcanvas-help.pd delete mode 100644 apps/plugins/pdbox/PDa/extra/makefile delete mode 100644 apps/plugins/pdbox/PDa/extra/sendOSC.c delete mode 100644 apps/plugins/pdbox/PDa/extra/sformat.h delete mode 100644 apps/plugins/pdbox/PDa/extra/shell.c delete mode 100644 apps/plugins/pdbox/PDa/extra/slider.c delete mode 100644 apps/plugins/pdbox/PDa/extra/sliderh.c delete mode 100644 apps/plugins/pdbox/PDa/extra/test-clip.pd delete mode 100644 apps/plugins/pdbox/PDa/extra/test-vcf.pd (limited to 'apps/plugins/pdbox/PDa/extra') diff --git a/apps/plugins/pdbox/PDa/extra/OSC-client.h b/apps/plugins/pdbox/PDa/extra/OSC-client.h deleted file mode 100644 index fe2c37b5cb..0000000000 --- a/apps/plugins/pdbox/PDa/extra/OSC-client.h +++ /dev/null @@ -1,189 +0,0 @@ -/* -Written by Matt Wright, The Center for New Music and Audio Technologies, -University of California, Berkeley. Copyright (c) 1996,97,98,99,2000,01,02,03 -The Regents of the University of California (Regents). - -Permission to use, copy, modify, distribute, and distribute modified versions -of this software and its documentation without fee and without a signed -licensing agreement, is hereby granted, provided that the above copyright -notice, this paragraph and the following two paragraphs appear in all copies, -modifications, and distributions. - -IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, -SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING -OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS -BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED -HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE -MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. -*/ - -/* - - OSC-client.h: library for constructing OpenSoundControl messages. - Derived from SynthControl.h - Author: Matt Wright - Version 0.1: 6/13/97 - Version 0.2: 7/21/2000: Support for type-tagged messages - - - General notes: - - This library abstracts away the data format for the OpenSoundControl - protocol. Users of this library can construct OpenSoundControl packets - with a function call interface instead of knowing how to lay out the bits. - - All issues of memory allocation are deferred to the user of this library. - There are two data structures that the user must allocate. The first - is the actual buffer that the message will be written into. This buffer - can be any size, but if it's too small there's a possibility that it - will become overfull. The other data structure is called an OSCbuf, - and it holds all the state used by the library as it's constructing - a buffer. - - All procedures that have the possibility of an error condition return int, - with 0 indicating no error and nonzero indicating an error. The variable - OSC_errorMessage will be set to point to a string containing an error - message explaining what the problem is. - -*/ - - - -/* The int4byte type has to be a 4-byte integer. You may have to - change this to long or something else on your system. */ -#ifdef __MWERKS__ - /* In Metrowerks you can set ints to be 2 or 4 bytes on 68K, but long is - always 4 bytes */ - typedef long int4byte; -#else - typedef int int4byte; -#endif - -/* OSC_timetag.h */ - - typedef struct { - int seconds; - int fraction; - } OSCTimeTag; - -OSCTimeTag OSCTT_Immediately(void); -OSCTimeTag OSCTT_PlusSeconds(OSCTimeTag original, float secondsOffset); -OSCTimeTag OSCTT_CurrentTime(void); - - - -/* The maximum depth of bundles within bundles within bundles within... - This is the size of a static array. If you exceed this limit you'll - get an error message. */ -#define MAX_BUNDLE_NESTING 32 - - -/* Don't ever manipulate the data in the OSCbuf struct directly. (It's - declared here in the header file only so your program will be able to - declare variables of type OSCbuf and have the right amount of memory - be allocated.) */ - -typedef struct OSCbuf_struct { - char *buffer; /* The buffer to hold the OSC packet */ - int size; /* Size of the buffer */ - char *bufptr; /* Current position as we fill the buffer */ - int state; /* State of partially-constructed message */ - int4byte *thisMsgSize; /* Pointer to count field before - currently-being-written message */ - int4byte *prevCounts[MAX_BUNDLE_NESTING]; - /* Pointers to count field before each currently - open bundle */ - int bundleDepth; /* How many sub-sub-bundles are we in now? */ - char *typeStringPtr; /* This pointer advances through the type - tag string as you add arguments. */ - int gettingFirstUntypedArg; /* nonzero if this message doesn't have - a type tag and we're waiting for the 1st arg */ -} OSCbuf; - - - -/* Initialize the given OSCbuf. The user of this module must pass in the - block of memory that this OSCbuf will use for a buffer, and the number of - bytes in that block. (It's the user's job to allocate the memory because - you do it differently in different systems.) */ -void OSC_initBuffer(OSCbuf *buf, int size, char *byteArray); - - -/* Reset the given OSCbuf. Do this after you send out the contents of - the buffer and want to start writing new data into it. */ -void OSC_resetBuffer(OSCbuf *buf); - - -/* Is the buffer empty? (I.e., would it be stupid to send the buffer - contents to the synth?) */ -int OSC_isBufferEmpty(OSCbuf *buf); - - -/* How much space is left in the buffer? */ -int OSC_freeSpaceInBuffer(OSCbuf *buf); - -/* Does the buffer contain a valid OSC packet? (Returns nonzero if yes.) */ -int OSC_isBufferDone(OSCbuf *buf); - -/* When you're ready to send out the buffer (i.e., when OSC_isBufferDone() - returns true), call these two procedures to get the OSC packet that's been - assembled and its size in bytes. (And then call OSC_resetBuffer() if you - want to re-use this OSCbuf for the next packet.) */ -char *OSC_getPacket(OSCbuf *buf); -int OSC_packetSize(OSCbuf *buf); - - - -/* Here's the basic model for building up OSC messages in an OSCbuf: - - - Make sure the OSCbuf has been initialized with OSC_initBuffer(). - - - To open a bundle, call OSC_openBundle(). You can then write - messages or open new bundles within the bundle you opened. - Call OSC_closeBundle() to close the bundle. Note that a packet - does not have to have a bundle; it can instead consist of just a - single message. - - - - For each message you want to send: - - - Call OSC_writeAddress() with the name of your message. (In - addition to writing your message name into the buffer, this - procedure will also leave space for the size count of this message.) - - - Alternately, call OSC_writeAddressAndTypes() with the name of - your message and with a type string listing the types of all the - arguments you will be putting in this message. - - - Now write each of the arguments into the buffer, by calling one of: - OSC_writeFloatArg() - OSC_writeFloatArgs() - OSC_writeIntArg() - OSC_writeStringArg() - - - Now your message is complete; you can send out the buffer or you can - add another message to it. -*/ - -int OSC_openBundle(OSCbuf *buf, OSCTimeTag tt); -int OSC_closeBundle(OSCbuf *buf); -int OSC_closeAllBundles(OSCbuf *buf); - -int OSC_writeAddress(OSCbuf *buf, char *name); -int OSC_writeAddressAndTypes(OSCbuf *buf, char *name, char *types); -int OSC_writeFloatArg(OSCbuf *buf, float arg); -int OSC_writeFloatArgs(OSCbuf *buf, int numFloats, float *args); -int OSC_writeIntArg(OSCbuf *buf, int4byte arg); -int OSC_writeStringArg(OSCbuf *buf, char *arg); - -extern char *OSC_errorMessage; - -/* How many bytes will be needed in the OSC format to hold the given - string? The length of the string, plus the null char, plus any padding - needed for 4-byte alignment. */ -int OSC_effectiveStringLength(char *string); - diff --git a/apps/plugins/pdbox/PDa/extra/OSC.pd b/apps/plugins/pdbox/PDa/extra/OSC.pd deleted file mode 100644 index 37841ef17a..0000000000 --- a/apps/plugins/pdbox/PDa/extra/OSC.pd +++ /dev/null @@ -1,14 +0,0 @@ -#N canvas 0 0 240 300 10; -#X obj 32 185 dumpOSC 5550; -#X obj 32 217 OSCroute /hello; -#X obj 32 239 print; -#X obj 133 238 print; -#X obj 26 87 sendOSC; -#X msg 50 43 connect localhost 5550; -#X msg 21 13 send /hello PDa; -#X connect 0 0 1 0; -#X connect 1 0 2 0; -#X connect 1 1 3 0; -#X connect 5 0 4 0; -#X connect 6 0 4 0; - diff --git a/apps/plugins/pdbox/PDa/extra/OSCroute.c b/apps/plugins/pdbox/PDa/extra/OSCroute.c deleted file mode 100644 index 64edbc777f..0000000000 --- a/apps/plugins/pdbox/PDa/extra/OSCroute.c +++ /dev/null @@ -1,628 +0,0 @@ -/* -Written by Adrian Freed, The Center for New Music and Audio Technologies, -University of California, Berkeley. Copyright (c) 1992,93,94,95,96,97,98,99,2000,01,02,03,04 -The Regents of the University of California (Regents). - -Permission to use, copy, modify, distribute, and distribute modified versions -of this software and its documentation without fee and without a signed -licensing agreement, is hereby granted, provided that the above copyright -notice, this paragraph and the following two paragraphs appear in all copies, -modifications, and distributions. - -IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, -SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING -OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS -BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED -HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE -MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - - -The OSC webpage is http://cnmat.cnmat.berkeley.edu/OpenSoundControl -*/ - - /* OSC-route.c - Max object for OSC-style dispatching - - To-do: - - Match a pattern against a pattern? - Declare outlet types / distinguish leaf nodes from other children - More sophisticated (2-pass?) allmessages scheme - set message? - - - pd - ------------- - -- tweaks for Win32 www.zeggz.com/raf 13-April-2002 - - - */ - -#ifdef ROCKBOX -#include "plugin.h" -#include "../../pdbox.h" -#else /* ROCKBOX */ -#ifdef WIN32 - #include - #include -#endif -#ifdef __APPLE__ - #include -#endif -#ifdef UNIX - #include -#endif -#endif /* ROCKBOX */ - -/* structure definition of your object */ - -#define MAX_NUM 20 -#define OSC_ROUTE_VERSION "1.05" -#define OSCWarning(x...) post(x) - -/* the required include files */ -#include "../src/m_pd.h" - - -#ifndef TRUE -typedef int Boolean; -#define TRUE 1 -#define FALSE 0 -#endif - - -/* Fixed byte width types */ -typedef int int4; /* 4 byte int */ - -Boolean PatternMatch (const char *pattern, const char *test); - - - -/* Version 1.04: Allows #1 thru #9 as typed-in arguments - Version 1.05: Allows "list" messages as well as "message" messages. -*/ - -static t_class *OSCroute_class; - -typedef struct _OSCroute -{ - t_object x_obj; // required header - t_int x_num; // Number of address prefixes we store - t_int x_complainmode; // Do we print a message if no match? - t_int x_sendmode; // use pd internal sends instead of outlets - char *x_prefixes[MAX_NUM]; - void *x_outlets[MAX_NUM+1]; -} t_OSCroute; - -t_symbol *ps_list, *ps_complain, *ps_emptySymbol; - -/* prototypes */ - -void OSCroute_doanything(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv); -void OSCroute_anything(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv); -void OSCroute_list(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv); -/* //void *OSCroute_new(t_symbol *s, int argc, atom *argv); */ -void *OSCroute_new(t_symbol *s, int argc, t_atom *argv); -void OSCroute_version (t_OSCroute *x); -/* void OSCroute_assist (OSCroute *x, void *box, long msg, long arg, */ -/* char *dstString); */ -void OSCroute_allmessages(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv); - -static char *NextSlashOrNull(char *p); -static void StrCopyUntilSlash(char *target, const char *source); - - -// free -static void OSCroute_free(t_OSCroute *x) -{ -#ifdef ROCKBOX - (void) x; -#endif - // freebytes(x->x_vec, x->x_nelement * sizeof(*x->x_vec)); -} - -/* initialization routine */ - -// setup -#ifdef WIN32 - OSC_API void OSCroute_setup(void) { -#else -void OSCroute_setup(void) { -#endif - OSCroute_class = class_new(gensym("OSCroute"), (t_newmethod)OSCroute_new, - (t_method)OSCroute_free,sizeof(t_OSCroute), 0, A_GIMME, 0); - class_addlist(OSCroute_class, OSCroute_list); - class_addanything(OSCroute_class, OSCroute_anything); - class_addmethod(OSCroute_class, (t_method)OSCroute_version, gensym("version"), A_NULL, 0, 0); - class_sethelpsymbol(OSCroute_class, gensym("OSCroute-help.pd")); - - /* - class_addmethod(OSCroute_class, (t_method)OSCroute_connect, - gensym("connect"), A_SYMBOL, A_FLOAT, 0); - class_addmethod(OSCroute_class, (t_method)OSCroute_disconnect, - gensym("disconnect"), 0); - class_addmethod(OSCroute_class, (t_method)OSCroute_send, gensym("send"), - A_GIMME, 0); - */ -/* ps_list = gensym("list"); */ -/* ps_complain = gensym("complain"); */ - ps_emptySymbol = gensym(""); - - post("OSCroute object version " OSC_ROUTE_VERSION " by Matt Wright. pd: jdl Win32 raf."); - post("OSCroute Copyright © 1999 Regents of the University of California. All Rights Reserved."); -} - - - -/* instance creation routine */ - -void *OSCroute_new(t_symbol *s, int argc, t_atom *argv) -{ -#ifdef ROCKBOX - (void) s; -#endif - t_OSCroute *x = (t_OSCroute *)pd_new(OSCroute_class); // get memory for a new object & initialize - - int i; //{{raf}} n not used - - // EnterCallback(); - - if (argc > MAX_NUM) { - post("* OSC-route: too many arguments: %ld (max %ld)", argc, MAX_NUM); - // ExitCallback(); - return 0; - } - - x->x_complainmode = 0; - x->x_num = 0; - for (i = 0; i < argc; ++i) { - if (argv[i].a_type == A_SYMBOL) { - if (argv[i].a_w.w_symbol->s_name[0] == '/') { - /* Now that's a nice prefix */ - x->x_prefixes[i] = argv[i].a_w.w_symbol->s_name; - ++(x->x_num); - } else if (argv[i].a_w.w_symbol->s_name[0] == '#' && - argv[i].a_w.w_symbol->s_name[1] >= '1' && - argv[i].a_w.w_symbol->s_name[1] <= '9') { - /* The Max programmer is trying to make a patch that will be - a subpatch with arguments. We have to make an outlet for this - argument. */ - x->x_prefixes[i] = "dummy"; - ++(x->x_num); - } else { - /* Maybe this is an option we support */ - -/* if (argv[i].a_w.w_sym == ps_complain) { */ -/* x->x_complainmode = 1; */ -/* } else { */ -/* post("* OSC-route: Unrecognized argument %s", argv[i].a_w.w_sym->s_name); */ -/* } */ - - } - - // no LONG - -/* } else if (argv[i].a_type == A_FLOAD) { */ -/* // Convert to a numeral. Max ints are -2147483648 to 2147483647 */ -/* char *string = getbytes(12); */ -/* // I can't be bothered to plug this 12 byte memory leak */ -/* if (string == 0) { */ -/* post("* OSC-route: out of memory!"); */ -/* // ExitCallback(); */ -/* return 0; */ -/* } */ -/* sprintf(string, "%d", argv[i].a_w.w_long); */ -/* x->x_prefixes[i] = string; */ -/* ++(x->x_num); */ - - } else if (argv[i].a_type == A_FLOAT) { - post("* OSC-route: float arguments are not OK."); - // ExitCallback(); - return 0; - } else { - post("* OSC-route: unrecognized argument type!"); - // ExitCallback(); - return 0; - } - } - - - /* Have to create the outlets in reverse order */ - /* well, not in pd ? */ - // for (i = x->x_num-1; i >= 0; --i) { - // for (i = 0; i <= x->x_num-1; i++) { - for (i = 0; i <= x->x_num; i++) { - // x->x_outlets[i] = listout(x); - x->x_outlets[i] = outlet_new(&x->x_obj, &s_list); - } - - // ExitCallback(); - return (x); -} - - -void OSCroute_version (t_OSCroute *x) { -#ifdef ROCKBOX - (void) x; -#endif - // EnterCallback(); - post("OSCroute Version " OSC_ROUTE_VERSION - ", by Matt Wright. pd jdl, win32: raf.\nOSCroute Compiled " __TIME__ " " __DATE__); - // ExitCallback(); -} - -/* I don't know why these aren't defined in some Max #include file. */ -#define ASSIST_INLET 1 -#define ASSIST_OUTLET 2 - -void OSCroute_assist (t_OSCroute *x, void *box, long msg, long arg, - char *dstString) { -#ifdef ROCKBOX - (void) box; -#endif - // EnterCallback(); - - if (msg==ASSIST_INLET) { -#ifdef ROCKBOX - strcpy(dstString, "Incoming OSC messages"); -#else - sprintf(dstString, "Incoming OSC messages"); -#endif - } else if (msg==ASSIST_OUTLET) { - if (arg < 0 || arg >= x->x_num) { - post("* OSCroute_assist: No outlet corresponds to arg %ld!", arg); - } else { -#ifdef ROCKBOX - strcpy(dstString, "subaddress + args for prefix "); - strcat(dstString, x->x_prefixes[arg]); -#else - sprintf(dstString, "subaddress + args for prefix %s", x->x_prefixes[arg]); -#endif - } - } else { - post("* OSCroute_assist: unrecognized message %ld", msg); - } - - // ExitCallback(); -} - -void OSCroute_list(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv) { -#ifdef ROCKBOX - (void) s; -#endif - // EnterCallback(); - if (argc > 0 && argv[0].a_type == A_SYMBOL) { - /* Ignore the fact that this is a "list" */ - OSCroute_doanything(x, argv[0].a_w.w_symbol, argc-1, argv+1); - } else { - // post("* OSC-route: invalid list beginning with a number"); - // output on unmatched outlet jdl 20020908 - if (argv[0].a_type == A_FLOAT) { - outlet_float(x->x_outlets[x->x_num], argv[0].a_w.w_float); - } else { - post("* OSC-route: unrecognized atom type!"); - } - } - // ExitCallback(); -} - - -void OSCroute_anything(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv) { - // EnterCallback(); - OSCroute_doanything(x, s, argc, argv); - // ExitCallback(); -} - - - - -void OSCroute_doanything(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv) { - char *pattern, *nextSlash; - int i; - int matchedAnything; - // post("*** OSCroute_anything(s %s, argc %ld)", s->s_name, (long) argc); - - pattern = s->s_name; - if (pattern[0] != '/') { - post("* OSC-route: invalid message pattern %s does not begin with /", s->s_name); - outlet_anything(x->x_outlets[x->x_num], s, argc, argv); - return; - } - - matchedAnything = 0; - - nextSlash = NextSlashOrNull(pattern+1); - if (*nextSlash == '\0') { - /* last level of the address, so we'll output the argument list */ - - -#ifdef NULL_IS_DIFFERENT_FROM_BANG - if (argc==0) { - post("* OSC-route: why are you matching one level pattern %s with no args?", - pattern); - return; - } -#endif - - for (i = 0; i < x->x_num; ++i) { - if (PatternMatch(pattern+1, x->x_prefixes[i]+1)) { - ++matchedAnything; - - // I hate stupid Max lists with a special first element - if (argc == 0) { - outlet_bang(x->x_outlets[i]); - } else if (argv[0].a_type == A_SYMBOL) { - // Promote the symbol that was argv[0] to the special symbol - outlet_anything(x->x_outlets[i], argv[0].a_w.w_symbol, argc-1, argv+1); - } else if (argc > 1) { - // Multiple arguments starting with a number, so naturally we have - // to use a special function to output this "list", since it's what - // Max originally meant by "list". - outlet_list(x->x_outlets[i], 0L, argc, argv); - } else { - // There was only one argument, and it was a number, so we output it - // not as a list -/* if (argv[0].a_type == A_LONG) { */ - -/* outlet_int(x->x_outlets[i], argv[0].a_w.w_long); */ - // } else - if (argv[0].a_type == A_FLOAT) { - - outlet_float(x->x_outlets[i], argv[0].a_w.w_float); - } else { - post("* OSC-route: unrecognized atom type!"); - } - } - } - } - } else { - /* There's more address after this part, so our output list will begin with - the next slash. */ - t_symbol *restOfPattern = 0; /* avoid the gensym unless we have to output */ - char patternBegin[1000]; - - - /* Get the first level of the incoming pattern to match against all our prefixes */ - StrCopyUntilSlash(patternBegin, pattern+1); - - for (i = 0; i < x->x_num; ++i) { - if (PatternMatch(patternBegin, x->x_prefixes[i]+1)) { - ++matchedAnything; - if (restOfPattern == 0) { - restOfPattern = gensym(nextSlash); - } - outlet_anything(x->x_outlets[i], restOfPattern, argc, argv); - } - } - } - - if (x->x_complainmode) { - if (!matchedAnything) { - post("* OSC-route: pattern %s did not match any prefixes", pattern); - } - } - - // output unmatched data on rightmost outlet a la normal 'route' object, jdl 20020908 - if (!matchedAnything) { - outlet_anything(x->x_outlets[x->x_num], s, argc, argv); - } - - -} - -static char *NextSlashOrNull(char *p) { - while (*p != '/' && *p != '\0') { - p++; - } - return p; -} - -static void StrCopyUntilSlash(char *target, const char *source) { - while (*source != '/' && *source != '\0') { - *target = *source; - ++target; - ++source; - } - *target = 0; -} - -static int MyStrCopy(char *target, const char *source) { - int i = 0; - while (*source != '\0') { - *target = *source; - ++target; - ++source; - ++i; - } - *target = 0; - return i; -} - - - -void OSCroute_allmessages(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv) { - int i; - t_symbol *prefixSymbol = 0; - char prefixBuf[1000]; - char *endOfPrefix; - t_atom a[1]; - - if (argc >= 1 && argv[0].a_type == A_SYMBOL) { - prefixSymbol = argv[0].a_w.w_symbol; - endOfPrefix = prefixBuf + MyStrCopy(prefixBuf, - prefixSymbol->s_name); - } else { - prefixSymbol = ps_emptySymbol; - prefixBuf[0] = '\0'; - endOfPrefix = prefixBuf; - } - - - for (i = 0; i < x->x_num; ++i) { - post("OSC: %s%s", prefixSymbol->s_name, x->x_prefixes[i]); - MyStrCopy(endOfPrefix, x->x_prefixes[i]); - SETSYMBOL(a, gensym(prefixBuf)); - outlet_anything(x->x_outlets[i], s, 1, a); - } -} - - -/* --------------------------------------------------- */ - - - -static const char *theWholePattern; /* Just for warning messages */ - -static Boolean MatchBrackets (const char *pattern, const char *test); -static Boolean MatchList (const char *pattern, const char *test); - -Boolean PatternMatch (const char * pattern, const char * test) { - theWholePattern = pattern; - - if (pattern == 0 || pattern[0] == 0) { - return test[0] == 0; - } - - if (test[0] == 0) { - if (pattern[0] == '*') - return PatternMatch (pattern+1,test); - else - return FALSE; - } - - switch (pattern[0]) { - case 0 : return test[0] == 0; - case '?' : return PatternMatch (pattern + 1, test + 1); - case '*' : - if (PatternMatch (pattern+1, test)) { - return TRUE; - } else { - return PatternMatch (pattern, test+1); - } - case ']' : - case '}' : - OSCWarning("Spurious %c in pattern \".../%s/...\"",pattern[0], theWholePattern); - return FALSE; - case '[' : - return MatchBrackets (pattern,test); - case '{' : - return MatchList (pattern,test); - case '\\' : - if (pattern[1] == 0) { - return test[0] == 0; - } else if (pattern[1] == test[0]) { - return PatternMatch (pattern+2,test+1); - } else { - return FALSE; - } - default : - if (pattern[0] == test[0]) { - return PatternMatch (pattern+1,test+1); - } else { - return FALSE; - } - } -} - - -/* we know that pattern[0] == '[' and test[0] != 0 */ - -static Boolean MatchBrackets (const char *pattern, const char *test) { - Boolean result; - Boolean negated = FALSE; - const char *p = pattern; - - if (pattern[1] == 0) { - OSCWarning("Unterminated [ in pattern \".../%s/...\"", theWholePattern); - return FALSE; - } - - if (pattern[1] == '!') { - negated = TRUE; - p++; - } - - while (*p != ']') { - if (*p == 0) { - OSCWarning("Unterminated [ in pattern \".../%s/...\"", theWholePattern); - return FALSE; - } - if (p[1] == '-' && p[2] != 0) { - if (test[0] >= p[0] && test[0] <= p[2]) { - result = !negated; - goto advance; - } - } - if (p[0] == test[0]) { - result = !negated; - goto advance; - } - p++; - } - - result = negated; - -advance: - - if (!result) - return FALSE; - - while (*p != ']') { - if (*p == 0) { - OSCWarning("Unterminated [ in pattern \".../%s/...\"", theWholePattern); - return FALSE; - } - p++; - } - - return PatternMatch (p+1,test+1); -} - -static Boolean MatchList (const char *pattern, const char *test) { - - const char *restOfPattern, *tp = test; - - - for(restOfPattern = pattern; *restOfPattern != '}'; restOfPattern++) { - if (*restOfPattern == 0) { - OSCWarning("Unterminated { in pattern \".../%s/...\"", theWholePattern); - return FALSE; - } - } - - restOfPattern++; /* skip close curly brace */ - - - pattern++; /* skip open curly brace */ - - while (1) { - - if (*pattern == ',') { - if (PatternMatch (restOfPattern, tp)) { - return TRUE; - } else { - tp = test; - ++pattern; - } - } else if (*pattern == '}') { - return PatternMatch (restOfPattern, tp); - } else if (*pattern == *tp) { - ++pattern; - ++tp; - } else { - tp = test; - while (*pattern != ',' && *pattern != '}') { - pattern++; - } - if (*pattern == ',') { - pattern++; - } - } - } - -} - diff --git a/apps/plugins/pdbox/PDa/extra/bandpass-help.pd b/apps/plugins/pdbox/PDa/extra/bandpass-help.pd deleted file mode 100644 index 52feeb16c2..0000000000 --- a/apps/plugins/pdbox/PDa/extra/bandpass-help.pd +++ /dev/null @@ -1,18 +0,0 @@ -#N canvas 428 285 240 300 8; -#X obj 24 78 noise~; -#X obj 15 215 dac~; -#X obj 24 167 biquad~; -#X floatatom 67 76 5 0 0 0 - - -; -#X floatatom 83 111 5 0 0 0 - - -; -#X obj 67 138 bandpass 600 10; -#X text 77 97 bandwidth: 100 = 1 octave; -#X text 67 58 frequency; -#X text 8 11 Calculation of biquad coefficients; -#X text 7 21 ==================================; -#X connect 0 0 2 0; -#X connect 2 0 1 0; -#X connect 2 0 1 1; -#X connect 3 0 5 0; -#X connect 4 0 5 1; -#X connect 5 0 2 0; - diff --git a/apps/plugins/pdbox/PDa/extra/dumpOSC.c b/apps/plugins/pdbox/PDa/extra/dumpOSC.c deleted file mode 100644 index b4ef97d7d1..0000000000 --- a/apps/plugins/pdbox/PDa/extra/dumpOSC.c +++ /dev/null @@ -1,1000 +0,0 @@ -/* -Written by Matt Wright and Adrian Freed, The Center for New Music and -Audio Technologies, University of California, Berkeley. Copyright (c) -1992,93,94,95,96,97,98,99,2000,01,02,03,04 The Regents of the University of -California (Regents). - -Permission to use, copy, modify, distribute, and distribute modified versions -of this software and its documentation without fee and without a signed -licensing agreement, is hereby granted, provided that the above copyright -notice, this paragraph and the following two paragraphs appear in all copies, -modifications, and distributions. - -IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, -SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING -OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS -BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED -HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE -MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - - -The OSC webpage is http://cnmat.cnmat.berkeley.edu/OpenSoundControl -*/ - - - /* - - dumpOSC.c - server that displays OpenSoundControl messages sent to it - for debugging client udp and UNIX protocol - - by Matt Wright, 6/3/97 - modified from dumpSC.c, by Matt Wright and Adrian Freed - - version 0.2: Added "-silent" option a.k.a. "-quiet" - - version 0.3: Incorporated patches from Nicola Bernardini to make - things Linux-friendly. Also added ntohl() in the right places - to support little-endian architectures. - - - - compile: - cc -o dumpOSC dumpOSC.c - - to-do: - - More robustness in saying exactly what's wrong with ill-formed - messages. (If they don't make sense, show exactly what was - received.) - - Time-based features: print time-received for each packet - - Clean up to separate OSC parsing code from socket/select stuff - - pd: branched from http://www.cnmat.berkeley.edu/OpenSoundControl/src/dumpOSC/dumpOSC.c - ------------- - -- added pd functions - -- socket is made differently than original via pd mechanisms - -- tweaks for Win32 www.zeggz.com/raf 13-April-2002 - -- the OSX changes from cnmat didnt make it here yet but this compiles - on OSX anyway. - -*/ - -#if HAVE_CONFIG_H -#include -#endif - -#include "../src/m_pd.h" -//#include "m_imp.h" -#include "s_stuff.h" - -/* declarations */ - -// typedef void (*t_fdpollfn)(void *ptr, int fd); -void sys_addpollfn(int fd, t_fdpollfn fn, void *ptr); - - -#if defined(__sgi) || defined(__linux) || defined(WIN32) || defined(__APPLE__) - -#ifdef WIN32 - #include "OSC-common.h" - #include - #include - #include - #include - #include - #include - #include - #include -#else - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - //#include - - #ifdef NEED_SCHEDCTL_AND_LOCK - #include - #include - #endif -#endif - - -char *htm_error_string; -typedef int Boolean; -typedef void *OBJ; - -typedef struct ClientAddressStruct { - struct sockaddr_in cl_addr; - int clilen; - int sockfd; -} *ClientAddr; - -typedef unsigned long long osc_time_t; - -Boolean ShowBytes = FALSE; -Boolean Silent = FALSE; - -/* Declarations */ -#ifndef WIN32 -static int unixinitudp(int chan); -#endif - -static int initudp(int chan); -static void closeudp(int sockfd); -Boolean ClientReply(int packetsize, void *packet, int socketfd, - void *clientaddresspointer, int clientaddressbufferlength); -void sgi_CleanExit(void); -Boolean sgi_HaveToQuit(void); -int RegisterPollingDevice(int fd, void (*callbackfunction)(int , void *), void *dummy); -static void catch_sigint(); -static int Synthmessage(char *m, int n, void *clientdesc, int clientdesclength, int fd) ; -char *DataAfterAlignedString(char *string, char *boundary) ; -Boolean IsNiceString(char *string, char *boundary) ; -void complain(char *s, ...); - -#define MAXMESG 32768 -static char mbuf[MAXMESG]; - -/* ----------------------------- dumpOSC ------------------------- */ - -#define MAXOUTAT 50 - -static t_class *dumpOSC_class; - -typedef struct _dumpOSC -{ - t_object x_obj; - t_outlet *x_msgout; - t_outlet *x_connectout; - t_atom x_outat[MAXOUTAT]; - int x_outatc; - t_binbuf *x_b; - int x_connectsocket; - int x_nconnections; - int x_udp; - struct sockaddr_in x_server; - int x_clilen; -} t_dumpOSC; - -void dumpOSC_ParsePacket(t_dumpOSC *x, char *buf, int n, ClientAddr returnAddr); -Boolean dumpOSC_SendReply(char *buf, int n, void *clientDesc, int clientDescLenght, int fd); -static void dumpOSC_Smessage(t_dumpOSC *x, char *address, void *v, int n, ClientAddr returnAddr); -static void dumpOSC_PrintTypeTaggedArgs(t_dumpOSC *x, void *v, int n); -static void dumpOSC_PrintHeuristicallyTypeGuessedArgs(t_dumpOSC *x, void *v, int n, int skipComma); - -static void dumpOSC_read(t_dumpOSC *x, int sockfd) { - int clilen = x->x_clilen; - int n; - struct ClientAddressStruct ras; - ClientAddr ra = &ras; - - //catchupflag= FALSE; - -/* if (ShowBytes) { */ -/* int i; */ -/* printf("%d byte message:\n", n); */ -/* for (i = 0; i < n; ++i) { */ -/* printf(" %x (%c)\t", m[i], m[i]); */ -/* if (i%4 == 3) printf("\n"); */ -/* } */ -/* printf("\n"); */ -/* } */ - - // return catchupflag; - //struct sockaddr_in x->x_server; - //while( (n = recvfrom(sockfd, mbuf, MAXMESG, 0, &cl_addr, &clilen)) >0) - // while(( - - #ifdef WIN32 - if ((n = recvfrom(sockfd, mbuf, MAXMESG, 0, (SOCKADDR*)&x->x_server, &clilen)) >0) - #else - if ((n = recvfrom(sockfd, mbuf, MAXMESG, 0, (struct sockaddr *)&x->x_server, &clilen)) >0) - #endif - { - //int r; - ras.cl_addr = *((struct sockaddr_in *) &x->x_server); - ras.clilen = x->x_clilen; - ras.sockfd = x->x_connectsocket; - - #ifdef DEBUG - printf("dumpOSC_read: received UDP packet of length %d\n", n); - #endif - - if(!dumpOSC_SendReply(mbuf, n, &x->x_server, clilen, sockfd)) - { - dumpOSC_ParsePacket(x, mbuf, n, ra); - } - //r = Synthmessage(mbuf, n, &x->x_server, clilen, sockfd); - //post ("%d", r); - //outlet_anything(x->x_msgout, at[msg].a_w.w_symbol, - // emsg-msg-1, at + msg + 1); - // outlet_list(x->x_msgout, 0, n, mbuf); - //if( sgi_HaveToQuit()) goto out; - //if(r>0) goto back; - //clilen = maxclilen; - } -} - -static void *dumpOSC_new(t_symbol *compatflag, - t_floatarg fportno) { - t_dumpOSC *x; - struct sockaddr_in server; - int clilen=sizeof(server); - int sockfd; - int portno=fportno; - int udp = 1; - - //x->x_b = binbuf_new(); - //x->x_outat = binbuf_getvec(x->x_b); - - //{{raf}} pointer not valid yet...moving this down - //x->x_outatc = 0; {{raf}} - - /* create a socket */ - if ((sockfd = socket(AF_INET, (udp ? SOCK_DGRAM : SOCK_STREAM), 0)) == -1) - { - sys_sockerror("socket"); - return (0); - } - - server.sin_family = AF_INET; - server.sin_addr.s_addr = INADDR_ANY; - /* assign server port number */ - server.sin_port = htons((u_short)portno); - /* name the socket */ - if (bind(sockfd, (struct sockaddr *)&server, sizeof(server)) < 0) - { - sys_sockerror("bind"); - sys_closesocket(sockfd); - return (0); - } - - x = (t_dumpOSC *)pd_new(dumpOSC_class); - x->x_outatc = 0; // {{raf}} now pointer is valid (less invalid) - - x->x_msgout = outlet_new(&x->x_obj, &s_anything); - - // if (udp) /* datagram protocol */ - { - - sys_addpollfn(sockfd, (t_fdpollfn)dumpOSC_read, x); - x->x_connectout = 0; - } - // else /* streaming protocol */ - /* { */ - /* if (listen(sockfd, 5) < 0) */ - /* { */ - /* sys_sockerror("listen"); */ - /* sys_closesocket(sockfd); */ - /* sockfd = -1; */ - /* } */ - /* else */ - /* { */ - /* sys_addpollfn(sockfd, (t_fdpollfn)dumpOSC_connectpoll, x); */ - /* x->x_connectout = outlet_new(&x->x_obj, &s_float); */ - /* } */ - /* } */ - - x->x_connectsocket = sockfd; - x->x_server = server; - x->x_clilen = clilen; - x->x_nconnections = 0; - x->x_udp = udp; - - return (x); -} - -static void dumpOSC_free(t_dumpOSC *x) -{ - /* LATER make me clean up open connections */ - if (x->x_connectsocket >= 0) - { - sys_rmpollfn(x->x_connectsocket); - sys_closesocket(x->x_connectsocket); - } -} - -#ifdef WIN32 -OSC_API void dumpOSC_setup(void) -#else -void dumpOSC_setup(void) -#endif -{ - dumpOSC_class = class_new(gensym("dumpOSC"), - (t_newmethod)dumpOSC_new, (t_method)dumpOSC_free, - sizeof(t_dumpOSC), CLASS_NOINLET, A_DEFFLOAT, A_DEFFLOAT, - A_DEFSYM, 0); - class_sethelpsymbol(dumpOSC_class, gensym("dumpOSC-help.pd")); -} - - -#ifndef WIN32 - #define UNIXDG_PATH "/tmp/htm" - #define UNIXDG_TMP "/tmp/htm.XXXXXX" - static int unixinitudp(int chan) - { - struct sockaddr_un serv_addr; - int sockfd; - - if((sockfd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) - return sockfd; - - bzero((char *)&serv_addr, sizeof(serv_addr)); - serv_addr.sun_family = AF_UNIX; - strcpy(serv_addr.sun_path, UNIXDG_PATH); - sprintf(serv_addr.sun_path+strlen(serv_addr.sun_path), "%d", chan); - unlink(serv_addr.sun_path); - if(bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr.sun_family)+strlen(serv_addr.sun_path)) < 0) - { - perror("unable to bind\n"); - return -1; - } - - fcntl(sockfd, F_SETFL, FNDELAY); - return sockfd; - } -#endif // #ifndef WIN32 - - - -static int initudp(int chan) -{ - -#ifdef WIN32 - struct sockaddr_in serv_addr; - unsigned int sockfd; - ULONG nonBlocking = (ULONG) TRUE; - - if( (sockfd = socket(AF_INET, SOCK_DGRAM, 0)) != INVALID_SOCKET ) { - ZeroMemory((char *)&serv_addr, sizeof(serv_addr)); - serv_addr.sin_family = AF_INET; - serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); - serv_addr.sin_port = htons(chan); - if(bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) >= 0) { - // set for non-blocking mode - if(ioctlsocket(sockfd, FIONBIO, &nonBlocking) == SOCKET_ERROR) { - perror("unable to set non-blocking\n"); - return -1; - } - } - else { perror("unable to bind\n"); return -1; } - } - return (sockfd == INVALID_SOCKET ? -1 : (int)sockfd); -#else - struct sockaddr_in serv_addr; - int sockfd; - - if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) - return sockfd; - - bzero((char *)&serv_addr, sizeof(serv_addr)); - serv_addr.sin_family = AF_INET; - serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); - serv_addr.sin_port = htons(chan); - - if(bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) - { - perror("unable to bind\n"); - return -1; - } - - fcntl(sockfd, F_SETFL, FNDELAY); - return sockfd; -#endif -} - - - - - - - - -static void closeudp(int sockfd) { - #ifdef WIN32 - closesocket(sockfd); - #else - close(sockfd); - #endif -} - -static Boolean catchupflag=FALSE; -Boolean ClientReply(int packetsize, void *packet, int socketfd, - void *clientaddresspointer, int clientaddressbufferlength) -{ - if(!clientaddresspointer) return FALSE; - catchupflag= TRUE; - return packetsize==sendto(socketfd, packet, packetsize, 0, clientaddresspointer, clientaddressbufferlength); -} - -static Boolean exitflag= FALSE; -void sgi_CleanExit(void) { - exitflag = TRUE; -} - -Boolean sgi_HaveToQuit(void) { - return exitflag; -} - - -/* file descriptor poll table */ -static int npolldevs =0; -typedef struct polldev -{ - int fd; - void (*callbackfunction)(int , void *); - void *dummy; -} polldev; -#define TABMAX 8 -static polldev polldevs[TABMAX]; - - -/* Register a device (referred to by a file descriptor that the caller - should have already successfully obtained from a system call) to be - polled as real-time constraints allowed. - - When a select(2) call indicates activity on the file descriptor, the - callback function is called with the file descripter as first - argument and the given dummy argument (presumably a pointer to the - instance variables associated with the device). -*/ -int RegisterPollingDevice(int fd, void (*callbackfunction)(int , void *), void *dummy) -{ - if(npolldevscl_addr.sin_addr.s_addr; - printf("Client address %p:\n", CA); - printf(" clilen %d, sockfd %d\n", CA->clilen, CA->sockfd); - printf(" sin_family %d, sin_port %d\n", CA->cl_addr.sin_family, - CA->cl_addr.sin_port); - printf(" address: (%x) %s\n", addr, inet_ntoa(CA->cl_addr.sin_addr)); - - printf(" sin_zero = \"%c%c%c%c%c%c%c%c\"\n", - CA->cl_addr.sin_zero[0], - CA->cl_addr.sin_zero[1], - CA->cl_addr.sin_zero[2], - CA->cl_addr.sin_zero[3], - CA->cl_addr.sin_zero[4], - CA->cl_addr.sin_zero[5], - CA->cl_addr.sin_zero[6], - CA->cl_addr.sin_zero[7]); - - printf("\n"); -} - -//******************* - -void WriteTime(char* dst, osc_time_t osctime) -{ - *(int32_t*)dst = htonl((int32_t)(osctime >> 32)); - *(int32_t*)(dst+4) = htonl((int32_t)osctime); -} - -void WriteMode(char* dst) -{ - *(int32_t*)dst = htonl(0); -} - -osc_time_t ReadTime(const char* src) -{ - osc_time_t osctime = ntohl(*(int32_t*)src); - return (osctime << 32) + ntohl(*(int32_t*)(src+4)); -} - -double TimeToSeconds(osc_time_t osctime) -{ - return (double)osctime * 2.3283064365386962890625e-10 /* 1/2^32 */; -} - -int timeRound(double x) -{ - return x >= 0.0 ? x+0.5 : x-0.5; -} -/* -void WriteLogicalTime(char* dst) -{ - static double startTime = -1.0; - double sTime; - - // Initialisierung der Startzeit. - // Knnte effizienter (ohne 'if') auch irgendwo vorher passieren. - // Knnte wahrscheinlich auch 0.0 sein. - if (startTime < 0.0) { - startTime = clock_getlogicaltime(); - } - - sTime = clock_gettimesince(startTime) * 0.001; - *(int32_t*)dst = hton'K l((int32_t)sTime); - *(int32_t*)(dst+4) = htonl((int32_t)(4294967296.0 * sTime)); -} -*/ - -void WriteLogicalTime(char* dst) -{ - double sTime = clock_gettimesince(19230720) / 1000.0; - double tau = sTime - timeRound(sTime); - - //fprintf(stderr, "sSec = %f tau = %f\n", sTime, tau); - - *(int32_t*)dst = htonl((int32_t)(sTime)); - *(int32_t*)(dst+4) = htonl((int32_t)(4294967296 * tau)); -} - -Boolean dumpOSC_SendReply(char *buf, int n, void *clientDesc, int clientDescLenght, int fd) -{ - if((n == 24) && (strcmp(buf, "#time") == 0)) - { - osc_time_t t0, t1, t2; - double dt0, dt1, dt2; - - WriteMode(buf+6); - - t0 = ReadTime(buf+8); - - WriteLogicalTime(buf+16); - t1 = ReadTime(buf+16); // reverse - dt0 = TimeToSeconds(t0); // client time - dt1 = TimeToSeconds(t1); // server time - - // fprintf(stderr, "%f\t%f\t%f\n", dt0, dt1, dt0 - dt1); - - sendto(fd, buf, n, 0, (struct sockaddr *)clientDesc, clientDescLenght); - return TRUE; - } - else - { - return FALSE; - } -} - -//********************** - -void dumpOSC_ParsePacket(t_dumpOSC *x, char *buf, int n, ClientAddr returnAddr) { - // t_dumpOSC *x; - int size, messageLen, i; - char *messageName; - char *args; - - //#ifdef PRINTADDRS - #ifdef DEBUG - //PrintClientAddr(returnAddr); - #endif - - - if ((n%4) != 0) { - complain("SynthControl packet size (%d) not a multiple of 4 bytes: dropping", n); - return; - } - - if ((n >= 8) && (strncmp(buf, "#bundle", 8) == 0)) { - /* This is a bundle message. */ - #ifdef DEBUG - printf("dumpOSC_ParsePacket: bundle msg: bundles not yet supported\n"); - #endif - - if (n < 16) { - complain("Bundle message too small (%d bytes) for time tag", n); - return; - } - - /* Print the time tag */ - #ifdef DEBUG - printf("[ %lx%08lx\n", ntohl(*((unsigned long *)(buf+8))), ntohl(*((unsigned long *)(buf+12)))); - #endif - - /* Note: if we wanted to actually use the time tag as a little-endian - 64-bit int, we'd have to word-swap the two 32-bit halves of it */ - - i = 16; /* Skip "#group\0" and time tag */ - - while(i n) { - complain("Bad size count %d in bundle (only %d bytes left in entire bundle)", - size, n-i-4); - return; - } - - /* Recursively handle element of bundle */ - dumpOSC_ParsePacket(x, buf+i+4, size, returnAddr); - i += 4 + size; - } - - if (i != n) { - complain("This can't happen"); - } - #ifdef DEBUG - printf("]\n"); - #endif - - } - else if ((n == 24) && (strcmp(buf, "#time") == 0)) - { - complain("Time message: %s\n :).\n", htm_error_string); - return; - - } - else - { - /* This is not a bundle message */ - - messageName = buf; - args = DataAfterAlignedString(messageName, buf+n); - if (args == 0) { - complain("Bad message name string: %s\nDropping entire message.\n", - htm_error_string); - return; - } - messageLen = args-messageName; - dumpOSC_Smessage(x, messageName, (void *)args, n-messageLen, returnAddr); - } -} - -#define SMALLEST_POSITIVE_FLOAT 0.000001f - -static void dumpOSC_Smessage(t_dumpOSC *x, char *address, void *v, int n, ClientAddr returnAddr) { - char *chars = v; - t_atom at; - //t_atom myargv[50]; - - int myargc = x->x_outatc; - t_atom* mya = x->x_outat; - int myi; - -#ifdef DEBUG - printf("%s ", address); -#endif - - // ztoln+cvt from envgen.c, ggee-0.18 .. - // outlet_anything's 'symbol' gets set to address - // so we dont need to append address to the atomlist - /* - SETSYMBOL(mya,gensym(address));myargc++; - x->x_outatc = myargc; - */ - - if (n != 0) { - if (chars[0] == ',') { - if (chars[1] != ',') { - /* This message begins with a type-tag string */ - dumpOSC_PrintTypeTaggedArgs(x, v, n); - } else { - /* Double comma means an escaped real comma, not a type string */ - dumpOSC_PrintHeuristicallyTypeGuessedArgs(x, v, n, 1); - } - } else { - dumpOSC_PrintHeuristicallyTypeGuessedArgs(x, v, n, 0); - } - } - - outlet_anything(x->x_msgout,gensym(address),x->x_outatc,(t_atom*)&x->x_outat); - x->x_outatc = 0; -#ifdef DEBUG - printf("\n"); -#endif - fflush(stdout); /* Added for Sami 5/21/98 */ -} - -static void dumpOSC_PrintTypeTaggedArgs(t_dumpOSC *x, void *v, int n) { - char *typeTags, *thisType; - char *p; - - int myargc = x->x_outatc; - t_atom* mya = x->x_outat; - int myi; - - typeTags = v; - - if (!IsNiceString(typeTags, typeTags+n)) { - /* No null-termination, so maybe it wasn't a type tag - string after all */ - dumpOSC_PrintHeuristicallyTypeGuessedArgs(x, v, n, 0); - return; - } - - p = DataAfterAlignedString(typeTags, typeTags+n); - - - for (thisType = typeTags + 1; *thisType != 0; ++thisType) { - switch (*thisType) { - case 'i': case 'r': case 'm': case 'c': -#ifdef DEBUG - //post("integer: %d", ntohl(*((int *) p))); -#endif - /* Martin Peach fix for negative floats: - * was: SETFLOAT(mya+myargc,ntohl(*((int *) p))); - * now is: - */ - SETFLOAT(mya+myargc,(signed)ntohl(*((int *) p))); - myargc++; - - p += 4; - break; - - case 'f': { - int i = ntohl(*((int *) p)); - float *floatp = ((float *) (&i)); -#ifdef DEBUG - post("float: %f", *floatp); -#endif - SETFLOAT(mya+myargc,*floatp); - myargc++; - - p += 4; - } - break; - - case 'h': case 't': -#ifdef DEBUG - printf("[A 64-bit int] "); -#endif - post("[A 64-bit int] not implemented"); - - p += 8; - break; - - case 'd': -#ifdef DEBUG - printf("[A 64-bit float] "); -#endif - post("[A 64-bit float] not implemented"); - - p += 8; - break; - - case 's': case 'S': - if (!IsNiceString(p, typeTags+n)) { - post("Type tag said this arg is a string but it's not!\n"); - return; - } else { -#ifdef DEBUG - post("string: \"%s\"", p); -#endif - SETSYMBOL(mya+myargc,gensym(p)); - myargc++; - //outlet_list(x->x_msgout, 0,sizeof(p), p); - //outlet_anything(x->x_msgout, 0, sizeof(p), p); - p = DataAfterAlignedString(p, typeTags+n); - // append to output vector .. - } - break; - - case 'T': -#ifdef DEBUG - printf("[True] "); -#endif - SETFLOAT(mya+myargc,1.); - myargc++; - break; - case 'F': -#ifdef DEBUG - printf("[False] "); -#endif - SETFLOAT(mya+myargc,0.); - myargc++; - break; - case 'N': -#ifdef DEBUG - printf("[Nil]"); -#endif - post("sendOSC: [Nil] not implemented"); - break; - case 'I': -#ifdef DEBUG - printf("[Infinitum]"); -#endif - post("sendOSC: [Infinitum] not implemented"); - break; - - default: - post("sendOSC: [Unrecognized type tag %c]", *thisType); - // return; - } - } - x->x_outatc = myargc; -} - -static void dumpOSC_PrintHeuristicallyTypeGuessedArgs(t_dumpOSC *x, void *v, int n, int skipComma) { - int i, thisi; - float thisf; - int *ints; - char *chars; - char *string, *nextString; - - int myargc= x->x_outatc; - t_atom* mya = x->x_outat; - int myi; - - - /* Go through the arguments 32 bits at a time */ - ints = v; - chars = v; - - for (i = 0; i= -1000 && thisi <= 1000000) { -#ifdef DEBUG - printf("%d ", thisi); -#endif - // append to output vector .. - SETFLOAT(mya+myargc,(t_float) (thisi)); - myargc++; - // outlet_float(x->x_msgout, thisi); - i++; - } else if (thisf >= -1000.f && thisf <= 1000000.f && - (thisf <=0.0f || thisf >= SMALLEST_POSITIVE_FLOAT)) { -#ifdef DEBUG - printf("%f ", thisf); -#endif - // append to output vector .. - SETFLOAT(mya+myargc,thisf); - myargc++; - //outlet_float(x->x_msgout, thisf); - i++; - } else if (IsNiceString(string, chars+n)) { - nextString = DataAfterAlignedString(string, chars+n); -#ifdef DEBUG - printf("\"%s\" ", (i == 0 && skipComma) ? string +1 : string); -#endif - // append to output vector .. - SETSYMBOL(mya+myargc,gensym(string)); - myargc++; - //outlet_symbol(x->x_msgout, gensym((i == 0 && skipComma) ? string +1 : string)); - i += (nextString-string) / 4; - } else { - // unhandled .. ;) -#ifdef DEBUG - printf("0x%x xx", ints[i]); -#endif - i++; - } - x->x_outatc = myargc; - } -} - - -#define STRING_ALIGN_PAD 4 - -char *DataAfterAlignedString(char *string, char *boundary) -{ - /* The argument is a block of data beginning with a string. The - string has (presumably) been padded with extra null characters - so that the overall length is a multiple of STRING_ALIGN_PAD - bytes. Return a pointer to the next byte after the null - byte(s). The boundary argument points to the character after - the last valid character in the buffer---if the string hasn't - ended by there, something's wrong. - - If the data looks wrong, return 0, and set htm_error_string */ - - int i; - - if ((boundary - string) %4 != 0) { - fprintf(stderr, "Internal error: DataAfterAlignedString: bad boundary\n"); - return 0; - } - - for (i = 0; string[i] != '\0'; i++) { - if (string + i >= boundary) { - htm_error_string = "DataAfterAlignedString: Unreasonably long string"; - return 0; - } - } - - /* Now string[i] is the first null character */ - i++; - - for (; (i % STRING_ALIGN_PAD) != 0; i++) { - if (string + i >= boundary) { - htm_error_string = "DataAfterAlignedString: Unreasonably long string"; - return 0; - } - if (string[i] != '\0') { - htm_error_string = "DataAfterAlignedString: Incorrectly padded string."; - return 0; - } - } - - return string+i; -} - -Boolean IsNiceString(char *string, char *boundary) -{ - /* Arguments same as DataAfterAlignedString(). Is the given "string" - really a string? I.e., is it a sequence of isprint() characters - terminated with 1-4 null characters to align on a 4-byte boundary? */ - - int i; - - if ((boundary - string) %4 != 0) { - fprintf(stderr, "Internal error: IsNiceString: bad boundary\n"); - return 0; - } - - for (i = 0; string[i] != '\0'; i++) { - if (!isprint(string[i])) return FALSE; - if (string + i >= boundary) return FALSE; - } - - /* If we made it this far, it's a null-terminated sequence of printing characters - in the given boundary. Now we just make sure it's null padded... */ - - /* Now string[i] is the first null character */ - i++; - for (; (i % STRING_ALIGN_PAD) != 0; i++) { - if (string[i] != '\0') return FALSE; - } - - return TRUE; -} - - - - - - - - - -#include -void complain(char *s, ...) { - va_list ap; - va_start(ap, s); - fprintf(stderr, "*** ERROR: "); - vfprintf(stderr, s, ap); - fprintf(stderr, "\n"); - va_end(ap); -} - -#endif /* __sgi or LINUX or WIN32 */ - diff --git a/apps/plugins/pdbox/PDa/extra/fatom.h b/apps/plugins/pdbox/PDa/extra/fatom.h deleted file mode 100644 index a7a153fad3..0000000000 --- a/apps/plugins/pdbox/PDa/extra/fatom.h +++ /dev/null @@ -1,486 +0,0 @@ -/* ------------------------ fatom ----------------------------- */ - -#define x_val a_pos.a_w.w_float -#define DEBUG(x) - -#include -#include - -typedef struct _fatom -{ - t_object x_obj; - t_atom a_pos; /* the value of the fatom */ - - t_symbol* x_send; - t_symbol* x_receive; - t_glist * x_glist; /* value of the current canvas, intialized in _new */ - int x_rect_width; /* width of the widget */ - int x_rect_height; /* height of the widget */ - t_symbol* x_sym; /* symbol for receiving callbacks from GUI */ - t_symbol* x_type; /* type of fatom (vslider, hslider, checkbutton) */ - - t_symbol* x_text; /* associated widget text */ - int x_max; /* maximum value of a_pos (x_val) */ - int x_min; /* minimum value of a_pos (x_val) */ - int x_width; /* width of widget (e.g x_rect_height + 15 for hslider, x_rect_width + 15 for slider) */ - t_symbol* x_color; - t_symbol* x_bgcolor; -} t_fatom; - -/* widget helper functions */ - - - - -static void draw_inlets(t_fatom *x, t_glist *glist, int firsttime, int nin, int nout) -{ - int n = nin; - int nplus, i; - nplus = (n == 1 ? 1 : n-1); - DEBUG(post("draw inlet");) - for (i = 0; i < n; i++) - { - int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH) * i / nplus; - if (firsttime) - sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xo%d\n", - glist_getcanvas(glist), - onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 1, - onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height, - x, i); - else - sys_vgui(".x%x.c coords %xo%d %d %d %d %d\n", - glist_getcanvas(glist), x, i, - onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 1, - onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height); - } - n = nout; - nplus = (n == 1 ? 1 : n-1); - for (i = 0; i < n; i++) - { - int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH) * i / nplus; - if (firsttime) - sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xi%d\n", - glist_getcanvas(glist), - onset, text_ypix(&x->x_obj, glist), - onset + IOWIDTH, text_ypix(&x->x_obj, glist) + 1, - x, i); - else - sys_vgui(".x%x.c coords %xi%d %d %d %d %d\n", - glist_getcanvas(glist), x, i, - onset, text_ypix(&x->x_obj, glist), - onset + IOWIDTH, text_ypix(&x->x_obj, glist) + 1); - - } - DEBUG(post("draw inlet end");) -} - - -static void draw_handle(t_fatom *x, t_glist *glist, int firsttime) { - int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH+2); - - if (firsttime) - sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xhandle\n", - glist_getcanvas(glist), - onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 12, - onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height-4, - x); - else - sys_vgui(".x%x.c coords %xhandle %d %d %d %d\n", - glist_getcanvas(glist), x, - onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 12, - onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height-4); -} - -static void create_widget(t_fatom *x, t_glist *glist) -{ - t_canvas *canvas=glist_getcanvas(glist); - - if (!strcmp(x->x_type->s_name,"vslider")) { - x->x_rect_width = x->x_width+15; - x->x_rect_height = x->x_max-x->x_min+26; - - sys_vgui("scale .x%x.c.s%x \ - -sliderlength 10 \ - -showvalue 0 \ - -length %d \ - -resolution 0.01 \ - -repeatinterval 20 \ - -from %d -to %d \ - -width %d \ - -bg %s \ - -activebackground %s \ - -troughcolor %s \ - -command fatom_cb%x\n",canvas,x, - x->x_max-x->x_min+14, - x->x_max, - x->x_min, - x->x_width, - x->x_color->s_name, - x->x_color->s_name, - x->x_bgcolor->s_name, - x); - } else if (!strcmp(x->x_type->s_name,"hslider")) { - x->x_rect_width = x->x_max-x->x_min + 24; - x->x_rect_height = x->x_width + 15; - sys_vgui("scale .x%x.c.s%x \ - -sliderlength 10 \ - -showvalue 0 \ - -length %d \ - -resolution 0.01 \ - -orient horizontal \ - -repeatinterval 20 \ - -from %d -to %d \ - -width %d \ - -bg %s \ - -activebackground %s \ - -troughcolor %s \ - -command fatom_cb%x\n",canvas,x, - x->x_max-x->x_min+14, - x->x_min, - x->x_max, - x->x_width, - x->x_color->s_name, - x->x_color->s_name, - x->x_bgcolor->s_name, - x); - } else if (!strcmp(x->x_type->s_name,"checkbutton")) { - x->x_rect_width = 32; - x->x_rect_height = 28; - sys_vgui("checkbutton .x%x.c.s%x \ - -command { fatom_cb%x $fatom_val%x} -variable fatom_val%x -text \"%s\" \ - -bg %s \ - -activebackground %s \ - \n",canvas,x,x,x,x, - x->x_text->s_name, - x->x_color->s_name, - x->x_bgcolor->s_name); - } else if (!strcmp(x->x_type->s_name,"hradio")) { - int i; - x->x_rect_width = 8*20; - x->x_rect_height = 25; - for (i=0;i<8;i++) { - sys_vgui("radiobutton .x%x.c.s%x%d \ - -command { fatom_cb%x $fatom_val%x} -variable fatom_val%x -value %d\n",canvas,x,i,x,x,x,i); - } - /* TODO pack them */ - } else if (!strcmp(x->x_type->s_name,"vradio")) { - int i; - x->x_rect_width = 30; - x->x_rect_height = 20*8+5; - for (i=0;i<8;i++) { - sys_vgui("radiobutton .x%x.c.s%x%d \ - -command { fatom_cb%x $fatom_val%x} -variable fatom_val%x -value %d\n",canvas,x,i,x,x,x,i); - } - /* TODO pack them */ - } else { - x->x_rect_width = 32; - x->x_rect_height = 140; - sys_vgui("scale .x%x.c.s%x \ - -sliderlength 10 \ - -showvalue 0 \ - -length 131 \ - -from 127 -to 0 \ - -command fatom_cb%x\n",canvas,x,x); - } - - /* set the start value */ - if (!strcmp(x->x_type->s_name,"checkbutton")) { - if (x->x_val) - sys_vgui(".x%x.c.s%x select\n",canvas,x,x->x_val); - else - sys_vgui(".x%x.c.s%x deselect\n",canvas,x,x->x_val); - } else - sys_vgui(".x%x.c.s%x set %f\n",canvas,x,x->x_val); - -} - - - - - -static void fatom_drawme(t_fatom *x, t_glist *glist, int firsttime) -{ - t_canvas *canvas=glist_getcanvas(glist);// x->x_glist;//glist_getcanvas(glist); - DEBUG(post("drawme %d",firsttime);) - if (firsttime) { - DEBUG(post("glist %x canvas %x",x->x_glist,canvas)); - create_widget(x,glist); - x->x_glist = canvas; - sys_vgui(".x%x.c create window %d %d -anchor nw -window .x%x.c.s%x -tags %xS\n", - canvas,text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)+2,x->x_glist,x,x); - - } - else { - sys_vgui(".x%x.c coords %xS \ -%d %d\n", - canvas, x, - text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)+2); - } - draw_inlets(x, glist, firsttime, 1,1); - // draw_handle(x, glist, firsttime); - -} - - -static void fatom_erase(t_fatom* x,t_glist* glist) -{ - int n; - - DEBUG(post("erase");) - sys_vgui("destroy .x%x.c.s%x\n",glist_getcanvas(glist),x); - - sys_vgui(".x%x.c delete %xS\n",glist_getcanvas(glist), x); - - /* inlets and outlets */ - - sys_vgui(".x%x.c delete %xi%d\n",glist_getcanvas(glist),x,0); - sys_vgui(".x%x.c delete %xo%d\n",glist_getcanvas(glist),x,0); - sys_vgui(".x%x.c delete %xhandle\n",glist_getcanvas(glist),x,0); -} - - - -/* ------------------------ fatom widgetbehaviour----------------------------- */ - - -static void fatom_getrect(t_gobj *z, t_glist *owner, - int *xp1, int *yp1, int *xp2, int *yp2) -{ - int width, height; - t_fatom* s = (t_fatom*)z; - - width = s->x_rect_width; - height = s->x_rect_height; - *xp1 = text_xpix(&s->x_obj, owner); - *yp1 = text_ypix(&s->x_obj, owner); - *xp2 = text_xpix(&s->x_obj, owner) + width; - *yp2 = text_ypix(&s->x_obj, owner) + height; -} - -static void fatom_displace(t_gobj *z, t_glist *glist, - int dx, int dy) -{ - t_fatom *x = (t_fatom *)z; - DEBUG(post("displace");) - x->x_obj.te_xpix += dx; - x->x_obj.te_ypix += dy; - if (glist_isvisible(glist)) - { - sys_vgui(".x%x.c coords %xSEL %d %d %d %d\n", - glist_getcanvas(glist), x, - text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), - text_xpix(&x->x_obj, glist) + x->x_rect_width, text_ypix(&x->x_obj, glist) + x->x_rect_height); - - fatom_drawme(x, glist, 0); - canvas_fixlinesfor(glist_getcanvas(glist),(t_text*) x); - } - DEBUG(post("displace end");) -} - -static void fatom_select(t_gobj *z, t_glist *glist, int state) -{ - t_fatom *x = (t_fatom *)z; - if (state) { - sys_vgui(".x%x.c create rectangle \ -%d %d %d %d -tags %xSEL -outline blue\n", - glist_getcanvas(glist), - text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), - text_xpix(&x->x_obj, glist) + x->x_rect_width, text_ypix(&x->x_obj, glist) + x->x_rect_height, - x); - } - else { - sys_vgui(".x%x.c delete %xSEL\n", - glist_getcanvas(glist), x); - } - - - -} - - -static void fatom_activate(t_gobj *z, t_glist *glist, int state) -{ -/* t_text *x = (t_text *)z; - t_rtext *y = glist_findrtext(glist, x); - if (z->g_pd != gatom_class) rtext_activate(y, state);*/ -} - -static void fatom_delete(t_gobj *z, t_glist *glist) -{ - t_text *x = (t_text *)z; - canvas_deletelinesfor(glist_getcanvas(glist), x); -} - - -static void fatom_vis(t_gobj *z, t_glist *glist, int vis) -{ - t_fatom* s = (t_fatom*)z; - t_rtext *y; - DEBUG(post("vis: %d",vis);) - if (vis) { -#ifdef PD_MINOR_VERSION - y = (t_rtext *) rtext_new(glist, (t_text *)z); -#else - y = (t_rtext *) rtext_new(glist, (t_text *)z,0,0); -#endif - fatom_drawme(s, glist, 1); - } - else { - y = glist_findrtext(glist, (t_text *)z); - fatom_erase(s,glist); - rtext_free(y); - } -} - -static void fatom_save(t_gobj *z, t_binbuf *b); - -t_widgetbehavior fatom_widgetbehavior; - - - - -static void fatom_size(t_fatom* x,t_floatarg w,t_floatarg h) { - x->x_rect_width = w; - x->x_rect_height = h; -} - -static void fatom_color(t_fatom* x,t_symbol* col) -{ - -} - - -static void fatom_f(t_fatom* x,t_floatarg f) -{ - x->x_val = f; - if (x->x_send == &s_) - outlet_float(x->x_obj.ob_outlet,f); - else - if (x->x_send->s_thing) pd_float(x->x_send->s_thing,f); -} - - -static void fatom_float(t_fatom* x,t_floatarg f) -{ - if (glist_isvisible(x->x_glist)) { - if (!strcmp(x->x_type->s_name,"checkbutton")) { - if (x->x_val) - sys_vgui(".x%x.c.s%x select\n",x->x_glist,x,f); - else - sys_vgui(".x%x.c.s%x deselect\n",x->x_glist,x,f); - } else - sys_vgui(".x%x.c.s%x set %f\n",x->x_glist,x,f); - } - fatom_f(x,f); -} - - -static void fatom_bang(t_fatom* x,t_floatarg f) -{ - outlet_float(x->x_obj.ob_outlet,x->x_val); -} - - -static void fatom_properties(t_gobj *z, t_glist *owner) -{ - post("N/I"); -} - - -static void fatom_save(t_gobj *z, t_binbuf *b) -{ - - t_fatom *x = (t_fatom *)z; - - binbuf_addv(b, "ssiiss", gensym("#X"),gensym("obj"), - x->x_obj.te_xpix, x->x_obj.te_ypix , - gensym("fatom"),x->x_type); - binbuf_addv(b, ";"); -} - - -static void *fatom_new(t_fatom* x,int argc,t_atom* argv) -{ - char buf[256]; - int n = 0; - x->x_glist = canvas_getcurrent(); - - x->x_text = gensym(""); - x->x_max = 127; - x->x_min = 0; - x->x_width = 15; - x->x_color = gensym("grey"); - x->x_bgcolor = gensym("grey"); - x->x_send = &s_; - - while (argc) { - if (argv->a_type == A_FLOAT) { - if (n==0) x->x_max = atom_getfloat(argv); - if (n==1) x->x_min = atom_getfloat(argv); - if (n==2) x->x_width = atom_getfloat(argv); - } - - if (argv->a_type == A_SYMBOL) { - post("%d: symbol value %s",n,atom_getsymbol(argv)->s_name); - if (n==3) x->x_send = atom_getsymbol(argv); - if (n==4) x->x_color = atom_getsymbol(argv); - if (n==5) x->x_bgcolor = atom_getsymbol(argv); - } - argv++; - argc--; - n++; - } - - /* bind to a symbol for slider callback (later make this based on the - filepath ??) */ - - sprintf(buf,"fatom%x",(t_int)x); - x->x_sym = gensym(buf); - pd_bind(&x->x_obj.ob_pd, x->x_sym); - - /* pipe startup code to tk */ - - sys_vgui("proc fatom_cb%x {v} {\n pd [concat fatom%x f $v \\;]\n }\n",x,x); - - outlet_new(&x->x_obj, &s_float); - return (x); -} - -static void fatom_setup_common(t_class* class) -{ - - fatom_widgetbehavior.w_getrectfn = fatom_getrect; - fatom_widgetbehavior.w_displacefn = fatom_displace; - fatom_widgetbehavior.w_selectfn = fatom_select; - fatom_widgetbehavior.w_activatefn = fatom_activate; - fatom_widgetbehavior.w_deletefn = fatom_delete; - fatom_widgetbehavior.w_visfn = fatom_vis; -#if PD_MINOR_VERSION < 37 - fatom_widgetbehavior.w_savefn = fatom_save; - fatom_widgetbehavior.w_propertiesfn = NULL; -#endif - fatom_widgetbehavior.w_clickfn = NULL; - - class_addfloat(class, (t_method)fatom_float); - class_addbang(class, (t_method)fatom_bang); - class_addmethod(class, (t_method)fatom_f, gensym("f"), - A_FLOAT, 0); - -/* - class_addmethod(class, (t_method)fatom_size, gensym("size"), - A_FLOAT, A_FLOAT, 0); - - class_addmethod(class, (t_method)fatom_color, gensym("color"), - A_SYMBOL, 0); -*/ -/* - class_addmethod(class, (t_method)fatom_open, gensym("open"), - A_SYMBOL, 0); -*/ - - class_setwidget(class,&fatom_widgetbehavior); -#if PD_MINOR_VERSION >= 37 - class_setsavefn(class,&fatom_save); -#endif -} - diff --git a/apps/plugins/pdbox/PDa/extra/gcanvas-help.pd b/apps/plugins/pdbox/PDa/extra/gcanvas-help.pd deleted file mode 100644 index 2844911261..0000000000 --- a/apps/plugins/pdbox/PDa/extra/gcanvas-help.pd +++ /dev/null @@ -1,9 +0,0 @@ -#N canvas 0 0 240 300 8; -#X obj 21 61 gcanvas 80 80; -#X text 14 9 gcanvas .. mouse coordinate enabled canvas; -#X text 13 22 ==========================================; -#X floatatom 21 148 5 0 0 0 - - -; -#X floatatom 94 147 5 0 0 0 - - -; -#X connect 0 0 3 0; -#X connect 0 1 4 0; - diff --git a/apps/plugins/pdbox/PDa/extra/makefile b/apps/plugins/pdbox/PDa/extra/makefile deleted file mode 100644 index 4bd6ed0960..0000000000 --- a/apps/plugins/pdbox/PDa/extra/makefile +++ /dev/null @@ -1,34 +0,0 @@ - -VERSION = 0.2 -SOURCE = $(shell ls *.c) -TARGETS = $(SOURCE:.c=.pd_linux) - -EXT= pd_linux - -AFLAGS = -g -O2 -I./ -DFIXEDPOINT -EFLAGS = -shared -Wl,-export-dynamic -PREFIX = /usr - - -all: $(TARGETS) - -clean: - -rm $(TARGETS) - -rm *.o *~ - -tar: clean - cd ..;tar czvf PDa-externals-$(VERSION).tgz PDa-externals - -upload: tar - scp ../PDa-externals-$(VERSION).tgz gige@xdv.org:~/www/pda/release - -install: - install -d $(DESTDIR)/$(PREFIX)/lib/pd/extra - cp $(TARGETS) $(DESTDIR)/$(PREFIX)/lib/pd/extra - -%.$(EXT) : %.o - $(CC) -o $@ $(EFLAGS) $+ - -%.o : %.c - $(CC) -c $(AFLAGS) $(CFLAGS) $+ - diff --git a/apps/plugins/pdbox/PDa/extra/sendOSC.c b/apps/plugins/pdbox/PDa/extra/sendOSC.c deleted file mode 100644 index 6bb809d68f..0000000000 --- a/apps/plugins/pdbox/PDa/extra/sendOSC.c +++ /dev/null @@ -1,1461 +0,0 @@ -/* -Written by Matt Wright, The Center for New Music and Audio Technologies, -University of California, Berkeley. Copyright (c) 1996,97,98,99,2000,01,02,03 -The Regents of the University of California (Regents). - -Permission to use, copy, modify, distribute, and distribute modified versions -of this software and its documentation without fee and without a signed -licensing agreement, is hereby granted, provided that the above copyright -notice, this paragraph and the following two paragraphs appear in all copies, -modifications, and distributions. - -IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, -SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING -OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS -BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED -HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE -MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - - -The OSC webpage is http://cnmat.cnmat.berkeley.edu/OpenSoundControl -*/ - - -/* sendOSC.c - - Matt Wright, 6/3/97 - based on sendOSC.c, which was based on a version by Adrian Freed - - Text-based OpenSoundControl client. User can enter messages via command - line arguments or standard input. - - Version 0.1: "play" feature - Version 0.2: Message type tags. - - pd version branched from http://www.cnmat.berkeley.edu/OpenSoundControl/src/sendOSC/sendOSC.c - ------------- - -- added bundle stuff to send. jdl 20020416 - -- tweaks for Win32 www.zeggz.com/raf 13-April-2002 - -- ost_at_test.at + i22_at_test.at, 2000-2002 - modified to compile as pd externel -*/ - -#define MAX_ARGS 2000 -#define SC_BUFFER_SIZE 64000 - -#include "../src/m_pd.h" -#include "OSC-client.h" - -#include -#include -#include -#include -#include -#include - -#ifdef WIN32 -#include -#include -#include -#include -#include -#include -#include -#else -#include -#include -#include -#include -#include -#include -#include -#include -#endif - -#ifdef __APPLE__ - #include -#endif - -#define UNIXDG_PATH "/tmp/htm" -#define UNIXDG_TMP "/tmp/htm.XXXXXX" - - - -OSCTimeTag OSCTT_Immediately(void) { - OSCTimeTag result; - result.seconds = 0; - result.fraction = 1; - return result; -} - - -OSCTimeTag OSCTT_CurrentTime(void) { - OSCTimeTag result; - result.seconds = 0; - result.fraction = 1; - return result; -} - -OSCTimeTag OSCTT_PlusSeconds(OSCTimeTag original, float secondsOffset) { - OSCTimeTag result; - result.seconds = 0; - result.fraction = 1; - return result; -} - - -typedef int bool; - -typedef struct -{ - float srate; - - struct sockaddr_in serv_addr; /* udp socket */ - #ifndef WIN32 - struct sockaddr_un userv_addr; /* UNIX socket */ - #endif - int sockfd; /* socket file descriptor */ - int index, len,uservlen; - void *addr; - int id; -} desc; - - -/* open a socket for HTM communication to given host on given portnumber */ -/* if host is 0 then UNIX protocol is used (i.e. local communication */ -void *OpenHTMSocket(char *host, int portnumber) -{ - struct sockaddr_in cl_addr; - #ifndef WIN32 - int sockfd; - struct sockaddr_un ucl_addr; - #else - unsigned int sockfd; - #endif - - desc *o; - int oval = 1; - o = malloc(sizeof(*o)); - if(!o) return 0; - - #ifndef WIN32 - - if(!host) - { - char *mktemp(char *); - int clilen; - o->len = sizeof(ucl_addr); - /* - * Fill in the structure "userv_addr" with the address of the - * server that we want to send to. - */ - - bzero((char *) &o->userv_addr, sizeof(o->userv_addr)); - o->userv_addr.sun_family = AF_UNIX; - strcpy(o->userv_addr.sun_path, UNIXDG_PATH); - sprintf(o->userv_addr.sun_path+strlen(o->userv_addr.sun_path), "%d", portnumber); - o->uservlen = sizeof(o->userv_addr.sun_family) + strlen(o->userv_addr.sun_path); - o->addr = &(o->userv_addr); - /* - * Open a socket (a UNIX domain datagram socket). - */ - - if ( (sockfd = socket(AF_UNIX, SOCK_DGRAM, 0)) >= 0) - { - /* - * Bind a local address for us. - * In the UNIX domain we have to choose our own name (that - * should be unique). We'll use mktemp() to create a unique - * pathname, based on our process id. - */ - - bzero((char *) &ucl_addr, sizeof(ucl_addr)); /* zero out */ - ucl_addr.sun_family = AF_UNIX; - strcpy(ucl_addr.sun_path, UNIXDG_TMP); - - mktemp(ucl_addr.sun_path); - clilen = sizeof(ucl_addr.sun_family) + strlen(ucl_addr.sun_path); - - if (bind(sockfd, (struct sockaddr *) &ucl_addr, clilen) < 0) - { - perror("client: can't bind local address"); - close(sockfd); - sockfd = -1; - } - } - else - perror("unable to make socket\n"); - - }else - - #endif - - { - /* - * Fill in the structure "serv_addr" with the address of the - * server that we want to send to. - */ - o->len = sizeof(cl_addr); - - #ifdef WIN32 - ZeroMemory((char *)&o->serv_addr, sizeof(o->serv_addr)); - #else - bzero((char *)&o->serv_addr, sizeof(o->serv_addr)); - #endif - - o->serv_addr.sin_family = AF_INET; - - /* MW 6/6/96: Call gethostbyname() instead of inet_addr(), - so that host can be either an Internet host name (e.g., - "les") or an Internet address in standard dot notation - (e.g., "128.32.122.13") */ - { - struct hostent *hostsEntry; - unsigned long address; - - hostsEntry = gethostbyname(host); - if (hostsEntry == NULL) { - fprintf(stderr, "Couldn't decipher host name \"%s\"\n", host); - #ifndef WIN32 - herror(NULL); - #endif - return 0; - } - address = *((unsigned long *) hostsEntry->h_addr_list[0]); - o->serv_addr.sin_addr.s_addr = address; - } - - /* was: o->serv_addr.sin_addr.s_addr = inet_addr(host); */ - - /* End MW changes */ - - /* - * Open a socket (a UDP domain datagram socket). - */ - - - #ifdef WIN32 - o->serv_addr.sin_port = htons((USHORT)portnumber); - o->addr = &(o->serv_addr); - if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) != INVALID_SOCKET) { - ZeroMemory((char *)&cl_addr, sizeof(cl_addr)); - cl_addr.sin_family = AF_INET; - cl_addr.sin_addr.s_addr = htonl(INADDR_ANY); - cl_addr.sin_port = htons(0); - - // enable broadcast: jdl ~2003 - if(setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &oval, sizeof(int)) == -1) { - perror("setsockopt"); - } - - if(bind(sockfd, (struct sockaddr *) &cl_addr, sizeof(cl_addr)) < 0) { - perror("could not bind\n"); - closesocket(sockfd); - sockfd = -1; - } - } - else { perror("unable to make socket\n");} - #else - o->serv_addr.sin_port = htons(portnumber); - o->addr = &(o->serv_addr); - if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) >= 0) { - bzero((char *)&cl_addr, sizeof(cl_addr)); - cl_addr.sin_family = AF_INET; - cl_addr.sin_addr.s_addr = htonl(INADDR_ANY); - cl_addr.sin_port = htons(0); - - // enable broadcast: jdl ~2003 - if(setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &oval, sizeof(int)) == -1) { - perror("setsockopt"); - } - - if(bind(sockfd, (struct sockaddr *) &cl_addr, sizeof(cl_addr)) < 0) { - perror("could not bind\n"); - close(sockfd); - sockfd = -1; - } - } - else { perror("unable to make socket\n");} - #endif - } - #ifdef WIN32 - if(sockfd == INVALID_SOCKET) { - #else - if(sockfd < 0) { - #endif - free(o); - o = 0; - } - else - o->sockfd = sockfd; - return o; -} - -static bool sendudp(const struct sockaddr *sp, int sockfd,int length, int count, void *b) -{ - int rcount; - if((rcount=sendto(sockfd, b, count, 0, sp, length)) != count) - { - printf("sockfd %d count %d rcount %dlength %d\n", sockfd,count,rcount,length); - return FALSE; - } - return TRUE; -} - -bool SendHTMSocket(void *htmsendhandle, int length_in_bytes, void *buffer) -{ - desc *o = (desc *)htmsendhandle; - return sendudp(o->addr, o->sockfd, o->len, length_in_bytes, buffer); -} -void CloseHTMSocket(void *htmsendhandle) -{ - desc *o = (desc *)htmsendhandle; - #ifdef WIN32 - if(SOCKET_ERROR == closesocket(o->sockfd)) { - perror("CloseHTMSocket::closesocket failed\n"); - return; - } - #else - if(close(o->sockfd) == -1) - { - perror("CloseHTMSocket::closesocket failed"); - return; - } - #endif - - free(o); -} - - -/////////////////////// -// from sendOSC - -typedef struct { - //enum {INT, FLOAT, STRING} type; - enum {INT_osc, FLOAT_osc, STRING_osc} type; - union { - int i; - float f; - char *s; - } datum; -} typedArg; - -void CommandLineMode(int argc, char *argv[], void *htmsocket); -OSCTimeTag ParseTimeTag(char *s); -void ParseInteractiveLine(OSCbuf *buf, char *mesg); -typedArg ParseToken(char *token); -int WriteMessage(OSCbuf *buf, char *messageName, int numArgs, typedArg *args); -void SendBuffer(void *htmsocket, OSCbuf *buf); -void SendData(void *htmsocket, int size, char *data); -/* defined in OSC-system-dependent.c now */ - -//static void *htmsocket; -static int exitStatus = 0; -static int useTypeTags = 0; - -static char bufferForOSCbuf[SC_BUFFER_SIZE]; - - -///////// -// end from sendOSC - -static t_class *sendOSC_class; - -typedef struct _sendOSC -{ - t_object x_obj; - int x_protocol; // UDP/TCP (udp only atm) - t_int x_typetags; // typetag flag - void *x_htmsocket; // sending socket - int x_bundle; // bundle open flag - OSCbuf x_oscbuf[1]; // OSCbuffer - t_outlet *x_bdpthout;// bundle-depth floatoutlet -} t_sendOSC; - -static void *sendOSC_new(t_floatarg udpflag) -{ - t_sendOSC *x = (t_sendOSC *)pd_new(sendOSC_class); - outlet_new(&x->x_obj, &s_float); - x->x_htmsocket = 0; // {{raf}} - // set udp - x->x_protocol = SOCK_STREAM; - // set typetags to 1 by default - x->x_typetags = 1; - // bunlde is closed - x->x_bundle = 0; - OSC_initBuffer(x->x_oscbuf, SC_BUFFER_SIZE, bufferForOSCbuf); - x->x_bdpthout = outlet_new(&x->x_obj, 0); // outlet_float(); - //x->x_oscbuf = - return (x); -} - - -void sendOSC_openbundle(t_sendOSC *x) -{ - if (x->x_oscbuf->bundleDepth + 1 >= MAX_BUNDLE_NESTING || - OSC_openBundle(x->x_oscbuf, OSCTT_Immediately())) - { - post("Problem opening bundle: %s\n", OSC_errorMessage); - return; - } - x->x_bundle = 1; - outlet_float(x->x_bdpthout, (float)x->x_oscbuf->bundleDepth); -} - -static void sendOSC_closebundle(t_sendOSC *x) -{ - if (OSC_closeBundle(x->x_oscbuf)) { - post("Problem closing bundle: %s\n", OSC_errorMessage); - return; - } - outlet_float(x->x_bdpthout, (float)x->x_oscbuf->bundleDepth); - // in bundle mode we send when bundle is closed? - if(!OSC_isBufferEmpty(x->x_oscbuf) > 0 && OSC_isBufferDone(x->x_oscbuf)) { - // post("x_oscbuf: something inside me?"); - if (x->x_htmsocket) { - SendBuffer(x->x_htmsocket, x->x_oscbuf); - } else { - post("sendOSC: not connected"); - } - OSC_initBuffer(x->x_oscbuf, SC_BUFFER_SIZE, bufferForOSCbuf); - x->x_bundle = 0; - return; - } - // post("x_oscbuf: something went wrong"); -} - -static void sendOSC_settypetags(t_sendOSC *x, t_float *f) - { - x->x_typetags = (int)f; - post("sendOSC.c: setting typetags %d",x->x_typetags); - } - - -static void sendOSC_connect(t_sendOSC *x, t_symbol *hostname, - t_floatarg fportno) -{ - int portno = fportno; - /* create a socket */ - - // make sure handle is available - if(x->x_htmsocket == 0) { - // - x->x_htmsocket = OpenHTMSocket(hostname->s_name, portno); - if (!x->x_htmsocket) - post("Couldn't open socket: "); - else { - post("connected to port %s:%d (hSock=%d)", hostname->s_name, portno, x->x_htmsocket); - outlet_float(x->x_obj.ob_outlet, 1); - } - } - else - perror("call to sendOSC_connect() against UNavailable socket handle"); -} - -void sendOSC_disconnect(t_sendOSC *x) -{ - if (x->x_htmsocket) - { - post("disconnecting htmsock (hSock=%d)...", x->x_htmsocket); - CloseHTMSocket(x->x_htmsocket); - x->x_htmsocket = 0; // {{raf}} semi-quasi-semaphorize this - outlet_float(x->x_obj.ob_outlet, 0); - } - else { - perror("call to sendOSC_disconnect() against unused socket handle"); - } -} - -void sendOSC_senduntyped(t_sendOSC *x, t_symbol *s, int argc, t_atom *argv) -{ - char* targv[MAXPDARG]; - char tmparg[MAXPDSTRING]; - char* tmp = tmparg; - //char testarg[MAXPDSTRING]; - int c; - - post("sendOSC: use typetags 0/1 message and plain send method so send untypetagged..."); - return; - - //atom_string(argv,testarg, MAXPDSTRING); - for (c=0;c= .. - if (x->x_htmsocket) - { - CommandLineMode(argc, targv, x->x_htmsocket); - // post("test %d", c); - } - else { - post("sendOSC: not connected"); - } -} - -////////////////////////////////////////////////////////////////////// -// this is the real and only sending routine now, for both typed and -// undtyped mode. - -static void sendOSC_sendtyped(t_sendOSC *x, t_symbol *s, int argc, t_atom *argv) -{ - char* targv[MAX_ARGS]; - char tmparg[MAXPDSTRING]; - char* tmp = tmparg; - int c; - - char *messageName; - char *token; - typedArg args[MAX_ARGS]; - int i,j; - int numArgs = 0; - - messageName = ""; -#ifdef DEBUG - post ("sendOSC: messageName: %s", messageName); -#endif - - - - for (c=0;c= .. - if (x->x_htmsocket > 0) - { -#ifdef DEBUG - post ("sendOSC: type tags? %d", useTypeTags); -#endif - - messageName = strtok(targv[0], ","); - j = 1; - for (i = j; i < argc; i++) { - token = strtok(targv[i],","); - args[i-j] = ParseToken(token); -#ifdef DEBUG - printf("cell-cont: %s\n", targv[i]); - printf(" type-id: %d\n", args[i-j]); -#endif - numArgs = i; - } - - - if(WriteMessage(x->x_oscbuf, messageName, numArgs, args)) { - post("sendOSC: usage error, write-msg failed: %s", OSC_errorMessage); - return; - } - - if(!x->x_bundle) { - SendBuffer(x->x_htmsocket, x->x_oscbuf); - OSC_initBuffer(x->x_oscbuf, SC_BUFFER_SIZE, bufferForOSCbuf); - } - - //CommandLineMode(argc, targv, x->x_htmsocket); - //useTypeTags = 0; - } - else { - post("sendOSC: not connected"); - } -} - -void sendOSC_send(t_sendOSC *x, t_symbol *s, int argc, t_atom *argv) -{ - if(!argc) { - post("not sending empty message."); - return; - } - if(x->x_typetags) { - useTypeTags = 1; - sendOSC_sendtyped(x,s,argc,argv); - useTypeTags = 0; - } else { - sendOSC_sendtyped(x,s,argc,argv); - } -} - -static void sendOSC_free(t_sendOSC *x) -{ - sendOSC_disconnect(x); -} - -#ifdef WIN32 - OSC_API void sendOSC_setup(void) { -#else - void sendOSC_setup(void) { -#endif - sendOSC_class = class_new(gensym("sendOSC"), (t_newmethod)sendOSC_new, - (t_method)sendOSC_free, - sizeof(t_sendOSC), 0, A_DEFFLOAT, 0); - class_addmethod(sendOSC_class, (t_method)sendOSC_connect, - gensym("connect"), A_SYMBOL, A_FLOAT, 0); - class_addmethod(sendOSC_class, (t_method)sendOSC_disconnect, - gensym("disconnect"), 0); - class_addmethod(sendOSC_class, (t_method)sendOSC_settypetags, - gensym("typetags"), - A_FLOAT, 0); - class_addmethod(sendOSC_class, (t_method)sendOSC_send, - gensym("send"), - A_GIMME, 0); - class_addmethod(sendOSC_class, (t_method)sendOSC_send, - gensym("senduntyped"), - A_GIMME, 0); - class_addmethod(sendOSC_class, (t_method)sendOSC_send, - gensym("sendtyped"), - A_GIMME, 0); - class_addmethod(sendOSC_class, (t_method)sendOSC_openbundle, - gensym("["), - 0, 0); - class_addmethod(sendOSC_class, (t_method)sendOSC_closebundle, - gensym("]"), - 0, 0); - class_sethelpsymbol(sendOSC_class, gensym("sendOSC-help.pd")); -} - - - - - -/* Exit status codes: - 0: successful - 2: Message(s) dropped because of buffer overflow - 3: Socket error - 4: Usage error - 5: Internal error -*/ - -void CommandLineMode(int argc, char *argv[], void *htmsocket) { - char *messageName; - char *token; - typedArg args[MAX_ARGS]; - int i,j, numArgs; - OSCbuf buf[1]; - - OSC_initBuffer(buf, SC_BUFFER_SIZE, bufferForOSCbuf); - - if (argc > 1) { - post("argc (%d) > 1", argc); - } - - // ParseInteractiveLine(buf, argv); - messageName = strtok(argv[0], ","); - - j = 1; - for (i = j; i < argc; i++) { - token = strtok(argv[i],","); - args[i-j] = ParseToken(token); -#ifdef DEBUG - printf("cell-cont: %s\n", argv[i]); - printf(" type-id: %d\n", args[i-j]); -#endif - numArgs = i; - } - - if(WriteMessage(buf, messageName, numArgs, args)) { - post("sendOSC: usage error. write-msg failed: %s", OSC_errorMessage); - return; - } - - SendBuffer(htmsocket, buf); -} - -#define MAXMESG 2048 - -void InteractiveMode(void *htmsocket) { - char mesg[MAXMESG]; - OSCbuf buf[1]; - int bundleDepth = 0; /* At first, we haven't seen "[". */ - - OSC_initBuffer(buf, SC_BUFFER_SIZE, bufferForOSCbuf); - - while (fgets(mesg, MAXMESG, stdin) != NULL) { - if (mesg[0] == '\n') { - if (bundleDepth > 0) { - /* Ignore blank lines inside a group. */ - } else { - /* blank line => repeat previous send */ - SendBuffer(htmsocket, buf); - } - continue; - } - - if (bundleDepth == 0) { - OSC_resetBuffer(buf); - } - - if (mesg[0] == '[') { - OSCTimeTag tt = ParseTimeTag(mesg+1); - if (OSC_openBundle(buf, tt)) { - post("Problem opening bundle: %s\n", OSC_errorMessage); - OSC_resetBuffer(buf); - bundleDepth = 0; - continue; - } - bundleDepth++; - } else if (mesg[0] == ']' && mesg[1] == '\n' && mesg[2] == '\0') { - if (bundleDepth == 0) { - post("Unexpected ']': not currently in a bundle.\n"); - } else { - if (OSC_closeBundle(buf)) { - post("Problem closing bundle: %s\n", OSC_errorMessage); - OSC_resetBuffer(buf); - bundleDepth = 0; - continue; - } - - bundleDepth--; - if (bundleDepth == 0) { - SendBuffer(htmsocket, buf); - } - } - } else { - ParseInteractiveLine(buf, mesg); - if (bundleDepth != 0) { - /* Don't send anything until we close all bundles */ - } else { - SendBuffer(htmsocket, buf); - } - } - } -} - -OSCTimeTag ParseTimeTag(char *s) { - char *p, *newline; - typedArg arg; - - p = s; - while (isspace(*p)) p++; - if (*p == '\0') return OSCTT_Immediately(); - - if (*p == '+') { - /* Time tag is for some time in the future. It should be a - number of seconds as an int or float */ - - newline = strchr(s, '\n'); - if (newline != NULL) *newline = '\0'; - - p++; /* Skip '+' */ - while (isspace(*p)) p++; - - arg = ParseToken(p); - if (arg.type == STRING_osc) { - post("warning: inscrutable time tag request: %s\n", s); - return OSCTT_Immediately(); - } else if (arg.type == INT_osc) { - return OSCTT_PlusSeconds(OSCTT_CurrentTime(), - (float) arg.datum.i); - } else if (arg.type == FLOAT_osc) { - return OSCTT_PlusSeconds(OSCTT_CurrentTime(), arg.datum.f); - } else { - error("This can't happen!"); - } - } - - if (isdigit(*p) || (*p >= 'a' && *p <='f') || (*p >= 'A' && *p <='F')) { - /* They specified the 8-byte tag in hex */ - OSCTimeTag tt; - if (sscanf(p, "%llx", &tt) != 1) { - post("warning: couldn't parse time tag %s\n", s); - return OSCTT_Immediately(); - } -#ifndef HAS8BYTEINT - if (ntohl(1) != 1) { - /* tt is a struct of seconds and fractional part, - and this machine is little-endian, so sscanf - wrote each half of the time tag in the wrong half - of the struct. */ - int temp; - temp = tt.seconds; - tt.seconds = tt.fraction ; - tt.fraction = temp; - } -#endif - return tt; - } - - post("warning: invalid time tag: %s\n", s); - return OSCTT_Immediately(); -} - - -void ParseInteractiveLine(OSCbuf *buf, char *mesg) { - char *messageName, *token, *p; - typedArg args[MAX_ARGS]; - int thisArg; - - p = mesg; - while (isspace(*p)) p++; - if (*p == '\0') return; - - messageName = p; - - if (strcmp(messageName, "play\n") == 0) { - /* Special kludge feature to save typing */ - typedArg arg; - - if (OSC_openBundle(buf, OSCTT_Immediately())) { - post("Problem opening bundle: %s\n", OSC_errorMessage); - return; - } - - arg.type = INT_osc; - arg.datum.i = 0; - WriteMessage(buf, "/voices/0/tp/timbre_index", 1, &arg); - - arg.type = FLOAT_osc; - arg.datum.i = 0.0f; - WriteMessage(buf, "/voices/0/tm/goto", 1, &arg); - - if (OSC_closeBundle(buf)) { - post("Problem closing bundle: %s\n", OSC_errorMessage); - } - - return; - } - - while (!isspace(*p) && *p != '\0') p++; - if (isspace(*p)) { - *p = '\0'; - p++; - } - - thisArg = 0; - while (*p != '\0') { - /* flush leading whitespace */ - while (isspace(*p)) p++; - if (*p == '\0') break; - - if (*p == '"') { - /* A string argument: scan for close quotes */ - p++; - args[thisArg].type = STRING_osc; - args[thisArg].datum.s = p; - - while (*p != '"') { - if (*p == '\0') { - post("Unterminated quote mark: ignoring line\n"); - return; - } - p++; - } - *p = '\0'; - p++; - } else { - token = p; - while (!isspace(*p) && (*p != '\0')) p++; - if (isspace(*p)) { - *p = '\0'; - p++; - } - args[thisArg] = ParseToken(token); - } - thisArg++; - if (thisArg >= MAX_ARGS) { - post("Sorry, your message has more than MAX_ARGS (%d) arguments; ignoring the rest.\n", - MAX_ARGS); - break; - } - } - - if (WriteMessage(buf, messageName, thisArg, args) != 0) { - post("Problem sending message: %s\n", OSC_errorMessage); - } -} - -typedArg ParseToken(char *token) { - char *p = token; - typedArg returnVal; - - /* It might be an int, a float, or a string */ - - if (*p == '-') p++; - - if (isdigit(*p) || *p == '.') { - while (isdigit(*p)) p++; - if (*p == '\0') { - returnVal.type = INT_osc; - returnVal.datum.i = atoi(token); - return returnVal; - } - if (*p == '.') { - p++; - while (isdigit(*p)) p++; - if (*p == '\0') { - returnVal.type = FLOAT_osc; - returnVal.datum.f = atof(token); - return returnVal; - } - } - } - - returnVal.type = STRING_osc; - returnVal.datum.s = token; - return returnVal; -} - -int WriteMessage(OSCbuf *buf, char *messageName, int numArgs, typedArg *args) { - int j, returnVal; - const int wmERROR = -1; - - returnVal = 0; - -#ifdef DEBUG - printf("WriteMessage: %s ", messageName); - - for (j = 0; j < numArgs; j++) { - switch (args[j].type) { - case INT_osc: - printf("%d ", args[j].datum.i); - break; - - case FLOAT_osc: - printf("%f ", args[j].datum.f); - break; - - case STRING_osc: - printf("%s ", args[j].datum.s); - break; - - default: - error("Unrecognized arg type, (not exiting)"); - return(wmERROR); - } - } - printf("\n"); -#endif - - if (!useTypeTags) { - returnVal = OSC_writeAddress(buf, messageName); - if (returnVal) { - post("Problem writing address: %s\n", OSC_errorMessage); - } - } else { - /* First figure out the type tags */ - char typeTags[MAX_ARGS+2]; - int i; - - typeTags[0] = ','; - - for (i = 0; i < numArgs; ++i) { - switch (args[i].type) { - case INT_osc: - typeTags[i+1] = 'i'; - break; - - case FLOAT_osc: - typeTags[i+1] = 'f'; - break; - - case STRING_osc: - typeTags[i+1] = 's'; - break; - - default: - error("Unrecognized arg type (not exiting)"); - return(wmERROR); - } - } - typeTags[i+1] = '\0'; - - returnVal = OSC_writeAddressAndTypes(buf, messageName, typeTags); - if (returnVal) { - post("Problem writing address: %s\n", OSC_errorMessage); - } - } - - for (j = 0; j < numArgs; j++) { - switch (args[j].type) { - case INT_osc: - if ((returnVal = OSC_writeIntArg(buf, args[j].datum.i)) != 0) { - return returnVal; - } - break; - - case FLOAT_osc: - if ((returnVal = OSC_writeFloatArg(buf, args[j].datum.f)) != 0) { - return returnVal; - } - break; - - case STRING_osc: - if ((returnVal = OSC_writeStringArg(buf, args[j].datum.s)) != 0) { - return returnVal; - } - break; - - default: - error("Unrecognized arg type (not exiting)"); - returnVal = wmERROR; - } - } - return returnVal; -} - -void SendBuffer(void *htmsocket, OSCbuf *buf) { -#ifdef DEBUG - printf("Sending buffer...\n"); -#endif - if (OSC_isBufferEmpty(buf)) { - post("SendBuffer() called but buffer empty"); - return; - } - if (!OSC_isBufferDone(buf)) { - error("SendBuffer() called but buffer not ready!, not exiting"); - return; //{{raf}} - } - SendData(htmsocket, OSC_packetSize(buf), OSC_getPacket(buf)); -} - -void SendData(void *htmsocket, int size, char *data) { - if (!SendHTMSocket(htmsocket, size, data)) { - post("SendData::SendHTMSocket()failure -- not connected"); - CloseHTMSocket(htmsocket); - } -} - - - -/* ---------------------- - OSC-client code - - */ - -/* Here are the possible values of the state field: */ - -#define EMPTY 0 /* Nothing written to packet yet */ -#define ONE_MSG_ARGS 1 /* Packet has a single message; gathering arguments */ -#define NEED_COUNT 2 /* Just opened a bundle; must write message name or - open another bundle */ -#define GET_ARGS 3 /* Getting arguments to a message. If we see a message - name or a bundle open/close then the current message - will end. */ -#define DONE 4 /* All open bundles have been closed, so can't write - anything else */ - -#ifdef WIN32 - #include - #include - #include - #include - #include - #include - #include -#endif - -#ifdef __APPLE__ - #include -#endif - -#ifdef unix - #include - #include -#endif - - -char *OSC_errorMessage; - -static int OSC_padString(char *dest, char *str); -static int OSC_padStringWithAnExtraStupidComma(char *dest, char *str); -static int OSC_WritePadding(char *dest, int i); -static int CheckTypeTag(OSCbuf *buf, char expectedType); - -void OSC_initBuffer(OSCbuf *buf, int size, char *byteArray) { - buf->buffer = byteArray; - buf->size = size; - OSC_resetBuffer(buf); -} - -void OSC_resetBuffer(OSCbuf *buf) { - buf->bufptr = buf->buffer; - buf->state = EMPTY; - buf->bundleDepth = 0; - buf->prevCounts[0] = 0; - buf->gettingFirstUntypedArg = 0; - buf->typeStringPtr = 0; -} - -int OSC_isBufferEmpty(OSCbuf *buf) { - return buf->bufptr == buf->buffer; -} - -int OSC_freeSpaceInBuffer(OSCbuf *buf) { - return buf->size - (buf->bufptr - buf->buffer); -} - -int OSC_isBufferDone(OSCbuf *buf) { - return (buf->state == DONE || buf->state == ONE_MSG_ARGS); -} - -char *OSC_getPacket(OSCbuf *buf) { -#ifdef ERROR_CHECK_GETPACKET - if (buf->state == DONE || buf->state == ONE_MSG_ARGS) { - return buf->buffer; - } else { - OSC_errorMessage = "Packet has unterminated bundles"; - return 0; - } -#else - return buf->buffer; -#endif -} - -int OSC_packetSize(OSCbuf *buf) { -#ifdef ERROR_CHECK_PACKETSIZE - if (buf->state == DONE || buf->state == ONE_MSG_ARGS) { - return (buf->bufptr - buf->buffer); - } else { - OSC_errorMessage = "Packet has unterminated bundles"; - return 0; - } -#else - return (buf->bufptr - buf->buffer); -#endif -} - -#define CheckOverflow(buf, bytesNeeded) { if ((bytesNeeded) > OSC_freeSpaceInBuffer(buf)) {OSC_errorMessage = "buffer overflow"; return 1;}} - -static void PatchMessageSize(OSCbuf *buf) { - int4byte size; - size = buf->bufptr - ((char *) buf->thisMsgSize) - 4; - *(buf->thisMsgSize) = htonl(size); -} - -int OSC_openBundle(OSCbuf *buf, OSCTimeTag tt) { - if (buf->state == ONE_MSG_ARGS) { - OSC_errorMessage = "Can't open a bundle in a one-message packet"; - return 3; - } - - if (buf->state == DONE) { - OSC_errorMessage = "This packet is finished; can't open a new bundle"; - return 4; - } - - if (++(buf->bundleDepth) >= MAX_BUNDLE_NESTING) { - OSC_errorMessage = "Bundles nested too deeply; change MAX_BUNDLE_NESTING in OpenSoundControl.h"; - return 2; - } - - if (CheckTypeTag(buf, '\0')) return 9; - - if (buf->state == GET_ARGS) { - PatchMessageSize(buf); - } - - if (buf->state == EMPTY) { - /* Need 16 bytes for "#bundle" and time tag */ - CheckOverflow(buf, 16); - } else { - /* This bundle is inside another bundle, so we need to leave - a blank size count for the size of this current bundle. */ - CheckOverflow(buf, 20); - *((int4byte *)buf->bufptr) = 0xaaaaaaaa; - buf->prevCounts[buf->bundleDepth] = (int4byte *)buf->bufptr; - - buf->bufptr += 4; - } - - buf->bufptr += OSC_padString(buf->bufptr, "#bundle"); - - - *((OSCTimeTag *) buf->bufptr) = tt; - - if (htonl(1) != 1) { - /* Byte swap the 8-byte integer time tag */ - int4byte *intp = (int4byte *)buf->bufptr; - intp[0] = htonl(intp[0]); - intp[1] = htonl(intp[1]); - -#ifdef HAS8BYTEINT - { /* tt is a 64-bit int so we have to swap the two 32-bit words. - (Otherwise tt is a struct of two 32-bit words, and even though - each word was wrong-endian, they were in the right order - in the struct.) */ - int4byte temp = intp[0]; - intp[0] = intp[1]; - intp[1] = temp; - } -#endif - } - - buf->bufptr += sizeof(OSCTimeTag); - - buf->state = NEED_COUNT; - - buf->gettingFirstUntypedArg = 0; - buf->typeStringPtr = 0; - return 0; -} - - -int OSC_closeBundle(OSCbuf *buf) { - if (buf->bundleDepth == 0) { - /* This handles EMPTY, ONE_MSG, ARGS, and DONE */ - OSC_errorMessage = "Can't close bundle; no bundle is open!"; - return 5; - } - - if (CheckTypeTag(buf, '\0')) return 9; - - if (buf->state == GET_ARGS) { - PatchMessageSize(buf); - } - - if (buf->bundleDepth == 1) { - /* Closing the last bundle: No bundle size to patch */ - buf->state = DONE; - } else { - /* Closing a sub-bundle: patch bundle size */ - int size = buf->bufptr - ((char *) buf->prevCounts[buf->bundleDepth]) - 4; - *(buf->prevCounts[buf->bundleDepth]) = htonl(size); - buf->state = NEED_COUNT; - } - - --buf->bundleDepth; - buf->gettingFirstUntypedArg = 0; - buf->typeStringPtr = 0; - return 0; -} - - -int OSC_closeAllBundles(OSCbuf *buf) { - if (buf->bundleDepth == 0) { - /* This handles EMPTY, ONE_MSG, ARGS, and DONE */ - OSC_errorMessage = "Can't close all bundles; no bundle is open!"; - return 6; - } - - if (CheckTypeTag(buf, '\0')) return 9; - - while (buf->bundleDepth > 0) { - OSC_closeBundle(buf); - } - buf->typeStringPtr = 0; - return 0; -} - -int OSC_writeAddress(OSCbuf *buf, char *name) { - int4byte paddedLength; - - if (buf->state == ONE_MSG_ARGS) { - OSC_errorMessage = "This packet is not a bundle, so you can't write another address"; - return 7; - } - - if (buf->state == DONE) { - OSC_errorMessage = "This packet is finished; can't write another address"; - return 8; - } - - if (CheckTypeTag(buf, '\0')) return 9; - - paddedLength = OSC_effectiveStringLength(name); - - if (buf->state == EMPTY) { - /* This will be a one-message packet, so no sizes to worry about */ - CheckOverflow(buf, paddedLength); - buf->state = ONE_MSG_ARGS; - } else { - /* GET_ARGS or NEED_COUNT */ - CheckOverflow(buf, 4+paddedLength); - if (buf->state == GET_ARGS) { - /* Close the old message */ - PatchMessageSize(buf); - } - buf->thisMsgSize = (int4byte *)buf->bufptr; - *(buf->thisMsgSize) = 0xbbbbbbbb; - buf->bufptr += 4; - buf->state = GET_ARGS; - } - - /* Now write the name */ - buf->bufptr += OSC_padString(buf->bufptr, name); - buf->typeStringPtr = 0; - buf->gettingFirstUntypedArg = 1; - - return 0; -} - -int OSC_writeAddressAndTypes(OSCbuf *buf, char *name, char *types) { - int result; - int4byte paddedLength; - - if (CheckTypeTag(buf, '\0')) return 9; - - result = OSC_writeAddress(buf, name); - - if (result) return result; - - paddedLength = OSC_effectiveStringLength(types); - - CheckOverflow(buf, paddedLength); - - buf->typeStringPtr = buf->bufptr + 1; /* skip comma */ - buf->bufptr += OSC_padString(buf->bufptr, types); - - buf->gettingFirstUntypedArg = 0; - return 0; -} - -static int CheckTypeTag(OSCbuf *buf, char expectedType) { - if (buf->typeStringPtr) { - if (*(buf->typeStringPtr) != expectedType) { - if (expectedType == '\0') { - OSC_errorMessage = - "According to the type tag I expected more arguments."; - } else if (*(buf->typeStringPtr) == '\0') { - OSC_errorMessage = - "According to the type tag I didn't expect any more arguments."; - } else { - OSC_errorMessage = - "According to the type tag I expected an argument of a different type."; - printf("* Expected %c, string now %s\n", expectedType, buf->typeStringPtr); - } - return 9; - } - ++(buf->typeStringPtr); - } - return 0; -} - - -int OSC_writeFloatArg(OSCbuf *buf, float arg) { - int4byte *intp; - //int result; - - CheckOverflow(buf, 4); - - if (CheckTypeTag(buf, 'f')) return 9; - - /* Pretend arg is a long int so we can use htonl() */ - intp = ((int4byte *) &arg); - *((int4byte *) buf->bufptr) = htonl(*intp); - - buf->bufptr += 4; - - buf->gettingFirstUntypedArg = 0; - return 0; -} - - - -int OSC_writeFloatArgs(OSCbuf *buf, int numFloats, float *args) { - int i; - int4byte *intp; - - CheckOverflow(buf, 4 * numFloats); - - /* Pretend args are long ints so we can use htonl() */ - intp = ((int4byte *) args); - - for (i = 0; i < numFloats; i++) { - if (CheckTypeTag(buf, 'f')) return 9; - *((int4byte *) buf->bufptr) = htonl(intp[i]); - buf->bufptr += 4; - } - - buf->gettingFirstUntypedArg = 0; - return 0; -} - -int OSC_writeIntArg(OSCbuf *buf, int4byte arg) { - CheckOverflow(buf, 4); - if (CheckTypeTag(buf, 'i')) return 9; - - *((int4byte *) buf->bufptr) = htonl(arg); - buf->bufptr += 4; - - buf->gettingFirstUntypedArg = 0; - return 0; -} - -int OSC_writeStringArg(OSCbuf *buf, char *arg) { - int len; - - if (CheckTypeTag(buf, 's')) return 9; - - len = OSC_effectiveStringLength(arg); - - if (buf->gettingFirstUntypedArg && arg[0] == ',') { - /* This un-type-tagged message starts with a string - that starts with a comma, so we have to escape it - (with a double comma) so it won't look like a type - tag string. */ - - CheckOverflow(buf, len+4); /* Too conservative */ - buf->bufptr += - OSC_padStringWithAnExtraStupidComma(buf->bufptr, arg); - - } else { - CheckOverflow(buf, len); - buf->bufptr += OSC_padString(buf->bufptr, arg); - } - - buf->gettingFirstUntypedArg = 0; - return 0; - -} - -/* String utilities */ - -#define STRING_ALIGN_PAD 4 -int OSC_effectiveStringLength(char *string) { - int len = strlen(string) + 1; /* We need space for the null char. */ - - /* Round up len to next multiple of STRING_ALIGN_PAD to account for alignment padding */ - if ((len % STRING_ALIGN_PAD) != 0) { - len += STRING_ALIGN_PAD - (len % STRING_ALIGN_PAD); - } - return len; -} - -static int OSC_padString(char *dest, char *str) { - int i; - - for (i = 0; str[i] != '\0'; i++) { - dest[i] = str[i]; - } - - return OSC_WritePadding(dest, i); -} - -static int OSC_padStringWithAnExtraStupidComma(char *dest, char *str) { - int i; - - dest[0] = ','; - for (i = 0; str[i] != '\0'; i++) { - dest[i+1] = str[i]; - } - - return OSC_WritePadding(dest, i+1); -} - -static int OSC_WritePadding(char *dest, int i) { - dest[i] = '\0'; - i++; - - for (; (i % STRING_ALIGN_PAD) != 0; i++) { - dest[i] = '\0'; - } - - return i; -} - - diff --git a/apps/plugins/pdbox/PDa/extra/sformat.h b/apps/plugins/pdbox/PDa/extra/sformat.h deleted file mode 100644 index 93d353785b..0000000000 --- a/apps/plugins/pdbox/PDa/extra/sformat.h +++ /dev/null @@ -1,56 +0,0 @@ - -#ifndef SFORMAT_H__ -#define SFORMAT_H__ - -typedef unsigned short uint16; -typedef unsigned long uint32; - -#define FORMAT_WAVE 0 -#define FORMAT_AIFF 1 -#define FORMAT_NEXT 2 - -/* the NeXTStep sound header structure; can be big or little endian */ - -typedef struct _nextstep -{ - char ns_fileid[4]; /* magic number '.snd' if file is big-endian */ - uint32 ns_onset; /* byte offset of first sample */ - uint32 ns_length; /* length of sound in bytes */ - uint32 ns_format; /* format; see below */ - uint32 ns_sr; /* sample rate */ - uint32 ns_nchans; /* number of channels */ - char ns_info[4]; /* comment */ -} t_nextstep; - -#define NS_FORMAT_LINEAR_16 3 -#define NS_FORMAT_LINEAR_24 4 -#define NS_FORMAT_FLOAT 6 -#define SCALE (1./(1024. * 1024. * 1024. * 2.)) - -/* the WAVE header. All Wave files are little endian. We assume - the "fmt" chunk comes first which is usually the case but perhaps not - always; same for AIFF and the "COMM" chunk. */ - -typedef unsigned word; -typedef unsigned long dword; - -typedef struct _wave -{ - char w_fileid[4]; /* chunk id 'RIFF' */ - uint32 w_chunksize; /* chunk size */ - char w_waveid[4]; /* wave chunk id 'WAVE' */ - char w_fmtid[4]; /* format chunk id 'fmt ' */ - uint32 w_fmtchunksize; /* format chunk size */ - uint16 w_fmttag; /* format tag, 1 for PCM */ - uint16 w_nchannels; /* number of channels */ - uint32 w_samplespersec; /* sample rate in hz */ - uint32 w_navgbytespersec; /* average bytes per second */ - uint16 w_nblockalign; /* number of bytes per sample */ - uint16 w_nbitspersample; /* number of bits in a sample */ - char w_datachunkid[4]; /* data chunk id 'data' */ - uint32 w_datachunksize; /* length of data chunk */ -} t_wave; - - -#endif - diff --git a/apps/plugins/pdbox/PDa/extra/shell.c b/apps/plugins/pdbox/PDa/extra/shell.c deleted file mode 100644 index 8653c63ff4..0000000000 --- a/apps/plugins/pdbox/PDa/extra/shell.c +++ /dev/null @@ -1,312 +0,0 @@ -/* (C) Guenter Geiger */ - -#include "../src/m_pd.h" -#ifdef NT -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -void sys_rmpollfn(int fd); -void sys_addpollfn(int fd, void* fn, void *ptr); - -/* ------------------------ shell ----------------------------- */ - -#define INBUFSIZE 1024 - -static t_class *shell_class; - - -static void drop_priority(void) -{ -#ifdef _POSIX_PRIORITY_SCHEDULING - struct sched_param par; - int p1 ,p2, p3; - par.sched_priority = 0; - sched_setscheduler(0,SCHED_OTHER,&par); -#endif -} - - -typedef struct _shell -{ - t_object x_obj; - int x_echo; - char *sr_inbuf; - int sr_inhead; - int sr_intail; - void* x_binbuf; - int fdpipe[2]; - int fdinpipe[2]; - int pid; - int x_del; - t_outlet* x_done; - t_clock* x_clock; -} t_shell; - -static int shell_pid; - - -void shell_cleanup(t_shell* x) -{ - sys_rmpollfn(x->fdpipe[0]); - - if (x->fdpipe[0]>0) close(x->fdpipe[0]); - if (x->fdpipe[1]>0) close(x->fdpipe[1]); - if (x->fdinpipe[0]>0) close(x->fdinpipe[0]); - if (x->fdinpipe[1]>0) close(x->fdinpipe[1]); - - x->fdpipe[0] = -1; - x->fdpipe[1] = -1; - x->fdinpipe[0] = -1; - x->fdinpipe[1] = -1; - clock_unset(x->x_clock); -} - -void shell_check(t_shell* x) -{ - int ret; - int status; - ret = waitpid(x->pid,&status,WNOHANG); - if (ret == x->pid) { - shell_cleanup(x); - if (WIFEXITED(status)) { - outlet_float(x->x_done,WEXITSTATUS(status)); - } - else outlet_float(x->x_done,0); - } - else { - if (x->x_del < 100) x->x_del+=2; /* increment poll times */ - clock_delay(x->x_clock,x->x_del); - } -} - - -void shell_bang(t_shell *x) -{ - post("bang"); -} - -/* snippet from pd's code */ -static void shell_doit(void *z, t_binbuf *b) -{ - t_shell *x = (t_shell *)z; - int msg, natom = binbuf_getnatom(b); - t_atom *at = binbuf_getvec(b); - - for (msg = 0; msg < natom;) - { - int emsg; - for (emsg = msg; emsg < natom && at[emsg].a_type != A_COMMA - && at[emsg].a_type != A_SEMI; emsg++) - ; - if (emsg > msg) - { - int i; - for (i = msg; i < emsg; i++) - if (at[i].a_type == A_DOLLAR || at[i].a_type == A_DOLLSYM) - { - pd_error(x, "netreceive: got dollar sign in message"); - goto nodice; - } - if (at[msg].a_type == A_FLOAT) - { - if (emsg > msg + 1) - outlet_list(x->x_obj.ob_outlet, 0, emsg-msg, at + msg); - else outlet_float(x->x_obj.ob_outlet, at[msg].a_w.w_float); - } - else if (at[msg].a_type == A_SYMBOL) - outlet_anything(x->x_obj.ob_outlet, at[msg].a_w.w_symbol, - emsg-msg-1, at + msg + 1); - } - nodice: - msg = emsg + 1; - } -} - - -void shell_read(t_shell *x, int fd) -{ - char buf[INBUFSIZE]; - t_binbuf* bbuf = binbuf_new(); - int i; - int readto = - (x->sr_inhead >= x->sr_intail ? INBUFSIZE : x->sr_intail-1); - int ret; - - ret = read(fd, buf,INBUFSIZE-1); - buf[ret] = '\0'; - - for (i=0;ifdpipe[0] = -1; - close(fd); - return; - } - else if (ret == 0) - { - post("EOF on socket %d\n", fd); - sys_rmpollfn(fd); - x->fdpipe[0] = -1; - close(fd); - return; - } - else - { - int natom; - t_atom *at; - binbuf_text(bbuf, buf, strlen(buf)); - - natom = binbuf_getnatom(bbuf); - at = binbuf_getvec(bbuf); - shell_doit(x,bbuf); - } - binbuf_free(bbuf); -} - - -static void shell_send(t_shell *x, t_symbol *s,int ac, t_atom *at) -{ - int i; - char tmp[MAXPDSTRING]; - int size = 0; - - if (x->fdinpipe[0] == -1) return; /* nothing to send to */ - - for (i=0;ifdinpipe[0],tmp,strlen(tmp)); -} - -static void shell_anything(t_shell *x, t_symbol *s, int ac, t_atom *at) -{ - int i; - char* argv[20]; - t_symbol* sym; - - if (!strcmp(s->s_name,"send")) { - post("send"); - shell_send(x,s,ac,at); - return; - } - - argv[0] = s->s_name; - - if (x->fdpipe[0] != -1) { - post("shell: old process still running"); - kill(x->pid,SIGKILL); - shell_cleanup(x); - } - - - if (pipe(x->fdpipe) < 0) { - error("unable to create pipe"); - return; - } - - if (pipe(x->fdinpipe) < 0) { - error("unable to create input pipe"); - return; - } - - - sys_addpollfn(x->fdpipe[0],shell_read,x); - - if (!(x->pid = fork())) { - int status; - char* cmd = getbytes(1024); - char* tcmd = getbytes(1024); - strcpy(cmd,s->s_name); - -#if 0 - for (i=1;i<=ac;i++) { - argv[i] = getbytes(255); - atom_string(at,argv[i],255); -/* post("argument %s",argv[i]); */ - at++; - } - argv[i] = 0; -#endif - for (i=1;i<=ac;i++) { - atom_string(at,tcmd,255); - strcat(cmd," "); - strcat(cmd,tcmd); - at++; - } - - - /* reassign stdout */ - dup2(x->fdpipe[1],1); - dup2(x->fdinpipe[1],0); - - /* drop privileges */ - drop_priority(); - seteuid(getuid()); /* lose setuid priveliges */ - - post("executing %s",cmd); - system(cmd); -// execvp(s->s_name,argv); - exit(0); - } - x->x_del = 4; - clock_delay(x->x_clock,x->x_del); - - if (x->x_echo) - outlet_anything(x->x_obj.ob_outlet, s, ac, at); -} - - - -void shell_free(t_shell* x) -{ - binbuf_free(x->x_binbuf); -} - -static void *shell_new(void) -{ - t_shell *x = (t_shell *)pd_new(shell_class); - - x->x_echo = 0; - x->fdpipe[0] = -1; - x->fdpipe[1] = -1; - x->fdinpipe[0] = -1; - x->fdinpipe[1] = -1; - - x->sr_inhead = x->sr_intail = 0; - if (!(x->sr_inbuf = (char*) malloc(INBUFSIZE))) bug("t_shell");; - - x->x_binbuf = binbuf_new(); - - outlet_new(&x->x_obj, &s_list); - x->x_done = outlet_new(&x->x_obj, &s_bang); - x->x_clock = clock_new(x, (t_method) shell_check); - return (x); -} - -void shell_setup(void) -{ - shell_class = class_new(gensym("shell"), (t_newmethod)shell_new, - (t_method)shell_free,sizeof(t_shell), 0,0); - class_addbang(shell_class,shell_bang); - class_addanything(shell_class, shell_anything); -} - - diff --git a/apps/plugins/pdbox/PDa/extra/slider.c b/apps/plugins/pdbox/PDa/extra/slider.c deleted file mode 100644 index 9c49eeb17a..0000000000 --- a/apps/plugins/pdbox/PDa/extra/slider.c +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include "../src/m_pd.h" -#include "g_canvas.h" /* for widgetbehaviour */ -#include "fatom.h" - -static t_class *slider_class; - -static void slider_save(t_gobj *z, t_binbuf *b) -{ - t_fatom *x = (t_fatom *)z; - - binbuf_addv(b, "ssiisiiisss", gensym("#X"),gensym("obj"), - x->x_obj.te_xpix, x->x_obj.te_ypix , - gensym("slider"),x->x_max,x->x_min,x->x_width,x->x_send,x->x_color,x->x_bgcolor); - binbuf_addv(b, ";"); -} - - -static void *slider_new(t_symbol* s,t_int argc, t_atom* argv) -{ - t_fatom *x = (t_fatom *)pd_new(slider_class); - x->x_type = gensym("vslider"); - return fatom_new(x,argc,argv); -} - - -t_widgetbehavior slider_widgetbehavior; - - -void slider_setup(void) { - slider_class = class_new(gensym("slider"), (t_newmethod)slider_new, 0, - sizeof(t_fatom),0,A_GIMME,0); - - slider_widgetbehavior.w_getrectfn = fatom_getrect; - slider_widgetbehavior.w_displacefn = fatom_displace; - slider_widgetbehavior.w_selectfn = fatom_select; - slider_widgetbehavior.w_activatefn = fatom_activate; - slider_widgetbehavior.w_deletefn = fatom_delete; - slider_widgetbehavior.w_visfn= fatom_vis; - slider_widgetbehavior.w_clickfn = NULL; - - fatom_setup_common(slider_class); - class_setwidget(slider_class,&slider_widgetbehavior); - -#if PD_MINOR_VERSION < 37 - slider_widgetbehavior.w_savefn = slider_save; - slider_widgetbehavior.w_propertiesfn = NULL; -#else - class_setsavefn(slider_class,&slider_save); - class_setpropertiesfn(slider_class,&fatom_properties); -#endif - -} - diff --git a/apps/plugins/pdbox/PDa/extra/sliderh.c b/apps/plugins/pdbox/PDa/extra/sliderh.c deleted file mode 100644 index ef3d096cf6..0000000000 --- a/apps/plugins/pdbox/PDa/extra/sliderh.c +++ /dev/null @@ -1,64 +0,0 @@ -#include "../src/m_pd.h" -#include "g_canvas.h" - - -#ifdef NT -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - -#include "fatom.h" - -/* can we use the normal text save function ?? */ - -static t_class *sliderh_class; - -static void sliderh_save(t_gobj *z, t_binbuf *b) -{ - - t_fatom *x = (t_fatom *)z; - - binbuf_addv(b, "ssiisiiisss", gensym("#X"),gensym("obj"), - x->x_obj.te_xpix, x->x_obj.te_ypix , - gensym("sliderh"),x->x_max,x->x_min,x->x_width,x->x_send,x->x_color,x->x_bgcolor); - binbuf_addv(b, ";"); -} - - -static void *sliderh_new(t_symbol* s, int argc, t_atom* argv) -{ - t_fatom *x = (t_fatom *)pd_new(sliderh_class); - x->x_type = gensym("hslider"); - return fatom_new(x,argc,argv); -} - - -t_widgetbehavior sliderh_widgetbehavior; - - - - -void sliderh_setup(void) { - sliderh_class = class_new(gensym("sliderh"), (t_newmethod)sliderh_new, 0, - sizeof(t_fatom),0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0); - - fatom_setup_common(sliderh_class); - - sliderh_widgetbehavior.w_getrectfn = fatom_getrect; - sliderh_widgetbehavior.w_displacefn= fatom_displace; - sliderh_widgetbehavior.w_selectfn= fatom_select; - sliderh_widgetbehavior.w_activatefn=fatom_activate; - sliderh_widgetbehavior.w_deletefn= fatom_delete; - sliderh_widgetbehavior.w_visfn= fatom_vis; -#if PD_MINOR_VERSION < 37 - sliderh_widgetbehavior.w_savefn= sliderh_save; - sliderh_widgetbehavior.w_propertiesfn= NULL; -#endif - sliderh_widgetbehavior.w_clickfn= NULL; - - class_setwidget(sliderh_class,&sliderh_widgetbehavior); -#if PD_MINOR_VERSION >= 37 - class_setsavefn(sliderh_class,&sliderh_save); -#endif -} - diff --git a/apps/plugins/pdbox/PDa/extra/test-clip.pd b/apps/plugins/pdbox/PDa/extra/test-clip.pd deleted file mode 100644 index ed6c0c8396..0000000000 --- a/apps/plugins/pdbox/PDa/extra/test-clip.pd +++ /dev/null @@ -1,14 +0,0 @@ -#N canvas 0 0 240 300 10; -#X obj 57 84 clip~ -0.1 0.1; -#X obj 58 61 sig~; -#X obj 57 111 snapshot~; -#X floatatom 58 19 5 0 0 0 - - -; -#X floatatom 57 144 5 0 0 0 - - -; -#X obj 58 37 t f b; -#X connect 0 0 2 0; -#X connect 1 0 0 0; -#X connect 2 0 4 0; -#X connect 3 0 5 0; -#X connect 5 0 1 0; -#X connect 5 1 2 0; - diff --git a/apps/plugins/pdbox/PDa/extra/test-vcf.pd b/apps/plugins/pdbox/PDa/extra/test-vcf.pd deleted file mode 100644 index 5f1b29381a..0000000000 --- a/apps/plugins/pdbox/PDa/extra/test-vcf.pd +++ /dev/null @@ -1,19 +0,0 @@ -#N canvas 0 0 240 300 10; -#X obj 38 93 noise~; -#X obj 44 161 vcf~; -#X obj 48 191 dac~; -#X floatatom 138 33 5 0 0 0 - - -; -#X obj 44 18 osc~ 1; -#X obj 46 75 *~ 800; -#X obj 48 48 +~ 2; -#X obj 106 125 sig~; -#X floatatom 132 77 5 0 0 0 - - -; -#X connect 0 0 1 0; -#X connect 1 0 2 0; -#X connect 1 0 2 1; -#X connect 3 0 1 2; -#X connect 4 0 6 0; -#X connect 6 0 5 0; -#X connect 7 0 1 1; -#X connect 8 0 7 0; - -- cgit v1.2.3