Page 1 of 2

Rotate stepnote patterns

Posted: 02 Dec 2014 18:59
by ChiLam
Hi,

I'm wondering if it is possible to shift/rotate the stepnote patterns using a script?

I'm looking to add a button which will move the entire stepnote pattern one step to the right/left but don't seem to find a way to achieve this - any ideas guys? ;)

I'm guessing that the StepNote object is built as an array but I can't find any details in the editor relating to this!

Re: Rotate stepnote patterns

Posted: 02 Dec 2014 20:55
by ndivuyo
Here is one solution. Take from the code, there are other ways to do it too.
hope it helps

Also you can add additional scripts to store the array so you won't lose the pattern if it goes too far left or right

Re: Rotate stepnote patterns

Posted: 02 Dec 2014 21:23
by ChiLam
Wow, thank you so much! I shall study this immediatley - i'm guessing from your advice that I will need to modify to allow the pattern to "wrap-around" without falling off?

Again, thank you very much!

Ok! Have tested and understood - great work - unfortunatley I cannot seem to fathom the way to "rotate" the steps so they don't dissappear!?

Re: Rotate stepnote patterns

Posted: 03 Dec 2014 02:49
by ChiLam
OOf - I tried all night to find a way to make the pattern wrap-around on itself with no joy :cry:

Its pretty darn hard for a total newb to understand all the programming jargon. Thanks to ndivuyo i'm tantalisingly close to realising the step-sequencer I desire but I need to get this wrap-around business done - desperatley! Hey, i'd be more than happy to pay for someone to help me out on this - I realise that it takes time and effort and brains to be good at this programming lark and i'm failing miserably.

I found this script posted by another Lemur master called Macciza but cannot for the life of me make it work!


Heres a script for shifting
shift(array, val) Manual Trigger

decl len = sizeof(array);
val = val % len;
if(val>0) array={subarray(array,len-val,val),subarray(array,0,len-val)};
if(val<0) array={subarray(array,abs(val),len-abs(val)),subarray(array,0,abs(val))};
return array;

Re: Rotate stepnote patterns

Posted: 03 Dec 2014 20:29
by ndivuyo
Hey ,
I'll take a look at it in a bit, so you need the pattern to repeat starting at the opposite end it moves off of (wrapping around)?
Unless another kind user helps you out, I'll see if I can put something together later, I'm not sure but if the StepNote object had a 'z' value it would probably be easier, I haven't thought about it much yet.
expect to hear back..

Re: Rotate stepnote patterns

Posted: 03 Dec 2014 20:35
by ChiLam
Hey big thanks for helping!

I have nearly managed - would you believe it! It works but only when going to the left! I can't seem to make it work going to the right though, which is strange since the script for both is identical apart from one plus/minus sign?

here is the template - massive thanks again, this is killing me it is so close!

Re: Rotate stepnote patterns

Posted: 03 Dec 2014 21:28
by ndivuyo
AA
well I almost got the right to work. It works except for the last value doesn't go through and they pop out at the start 1 space too far ahead.
It's almost there, so maybe you, or a greater mind, or me later when I have time will figure it out!
Good luck

Re: Rotate stepnote patterns

Posted: 03 Dec 2014 21:36
by ChiLam
Thanks - much appreciated! Ill take a look and see but I doubt ill be able to solve this puzzler alone, Im too much of a newb unfortunately but ill give it a go.

Seems odd that it goes ok in one direction but not the other?

Thanks again kind sir!

Re: Rotate stepnote patterns

Posted: 03 Dec 2014 22:07
by ChiLam
Nice one! Solved!

Thanks so much for your help - I enjoyed seeing the template come back noticeably more streamlined and of a smaller size he he!

It all got fixed by changing the line from:

StepNote.x = subarray(vals,1-i,N);

to:

StepNote.x = subarray(vals,abs(1-i),N);

I have no idea what this means but it worked and I am a happy happy man! Could not have done it without your help so thanks a million! :D


AAAArghhh! No it doesn't work! I should have tested more - back to it then :cry:

Re: Rotate stepnote patterns

Posted: 03 Dec 2014 22:21
by Macciza
Hi
Here is a version using the above shift script,
Just read through the logic of the script
If it larger then 0 the script subarrays the array one way ,if less then 0 it does it differently
If you look at the subarray stuff you will see it is merely reassembling the original array based on the input number
In the switches i have merely used 1 and -1 but it could be any number to shift larger amounts ..

Cheers
RotateStepNote_mac.jzml
(8.81 KiB) Downloaded 51 times