Forums > MaxMSP

building a text string / execution order – surely my patch could be much simpler

October 12, 2011 | 7:14 pm

Hi all, I’ve been stuck on this problem for ages, I have something that works but I suspect it could be done a lot simpler, but I’m just hitting a mental block. I’m building just one list from 3 inputs (integer, path prefix, retrieved name) and I can’t believe I end up with so much logic!

It’s a general execution sequence / string building problem but just so you know why I’m doing it: I’m building an iPad interface into LIVE using TouchOSC. I’m requesting names from Live which then need to be appended to a text string to send to the iPad using OSC.

few points to note (I might be wrong about any of these!):
-the OSC path (e.g. /1/label1) needs to be without spaces
-sending a ‘name with spaces’ to OSC needs to be with quotes, otherwise it only picks up the first word (so I’m using symbols to move names around my patches)

Here’s what should happen:
1) In order to populate, say, ‘parameter 1′ (2, 3…) : start by sending the integer ’1′ (2, 3…) into the patch, this should be the trigger
2) a text string needs to be built which is the path for OSC: /1/label1 (/1/label2, /1/label3..)
3) a name needs to be retrieved from LIVE (simplified in the grey box in the patch) to be added to the OSC path
4) the full string to send to OSC needs to be built, the result should look like this: /1/label1 "parameter name blabla"

Could you have a look at the attached patcher and see how it could be simplified?

I think this should be a lot simpler, but I can’t work it out
-I tried using ‘sprintf’ but it’s triggered by the first inlet, and I need it from the second – or I have to add logic which again is clutter
-I tried using sets of prepends but they don’t allow you to combine text strings without spaces (Eg "label" + "1" = "label1")

– Pasted Max Patch, click to expand. –

Thanks so much!!



MIB
October 12, 2011 | 7:28 pm

not sure if this is any simpler. you use 4 objects, here I use three… yours seems pretty straight forward…

– Pasted Max Patch, click to expand. –

October 12, 2011 | 8:05 pm

thanks! I like the use of ‘i’ rather than a message box, I am told I should prevent using message boxes. Still a lot of logic just to turn 3 inputs into one string, or is it me?


October 12, 2011 | 8:14 pm

It’s not a lot … this is max after all – comes with the territory :p


October 12, 2011 | 8:22 pm

really? ok I may just have to get used to it… lots of subpatching and abstractions then :-)


October 13, 2011 | 9:46 am

Alternately:

– Pasted Max Patch, click to expand. –

Not much difference on the object count front, but just another way to solve the task.

Don’t get too hung up about message boxes. Yes, they use a few more cycles than non-UI objects (this is true, of course, for all UI objects to varying degrees). But if you need the visualization they provide, by all means make use of them.

Lots of subpatching and abstractions is Good. In general.


October 13, 2011 | 10:06 am

MIB, Tim, Peter, thanks a lot for your help!


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