9. Line16 Graforge Nodes

9.1. Main Node

This is the main line16 compute routine. This should only be called once. This node takes in one trigger input, which is used for a hard reset back to the beginning of the line.

9.1.1. Main Node Function

<<line16_function_declarations>>=
static int node_line16(gf_node *node, page_line16_d *line16);
<<line16_functions>>=
<<line16_node_functions>>
static int node_line16(gf_node *node, page_line16_d *line16)
{
    gf_node_cables_alloc(node, 1);
    gf_node_set_data(node, line16);
    gf_node_set_destroy(node, line16_destroy);
    gf_node_set_compute(node, line16_compute);
    return GF_OK;
}

9.1.2. Main Compute

<<line16_node_functions>>=
static void line16_compute(gf_node *n)
{
    gf_cable *in;
    gf_patch *patch;
    page_line16_d *l;

    l = gf_node_get_data(n);
    gf_node_get_cable(n, 0, &in);
    gf_node_get_patch(n, &patch);
    line16_compute_line(l, patch, in);
}

9.1.3. Main Destroy

<<line16_node_functions>>=
static void line16_destroy(gf_node *node)
{
     gf_node_cables_free(node);
}

9.2. Line Node

This node actually returns a copy of the line computed by the main line16 mission control node. Should be called after tha main node is called.

9.2.1. Line Node Function

<<line16_function_declarations>>=
static int node_line(gf_node *node, page_line16_d *line16);
<<line16_functions>>=
<<line_node_functions>>
static int node_line(gf_node *node, page_line16_d *line16)
{
    gf_node_cables_alloc(node, 1);
    gf_node_set_block(node, 0);
    gf_node_set_data(node, line16);
    gf_node_set_destroy(node, line_destroy);
    gf_node_set_compute(node, line_compute);
    return GF_OK;
}

9.2.2. Line Compute

<<line_node_functions>>=
static void line_compute(gf_node *n)
{
    int blksize;
    int s;
    gf_cable *out;
    page_line16_d *l;

    blksize = gf_node_blksize(n);
    l = gf_node_get_data(n);

    gf_node_get_cable(n, 0, &out);

    for(s = 0; s < blksize; s++) {
        gf_cable_set(out,
                     s,
                     gf_cable_get(&l->out, s));
    }
}

9.2.3. Line Destroy

<<line_node_functions>>=
static void line_destroy(gf_node *node)
{
     gf_node_cables_free(node);
}

9.3. Global playback rate (GPR) Node

This node is used to transform the global playback rate of the line from inside the runt patch.

9.3.1. GPR Node Function

<<line16_function_declarations>>=
static int node_gpr(gf_node *node, page_line16_d *gpr);
<<line16_functions>>=
<<gpr_node_functions>>
static int node_gpr(gf_node *node, page_line16_d *gpr)
{
    gf_node_cables_alloc(node, 1);
    gf_node_set_data(node, gpr);
    gf_node_set_destroy(node, gpr_destroy);
    gf_node_set_compute(node, gpr_compute);
    return GF_OK;
}

9.3.2. GPR Compute

The rate is retrieved at a control rate, since there is no way to store the block.

The rate can't be negative, so it is also clipped.

<<gpr_node_functions>>=
static void gpr_compute(gf_node *n)
{
    gf_cable *in;
    page_line16_d *l;
    GFFLT rate;

    l = gf_node_get_data(n);

    gf_node_get_cable(n, 0, &in);

    rate = gf_cable_get(in, 0);

    if(rate < 0) rate = 0;
    l->rate = rate;
}

9.3.3. GPR Destroy

<<gpr_node_functions>>=
static void gpr_destroy(gf_node *node)
{
     gf_node_cables_free(node);
}

9.4. Local playback rate (LPR) Node

This adjust the playback rate for an individual point from within graforge.

9.4.1. LPR Node Function

<<line16_function_declarations>>=
static int node_lpr(gf_node *node, page_line16_d *line);
<<line16_functions>>=
<<lpr_node_functions>>
static int node_lpr(gf_node *node, page_line16_d *line)
{
    gf_node_cables_alloc(node, 3);
    gf_node_set_data(node, line);
    gf_node_set_destroy(node, lpr_destroy);
    gf_node_set_compute(node, lpr_compute);
    return GF_OK;
}

