help with maths for duration
I am creating a time based effect patch that falls in to a predetermined interval, and I need help with the math involved.
What I am looking to do is change playback speed of a buffer for a selectable amount of time, with selectable ramp-up to speed curves.
Example: You could choose to playback 1 bar of a sample in the space of a half note. But, I would like the user to be able to select from several different ramp-up curves, and i'm unsure of how to calculate the time compression on those.
To distract you from my lack of math skills, I have created a diagram to highlight my lack of drawing skills instead.
Thank you for the help
you have to integrate the rampfunction. let me explane:
imagine "speed" as length/time (like usual). now you have a function for speed, lets say linear ramp from 0 to 1 m/sec. the area under the function is the length:
y= m/sec:
1- .:
I . :
I . x:
I . xx:
I . xxx:
I . xxxx:
I. xxxxx:
0-------------> x=sec
integrate x --> 0.5 x^2 from 0 to 1 (for example) is 0.5* (1)^2 - 0.5*0^2 = 0.5 as you see as the area of a triangle. its the same for other functions like x^2 as ramp function.
now to your problem
speed in this case is not length but samples per minute ( doesn't infact the math) and if you want to know the length,that is passed after an amount of time, thats it:
y=0.5*x^2
sorry for writing so much, just trying to make things clear and im not a teacher. so summary:
- integrate the ramp function f(x)-->F(x)
- calculate with ramp time F(ramptime)
example: ramp from speed in 3seconds with rampfunction f(x):
you want to know how long does it take my function to pass 0.7 speed
so F(3) is the "original time" you have passed threw ramp.
if you want to stretch lets say the first 4 seconds of a song with a ramp function and want to know how long it takes than, you have to solve the other way around so F(x)=4 and x is it.
....oh god, im really not a teacher. but its not difficult at all, easy school stuff... perhaps you have particular ramp functions, so i can give you an example. hope it helped
forget the "graphic" i just expected it to fail, not importand
great! thanks for the info. i'll be on a plane for a few hours tomorrow, so i'll tackle it at that time, as i've been solid busy since posting this problem.
i'll let you know of any success/failure/ignorance that i encounter.
you need to know what the equation of the ramp-up curve is before you can integrate it. so you need to provide that information before anyone can really help you... did you try implementing the formula for a straight line ramp I provided here:
if so, did it work?
T
[redacted]
So, it turns out that there is a curve~ object that does exactly what I was looking for.
I got to finally spend some time on this patch while on a plane to SF and back, and I've simplified it down to just the time comparison and ramp time. At present the patch just ramps back down with the same duration as the initial ramp up.
Does what I've done here make sense? Is this a good way to do it?
Eventually I'd like this to be inside a poly~ , so that i can set it up as an MLR-type monome patch, once i get this idea more refined.
Here's the patch: