jit.matrix setcell messages… should they be used intensively?

Jul 12, 2012 at 5:24pm

jit.matrix setcell messages… should they be used intensively?

Here’s a extract of a patch I’m working on at the moment.

Notice the part in the bottom right corner – I am using the setcell message to change the colour and alpha of the single cell matrix every 20ms.

Is it advisable to use the setcell message this intensively? Is that what it was intended for?

In this patch, there seems to be no problem. However, in the context of my larger patch (a Max for Live device), the matrix seems to be lagging behind the panel (on the left of the patch). It could just be another part of the patch that is causing issues.

– Pasted Max Patch, click to expand. –
#35936
Jul 12, 2012 at 6:05pm

Should work. I have patches with way more setcells running fine.

Does your larger patch have all these GUI objects updating all the time as well (message boxes, pwindows, swatch, dial, attrui)? These eat a lot of performance when updated at high rates.

In an older version of Max I used swatch in the same way to convert hsl to rgb. I found that back then it was taking a lot of CPU. I switched to an external or a javascript to do the conversion math instead, don’t remember which exactly.

Little note: round already outputs integers so no need for the unpack-pack behind it.

#123095
Jul 12, 2012 at 7:07pm

Thanks for your input dtr.

Yes, I do have a few pwindows running in different patches. I do need them for monitoring purposes, but don’t necessarily need all of them running all of the time. Perhaps I should dynamically patch them in when a device is in focus.

I was also using my own js file in my patch, but I swapped it for the internal conversion for the purposes of pasting it here – I didn’t know there was a performance difference, but I’ll keep an eye on that.

Finally, thanks for your tip on the [round] object :)

#123096
Jul 12, 2012 at 8:39pm

As many other objects round will only give float output when initialized with a float argument.

#123097
Jul 12, 2012 at 8:48pm

I would definitely gate the pwindows when not in use, that should help a lot.

#123098
Jul 13, 2012 at 7:47am

you can also use a speedlim if you don’t need them to update at the full framerate

#123099
Jul 15, 2012 at 7:12pm

dtr – [round] is outputting floats. It’s rounding them to the nearest integer, but the data type is still float e.g. 1. instead of 1

How can I make it output an integer?

edit: the input is a float.

#123100
Jul 16, 2012 at 11:29am

In the patch in your first post, connect a message box or print to your round output and you’ll see it’s outputting ints.

#123101
Jul 16, 2012 at 1:08pm

Ok, have done that and pasted it below.

– Pasted Max Patch, click to expand. –

Here’s an example of the output shown in the message box:

0. 255. 71. 97.

These are not ints. They are floats rounded to the nearest integer. You can tell this by the dot after each one. Some objects expect integer input, they will not accept rounded floats.

For example – look what happens when I remove the unpack/pack and feed the matrix with setcell messages using floats. The colours in the jit.pwindow are incorrect:

– Pasted Max Patch, click to expand. –

See what I mean?

Perhaps we are using different versions of Max? I’m on 6.0.5

#123102
Jul 16, 2012 at 1:35pm

Well on my 2 machines they're ints! OSX 10.7.2, Max 6.0.5

[attachment=199449,4189]

Attachments:
  1. intsorfloats.jpg
#123103
Jul 16, 2012 at 1:39pm

Ah I see what ‘s going on… I had another ’round’ external in my search path. Sorry for the confusion!

#123104
Jul 16, 2012 at 3:11pm

That’ll explain it! No worries dtr, thanks for your help :)

#123105

You must be logged in to reply to this topic.