Forums > MaxMSP

### Multitouch data "pixelate" into a matrix

Oct 04 2013 | 9:54 am

Hi, sorry for the confusing title.

For example I have a 16×16 2D matrix. and I’ve pressed on a multitouch pad around (4,4) with a certain force, then the data in the (4,4) slot will be 1. And the slots around (4,4) – 8 of them – will have a number a bit lower (like 0.8). and the slots a step further away – 16 of them – will be lower again (e.g. 0.5).

And in this process, I can use my force to control how much the date would be in the slots.

Here in attachment I’ve made a simple drawing shows what I mean, there are 2 presses, the top-left is harder than the lower-right.

Thanks.

Edit: the top attachment is the right one, how do I delete posted attachments?

###### Attachments:
1. press-to-matrix1.png

2. Q截图-20131005005133.png

3. press-to-matrix.png

Oct 04 2013 | 11:08 am

So uhm… what’s the question? :)

Oct 04 2013 | 11:45 am

you could do that with jit.matrix
– jit.expr a 7×7 single plane float matrix with something like
expr sin(norm[0]*PI)*sin(norm[1]*PI) or expr 1.-hypot(snorm[0]\,snorm[1])
– multiply this matrix (jit.op @op *) with a float that is the scaled velocity (f.e. scale 0 127 0. 1.)
– overwrite your main 16×16 matrix at the right offset with that matrix
– jit.spill

Oct 05 2013 | 2:32 am

@tobiasros Thank you very much! I’ve nailed this down.

But my macbook pro gets so slow and lagging when I use this patch. Is this normal? I am totally beginner to jitter so I wonder if there’s some setting or optimization I can do to the computer or the patch. Thanks.

Here is the patch:

```<code>
-- Pasted Max  Patch, click to expand. --

</code>
```
Oct 05 2013 | 6:08 am

here some quick improvements:

call this abstraction placethematrix:

```<code>
-- Pasted Max  Patch, click to expand. --

</code>
this is main patcher:
<code>
-- Pasted Max  Patch, click to expand. --

</code>
next you could f.e. put the abstractions in a poly…
```
Oct 05 2013 | 6:04 pm

i gave it another go:
this one now is pretty fast on my 4 year old mbp

###### Attachments:
1. pixelate.zip
Oct 06 2013 | 9:47 am

Thank you @tobiasros!
This is super awesome and fast.

Btw, I found that if I have too many UI objects on my retina macbook, it can get slow very quick. I found out I can lug the system pretty efficiently just by dragging the jit.pwindow bigger… seems like a bug between max and retina macbook.

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

Forums > MaxMSP