[sdiy] Random Timbre Synth
Tom Wiltshire
tom at electricdruid.net
Sat Aug 20 20:10:54 CEST 2011
On 20 Aug 2011, at 17:24, Scott Gravenhorst wrote:
> Joel B <onephatcat at earthlink.net> wrote:
>> Hi Scott,
>>
>> Question about your Spline function:
>>
>> y = ( x - 1 ) * x * ( x + 1 )
>>
>> How does this get you the points in between known point x1,y1 and
>> known point x2,y2? I've been trying to figure out some things
>> like this for both a game I am working on (computing curved
>> attack vectors) and for a simple synthesis program I'm working on
>> (figuring out how to draw & scale smooth waveforms on the screen)
>>
>> How are you getting from the starting y position to the
>> destination y position, since that formula doesn't seem to take
>> into account either, but just generates a y based on an x value,
>> but you are somehow using this formula to connect two points on
>> the y axis over time (or distance)
>
> Hopefully, I won't mumble-bumble this explanation...
>
> First, I restrict the cubic function's operation to go from one peak to
> the other. This means x is restricted to -0.58 <= x <= 0.58. This and
> the peak Y values are scaled so that the spline output is -1.0 < y < 1.0.
>
> The x difference for the two points, (x1,y1) and (x2,y2) is calculated.
> The x span for a full spline is 1.16, this value is divided by the x
> difference to give an x increment value used in the point generation
> process.
>
> The original y1 and y2 values are used to calculate a y offset and a
> sign value. Since the Y values are pre-adjusted to be forced
> symmetrical about the x axis, the offset is used to restore their
> original positions. The sign value is used to flip the spline.
Ok, so can I check that I understand this?
You're using a cubic function that starts bottom-left, comes up, passes through x=-1, curves back down through x=y=0, and then (symmetrically) curves back up through x=1 before heading off to the top-right (I checked it in a graphing program).
But you're only using the section between X=-0.58 and x=0.58, which looks pretty much like the downhill right hand side of a raised cosine curve. Mathematically not very similar, but visually it's close, and it'd serve the same purpose. Presumably it has the same property as the cosine that the slope is zero at the given points. This is good because it hides the joins!
So what you're doing between the random point is basically an alternative cosine interp?
Or does it involve more than just two points?
Thanks,
Tom
More information about the Synth-diy
mailing list