static void* substr_create(int argc, char** argv) {
    substr_struct *obj = p_new(substr_class);
    if (argc > 1) {
        if (argc > 2) {
            obj->to = atoi(argv[2]);
        } else {
            obj->to = -1;
        }
        obj->from = atoi(argv[1]);
    } else {
        obj->from = 0;
        obj->to = -1;
    }
    obj->part = strdup("");
    
    t_inlet *str_in = add_inlet(obj, "string", NULL);
    t_inlet *from_in = add_inlet(obj, "from", NULL);
    t_inlet *to_in = add_inlet(obj, "to", NULL);
    p_inlet_add_string_fn(str_in, substr_perform);
    p_inlet_add_trigger_fn(str_in, substr_send_part);
    p_inlet_add_int_fn(from_in, substr_set_from);
    p_inlet_add_int_fn(to_in, substr_set_to);
    obj->out = add_outlet(obj, "substring");
    return obj;
}
Exemple #2
0
v1001::v1001()
{
    name = "Audio out";
    caption = "AUDIO OUT";
    type_id = 1001;
    panel_width = 136;
    add_inlet(68,90); //mono
    add_inlet(33,280); //stereo l
    add_inlet(103,280); //stereo r
    add_knob(68,190,0.0,0.0,100.0,10); //amplitude
    knobs[0]->size = 30.0;
}
static void* char_at_create(int argc, char**argv)
{
    char_at_struct *obj = p_new(char_at_class);
    if (argc>1) {
        obj->pos = atoi(argv[1]);
    } else {
        obj->pos = 0;
    }
    t_inlet * str_in = add_inlet(obj, "string", NULL);
    p_inlet_add_string_fn(str_in, char_at_perform);
    t_inlet * pos_in = add_inlet(obj, "position", NULL);
    p_inlet_add_int_fn(pos_in, char_at_set_pos);
    obj->out = add_outlet(obj, "character");
    return obj;
}
static void* strlen_create(int argc, char **argv)
{
    strlen_struct *op = p_new(strlen_class);
    op->len= 0;
    op->out = add_outlet(op, "length");
    t_inlet *string = add_inlet(op, "string", NULL);
    p_inlet_add_string_fn(string, strlen_perform);
    return op;
}
static void* itoa_create(int argc, char **argv)
{
    itoa_obj *obj = p_new(itoa_class);
    obj->result = strdup("");
    t_inlet *int_in = add_inlet(obj, "int", NULL);
    p_inlet_add_int_fn(int_in, itoa_perform);
    obj->out = add_outlet(obj, "string");
    return obj;
}
static void* strcat_create(int argc, char **argv)
{
    strcat_struct *op = p_new(strcat_class);
    op->result = strdup("");
    if (argc > 1) {
        op->to_concat = strdup((const char*)argv[1]);
    } else {
        op->to_concat = strdup("");
    }
    t_inlet *str_i = add_inlet(op, "string", NULL);
    if (strcmp("strcat", (const char *)argv[0])==0)
    { p_inlet_add_string_fn(str_i, strcat_perform); }
    else
    { p_inlet_add_string_fn(str_i, strcat_perform); }
    t_inlet *to_concat = add_inlet(op, "string", NULL);
    p_inlet_add_string_fn(to_concat, strcat_set_to_concat);
    op->out = add_outlet(op, "concatenated");
    return op;
}