cleaner~/Source/cleaner~common.c
void *cleaner_common_new(t_cleaner *x, short argc, t_atom *argv)
{
#ifdef TARGET_IS_MAX
    /* Create inlets */
    dsp_setup((t_pxobject *)x, NUM_INLETS);

    /* Create signal outlets */
    outlet_new((t_object *)x, "signal");

    /* Avoid sharing memory among audio vectors */
    x->obj.z_misc |= Z_NO_INPLACE;

#elif TARGET_IS_PD
    /* Create inlets */
    inlet_new(&x->obj, &x->obj.ob_pd, gensym("signal"), gensym("signal"));
    inlet_new(&x->obj, &x->obj.ob_pd, gensym("signal"), gensym("signal"));

    /* Create signal outlets */
    outlet_new(&x->obj, gensym("signal"));

#endif

    /* Initialize input arguments */
    float threshold_value = DEFAULT_THRESHOLD;
    float attenuation_value = DEFAULT_ATTENUATION;

    /* Parse passed arguments */
    if (argc > A_THRESHOLD) {
        threshold_value = atom_getfloatarg(A_THRESHOLD, argc, argv);
    }
    if (argc > A_ATTENUATION) {
        attenuation_value = atom_getfloatarg(A_ATTENUATION, argc, argv);
    }

    /* Check validity of passed arguments */
    if (threshold_value < MINIMUM_THRESHOLD) {
        threshold_value = MINIMUM_THRESHOLD;
        post("cleaner~ • Invalid argument: Minimum threshold value set to %.4f", threshold_value);
    }
    else if (threshold_value > MAXIMUM_THRESHOLD) {
        threshold_value = MAXIMUM_THRESHOLD;
        post("cleaner~ • Invalid argument: Maximum threshold value set to %.4f", threshold_value);
    }
    if (attenuation_value < MINIMUM_ATTENUATION) {
        attenuation_value = MINIMUM_ATTENUATION;
        post("cleaner~ • Invalid argument: Minimum attenuation value set to %.4f", attenuation_value);
    }
    else if (attenuation_value > MAXIMUM_ATTENUATION) {
        attenuation_value = MAXIMUM_ATTENUATION;
        post("cleaner~ • Invalid argument: Maximum attenuation value set to %.4f", attenuation_value);
    }

    /* Initialize some state variables */
    x->fs = sys_getsr();
    x->threshold_value = threshold_value;
    x->attenuation_value = attenuation_value;

    /* Print message to Max window */
    post("cleaner~ • Object was created");

    /* Return a pointer to the new object */
    return x;
}
/* The common 'new instance' routine ******************************************/
The common 'new instance' routine
The common ' new instance ' routine
void *cleaner_common_new(t_cleaner *x, short argc, t_atom *argv)
{
#ifdef TARGET_IS_MAX
    dsp_setup((t_pxobject *)x, NUM_INLETS);
    outlet_new((t_object *)x, "signal");
    x->obj.z_misc |= Z_NO_INPLACE;
#elif TARGET_IS_PD
    inlet_new(&x->obj, &x->obj.ob_pd, gensym("signal"), gensym("signal"));
    inlet_new(&x->obj, &x->obj.ob_pd, gensym("signal"), gensym("signal"));
    outlet_new(&x->obj, gensym("signal"));
#endif
    float threshold_value = DEFAULT_THRESHOLD;
    float attenuation_value = DEFAULT_ATTENUATION;
    if (argc > A_THRESHOLD) {
        threshold_value = atom_getfloatarg(A_THRESHOLD, argc, argv);
    }
    if (argc > A_ATTENUATION) {
        attenuation_value = atom_getfloatarg(A_ATTENUATION, argc, argv);
    }
    if (threshold_value < MINIMUM_THRESHOLD) {
        threshold_value = MINIMUM_THRESHOLD;
        post("cleaner~ • Invalid argument: Minimum threshold value set to %.4f", threshold_value);
    }
    else if (threshold_value > MAXIMUM_THRESHOLD) {
        threshold_value = MAXIMUM_THRESHOLD;
        post("cleaner~ • Invalid argument: Maximum threshold value set to %.4f", threshold_value);
    }
    if (attenuation_value < MINIMUM_ATTENUATION) {
        attenuation_value = MINIMUM_ATTENUATION;
        post("cleaner~ • Invalid argument: Minimum attenuation value set to %.4f", attenuation_value);
    }
    else if (attenuation_value > MAXIMUM_ATTENUATION) {
        attenuation_value = MAXIMUM_ATTENUATION;
        post("cleaner~ • Invalid argument: Maximum attenuation value set to %.4f", attenuation_value);
    }
    x->fs = sys_getsr();
    x->threshold_value = threshold_value;
    x->attenuation_value = attenuation_value;
    post("cleaner~ • Object was created");
    return x;
}
void * cleaner_common_new ( t_cleaner * x , short argc , t_atom * argv ) { #ifdef TARGET_IS_MAX dsp_setup ( ( t_pxobject * ) x , NUM_INLETS ) ; outlet_new ( ( t_object * ) x , " " ) ; x -> obj . z_misc |= Z_NO_INPLACE ; #elif TARGET_IS_PD inlet_new ( & x -> obj , & x -> obj . ob_pd , gensym ( " " ) , gensym ( " " ) ) ; inlet_new ( & x -> obj , & x -> obj . ob_pd , gensym ( " " ) , gensym ( " " ) ) ; outlet_new ( & x -> obj , gensym ( " " ) ) ; #endif float threshold_value = DEFAULT_THRESHOLD ; float attenuation_value = DEFAULT_ATTENUATION ; if ( argc > A_THRESHOLD ) { threshold_value = atom_getfloatarg ( A_THRESHOLD , argc , argv ) ; } if ( argc > A_ATTENUATION ) { attenuation_value = atom_getfloatarg ( A_ATTENUATION , argc , argv ) ; } if ( threshold_value < MINIMUM_THRESHOLD ) { threshold_value = MINIMUM_THRESHOLD ; post ( " t reshold_value); } else if ( threshold_value > MAXIMUM_THRESHOLD ) { threshold_value = MAXIMUM_THRESHOLD ; post ( " t reshold_value); } if ( attenuation_value < MINIMUM_ATTENUATION ) { attenuation_value = MINIMUM_ATTENUATION ; post ( " a tenuation_value); } else if ( attenuation_value > MAXIMUM_ATTENUATION ) { attenuation_value = MAXIMUM_ATTENUATION ; post ( " a tenuation_value); } x -> fs = sys_getsr ( ) ; x -> threshold_value = threshold_value ; x -> attenuation_value = attenuation_value ; post ( " ; return x ; }
The common 'new instance' routine
The common ' new instance ' routine
/* Create inlets */ /* Create signal outlets */ /* Avoid sharing memory among audio vectors */ /* Create inlets */ /* Create signal outlets */ /* Initialize input arguments */ /* Parse passed arguments */ /* Check validity of passed arguments */ /* Initialize some state variables */ /* Print message to Max window */ /* Return a pointer to the new object */