Issues on creating a dinamically resizable mosaic

LSka's icon

Hello everybody,
Taking inspiration from Jitter Recipe #36 https://cycling74.com/tutorials/jitter-recipes-book-3/, I started working on a patch that grabs single frames and sends them to a matrix in a "mosaic" fashion. What I was trying to obtain was that the size of the "tiles" varies according to frames number. Hence, a single frame takes all the screen, two frames split it in a half and so on.

Max Patch
Copy patch and select New From Clipboard in Max.

I'm almost there. I found the way to create a square grid that adapts to the number of frames, and I can use this info to control the mesh and to feed the texture (as in the "TinyVideo" recipe)
Now I'm stuck in correctly set the vertical position of the frames in the matrix that will become the texture. It seems I can't figure out the correct math.

Please have a look at this patch. Try clicking a few times. It seems to work somehow for some values, but at the beginning it outputs values too high for the "row" coordinates, while the "columns" are set correctly.
Any hint would be appreciated.

LSka's icon

Still banging my head against the wall.

Max Patch
Copy patch and select New From Clipboard in Max.

Here's the original part of the TinyVideo patch, which works with 100 frames

Max Patch
Copy patch and select New From Clipboard in Max.

And here's my attempt to make it work with a different number of frames.
I made some modifications and now it works correctly for the first four frames (I decided to start from a 2x2 grid), then the vertical values start to go somewhere I don't understand....

matmat's icon
Max Patch
Copy patch and select New From Clipboard in Max.

hi
the original part of "TinyVideo" with some tricks....

LSka's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Thank you, matmat, you solved the issue.
Now I got my patch to work!

the only small issue remaining is related to the redrawing of the tiles when the page is filled.
For example, when 4 tiles are displayed and I grab the 5th frame, the tiles are not resized until the 6th frame is grabbed. This happens also for the 17th frame, and so on.

P.S.
Here I limited the matrixset to 64, but I am currently using it with 1024 and seems to work fine.

Wetterberg's icon

LSka, it seems your problem for that lies in the power of two math you've got going on, plus the count itself. Try adding a [+ 1] between the counter and the subpatcher and see what happens :)

LSka's icon

Great, thank you Wetterberg!

LSka's icon
Max Patch
Copy patch and select New From Clipboard in Max.

So, here we are! Let's share it!

Thanks again