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

    Jul 12 2012 | 5:24 pm
    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.

    • Jul 12 2012 | 6:05 pm
      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.
    • Jul 12 2012 | 7:07 pm
      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 :)
    • Jul 12 2012 | 8:39 pm
      As many other objects round will only give float output when initialized with a float argument.
    • Jul 12 2012 | 8:48 pm
      I would definitely gate the pwindows when not in use, that should help a lot.
    • Jul 13 2012 | 7:47 am
      you can also use a speedlim if you don't need them to update at the full framerate
    • Jul 15 2012 | 7:12 pm
      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.
    • Jul 16 2012 | 11:29 am
      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.
    • Jul 16 2012 | 1:08 pm
      Ok, have done that and pasted it below.
      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:
      See what I mean?
      Perhaps we are using different versions of Max? I'm on 6.0.5
    • Jul 16 2012 | 1:35 pm
      Well on my 2 machines they're ints! OSX 10.7.2, Max 6.0.5
    • Jul 16 2012 | 1:39 pm
      Ah I see what 's going on... I had another 'round' external in my search path. Sorry for the confusion!
    • Jul 16 2012 | 3:11 pm
      That'll explain it! No worries dtr, thanks for your help :)