Hi all,
trying to load abstractions into a patch dynamically from a self written external sometimes leads to a segfault when turning on dsp rendering.
Here is what I'm trying to do: The patch is some specialized synth where a program change loads a predefined number of synth voices, stored as abstractions, into a subpatcher and connects them within the subpatcher. Connections to the outside world are done via throw~ and catch~ within the abstractions.
When dsp is turned on all the time during this, sometimes, audio generated in the synth voices isn't appearing at the outlets (it seems the audio isn't integrated into the dsp path at all). All the created objects and their connections are visible in the gui. Turning dsp off and on makes it work, but trying to automatize it leads to the segfaults from time to time.
I used a clock object to delay the reinitialisation of dsp rendering which helps tremendously, but even with delaytimes of 1000-2500 ms I sometimes run into the segfaults (and I consider this not really as a "solution").
Below are the relevant code segments which are run within the same function (lots of lines omitted).
I've spent lots of hours in gdb trying to chase this down but I'm at loss here. This thing is killing me. Any help is greatly appreciated!
-- Orm
t_atom *p; int n,m,xoffs,yoffs; t_atom mess[5], atarget, aroute;
/* Clear the voices canvas */
if (x->x_synth_voices_canvas.a_w.w_symbol->s_thing)
typedmess(x->x_synth_voices_canvas.a_w.w_symbol->s_thing,
gensym("clear"), 0,0);
/* Load the abstractions into it */
for (n=4, xoffs=0, yoffs=0;
n>=0;
n--, xoffs++, yoffs++)
{
SETFLOAT(mess, ((xoffs*20)+500));
SETFLOAT(mess+1, ((yoffs*20)+50));
/* "catch-vu.pd" */
SETSYMBOL(mess+2, gensym("catch-vu"));
SETFLOAT(mess+3, x->x_canvasdollarzero);
SETFLOAT(mess+4, (float)n);
if (x->x_synth_voices_canvas.a_w.w_symbol->s_thing)
typedmess(x->x_synth_voices_canvas.a_w.w_symbol->s_thing,
gensym("obj"), 5, mess);
else {
error("synth_voices_canvas doesn't exist");
goto exit;
}
}
p=x->x_initseq->b_vec; /* this variable holds the number of voices */
for (n=1, xoffs=0, yoffs=0;
n<=(int)p->a_w.w_float;
n++, xoffs++, yoffs++)
{
SETFLOAT(mess, (((xoffs%3)*120)+50));
SETFLOAT(mess+1, ((floor((yoffs)/3)*30)+200));
/* "rec-voice.pd" */
SETSYMBOL(mess+2, gensym("rec-voice"));
SETFLOAT(mess+3, x->x_canvasdollarzero);
SETFLOAT(mess+4, (float)n);
if (x->x_synth_voices_canvas.a_w.w_symbol->s_thing)
typedmess(x->x_synth_voices_canvas.a_w.w_symbol->s_thing,
gensym("obj"), 5, mess);
else {
error("synth_voices_canvas doesn't exist");
goto exit;
}
/* connect the catch-vu objects with the rec-voices */
SETFLOAT(mess+1, 0);
SETFLOAT(mess+2, (n+4));
for (m=0;m<5;m++)
{
SETFLOAT(mess, m);
SETFLOAT(mess+3, m);
if (x->x_synth_voices_canvas.a_w.w_symbol->s_thing)
typedmess(x->x_synth_voices_canvas.a_w.w_symbol->s_thing,
gensym("connect"), 4, mess);
else {
error("synth_voices_canvas doesn't exist");
goto exit;
}
}
}
/* Turn on dsp with a delay */
clock_delay(x->x_dspclock, 500);
return;
Orm Finnendahl wrote:
Hi all,
When dsp is turned on all the time during this, sometimes, audio generated in the synth voices isn't appearing at the outlets (it seems the audio isn't integrated into the dsp path at all). All the created objects and their connections are visible in the gui. Turning dsp off and on makes it work, but trying to automatize it leads to the segfaults from time to time.
have you looked at:
EXTERN int canvas_suspend_dsp(void); EXTERN void canvas_resume_dsp(int oldstate);
something like:
<snip> int oldstate=canvas_suspend_dsp(); /* your creation code here */ canvas_resume_dsp(oldstate); </snip>
fmasdr IOhannes
On Wed, 30 Sep 2009, IOhannes m zmoelnig wrote:
Orm Finnendahl wrote:
objects and their connections are visible in the gui. Turning dsp off and on makes it work, but trying to automatize it leads to the segfaults from time to time.
have you looked at: EXTERN int canvas_suspend_dsp(void); EXTERN void canvas_resume_dsp(int oldstate);
So, why would this work, while automatising the turning of dsp off and on would not, and can this happen in a self-modifying abstraction, and then in that case, how does a self-modifying abstraction get to be able to use those two special functions?
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard, Montréal, Québec. téléphone: +1.514.383.3801
Am Donnerstag, den 01. Oktober 2009 um 12:36:43 Uhr (-0400) schrieb Mathieu Bouchard:
EXTERN int canvas_suspend_dsp(void); EXTERN void canvas_resume_dsp(int oldstate);
So, why would this work, while automatising the turning of dsp off and on would not, and can this happen in a self-modifying abstraction,
sorry, don't know.
and then in that case, how does a self-modifying abstraction get to be able to use those two special functions?
I don't see any way to access these functions automatically within a pd patch (except writing a code external which calls the functions).
-- Orm