Forums > MaxMSP

another way to do this?


April 12, 2008 | 7:48 am

Okay, I’ve tracked down an error in my patch to the attached object.

I wanted to translate incoming OSC messages so that the "/" characters were all replaced by " " (blank spaces), so that I could then use "route" objects to sort them.

The problem is in my use of [thresh], to recombine the string after it goes through the [if]. It works fine most of the time, but if I get two separate OSC messages within the threshold interval, they get combined into one message.

I need to keep each incoming OSC message distinct. The OSC messages are not of equal length. How else could I do this?

Appreciate the help.

max v2;
#N vpatcher 337 117 937 517;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 50 226 64 196617 fromsymbol;
#P newex 50 180 49 196617 route 32;
#P newex 50 253 44 196617 s OSCin;
#P newex 50 203 40 196617 itoa;
#P newex 50 135 141 196617 if $i1 == 47 then 32 else $i1;
#P newex 50 114 25 196617 iter;
#P newex 50 92 40 196617 atoi;
#P newex 50 156 48 196617 thresh 1;
#P newex 50 71 51 196617 tosymbol;
#P newex 50 49 86 196617 udpreceive 8000;
#P connect 0 0 1 0;
#P connect 1 0 3 0;
#P connect 3 0 4 0;
#P connect 4 0 5 0;
#P connect 5 0 2 0;
#P connect 2 0 8 0;
#P connect 8 0 6 0;
#P connect 6 0 9 0;
#P connect 9 0 7 0;
#P pop;

April 12, 2008 | 8:48 am

Hello Adam,
There is an object which handles OSC message strings. Use [osc-route] in
your application, it’s very easy to use. you can download the object at
http://cnmat.berkeley.edu/downloads .
Also download the objects [OpenSoundControl] and [osc-unroute] they may
become handy.
cheers,
Jeroen.

2008/4/12 Adam Barnett :

> Okay, I’ve tracked down an error in my patch to the attached object.
>
> I wanted to translate incoming OSC messages so that the "/" characters
> were all replaced by " " (blank spaces), so that I could then use "route"
> objects to sort them.
>
> The problem is in my use of [thresh], to recombine the string after it
> goes through the [if]. It works fine most of the time, but if I get two
> separate OSC messages within the threshold interval, they get combined into
> one message.
>
> I need to keep each incoming OSC message distinct. The OSC messages are
> not of equal length. How else could I do this?
>
> Appreciate the help.
>
> max v2;
> #N vpatcher 337 117 937 517;
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P newex 50 226 64 196617 fromsymbol;
> #P newex 50 180 49 196617 route 32;
> #P newex 50 253 44 196617 s OSCin;
> #P newex 50 203 40 196617 itoa;
> #P newex 50 135 141 196617 if $i1 == 47 then 32 else $i1;
> #P newex 50 114 25 196617 iter;
> #P newex 50 92 40 196617 atoi;
> #P newex 50 156 48 196617 thresh 1;
> #P newex 50 71 51 196617 tosymbol;
> #P newex 50 49 86 196617 udpreceive 8000;
> #P connect 0 0 1 0;
> #P connect 1 0 3 0;
> #P connect 3 0 4 0;
> #P connect 4 0 5 0;
> #P connect 5 0 2 0;
> #P connect 2 0 8 0;
> #P connect 8 0 6 0;
> #P connect 6 0 9 0;
> #P connect 9 0 7 0;
> #P pop;
>
>
>
>
>

April 12, 2008 | 8:53 am

Hi Adam,

Check out regexp – it makes these sort of substitutions really easy.
like:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 160 209 146 196617;
#P newex 160 185 66 196617 prepend set;
#P message 161 85 180 196617 /this/is/a/message/of/some/sort 5;
#P message 68 69 77 196617 substitute " ";
#P newex 66 43 48 196617 loadbang;
#P newex 160 134 66 196617 regexp (/);
#P connect 0 0 4 0;
#P connect 4 0 5 0;
#P connect 3 0 0 0;
#P connect 2 0 0 0;
#P connect 1 0 2 0;
#P window clipboard copycount 6;

