making a matrix scroll the *other* direction

Jan 13, 2010 at 12:50am

making a matrix scroll the *other* direction

I recently learned the trick where one can make a jitter matrix seem to scroll to the right by offsetting the source and destination dimensions.

I’m wondering why this isn’t reversible, in other words why making the dstdim range one value higher than the srcdim range seems to erase the matrix rather than making it scroll to the left.

Is there a way to make a jitter matrix scroll in both directions?

#47753
Jan 13, 2010 at 4:53am

You wanna try posting up a small patch that shows what you’ve got so far?

AB

#171732
Jan 13, 2010 at 5:29am

Andrew, how do I get an icon on the forums?!

#171733
Jan 13, 2010 at 6:12pm

Here you go:

– Pasted Max Patch, click to expand. –
#171734
Jan 15, 2010 at 12:16am

huh, interesting patch! Might be some different approaches that would work better, depending on your end goal, but with your current configuration, you can just flip ‘er around:

– Pasted Max Patch, click to expand. –
#171735
Jan 15, 2010 at 12:25am

I’m a little confused. Doesn’t this work exactly the same as the patch I posted?

#171736
Jan 15, 2010 at 12:33am

whoops, posted wrong patch. i’ve updated the previous post.

-Ben

#171737
Jan 15, 2010 at 5:14am

Interesting, I never thought of just flipping it around like that. This works for what I need, but I still want to know why my way didn’t. I don’t understand it.

#171738
Jan 15, 2010 at 11:49pm

On second thought, I’m not sure this solution would work for my patch as I wanted to be able to toggle between scrolling both directions so I can center the data in the pwindow. Back to the beginning…

#171739
Jan 25, 2010 at 4:10pm

Any more ideas?

#171740
Jan 25, 2010 at 10:19pm

jit.convolve can also be used for shift-register style scrolling. Just change which pixel of the kernel is set to 1. to switch scrolling direction.

– Pasted Max Patch, click to expand. –
#171741
Jan 26, 2010 at 12:35am

Thanks Andrew! This should do everything I need. And good guess as to its use: a shift register.

I only barely understand how this works and still don’t understand why my original example doesn’t, but perhaps I should let it go unless anyone wants to offer an explanation.

#171742
Jun 22, 2013 at 4:54pm

(Sorry, a little late to the party…)

I think I see what was wrong with original coding.
The matrix was being copied onto itself. That is an okay thing to do, unless you are overwriting data in the matrix that has not been copied yet.

So apparently Max first copies location 1 into location 0…
0 <- 1
1 <- 2
etc
and that works for the shift left.

But for the shift right, the original data in location 1 is destroyed by the copy, for it now contains the data from 0, so that data is replicated throughout the matrix.
1 <- 0
2 <- 1 ; wrong
3 <- 2

So the solution is to use an extra data copy, a second matrix.

– Pasted Max Patch, click to expand. –
#253759
Jun 22, 2013 at 10:02pm

You could use the ‘offset_x’ attribute of jit.rota.
<code>

– Pasted Max Patch, click to expand. –

</code>

#253766
Jun 23, 2013 at 2:37pm

Nice. That is definitely the most elegant way to do it.

I think I looked briefly at jit.rota, but got scared away by the apparent complexity of the underlying operations. (Cosines and such for each x,y new location, according to the formula on the help page.) I have an underlying aversion, maybe a phobia, about code that is not at least reasonably efficient. Of course, particularly on modern machines, I’m being silly.

#253811

You must be logged in to reply to this topic.