~pbatch/gestvm

ad3daddae39de364e8a9bfcef58c2ddb4d776f94 — Paul Batchelor 1 year, 2 months ago 51848f5
implemented initial exponential behaviors
4 files changed, 119 insertions(+), 0 deletions(-)

A examples/expon.lil
A examples/expon.tal
M examples/render.sh
M gestvm.org
A examples/expon.lil => examples/expon.lil +21 -0
@@ 0,0 1,21 @@

gestvmnew gvm

gestvmload [grab gvm] expon.rom


phasor 2 0
hold zz
regset zz 0

gestvmnode [grab gvm] [gestvmsym expon.rom mel] [regget 0]

mtof zz
blsaw zz

butlp zz 800

unhold [regget 0]

wavout zz expon.wav
computes 15

A examples/expon.tal => examples/expon.tal +31 -0
@@ 0,0 1,31 @@
%NUM { #24 DEO }
%DEN { #25 DEO }
%NEXT { #26 DEO }
%NOTE { #3c ADD NEXT }
%BHVR { #27 DEO }

|0100

@mel

( exponential convex low )
#00 NOTE BRK
#01 NUM #04 DEN #07 BHVR #0c NOTE BRK
#01 DEN #01 BHVR

( exponential convex high )
#00 NOTE BRK
#01 NUM #04 DEN #08 BHVR #0c NOTE BRK
#01 DEN #01 BHVR

( exponential concave low )
#00 NOTE BRK
#01 NUM #04 DEN #09 BHVR #0c NOTE BRK
#01 DEN #01 BHVR

( exponential concave high )
#00 NOTE BRK
#01 NUM #04 DEN #0a BHVR #0c NOTE BRK
#01 DEN #01 BHVR

;mel JMP2

M examples/render.sh => examples/render.sh +1 -0
@@ 9,3 9,4 @@ render () {
render sequence
render skew
render weight
render expon

M gestvm.org => gestvm.org +66 -0
@@ 1455,6 1455,60 @@ static SKFLT b_gliss(gestvm *gvm, SKFLT a)
    return a;
}
#+END_SRC
*** Exponential
Exponetial behaviors apply various kinds of exponential
curves. There are two main types of exponential curves:
convex and concave. A convex exponential curve will more
quickly grow, while a concave curve will only grow at the
end, and mostly stay at a lower state.

Of those types, there are two different slopes: a "high"
slope provides a sharp incline, while a "low" slope
provides a more regular exponential curve.
A convex high curve will quickly rise like an attack
envelope, while a concave
high will wait until the very last moment to rise to the
next value.

#+NAME: funcdefs
#+BEGIN_SRC c
static SKFLT expmap(SKFLT in, SKFLT slope);
static SKFLT b_expon_convex_high(gestvm *gvm, SKFLT a);
static SKFLT b_expon_convex_low(gestvm *gvm, SKFLT a);
static SKFLT b_expon_concave_high(gestvm *gvm, SKFLT a);
static SKFLT b_expon_concave_low(gestvm *gvm, SKFLT a);
#+END_SRC

#+NAME: funcs
#+BEGIN_SRC c
static SKFLT expmap(SKFLT in, SKFLT slope)
{
    return (1 - exp(in*slope)) / (1 - exp(slope));
}

static SKFLT b_expon_convex_high(gestvm *gvm, SKFLT a)
{
    return expmap(a, -4);
}

static SKFLT b_expon_convex_low(gestvm *gvm, SKFLT a)
{

    return expmap(a, -1);
}

static SKFLT b_expon_concave_high(gestvm *gvm, SKFLT a)
{

    return expmap(a, 4);
}

static SKFLT b_expon_concave_low(gestvm *gvm, SKFLT a)
{
    return expmap(a, 1);
}
#+END_SRC

** Main Function
#+NAME: static_funcdefs
#+BEGIN_SRC c


@@ 1510,6 1564,18 @@ static gestvm_behavior find_behavior(int id)
        case 6:
            b = b_gate_rel_50;
            break;
        case 7:
            b = b_expon_convex_low;
            break;
        case 8:
            b = b_expon_convex_high;
            break;
        case 9:
            b = b_expon_concave_low;
            break;
        case 10:
            b = b_expon_concave_high;
            break;
        default:
            break;
    }