From 94871ad26506febf04afe90a9ec0427877d473fe Mon Sep 17 00:00:00 2001 From: jdl Date: Sun, 8 Sep 2002 16:34:07 +0000 Subject: 0.16-4: added non-match / unmatched outlet to OSCroute updated doc/OSCroute-help.pd including a new chapter about patternmatching. svn path=/trunk/externals/OSCx/; revision=122 --- OSC/OSC-pattern-match.c | 2 ++ OSC/VERSION | 2 +- OSC/routeOSC.c | 34 ++++++++++++++++++--------- README.txt | 23 ++++++++++++++---- doc/OSCroute-help.pd | 62 ++++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 105 insertions(+), 18 deletions(-) diff --git a/OSC/OSC-pattern-match.c b/OSC/OSC-pattern-match.c index 01515f8..2d6a541 100644 --- a/OSC/OSC-pattern-match.c +++ b/OSC/OSC-pattern-match.c @@ -46,6 +46,8 @@ static Boolean MatchList (const char *pattern, const char *test); Boolean PatternMatch (const char * pattern, const char * test) { + // printf("OSC-pattern-match.c: pattern: %s, test: %s\n", pattern, test); + theWholePattern = pattern; if (pattern == 0 || pattern[0] == 0) { diff --git a/OSC/VERSION b/OSC/VERSION index 689f5a7..653397c 100644 --- a/OSC/VERSION +++ b/OSC/VERSION @@ -1 +1 @@ -0.16-3 +0.16-4 diff --git a/OSC/routeOSC.c b/OSC/routeOSC.c index 4ff38cb..0e297dd 100644 --- a/OSC/routeOSC.c +++ b/OSC/routeOSC.c @@ -75,7 +75,7 @@ typedef struct _OSCroute t_int x_num; // Number of address prefixes we store t_int x_complainmode; // Do we print a message if no match? char *x_prefixes[MAX_NUM]; - void *x_outlets[MAX_NUM]; + void *x_outlets[MAX_NUM+1]; } t_OSCroute; t_symbol *ps_list, *ps_complain, *ps_emptySymbol; @@ -106,9 +106,9 @@ static void OSCroute_free(t_OSCroute *x) // setup #ifdef WIN32 - OSC_API void OSCroute_setup(void) { + OSC_API void OSCroute_setup(void) { #else - void OSCroute_setup(void) { +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); @@ -129,7 +129,7 @@ static void OSCroute_free(t_OSCroute *x) /* ps_complain = gensym("complain"); */ ps_emptySymbol = gensym(""); - post("OSCroute object version " OSC_ROUTE_VERSION " by Matt Wright. pd-fication cxc. Win32 raf."); + 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."); } @@ -139,10 +139,9 @@ static void OSCroute_free(t_OSCroute *x) void *OSCroute_new(t_symbol *s, int argc, t_atom *argv) { - //OSCroute *x; + t_OSCroute *x = (t_OSCroute *)pd_new(OSCroute_class); // get memory for a new object & initialize - //int i, n; int i; //{{raf}} n not used // EnterCallback(); @@ -153,8 +152,6 @@ void *OSCroute_new(t_symbol *s, int argc, t_atom *argv) return 0; } - //x = newobject(OSCroute_class); // get memory for a new object & initialize - x->x_complainmode = 0; x->x_num = 0; for (i = 0; i < argc; ++i) { @@ -212,7 +209,8 @@ void *OSCroute_new(t_symbol *s, int argc, t_atom *argv) /* 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-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); } @@ -225,7 +223,7 @@ void *OSCroute_new(t_symbol *s, int argc, t_atom *argv) void OSCroute_version (t_OSCroute *x) { // EnterCallback(); post("OSCroute Version " OSC_ROUTE_VERSION - ", by Matt Wright. pd-fication cxc@web.fm\nOSCroute Compiled " __TIME__ " " __DATE__); + ", by Matt Wright. pd jdl, win32: raf.\nOSCroute Compiled " __TIME__ " " __DATE__); // ExitCallback(); } @@ -258,7 +256,13 @@ void OSCroute_list(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv) { /* 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"); + // 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(); } @@ -282,6 +286,7 @@ void OSCroute_doanything(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv) { 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; } @@ -358,6 +363,13 @@ void OSCroute_doanything(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv) { 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) { diff --git a/README.txt b/README.txt index 4a0dc8c..07afa40 100644 --- a/README.txt +++ b/README.txt @@ -1,7 +1,8 @@ OSC, OpenSoundControl for pd ============================ -OSC: http://cnmat.cnmat.berkeley.edu/OSC -pd: http://lena.ucsd.edu/~msp/ +for more information on OSC see: http://cnmat.cnmat.berkeley.edu/OSC +they also have an osc_dev mailinglist. +primary source for pd: http://lena.ucsd.edu/~msp/ ok, merged the windows and linux trees. for linux do the usual makes etc, for window either use extra/OSC.dll, @@ -21,12 +22,22 @@ send+dump/ CNMAT's OSC commandline utils log: - 20020417: 0.16-2: more changes by raf + jdl (send with no argument fix, send / fix, + 20020908: 0.16-4: + added non-match / unmatched outlet to OSCroute + updated doc/OSCroute-help.pd including a new chapter + about patternmatching. + + 20020901: ca., refixed MAXPDARG vs. MAX_ARGS, causing crash when sending + messages with more than 4 arguments + + 20020417: 0.16-2: + more changes by raf + jdl (send with no argument fix, send / fix, ...) 20020416: added bundle stuff to sendOSC - 200204: 0.15b1: windowified version and implied linux enhancements + 200204: 0.15b1: + windowified version and implied linux enhancements by raf@interaccess.com for now get it at http://207.208.254.239/pd/win32_osc_02.zip most importantly: enhanced connect->disconnect-connect behaviour @@ -76,6 +87,8 @@ TODO see also TODO.txt in OSC/ -- -jdl at xdv.org, http://barely.a.live.fm/pd/OSC +jdl at xdv.org +http://barely.a.live.fm/pd/OSC +http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pure-data/externals/OSCx/ windows version: raf at interaccess.com, http://207.208.254.239/pd/win32_osc_02.zip diff --git a/doc/OSCroute-help.pd b/doc/OSCroute-help.pd index 3d9dd2a..194cd93 100644 --- a/doc/OSCroute-help.pd +++ b/doc/OSCroute-help.pd @@ -1,4 +1,4 @@ -#N canvas 112 247 446 321 10; +#N canvas 112 247 493 349 10; #X msg 20 72 version; #X obj 86 72 r rcvOSC; #X obj 86 109 OSCroute /test /ix /yps; @@ -12,6 +12,65 @@ #X text 20 11 OSCroute works pretty much like route but outputs remainder of routing tag after match.; #X obj 68 143 print test; +#X obj 241 212 print rejected; +#N canvas 663 325 473 347 patternmatching 0; +#X obj 26 242 OSCroute /freq; +#X obj 150 242 OSCroute /freq; +#X obj 272 241 OSCroute /freq; +#X msg 81 115 /*/freq 23 45 67; +#X obj 72 201 OSCroute /inst1 /inst2 /inst3; +#X obj 26 266 unpack f f f; +#X floatatom 26 287 3 0 0; +#X floatatom 65 287 3 0 0; +#X floatatom 105 287 3 0 0; +#X obj 150 265 unpack f f f; +#X floatatom 150 286 3 0 0; +#X floatatom 189 286 3 0 0; +#X floatatom 229 286 3 0 0; +#X obj 272 265 unpack f f f; +#X floatatom 272 286 3 0 0; +#X floatatom 311 286 3 0 0; +#X floatatom 351 286 3 0 0; +#X msg 55 44 /inst1/freq 100 200 300; +#X msg 64 66 /inst2/freq 111 222 333; +#X msg 70 88 /inst3/freq 321 432 543; +#X text 45 116 4->; +#X text 37 89 3->; +#X text 30 67 2->; +#X text 22 45 1->; +#X text 11 7 took me a while to figure this out \, somehow i always +thought it should work the other way round:; +#X msg 96 145 /inst[12]/freq 0 99 88; +#X msg 119 174 /inst?/freq 22.33 44.55 66.77; +#X connect 0 0 5 0; +#X connect 1 0 9 0; +#X connect 2 0 13 0; +#X connect 3 0 4 0; +#X connect 4 0 0 0; +#X connect 4 1 1 0; +#X connect 4 2 2 0; +#X connect 5 0 6 0; +#X connect 5 1 7 0; +#X connect 5 2 8 0; +#X connect 9 0 10 0; +#X connect 9 1 11 0; +#X connect 9 2 12 0; +#X connect 13 0 14 0; +#X connect 13 1 15 0; +#X connect 13 2 16 0; +#X connect 17 0 4 0; +#X connect 18 0 4 0; +#X connect 19 0 4 0; +#X connect 25 0 4 0; +#X connect 26 0 4 0; +#X restore 288 57 pd patternmatching; +#X text 184 57 check here =>; +#X text 239 235 last outlet emits all non-matches; +#X text 252 269 -OSC patterns that didnt match; +#X text 239 252 (like classic route):; +#X text 252 280 -patterns not starting with /; +#X text 252 294 -patterns starting with a number; +#X text 325 324 2002-09-08 \, jdl xdv.org; #X connect 0 0 2 0; #X connect 1 0 2 0; #X connect 2 0 5 0; @@ -21,6 +80,7 @@ of routing tag after match.; #X connect 2 2 4 0; #X connect 2 2 5 0; #X connect 5 0 6 0; +#X connect 5 3 12 0; #X connect 6 0 7 0; #X connect 6 1 8 0; #X connect 6 2 9 0; -- cgit v1.2.1