8. Knobs Graforge Nodes

8.1. Knob Value Node

This is a knob value graforge node called node_knobs.

8.1.1. Knob Value Node Function

<<knobs_function_declarations>>=
static int node_knobs_val(gf_node *node,
                          page_knobs_d *knobs,
                          int lane,
                          int x,
                          int y);
<<knobs_functions>>=
<<knobs_node_functions>>
static int node_knobs_val(gf_node *node,
                          page_knobs_d *knobs,
                          int lane,
                          int x,
                          int y)
{
    GFFLT *val;
    val = knobs_val(knobs, lane, x, y);
    if (val == NULL) return GF_NOT_OK;
    gf_node_cables_alloc(node, 1);
    gf_node_set_block(node, 0);
    gf_node_set_data(node, val);
    gf_node_set_compute(node, knobs_val_compute);
    return GF_OK;
}

8.1.2. Knob Value Compute

<<knobs_node_functions>>=
static void knobs_val_compute(gf_node *n)
{
    int blksize;
    int s;
    gf_cable *out;
    GFFLT *val;
    GFFLT x;

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

    gf_node_get_cable(n, 0, &out);

    x = *val;
    for (s = 0; s < blksize; s++) {
        gf_cable_set(out, s, x);
    }
}



prev | home | next