~pbatch/gestvm

23122bfacfa56778e1faf19f9dcf1ce9b674ae26 — Paul Batchelor 1 year, 10 months ago 5280caf
added get_last_values
1 files changed, 53 insertions(+), 3 deletions(-)

M gestvm.org
M gestvm.org => gestvm.org +53 -3
@@ 279,11 279,11 @@ SKFLT gestvm_tick(gestvm *gvm, SKFLT cnd)

    cnd = rephasor_tick(gvm, cnd);

    /* VM process */
    /* VM process! */

    vm_tick(gvm, cnd);

    /* Interpolate */
    /* Interpolate! */

    out = interpolate(gvm, cnd);



@@ 1316,6 1316,21 @@ gestvm_behavior behavior;
#+BEGIN_SRC c
gvm->behavior = b_linear;
#+END_SRC

The =a= value caches the last alpha value used for
interpolation. Intended to be used for applications
that want to build on top of or enhance the gesture
synthesizer.

#+NAME: gestvm
#+BEGIN_SRC c
SKFLT a;
#+END_SRC

#+NAME: init
#+BEGIN_SRC c
gvm->a = 0;
#+END_SRC
** Some Behaviors
Some behaviors include linear, step, and glissando.



@@ 1382,7 1397,8 @@ static SKFLT interpolate(gestvm *gvm, SKFLT phs)
{
    SKFLT a;
    a = gvm->behavior(gvm, phs);

    /* cache interpolation value */
    gvm->a = a;
    if (gvm->interp)
        return (1.0 - a)*gvm->cur + a*gvm->nxt;
    return a;


@@ 1431,6 1447,40 @@ static gestvm_behavior find_behavior(int id)
    return b;
}
#+END_SRC
** Get Last Interpolator Values (for extending GestVM)
GestVM will cache the state of the last call
to =gestvm_tick=. By the time it comes to the interpolator,
this boils down to 2 values (called =x= and =y=), and some
interpolation coefficient.

This function retrieves these copies these values to their
respective variables.

#+NAME: funcdefs
#+BEGIN_SRC c
void gestvm_get_last_values(gestvm *gvm,
                            SKFLT *x,
                            SKFLT *y,
                            SKFLT *a);
#+END_SRC

The x and y variables are substitutes for cur (current)
and nxt (next). Outside the scope of gestvm, these
terser variable names align more with the more cannonical
mathematical notations for interpolation.

#+NAME: funcs
#+BEGIN_SRC c
void gestvm_get_last_values(gestvm *gvm,
                            SKFLT *x,
                            SKFLT *y,
                            SKFLT *a)
{
    *x = gvm->cur;
    *y = gvm->nxt;
    *a = gvm->a;
}
#+END_SRC
* Weight
** Overview
This is an optional signal generator used to influence