Ok, I found out that the switch~ external was doing exactly what I wanted, sorry for the spam.<br>However,
I still wonder why this is a workaround, rather than a feature. I found
out on the pd-dev archive, that the clicking with arrays was an issue.<br>
So I guess I am not the only one facing those problems. I first tought
that the switch~ object was too cpu greedy, but it doesn't change
anything ...<br>Just a thought<br><br>Best<br><br>S.<br><br><div><span class="gmail_quote">2008/4/1, Sylvain Le Beux <<a href="mailto:artheist@gmail.com">artheist@gmail.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>I think I figured out how dsp on/off was handling with garrays. Let'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> x->x_usedindsp = 1;<br>}<br><br>This usedindsp flag then sets the following (still in g_array.c) :<br>
<br>if (x->x_usedindsp)<br> canvas_update_dsp();<br><br>Let's then look at canvas_update_dsp function, defined in g_canvas.c :<br><br>void canvas_update_dsp(void)<br>{<br> 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> t_canvas *x;<br> if (canvas_dspstate) ugen_stop();<br>
else sys_gui("pdtk_pd_dsp ON\n");<br> ugen_start();<br> <br> for (x = canvas_list; x; x = x->gl_next)<br> canvas_dodsp(x, 1, 0);<br> <br> canvas_dspstate = 1;<br>}<br><br>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<br>
and then is start the ugen. Ok, well, why not.<br>Let's now have a look at d_ugen.c<br><br>void ugen_stop(void)<br>{<br> t_signal *s;<br> int i;<br> if (dsp_chain)<br> {<br> freebytes(dsp_chain, dsp_chainsize * sizeof (t_int));<br>
dsp_chain = 0;<br> }<br> signal_cleanup();<br> <br>}<br><br>void ugen_start(void)<br>{<br> ugen_stop();<br> ugen_sortno++;<br> dsp_chain = (t_int *)getbytes(sizeof(*dsp_chain));<br> dsp_chain[0] = 0;<br>
dsp_chainsize = 1;<br> if (ugen_currentcontext) bug("ugen_start");<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><span class="sg"><br>Sylvain<br><br><br>
</span></blockquote></div><br>