9. Skewer

9.1. Overview

A skewer specialized rephasor that applies temporal skewing. It can be computed with skewer_tick.

<<gestvm>>=
gestvm_rephasor skew;

9.2. Compute Function

<<static_funcdefs>>=
static SKFLT skewer_tick(gestvm *gvm, SKFLT phs);
<<funcs>>=
static SKFLT skewer_tick(gestvm *gvm, SKFLT phs)
{
    SKFLT out;

    if (gvm->update_skewer) {
        gvm->update_skewer = 0;

        if (gvm->skewdur > 0) {
            SKFLT scale;
            scale = 1.0 / gvm->skewdur;
            gestvm_rephasor_scale(&gvm->skew, scale);
        }
    }

    out = gestvm_rephasor_tick(&gvm->skew, phs);

    out = gvm->skewer(gvm, out);

    return out;
}

9.3. Initialization

When first initialized, this works as a pass-thru signal, which is a rephasor with a scale of 1.

<<init>>=
gestvm_rephasor_init(&gvm->skew);
gestvm_rephasor_scale(&gvm->skew, 1.0);

9.4. Skewdur

Since the Skewer only produces slower values, rephasor scaling values are always less than 1. This value is represented as an inverse value called skewdur. So, 1/2 scale would be 2, 1/3 would be 3, etc. Only positive integer values greater than 0 are used.

<<gestvm>>=
int skewdur;
<<init>>=
gvm->skewdur = 1;

Any time this integer value is changed, the Skewer rephasor scaling value is also updated (as the inverse).

The integer value is also sent to the Main Rephasor scaling amount. It will scale the Main Rephasor's numerator value. This will invert the rephasor of the skewer.

9.5. Update Skewer Flag

The update_skewer flag is set every time the VM changes the skewdur value is updated. This will tell the skewer to update the rephasor scaling value.

<<init>>=
gvm->update_skewer = 0;

In Uxn, skewing behavior type is set via an id. These can be found in the callback find_skewer.

<<static_funcdefs>>=
static gestvm_behavior find_skewer(int id);
<<funcs>>=
static gestvm_behavior find_skewer(int id)
{
    gestvm_behavior s;

    s = s_passthru;

    switch (id) {
        case 0:
            s = s_passthru;
            break;
        case 1:
            s = s_exp_pos;
            break;
        case 2:
            s = s_exp_neg;
            break;
        default:
            break;
    }

    return s;
}

9.6. Skewing Behavior

The actual "skewing" is done using a stateless function via a behavior callback called skewer.

<<gestvm>>=
gestvm_behavior skewer;
<<init>>=
gvm->skewer = s_passthru;

9.7. Some Skewing Behavior Functions

Pass-thru will disable any skewing. Exponential will apply either positive or negative exponential skewing. This is applied after the rephasor.

<<static_funcdefs>>=
static SKFLT s_passthru(gestvm *gvm, SKFLT a);
static SKFLT s_exp_pos(gestvm *gvm, SKFLT a);
static SKFLT s_exp_neg(gestvm *gvm, SKFLT a);
<<funcs>>=
static SKFLT s_passthru(gestvm *gvm, SKFLT a)
{
    return a;
}
<<funcs>>=
static SKFLT s_exp_pos(gestvm *gvm, SKFLT a)
{
    return (1.0 - exp(1.5*a)) / (1.0 - exp(1.5));
}
<<funcs>>=
static SKFLT s_exp_neg(gestvm *gvm, SKFLT a)
{
    return (1.0 - exp(-1.5*a)) / (1.0 - exp(-1.5));
}
<<gestvm>>=
int update_skewer;



prev | home | next