a question for advanced scripting - interpolating

Discuss Lemur and share techniques.
Post Reply
Softcore
Regular
Posts:1639
Joined:04 Nov 2012 08:34
a question for advanced scripting - interpolating

Post by Softcore » 22 Feb 2013 21:14

Ok Im not sure how to phrase this...but I definitely need to study - learn a bit how to achieve things like: a value-expression after some sort of trigger rises to another value but not jumps to it - or lets say it interpolates between two target values, with a non linear curve for a given amount of time....

Not sure what exactly templates I should study or ermmm - well actually I'm lost....

for example how do I achieve

(if Switch.x==1) Multiball.x goes from 0 to 1 with a specific curve and a specific speed? Or what if I dont have target values and I just want it to interpolate non-linearly from current value to bigger ones for a given period of time?

Im quite sure I havent even scratched the surface of Lemur when it comes to working with vectors, mathematics and all that stuff and that my answers are over there somewhere.

Any chance of a guidance, tips, clues? even already made templates in the user library which might include helpful scripts are welcome.

Thanks!

P.S. - Also is there sometghing wrong with sign(a) arithmetic function? Im not getting what I should - I get zero when a<0 and error/null when a>0

brianc
Regular
Posts:87
Joined:10 Jan 2012 02:16

Re: a question for advanced scripting - interpolating

Post by brianc » 22 Feb 2013 21:59

Softcore wrote:P.S. - Also is there sometghing wrong with sign(a) arithmetic function? Im not getting what I should - I get zero when a<0 and error/null when a>0
Yeah, I ran into issues with sign as well (http://liine.net/forum/viewtopic.php?f=25&t=2335).

An easy work around is to make your own sign(val) expression that does something like val<0?-1:1


Traxus
Regular
Posts:216
Joined:30 Nov 2012 06:19
Location:Detroit
Contact:

Re: a question for advanced scripting - interpolating

Post by Traxus » 22 Feb 2013 23:34

I've done a bit with timing, as far as making breathing EFX faders on my template for Serato Scratch Live, however that was a linear fade.

Just digging though my code again, its an awful lot to try and explain via example or in absract, but a lot of it has to do with the added features I have regarding temporarily pausing a fade in or fade out etc...

If i recall correctly, the jist of it was revolved around treating the frame as an interval.

When you fire your act(); function, you need to store a variable of the millisecond value of the Lemur clock for that particular moment. I believe I refer back to this value at every iteration.
You can then add to that value to determine an end time for this action, this will help you determine the size of the steps that get taken every frame. Longer action times mean smaller steps, mean smother transitions.
You'll need a function that returns the desired step value for both the x and the y of the multiball. This needs to take into account the total distance to be traveled as well as the time it takes to travel.
I think i then setup a listener that stopped everything when the fader x (or x and y in your situation) reached their locations. This can sometimes leave a few MS difference in the timing but nothing noticeable.
Then basically, on every frame, if the transition is not marked as complete set the x and y to their current locations plus the step values calculated on the previous iteration, fire the step calculator again, store the new values, repeat.

Hope this was enough to atleast get some gears turning. It was a helluva headache just to get a linear one working, albeit i was also learning the Lemur syntax etc...

Joe Soap
Regular
Posts:475
Joined:07 Jul 2012 15:04

Re: a question for advanced scripting - interpolating

Post by Joe Soap » 25 Feb 2013 05:40

AB Vekter?

Softcore
Regular
Posts:1639
Joined:04 Nov 2012 08:34

Re: a question for advanced scripting - interpolating

Post by Softcore » 25 Feb 2013 08:43

Thanks for the replies so far! I 'll have a look at AB's stuff - even though I have tried in the past and I was kinda getting lost...lol

Post Reply