On Sun, Nov 12, 2017 at 3:39 PM, Henning Thielemann <email obscured>> wrote: > > On Sun, 12 Nov 2017, Evan Laforge wrote: > >> Oh ok, I'll take a closer look at the source. I thought the >> underlying representation was a list, but it's hard to tell how >> anything works with no documentation. > > Please look at the two examples. I see, I guess you mean NodeList.lookup is looking in a binary tree. > Multiplication cannot be done exactly. You could try an approximation. > > For max(f,g) you need to solve the cubic equation f(x)-g(x)=0 and split at > the zeros of f-g. > > For ad-hoc functions you need an approximation, again. But ... audio rate > sampling is approximation, too, isn't it? Right, I'm not worried about approximation, as long as it's not too approximate. It's just that I'm not sure about the complexity of the implementation for those operations. If it's too hard for me to figure out, then it's as good as impossible! If it's possible, but makes me have to think really hard for a long time every time I want to add some new operation, or worse wind up with something which is not obviously correct and hence buggy, then that's not too great either. I tend to experiment with possibly "unprincipled" ones which are nevertheless useful in practice, for instance I quite frequently use a kind of scaling where (-1, 0) scales from 0 to x, and (0, 1) scales from x to the max, which is usually 1, and a nice thing about the constant samples is you just give the function to a 'zipWithY :: (Y -> Y -> Y) -> Signal -> Signal -> Signal' and you're done. Anyway, there's nothing for it but to try and see how it looks like it'll turn out. Thanks for the reference to cubic hermite splines. I previously used cubic bezier curves, and muddled through the implementation from various wikipedia pages. It takes two weights, which influence flatness at the beginning and end, which is ok to use, but less general than a slope. Also I see I had to do some awkward binary search guessing to find the value at a specific 'x'. I forget the details now but I guess since the bezier's output is (x, y) pairs, I can't just directly find the y for a given 'x', hence the searching. That's probably pretty inefficient and a sign I should have used a better technique. It looks like Piece.hermite1 takes an arbitrary x and directly computes the result, so it doesn't have that problem. What's the difference with the other Types, like cubicLinear and cubicParabola, given that interpolatePiece functions are all the same? I gather the Basis.coefficientsToCubicLinear and CubicParabola are just using different techniques and inputs to compute hermite1 values, which ultimately goes into the same kind of interpolation. I guess the idea with the Hermite spline is that since in and out slope are the same, you automatically get a smooth function. But on the other hand, how do you influence how sharp the curve is? With the bezier implementation I can get back to linear interpolation by setting both weights to 0, or get a sigmoid kind of shape by setting them both to 0.5. However, the Wikipedia page claims that Hermite and Bezier are simply different representations for the same thing, and can be converted mechanically, so surely they should have the same capabilities?