smooth "bezier-like" fonction from 7 sliders ?

    Apr 03 2010 | 3:48 pm
    Hi, I'm trying to make a smooth "bezier-like" fonction from a little multislider that would have, for example, 7 sliders. I have built a little algorythm to do this, using a kind of "slopes-means" method - see picture below - but i'm not satisfied by the result, it is not smooth enough for me. How could i do to get a smoother result ? Do you know any object that already do this ?

    • Apr 03 2010 | 3:56 pm
      hey, that looks pretty good to me. a smoothing-styled function would be a nice addition to [function] or as a new object.
      You can also use filtergraph~ (with cascade~ to have multiple ones at once), then with the right filter type and other settings, your mousing will get you similar curves. just take the output and use it as you want (there's a query inlet to get the value of any point on the curve).
    • Apr 03 2010 | 4:34 pm
      >>hey, that looks pretty good to me.
      No!!! That's not good at all ! look at the handmade drawing below, made from the same exactly sliders values. This is what i'm looking for. It is quite different. The one above really have too much "mountains" compared to this one below...
      (p.s: but if you like it, the patch is in attachment)
      mmh, thanks for the filtergraph idea but I don't find this solution really practical. (i need the first value to be exactly 0., and the last exactly 1.)
      Aren't there anywhere a real "bezier" object or something similar ?
    • Apr 03 2010 | 5:20 pm
      hehe, I like the sketch. Just scan it and use that one! lol
      Will take a look at your mxj, sounds interesting. Would like to see how you did the math part.
      For bezier-style, maybe something with / strokepoint / Wonder if the nurbs object will do the smoothing automatically, seems like it might.
      I know this topic has been talked about before, and I think there were some other examples from people on here. Not sure what the results were though.
      Again, a real bezier-type object in the standard distribution would be great... or a solid way to make them out of [function] etc. via just the right math.
    • Apr 03 2010 | 10:20 pm
      In fact i realized that my math part (very simple averaging between slopes using a cosine fonction) is just wrong for this application.
      >>I know this topic has been talked about before, and I think there were some other >>examples from people on here. Not sure what the results were though.
      me too i remember more or less about a topic like this that i cannot recover. what i remember is that the result wasn't so interesting.
      >>Again, a real bezier-type object in the standard distribution would be great...
      ;-) ++1
      >>For bezier-style, maybe something with / strokepoint / >>Wonder if the nurbs object will do the smoothing automatically, seems like it might.
      mmh... you're the jitter pro. i found this : all this gl stuff is really mysterious to me... you think you could manage some simple example using this ?
    • Apr 04 2010 | 12:43 am
      The a-hspline3d external by André Sier. implements a Hermite spline - guaranteed to pass through the control points and allows adjustment of tension etc. I thought there was a 2d version too but I can't find it..
    • Apr 04 2010 | 3:23 pm
      iirc, there is a bspline object in jasch's lib, too, so you might like to have a look there.
      i did some testing of different interpolation methods some time ago. below is a short example that compares hermite vs. windowed sinc interpolation. i hope i got the maths right (the hermite code is from i think), it looks ok though.
      Max Patcher
      In Max, select New From Clipboard.
      sinc-interpolation should be 'smoothest' in theory. to make it work in praxis you need to truncate the infinite function using a window. the size of it and the window function itself have a big influence on the results of the interpolation. for simplicity in the example below i used a von hann window, but if you want to get serious with this method, you should consider something more versatile, e.g. a kaiser window. volker.
    • Apr 06 2010 | 6:22 pm
      Thanks guys!
      a-hspline3d is a very nice object.
      Volker, I put your hermite (in your example it was looking better than sinc) algorithm in mxj (mxj is much more manageable to put severals "smooth-func" in a patch), mmh there is still some situations where i feel it be could better*, (see preset n°5), but in general it's not that bad.
      I also managed to adjust better my slope-algorithm but hermite is really better. + some weird curves options.
      patch below.
      * i don't know if there is a way to change the "smoothness" of your hermite algorithm by changing the numerical factors ?
    • Jul 22 2010 | 4:35 am
      The thread is 3 months old, but I thought I would comment...
      I wrote an external called sa.function a while back that is like the function object and has multiple lines and bezier curve support. I attached a sample file with the curve you're looking for. It has a lot of features and requires combinations of shift/alit/cmd/ctrl/right-click to manipulate the curves, so make sure to check out the help file.
      The attachment only includes a OS X external, so let me know if you're using Windows. It's also only for Max5.
    • Jul 22 2010 | 7:44 pm
      Great work!!!
    • Jul 22 2010 | 10:55 pm
      Thanks Ben!
      I also forgot to mention this:
      Getting the y value of the curve requires solving an equation and sa.function has a couple of attributes to balance accuracy vs. cpu cost. @iter sets the maximum iteration the root finding algorithm will perform until it finds the root within the specified accuracy. @eps sets the accuracy and is specified as 1.0 * 10^@eps. So @eps = -6 (default) has accuracy of +/-0.000001. This means that the lower the value of @eps, the more iterations are required. If @eps is set too low, it may hit the maximum iteration set at @iter and may not produce the desired accuracy.
    • Sep 01 2010 | 9:06 pm
      Hello Toshiro,
      first of all, your sa.function is really great.
      I would like to use it for my patches but it can't be saved and recalled via pattrstorage nor preset, I'm looking for a workaround.
      The second minor problem, for me in a selfish perspective :-( , is it gives only the interpolated value of the working line in multipleline mode. I would like to have sometimes 1, 2, 3 or all working in parallel, I'm looking for a workaround too.
      If you've still time to spend on it, we never know ;-)
      Thanks Toshiro
    • Oct 07 2010 | 12:31 pm
      I can't believe I only just stumbled upon this thread. Toshiro, this is brilliant. Thankyou so much, I've been wishing Max had something like this in the distro since I bought it, and yours is so much better and more flexible than I could have wished for!
      How easy would it be to compile a Windows version too? :)
    • Feb 08 2011 | 11:53 pm
      I just bump this thread hoping the great Toshiro will read it.
      I was waiting for that object for ages so thank you very much !!!
      The only problem I have is the same as Filippo : it would be cool to be able to use it with pattrstorage or preset.
      For now I do it with coll...
      I think it should be add to the toolbox too.
    • Jul 14 2011 | 7:35 am
      Once again, this thread is being bumped because of the awesomeness of sa.function!
      Now, my wish for christmas this year is the merging of sa.function and ej.function...
      (Emmanuel Jourdan, are you reading this?)
    • Aug 23 2011 | 11:13 pm
      Hello again and I'm so sorry for the longest silence! I wasn't expecting responses and I'm also not very active on the Max forum...
      I very much appreciate all your feedbacks and I am happy to announce that I have a few exciting updates on sa.function!
      - preset now works. I'm still working on a bug with pattrstorage... I'm hoping to have that ready sometime in the near future ;-) - You can read multiple lines by setting the "readmultiline" attribute. - You can "refer" to another sa.funciton and save the hassle of duplicating functions. - You can undo/redo (!!) most editing. You can set the undo level by sending @undos when creating a sa.function. Default is 10 levels. - And of course, this all works on Windows now.
    • Aug 24 2011 | 10:40 am
      man toshiro. complete awesomeness.
      are you sure cycling74 haven't contacted you yet about including this in max6 ?!?!?!
      anyway, many thanks, i realise what a huge amount of skill and work that is and sharing is fantastic.
    • Aug 25 2011 | 3:40 am
      Thanks pid! I'm glad you like it! Cycling '74 hasn't contacted me yet, but maybe they will soon ;-)
    • Sep 08 2011 | 2:20 pm
      Toshiro, you're an absolute badman. I was just muttering about this in another thread. No disrespect to the other java-based bezier function object kicking around (I forget its name...), but yours is way more responsive and slick!
      And don't forget to let us know when you iron out that pattrstorage problem! Still, now that it's preset-compatible I don't need my ugly hacks to dump it to and from a jitter matrix.
      This really needs to be in the standard distro. It kicks arse. Maximum respec'
    • Sep 08 2011 | 9:24 pm
      I've spotted a small bug (gasp!)
      If you alt-click to delete a control point, no bang is sent out the right outlet.
    • Jan 19 2012 | 1:39 pm
      I cant get [preset] working at all from the download in this post or the download at
      Max 5.1.9 running as M4L on max lion 10.7.2
      Really really love the object a lot though ! However the issues with [pattrstorage] and [preset] are really killing it for me at the moment :(
      Edit: My bad - got this working with preset, thought id closed max and changed the object but it was still open in the background when changing the object :p Im using the latest version of the patch available from the link i posted in this post. Look forward to seeing pattr working :)