Hi,

I think I figured out how dsp on/off was handling with garrays. Let's climb up hierachies.
So, the generic setarray function (that can be found in most of externals dealing with arrays) use the function :

garray_usedindsp(x);

This function is defined in g_array.c like this :

void garray_usedindsp(t_garray *x)
{
    x->x_usedindsp = 1;
}

This usedindsp flag then sets the following (still in g_array.c) :

if (x->x_usedindsp)
        canvas_update_dsp();

Let's then look at canvas_update_dsp function, defined in g_canvas.c :

void canvas_update_dsp(void)
{
    if (canvas_dspstate) canvas_start_dsp();
}

I guess canvas_dspstate is one on dsp start and zero on dsp off ...
So when turning dsp on, it launches canvas_start_dsp, allright.

static void canvas_start_dsp(void)
{
    t_canvas *x;
    if (canvas_dspstate) ugen_stop();
    else sys_gui("pdtk_pd_dsp ON\n");
    ugen_start();
   
    for (x = canvas_list; x; x = x->gl_next)
        canvas_dodsp(x, 1, 0);
   
    canvas_dspstate = 1;
}

We're almost at it, so the first thing is that when turning dsp on, it turns ugen off, which seems quite strange to me, but I supposed it's for being sure
and then is start the ugen. Ok, well, why not.
Let's now have a look at d_ugen.c

void ugen_stop(void)
{
    t_signal *s;
    int i;
    if (dsp_chain)
    {
        freebytes(dsp_chain, dsp_chainsize * sizeof (t_int));
        dsp_chain = 0;
    }
    signal_cleanup();
   
}

void ugen_start(void)
{
    ugen_stop();
    ugen_sortno++;
    dsp_chain = (t_int *)getbytes(sizeof(*dsp_chain));
    dsp_chain[0] = 0;
    dsp_chainsize = 1;
    if (ugen_currentcontext) bug("ugen_start");
}

So,here we are, when turning dsp on, we anyway call ugen_start, which stop the ugen, and here is the problem I have.
When executing ugen_stop, it flushes out the dspchain buffer, argh ... and does the signal_cleanup
So, it results for me in a click anytime I restart the dsp, because previous unfinished buffer was flushed out beforehand.
But, I also saw that just below definition of signal_cleanup function, lies a function called signal_makereusable.
Does this mean that it is possible to freeze and/or save the current state of any signal before switching dsp off ?
If yes, where should this function lie ?
Sorry for my poor knowledge of internal Pd dsp functions.

Best

Sylvain