light function

yopla's icon

hi,
does anyone have any method or any tool or any idea for remove some points in a function ?

if i have 100 points (like in motion capture), haw can i have less point ?

like a factorization or a simplification, in order to keep almost the same form of the function
even if the form is not exacty the same... like a smoother

i think it's a known problem in math..
thanks

brendan mccloskey's icon

Is there any information in this thread that will help? It's about interpolating between points in a function:

Brendan

yopla's icon

thanks, i've already seen this post,
but it's about smoothing betwen points, not removing some of them (by the way, safunction is great, i'm waiting the pattr or write-file implementation)
ej.function allows removing same y point with different x, but it's not enough

brendan mccloskey's icon

Can you 'remove' points in realtime, with [snapshot~] or [speedlim]?

Chris Muir's response here has kind of gained legendary status:

Brendan

sorry that my maths is too weak to help directly :(

yopla's icon

yes, i've implemanted a speedlim
smothing could be nice to, but it still record a lot of point..

My goal is to record data and allow a nice way to edit it simply. Like for making a score from an improvisation,
with number boxes wich are mapped to a numerical music or a visual instrument, lights or automates.

in adobe after effect for exmaple, it's possible to smooth a function by removing keyframes and keep almost the same form of the interpolation.

after you move, change value, copy-paste keys,
it could be greate to do the same with some values in max ! by reducing the number of points and why not quantize thems, in a function curve.

I hope some algorythms already existing.. or i have to find great developers who can help me to do this tool. I'm sure it miss for music writers

cheers

Chris Muir's icon

One simple way to approach this is to drastically subsample, taking the maxima and minima per sample frame. For example, if you were taking decimating (ten data points to two, in this case) you would take the highest and lowest of the ten points and output those as your two. I've used this technique to draw audio waveforms which were drastically compressed from the real audio file.

seejayjames's icon

you could work with two [function] objects, one is the original. Grab every X number of points from the original one and put it into the new one, voila, downsample. This doesn't take the values into account, so you can't guarantee the same rough overall form, but it might be a start.

yopla's icon

an idea is to estimate Y-delta between two consecutive points (A and B). If the Y-delta bewteen the B and C points is almsot the same (with a tolerance), i estimate Ydelta between B and C and remove the B point. then estimate Ydelta between B(old) and C, if it's not almost the same, i keep C and estimate Ydelta between C and D ....

of course it could works only if points have a regular space between them on the X axis.
I'll maybe try this, if i can't find a better solution instead the chris muir sample frame one.
Seejayjames, i think your way gives the same result than speedlim during recording

Thanks a lot for your intereset

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

it's a proposition
it don't keep the max and the min :(
but estimate difference between points and keep some of them wich are really different from the lasts
maybe cumulate chris sampleframe method with this one...

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

a bit more effecient