multislider like UI

klaus filip's icon

hello there,
first i want to thank everybody who helped me with my basic questions building my first GUI. i could not make it without this forum.
it seems to be ready and can be found here:
http://ppooll.klingt.org/index.php/max_externals

however here is my next Q:

i want to add list-abiltity to that UI and i am not sure which data-type is
best to make it going (lists of floats).
basically it should do the same as multislider (including pattr communication).
t_linklist seems to be the choice, right ?
what is used in multislider?

best
klaus

klaus filip's icon

basically the external should do the same as a multislider.
(having the multislider.c as an example would save me a lot of time of course)
but it will have a few additions (as in ll_number),
like displaying the value as number,
allowing the arrow- and number keys for input
write labels in the slider. etc

Emmanuel Jourdan's icon

multislider stores the values into an array of t_atom or double.

klaus filip's icon

hello again,
finally got some time left to resume on this project.

but i am still stuck on how to deal with lists.
namely how to put the correct pattr-comunication...
the following try is very close i guess, but crashes.

t_max_err MY_getvalueof(t_MY *x, long *ac, t_atom **av)
{
        short i;
    if (ac && av) {
        if (*ac && *av) {
            //memory passed in use it
        } else {
            *av = (t_atom *)getbytes(sizeof(t_atom)*x->listlen);
        }
        *ac = x->listlen;
        for (i=0; i < *ac; i++, av++) {
            atom_setfloat(*av,x->myval[i]);
        }
    }
    return MAX_ERR_NONE;
}

any advices??
thanks
klaus

Luigi Castelli's icon

Hi Klaus,

there are functions in the Max/MSP API that make this sort of thing a lot easier and less error prone...
I would do:

t_max_err MY_getvalueof(t_MY *x, long *ac, t_atom **av)
{
    if (ac && av) {
        char alloc;
        if (atom_alloc_array(x->listlen, ac, av, &alloc)) {
            return MAX_ERR_OUT_OF_MEM;
        }
        atom_setfloat_array(*ac, *av, x->listlen, x->myval);
    }
    return MAX_ERR_NONE;
}

Let me know if it works for you.

Cheers.

- Luigi

klaus filip's icon

yes worked,
thanks luigi.

i can tumble forward.
klaus