9.4.2. LPR Compute

<<lpr_node_functions>>=
static void lpr_compute(gf_node *n)
{
    gf_cable *line;
    gf_cable *pos;
    gf_cable *val;
    int iline;
    int ipos;
    GFFLT x;
    page_line16_d *l;

    l = gf_node_get_data(n);

    gf_node_get_cable(n, 0, &val);
    gf_node_get_cable(n, 1, &line);
    gf_node_get_cable(n, 2, &pos);

    iline = floor(gf_cable_get(line, 0));
    ipos = floor(gf_cable_get(pos, 0));
    x = gf_cable_get(val, 0);

    line16_point_rate_set(l, iline, ipos, x);
}

9.4.3. LPR Destroy

<<lpr_node_functions>>=
static void lpr_destroy(gf_node *node)
{
     gf_node_cables_free(node);
}

9.5. Aux Node

This node is used to control aux values from within a graforge patch. Ideally, these should be called before calling the main node.

9.5.1. Aux Node Function

<<line16_function_declarations>>=
static int node_aux(gf_node *node, page_line16_d *line16);
<<line16_functions>>=
<<aux_node_functions>>
static int node_aux(gf_node *node, page_line16_d *line16)
{
    gf_node_cables_alloc(node, 4);
    gf_node_set_data(node, line16);
    gf_node_set_destroy(node, aux_destroy);
    gf_node_set_compute(node, aux_compute);
    return GF_OK;
}

9.5.2. Aux Compute

<<aux_node_functions>>=
static void aux_compute(gf_node *n)
{
    gf_cable *line;
    gf_cable *pos;
    gf_cable *val;
    gf_cable *aux;
    int iline;
    int ipos;
    int iaux;
    GFFLT x;
    page_line16_d *l;

    l = gf_node_get_data(n);

    gf_node_get_cable(n, 0, &val);
    gf_node_get_cable(n, 1, &aux);
    gf_node_get_cable(n, 2, &line);
    gf_node_get_cable(n, 3, &pos);

    iline = floor(gf_cable_get(line, 0));
    ipos = floor(gf_cable_get(pos, 0));
    iaux = floor(gf_cable_get(aux, 0));
    x = gf_cable_get(val, 0);

    if(iaux < 0) iaux = 0;
    if(iaux > 1) iaux = 1;

    line16_point_aux_set(l, iline, ipos, iaux, x);
}

9.5.3. Aux Destroy

<<aux_node_functions>>=
static void aux_destroy(gf_node *node)
{
     gf_node_cables_free(node);
}

9.6. TODO Local Line Node (lline)

9.6.1. LLine Node Function

<<line16_function_declarations>>=
static int node_lline(gf_node *node,
                      page_line16_d *pg,
                      line16_line *line);
<<line16_functions>>=
<<lline_node_functions>>
static int node_lline(gf_node *node,
                      page_line16_d *pg,
                      line16_line *line)
{
    line16_localline *lline;
    gf_patch *patch;

    gf_node_get_patch(node, &patch);
    gf_node_cables_alloc(node, 2);

    gf_memory_alloc(patch,
                    sizeof(line16_localline),
                    (void **)&lline);

    line16_localline_init(lline, line, pg);
    gf_node_set_block(node, 1);
    gf_node_set_data(node, lline);
    gf_node_set_destroy(node, lline_destroy);
    gf_node_set_compute(node, lline_compute);
    return GF_OK;
}

9.6.2. LLine Compute

<<lline_node_functions>>=
static void lline_compute(gf_node *n)
{
    line16_localline *ll;
    gf_cable *in;
    gf_cable *out;
    gf_patch *patch;

    ll = gf_node_get_data(n);
    gf_node_get_patch(n, &patch);
    gf_node_get_cable(n, 0, &in);
    gf_node_get_cable(n, 1, &out);

    line16_compute_localline(ll, patch, in, out);
}

9.6.3. LLine Destroy

<<lline_node_functions>>=
static void lline_destroy(gf_node *node)
{
    gf_patch *patch;
    line16_localline *lline;

    gf_node_get_patch(node, &patch);
    lline = gf_node_get_data(node);
    gf_memory_free(patch, (void **)&lline);
    gf_node_cables_free(node);
}



prev | home | next