calling attribute setters for default values at startup


    Apr 03 2020 | 1:24 pm
    Dear all,
    Each time I code an external, I am facing a very basic question for which I never found a clean answer: how to properly set default values of the attributes in the new methods with custom setters?
    For instance, if the new() method looks like the one in the API doc, i.e.: void *myobject_new(t_symbol *s, long ac, t_atom *av) { t_myobject *x = NULL;
    if (x=(t_myobject *)object_alloc(myobject_class)) { // initialize any data before processing // attributes to avoid overwriting // attribute argument-set values x->data = 0;
    // process attr args, if any attr_args_process(x, ac, av); } return x;
    This is ok as long as the attribute "data" does not have a custom setter. But if it has, then as far as I know, the setter is not being called at all in this method.
    So my question: how to define default attribute values in the new() methods and be sure that all setters are called?
    Best Alexis

    • Apr 03 2020 | 4:02 pm
      I don't have an answer, but I'd like to know too!
    • Apr 08 2020 | 6:55 pm
      Hi,
      In your new method, you should be able to call object_attr_setfloat() and friends to accomplish this.
      Cheers!
    • Apr 09 2020 | 6:44 am
      Great, I didn't know that the object_attr_setXXX also trigger the setters. Thanks for the answer,
      Alexis