Also, if it’s just routing you’re after, there’s osc-route from CNMAT,
that has the added bonus of pattern matching magic:
< http://cnmat.berkeley.edu/patch/4029>


Owen

Adam Barnett wrote:
> Okay, I’ve tracked down an error in my patch to the attached object.
>
>
> I wanted to translate incoming OSC messages so that the "/"
> characters were all replaced by " " (blank spaces), so that I could
> then use "route" objects to sort them.
>
> The problem is in my use of [thresh], to recombine the string after
> it goes through the [if]. It works fine most of the time, but if I
> get two separate OSC messages within the threshold interval, they get
> combined into one message.
>
> I need to keep each incoming OSC message distinct. The OSC messages
> are not of equal length. How else could I do this?
>
> Appreciate the help.
>
> max v2;

April 12, 2008 | 9:10 am

there is the dedicated [osc-route] object available from CNMAT to
route using slash-delimited addresses.

to cut a string (ahem, ‘symbol’) at a specific delimiter, i ported the
c-string function [strtok] to a max external: http://www.jasch.ch/dl
http://www.cplusplus.com/reference/clibrary/cstring/strtok.html

as for simple substitutions there’s also the stock [substitute]
object, see patch below

hth

/*j

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 66 105 141 196617 /deep/sea/creature/feature;
#P newex 57 224 32 196617 print;
#P message 57 87 88 196617 /tree/frog/jump;
#P newex 57 193 64 196617 fromsymbol;
#P newex 57 172 40 196617 itoa;
#P newex 57 151 85 196617 substitute 47 32;
#P newex 57 130 40 196617 atoi;
#P connect 3 0 5 0;
#P connect 6 0 0 0;
#P connect 4 0 0 0;
#P connect 1 0 2 0;
#P connect 0 0 1 0;
#P connect 2 0 3 0;
#P window clipboard copycount 7;

April 12, 2008 | 6:23 pm

Ah, thank you. [substitute] just did the trick. I don’t want to mess about with [osc-route] at this point, since everything downwind in my patch would need replacing, but next time…

I have an etiquette question, since I’m new to mailing list-type forums. Is it customary to thank people for their help, and/or update posts when a problem has been solved, or is that considered unnecessary noise?

Cheers.

April 12, 2008 | 7:13 pm

On Sat, Apr 12, 2008 at 11:23 AM, Adam Barnett wrote:
>
> I have an etiquette question, since I’m new to mailing list-type forums. Is it customary to thank people for their help, and/or update posts when a problem has been solved, or is that considered unnecessary noise?

It’s good to thank people. Makes ‘em more willing to help next time.
Plus it’s always good to get verification that a suggested solution
actually works.

-the other Adam


kjg
April 13, 2008 | 1:28 pm

Quote: Adam Murray wrote on Sat, 12 April 2008 21:13
—————————————————-
> On Sat, Apr 12, 2008 at 11:23 AM, Adam Barnett wrote:
> >
> > I have an etiquette question, since I’m new to mailing list-type forums. Is it customary to thank people for their help, and/or update posts when a problem has been solved, or is that considered unnecessary noise?
>
> It’s good to thank people. Makes ‘em more willing to help next time.
> Plus it’s always good to get verification that a suggested solution
> actually works.
>
> -the other Adam
>

I agree with mister Murray.
Personally, when I have spent 5, 10, 15 minutes of my time to try answer a question and post an example patch, I like to know if it helped or not. When I get no verification/reply/thank you I will be less motivated to reply to a question by this person again.

Even if the patch/answer posted makes no sense at all, reply and explain why. 9 out of 10 times it is just because the original question was not phrased clearly enough. So, phrase questions carefully and be appreciative for any help offered to you.

Regards,
kjg

Viewing 7 posts - 1 through 7 (of 7 total)

Forums > MaxMSP