1

I am working with bezier curves to represent wave data for audio. I want to then sample the wave at an x coordinate and get the y coordinate so that I can then convert it to PCM data. Now since bezier curve are represented with a parametric equation this could pose problems as there could be multiple y values an x value, but with the curves I would sampling I can guarantee that they meet the criteria of a function only they are still represented para-metrically. So my question is, is there a way to directly sample the y value based on an x value? If not what would be the best way to go about doing this? My best idea right now is move along the curve until I reach the desired x-value and then use that y value, but this feels slow and inefficient. Thank you.

  • Not knowing the details of the equations for Bezier curves, I'd think you'd just solve the parametric equation for x for t in terms of x, and then plug that value into the equation for y. My bigger question is why you would use Bezier curves to model audio? What are you trying to achieve, and do you know about the Fourier transform and the spectral nature of audio? – Linuxios Nov 08 '17 at 20:21

1 Answers1

1

Yes, it is possible but it is somewhat complex. You must solve for t at a given x and then calculate y from t. This can be approximated with the newton-raphson method. This link does a much better job explaining how to implement it: http://greweb.me/2012/02/bezier-curve-based-easing-functions-from-concept-to-implementation/

Another option is to use a an explicit bezier curve, not a parametric bezier curve. Explicit meaning that y is a function of x (i.e. y=f(x)). As opposed to a parametric equation where both x and y are functions of t (i.e. x=f(t) and y=f(t)). As long as the x values of the control points are evenly spaced the curve is explicit and you can assume that x=t.

EDIT: I should point out that my statement of equally spaced x coordinates means x=t is an over-simplification. That would be true if the x coordinates were evenly spaced between 0 and 1. Otherwise you need to convert the x coordinate to a value between 0 and 1. For example if the x coordinates were evenly spaced and located at 3,4,5,6 then t = (x - 3) / (6 - 3).

GCB613
  • 174
  • 13