7. Sliders Graforge Nodes

7.1. Sliderval

Sliderval is a graforge node which reads a slider value from a sliders page. The slider selected can be changed at audio-rate.

7.1.1. Sliderval Node Function

This node can be created with the function node_sliderval.

<<sliders_function_declarations>>=
static int node_sliderval(gf_node *node, monolith_page *pg);
<<sliders_functions>>=
<<sliderval_node_functions>>
static int node_sliderval(gf_node *node, monolith_page *pg)
{
    gf_node_cables_alloc(node, 2);
    gf_node_set_block(node, 1);
    gf_node_set_data(node, pg);
    gf_node_set_destroy(node, sliderval_destroy);
    gf_node_set_compute(node, sliderval_compute);
    return GF_OK;
}

7.1.2. Sliderval Compute

<<sliderval_node_functions>>=
static void sliderval_compute(gf_node *n)
{
    int blksize;
    int s;
    int icurslider;
    gf_cable *curslider;
    gf_cable *out;
    GFFLT tmp;
    page_sliders_d *slide;
    monolith_page *pg;

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

    slide = monolith_page_data_get(pg);

    gf_node_get_cable(n, 0, &curslider);
    gf_node_get_cable(n, 1, &out);

    for(s = 0; s < blksize; s++) {
        tmp = 0;
        icurslider = floor(gf_cable_get(curslider, s));
        if(icurslider >= 0 && icurslider < 8) {
            tmp = slide->vals[icurslider];
        }
        gf_cable_set(out, s, tmp);
    }

}

7.1.3. Sliderval Destroy

<<sliderval_node_functions>>=
static void sliderval_destroy(gf_node *node)
{
     /* TODO: "unpin" page here */
     gf_node_cables_free(node);
}

7.2. Slidergate

Slidergate is a graforge node which reads the griffin "gate" signal as an audio-rate signal.

7.2.1. Slidergate Node Function

This node can be created with the function node_slidergate.

<<sliders_function_declarations>>=
static int node_slidergate(gf_node *node, monolith_page *pg);
<<sliders_functions>>=
<<slidergate_node_functions>>
static int node_slidergate(gf_node *node, monolith_page *pg)
{
    gf_node_cables_alloc(node, 1);
    gf_node_set_block(node, 0);
    gf_node_set_data(node, pg);
    gf_node_set_destroy(node, slidergate_destroy);
    gf_node_set_compute(node, slidergate_compute);
    return GF_OK;
}

7.2.2. Slidergate Compute

<<slidergate_node_functions>>=
static void slidergate_compute(gf_node *n)
{
    int blksize;
    int s;
    gf_cable *out;
    page_sliders_d *slide;
    monolith_page *pg;
    int gate;

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

    slide = monolith_page_data_get(pg);

    gf_node_get_cable(n, 0, &out);
    gate = slide->gate;
    for(s = 0; s < blksize; s++) {
        gf_cable_set(out, s, gate);
    }

}

7.2.3. Sliderval Destroy

<<slidergate_node_functions>>=
static void slidergate_destroy(gf_node *node)
{
     /* TODO: "unpin" page here */
     gf_node_cables_free(node);
}



prev | home | next