Hi,<br><br>I think I figured out how dsp on/off was handling with garrays. Let&#39;s climb up hierachies.<br>So, the generic setarray function (that can be found in most of externals dealing with arrays) use the function :<br>
<br>garray_usedindsp(x);<br><br>This function is defined in g_array.c like this :<br><br>void garray_usedindsp(t_garray *x)<br>{<br>&nbsp;&nbsp;&nbsp; x-&gt;x_usedindsp = 1;<br>}<br><br>This usedindsp flag then sets the following (still in g_array.c) :<br>
<br>if (x-&gt;x_usedindsp)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; canvas_update_dsp();<br><br>Let&#39;s then look at canvas_update_dsp function, defined in g_canvas.c :<br><br>void canvas_update_dsp(void)<br>{<br>&nbsp;&nbsp;&nbsp; if (canvas_dspstate) canvas_start_dsp();<br>
}<br><br>I guess canvas_dspstate is one on dsp start and zero on dsp off ...<br>So when turning dsp on, it launches canvas_start_dsp, allright.<br><br>static void canvas_start_dsp(void)<br>{<br>&nbsp;&nbsp;&nbsp; t_canvas *x;<br>&nbsp;&nbsp;&nbsp; if (canvas_dspstate) ugen_stop();<br>
&nbsp;&nbsp;&nbsp; else sys_gui(&quot;pdtk_pd_dsp ON\n&quot;);<br>&nbsp;&nbsp;&nbsp; ugen_start();<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; for (x = canvas_list; x; x = x-&gt;gl_next)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; canvas_dodsp(x, 1, 0);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; canvas_dspstate = 1;<br>}<br><br>We&#39;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&#39;s for being sure<br>
and then is start the ugen. Ok, well, why not.<br>Let&#39;s now have a look at d_ugen.c<br><br>void ugen_stop(void)<br>{<br>&nbsp;&nbsp;&nbsp; t_signal *s;<br>&nbsp;&nbsp;&nbsp; int i;<br>&nbsp;&nbsp;&nbsp; if (dsp_chain)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; freebytes(dsp_chain, dsp_chainsize * sizeof (t_int));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dsp_chain = 0;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; signal_cleanup();<br>&nbsp;&nbsp;&nbsp; <br>}<br><br>void ugen_start(void)<br>{<br>&nbsp;&nbsp;&nbsp; ugen_stop();<br>&nbsp;&nbsp;&nbsp; ugen_sortno++;<br>&nbsp;&nbsp;&nbsp; dsp_chain = (t_int *)getbytes(sizeof(*dsp_chain));<br>&nbsp;&nbsp;&nbsp; dsp_chain[0] = 0;<br>
&nbsp;&nbsp;&nbsp; dsp_chainsize = 1;<br>&nbsp;&nbsp;&nbsp; if (ugen_currentcontext) bug(&quot;ugen_start&quot;);<br>}<br><br>So,here we are, when turning dsp on, we anyway call ugen_start, which stop the ugen, and here is the problem I have.<br>When executing ugen_stop, it flushes out the dspchain buffer, argh ... and does the signal_cleanup<br>
So, it results for me in a click anytime I restart the dsp, because previous unfinished buffer was flushed out beforehand.<br>But, I also saw that just below definition of signal_cleanup function, lies a function called signal_makereusable.<br>
Does this mean that it is possible to freeze and/or save the current state of any signal before switching dsp off ?<br>If yes, where should this function lie ? <br>Sorry for my poor knowledge of internal Pd dsp functions.<br>
<br>Best<br><br>Sylvain<br><br><br>