retroseq~/Source/retroseq~common.c
void *retroseq_common_new(t_retroseq *x, short argc, t_atom *argv)
{
#ifdef TARGET_IS_MAX
    /* Create non-signal outlets */
    x->shuffle_durs_outlet = listout((t_pxobject *)x);
    x->shuffle_freqs_outlet = listout((t_pxobject *)x);
    x->bang_outlet = bangout((t_pxobject *)x);
    x->adsr_outlet = listout((t_pxobject *)x);

    /* 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;

    /* Initialize clocks */
    x->bang_clock = clock_new(x, (method)retroseq_send_bang);
    x->adsr_clock = clock_new(x, (method)retroseq_send_adsr);
#elif TARGET_IS_PD
    /* Create inlets */
    //nothing

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

    /* Create non-signal outlets */
    x->adsr_outlet = outlet_new(&x->obj, gensym("list"));
    x->bang_outlet = outlet_new(&x->obj, gensym("bang"));
    x->shuffle_freqs_outlet = outlet_new(&x->obj, gensym("list"));
    x->shuffle_durs_outlet = outlet_new(&x->obj, gensym("list"));

    /* Initialize clocks */
    x->bang_clock = clock_new(x, (t_method)retroseq_send_bang);
    x->adsr_clock = clock_new(x, (t_method)retroseq_send_adsr);
#endif

    /* Parse passed arguments */
    //nothing

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

    x->max_sequence_bytes = MAXIMUM_SEQUENCE_LENGTH * sizeof(float);

    x->note_sequence = (float *)new_memory(x->max_sequence_bytes);
    x->note_sequence_length = DEFAULT_SEQUENCE_LENGTH;
    x->note_sequence[0] = F0;
    x->note_sequence[1] = F1;
    x->note_sequence[2] = F2;

    x->duration_sequence = (float *)new_memory(x->max_sequence_bytes);
    x->duration_sequence_length = DEFAULT_SEQUENCE_LENGTH;
    x->duration_sequence[0] = D0;
    x->duration_sequence[1] = D1;
    x->duration_sequence[2] = D2;

    srand((unsigned int)clock());
    x->shuffle_list = (t_atom *)new_memory(MAXIMUM_SEQUENCE_LENGTH * sizeof(t_atom));

    x->tempo_bpm = DEFAULT_TEMPO_BPM;
    x->elastic_sustain = 0;
    x->sustain_amplitude = DEFAULT_SUSTAIN_AMPLITUDE;

    x->adsr_bytes = 4 * sizeof(float);
    x->adsr = (float *)new_memory(x->adsr_bytes);
    x->adsr[0] = DEFAULT_ATACK_DURATION;
    x->adsr[1] = DEFAULT_DECAY_DURATION;
    x->adsr[2] = DEFAULT_SUSTAIN_DURATION;
    x->adsr[3] = DEFAULT_RELEASE_DURATION;

    x->adsr_out_bytes = 10 * sizeof(float);
    x->adsr_out = (float *)new_memory(x->adsr_out_bytes);
    x->adsr_list_bytes = 10 * sizeof(t_atom);
    x->adsr_list = (t_atom *)new_memory(x->adsr_list_bytes);

    /* Print message to Max window */
    post("retroseq~ • 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 *retroseq_common_new(t_retroseq *x, short argc, t_atom *argv)
{
#ifdef TARGET_IS_MAX
    x->shuffle_durs_outlet = listout((t_pxobject *)x);
    x->shuffle_freqs_outlet = listout((t_pxobject *)x);
    x->bang_outlet = bangout((t_pxobject *)x);
    x->adsr_outlet = listout((t_pxobject *)x);
    dsp_setup((t_pxobject *)x, NUM_INLETS);
    outlet_new((t_object *)x, "signal");
    x->obj.z_misc |= Z_NO_INPLACE;
    x->bang_clock = clock_new(x, (method)retroseq_send_bang);
    x->adsr_clock = clock_new(x, (method)retroseq_send_adsr);
#elif TARGET_IS_PD
    outlet_new(&x->obj, gensym("signal"));
    x->adsr_outlet = outlet_new(&x->obj, gensym("list"));
    x->bang_outlet = outlet_new(&x->obj, gensym("bang"));
    x->shuffle_freqs_outlet = outlet_new(&x->obj, gensym("list"));
    x->shuffle_durs_outlet = outlet_new(&x->obj, gensym("list"));
    x->bang_clock = clock_new(x, (t_method)retroseq_send_bang);
    x->adsr_clock = clock_new(x, (t_method)retroseq_send_adsr);
#endif
    x->fs = sys_getsr();
    x->max_sequence_bytes = MAXIMUM_SEQUENCE_LENGTH * sizeof(float);
    x->note_sequence = (float *)new_memory(x->max_sequence_bytes);
    x->note_sequence_length = DEFAULT_SEQUENCE_LENGTH;
    x->note_sequence[0] = F0;
    x->note_sequence[1] = F1;
    x->note_sequence[2] = F2;
    x->duration_sequence = (float *)new_memory(x->max_sequence_bytes);
    x->duration_sequence_length = DEFAULT_SEQUENCE_LENGTH;
    x->duration_sequence[0] = D0;
    x->duration_sequence[1] = D1;
    x->duration_sequence[2] = D2;
    srand((unsigned int)clock());
    x->shuffle_list = (t_atom *)new_memory(MAXIMUM_SEQUENCE_LENGTH * sizeof(t_atom));
    x->tempo_bpm = DEFAULT_TEMPO_BPM;
    x->elastic_sustain = 0;
    x->sustain_amplitude = DEFAULT_SUSTAIN_AMPLITUDE;
    x->adsr_bytes = 4 * sizeof(float);
    x->adsr = (float *)new_memory(x->adsr_bytes);
    x->adsr[0] = DEFAULT_ATACK_DURATION;
    x->adsr[1] = DEFAULT_DECAY_DURATION;
    x->adsr[2] = DEFAULT_SUSTAIN_DURATION;
    x->adsr[3] = DEFAULT_RELEASE_DURATION;
    x->adsr_out_bytes = 10 * sizeof(float);
    x->adsr_out = (float *)new_memory(x->adsr_out_bytes);
    x->adsr_list_bytes = 10 * sizeof(t_atom);
    x->adsr_list = (t_atom *)new_memory(x->adsr_list_bytes);
    post("retroseq~ • Object was created");
    return x;
}
void * retroseq_common_new ( t_retroseq * x , short argc , t_atom * argv ) { #ifdef TARGET_IS_MAX x -> shuffle_durs_outlet = listout ( ( t_pxobject * ) x ) ; x -> shuffle_freqs_outlet = listout ( ( t_pxobject * ) x ) ; x -> bang_outlet = bangout ( ( t_pxobject * ) x ) ; x -> adsr_outlet = listout ( ( t_pxobject * ) x ) ; dsp_setup ( ( t_pxobject * ) x , NUM_INLETS ) ; outlet_new ( ( t_object * ) x , " " ) ; x -> obj . z_misc |= Z_NO_INPLACE ; x -> bang_clock = clock_new ( x , ( method ) retroseq_send_bang ) ; x -> adsr_clock = clock_new ( x , ( method ) retroseq_send_adsr ) ; #elif TARGET_IS_PD outlet_new ( & x -> obj , gensym ( " " ) ) ; x -> adsr_outlet = outlet_new ( & x -> obj , gensym ( " " ) ) ; x -> bang_outlet = outlet_new ( & x -> obj , gensym ( " " ) ) ; x -> shuffle_freqs_outlet = outlet_new ( & x -> obj , gensym ( " " ) ) ; x -> shuffle_durs_outlet = outlet_new ( & x -> obj , gensym ( " " ) ) ; x -> bang_clock = clock_new ( x , ( t_method ) retroseq_send_bang ) ; x -> adsr_clock = clock_new ( x , ( t_method ) retroseq_send_adsr ) ; #endif x -> fs = sys_getsr ( ) ; x -> max_sequence_bytes = MAXIMUM_SEQUENCE_LENGTH * sizeof ( float ) ; x -> note_sequence = ( float * ) new_memory ( x -> max_sequence_bytes ) ; x -> note_sequence_length = DEFAULT_SEQUENCE_LENGTH ; x -> note_sequence [ 0 ] = F0 ; x -> note_sequence [ 1 ] = F1 ; x -> note_sequence [ 2 ] = F2 ; x -> duration_sequence = ( float * ) new_memory ( x -> max_sequence_bytes ) ; x -> duration_sequence_length = DEFAULT_SEQUENCE_LENGTH ; x -> duration_sequence [ 0 ] = D0 ; x -> duration_sequence [ 1 ] = D1 ; x -> duration_sequence [ 2 ] = D2 ; srand ( ( unsigned int ) clock ( ) ) ; x -> shuffle_list = ( t_atom * ) new_memory ( MAXIMUM_SEQUENCE_LENGTH * sizeof ( t_atom ) ) ; x -> tempo_bpm = DEFAULT_TEMPO_BPM ; x -> elastic_sustain = 0 ; x -> sustain_amplitude = DEFAULT_SUSTAIN_AMPLITUDE ; x -> adsr_bytes = 4 * sizeof ( float ) ; x -> adsr = ( float * ) new_memory ( x -> adsr_bytes ) ; x -> adsr [ 0 ] = DEFAULT_ATACK_DURATION ; x -> adsr [ 1 ] = DEFAULT_DECAY_DURATION ; x -> adsr [ 2 ] = DEFAULT_SUSTAIN_DURATION ; x -> adsr [ 3 ] = DEFAULT_RELEASE_DURATION ; x -> adsr_out_bytes = 10 * sizeof ( float ) ; x -> adsr_out = ( float * ) new_memory ( x -> adsr_out_bytes ) ; x -> adsr_list_bytes = 10 * sizeof ( t_atom ) ; x -> adsr_list = ( t_atom * ) new_memory ( x -> adsr_list_bytes ) ; post ( " ; return x ; }
The common 'new instance' routine
The common ' new instance ' routine
/* Create non-signal outlets */ /* Create inlets */ /* Create signal outlets */ /* Avoid sharing memory among audio vectors */ /* Initialize clocks */ /* Create inlets */ //nothing /* Create signal outlets */ /* Create non-signal outlets */ /* Initialize clocks */ /* Parse passed arguments */ //nothing /* Initialize some state variables */ /* Print message to Max window */ /* Return a pointer to the new object */