[chuck-users] Vec3 interpolation interpolate.ck

herman verbaeten hverb54 at hotmail.com
Sat Mar 7 06:01:18 EST 2020


Hi,
In the examples included in the miniaudicle installation there is a "interpolate.ck"
But i cant't find any documentation about this. It uses vec3. I'd like to know more about how to use i.update and i.interp. Thanks !
Kind regards,
Herman

// name: interpolate.ck
// desc: using vec3 as an non-linear, slewing interpolator
//       this is quite useful to making a percentage progress
//       towards a goal, in an amount proportional to the slew
//       and some delta time

// connect
SinOsc foo => dac;

// the interpolator
vec3 i;
// the interpolation rate
10::ms => dur irate;
// set initial .value, .goal, .slew
i.set( 440, 440, .05 * (second/irate) );

// spork interpolate function
spork ~ interpolate( irate );

// main shred sets the goal
while( true )
{
    // set interpolator goal
    i.update( Math.random2f(200,1000) );
    // every so often
    500::ms => now;
}

// function to drive interpolator(s) concurrently
fun void interpolate( dur delta )
{
    while( true )
    {
        // interpolate (can also get new value via .value)
        i.interp( delta ) => foo.freq;
        // advance time by rate
        delta => now;
    }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20200307/3809c216/attachment.html>


More information about the chuck-users mailing list