~pbatch/gestvm

5280cafbd1fa6dd6f2b8420d9d2884c7110042aa — Paul Batchelor 1 year, 10 months ago 06e8c04
removed counter, samplerates, and absolute gates
2 files changed, 0 insertions(+), 112 deletions(-)

M gestvm.org
M l_gestvm.c
M gestvm.org => gestvm.org +0 -109
@@ 1163,28 1163,6 @@ case 7:
    gvm->behavior = find_behavior(d->dat[port]);
    break;
#+END_SRC
*** Set Counter (8, with 9 reserved)
The counter takes up 2 ports. This is done so the counter
can support both 8-bit and 16-bit values using =DEO=
and =DEO2=, respectively. Both can use port 8 and should
behave as expected.

Uxn processes 16-bit values with
DEO2 by splitting it into 2 8-bit values and writing them
to neighboring ports in sequence. The MSB (port 8) gets
written first, followed by the LSB (port 9). GestVM
will store the previous value, and will use that
to set the correct timing value.

#+NAME: port_commands
#+BEGIN_SRC c
case 8:
    gestvm_counter_set(gvm, d->dat[port]);
    break;
case 9:
    gestvm_counter_set(gvm, (gvm->ms << 8) | d->dat[port]);
    break;
#+END_SRC
*** Enable/Disable Interpolator (10)
#+NAME: port_commands
#+BEGIN_SRC c


@@ 1446,9 1424,6 @@ static gestvm_behavior find_behavior(int id)
        case 6:
            b = b_gate_rel_50;
            break;
        case 7:
            b = b_gate_abs;
            break;
        default:
            break;
    }


@@ 1695,7 1670,6 @@ a gate in absolute time, in seconds or milliseconds.
static SKFLT b_gate_rel_25(gestvm *gvm, SKFLT a);
static SKFLT b_gate_rel_50(gestvm *gvm, SKFLT a);
static SKFLT b_gate_rel_125(gestvm *gvm, SKFLT a);
static SKFLT b_gate_abs(gestvm *gvm, SKFLT a);
#+END_SRC

#+NAME: funcs


@@ 1714,16 1688,6 @@ static SKFLT b_gate_rel_125(gestvm *gvm, SKFLT a)
{
    return a <= 0.125;
}

static SKFLT b_gate_abs(gestvm *gvm, SKFLT a)
{
    if (gvm->counter > 0) {
        gvm->counter--;
        return 1.0;
    }

    return 0.0;
}
#+END_SRC

Typically, behaviors are intermediate signals used to


@@ 1742,76 1706,3 @@ int interp;
#+BEGIN_SRC c
gvm->interp = 1;
#+END_SRC

In order to produce absolute gates, GestVM needs to have
some sense of time. In a DSP context, the past of least
resistance is to use sample-accurate timing with a counter.
Such a system would be able to set a counter to a unit in
milliseconds or seconds, which is internally converted
to samples. The counter could then count down to 0.

The =ms= value is cached for Uxn incase a 16-byte value
is used with DEO2, which processes in 2 write operations.

#+NAME: gestvm
#+BEGIN_SRC c
unsigned long counter;
unsigned long ms;
#+END_SRC

#+NAME: init
#+BEGIN_SRC c
gvm->counter = 0;
gvm->ms = 0;
#+END_SRC

The counter is intended to be set in units
of milliseconds. This makes it sample-rate independent.
Milliseconds are an ideal unit, as they are the best
fit for the order of durations usually considered while
also making use of the 16-bit integer values of the UXN
VM.

The conversion from millesconds will happen implicitely.

#+NAME: funcdefs
#+BEGIN_SRC c
void gestvm_counter_set(gestvm *gvm, unsigned int ms);
#+END_SRC

#+NAME: funcs
#+BEGIN_SRC c
void gestvm_counter_set(gestvm *gvm, unsigned int ms)
{
    gvm->counter = floor(ms * gvm->ms2samps);
    gvm->ms = ms;
}
#+END_SRC

In order to convert from milliseconds to samples, a
multiplier scalar value is used. By default this is set to
be 1. When the function =gestvm_sr_set=, it will set the
constant.

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

#+NAME: init
#+BEGIN_SRC c
gvm->ms2samps = 1;
#+END_SRC

#+NAME: funcdefs
#+BEGIN_SRC c
void gestvm_sr_set(gestvm *gvm, int sr);
#+END_SRC

#+NAME: funcs
#+BEGIN_SRC c
void gestvm_sr_set(gestvm *gvm, int sr)
{
    gvm->ms2samps = sr / 1000.0;
}
#+END_SRC

M l_gestvm.c => l_gestvm.c +0 -3
@@ 84,7 84,6 @@ int sk_node_gestvm(sk_core *core, unsigned int ptr)
    gf_node *node;
    sk_param cnd;
    gestvm *gvm;
    int sr;

    rc = sk_param_get(core, &cnd);
    SK_ERROR_CHECK(rc);


@@ 101,8 100,6 @@ int sk_node_gestvm(sk_core *core, unsigned int ptr)
    gvm = ud;

    gestvm_init(gvm, gu);
    sr = gf_patch_srate_get(patch);
    gestvm_sr_set(gvm, sr);
    gestvm_pointer(gvm, ptr);

    rc = gf_patch_new_node(patch, &node);