diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c index f8b9fd7c310488aa60fe38c8e4245a527f3e16d4..1eaade0089ebec06a3a12b68786e45fbc82474ca 100644 --- a/pd/src/g_canvas.c +++ b/pd/src/g_canvas.c @@ -1539,7 +1539,7 @@ static void canvas_dsp(t_canvas *x, t_signal **sp) } /* this routine starts DSP for all root canvases. */ -static void canvas_start_dsp(void) +static void canvas_dostart_dsp(void) { t_canvas *x; if (pd_this->pd_dspstate) @@ -1556,7 +1556,13 @@ static void canvas_start_dsp(void) pd_bang(gensym("pd-dsp-started")->s_thing); } -static void canvas_stop_dsp(void) +static void canvas_start_dsp(void) +{ + pd_this->pd_dspstate_user = 1; + canvas_dostart_dsp(); +} + +static void canvas_dostop_dsp(void) { if (pd_this->pd_dspstate) { @@ -1568,6 +1574,12 @@ static void canvas_stop_dsp(void) } } +static void canvas_stop_dsp(void) +{ + pd_this->pd_dspstate_user = 0; + canvas_dostop_dsp(); +} + /* DSP can be suspended before, and resumed after, operations which might affect the DSP chain. For example, we suspend before loading and resume afterward, so that DSP doesn't get resorted for every DSP object @@ -1577,14 +1589,14 @@ int canvas_suspend_dsp(void) { //fprintf(stderr,"canvas_suspend_dsp %d\n", rval); int rval = pd_this->pd_dspstate; - if (rval) canvas_stop_dsp(); + if (rval) canvas_dostop_dsp(); return (rval); } void canvas_resume_dsp(int oldstate) { //fprintf(stderr,"canvas_resume_dsp %d\n", oldstate); - if (oldstate) canvas_start_dsp(); + if (oldstate) canvas_dostart_dsp(); } /* this is equivalent to suspending and resuming in one step. */ diff --git a/pd/src/m_imp.h b/pd/src/m_imp.h index c54267124efe27cdf18114417ffee4649132be7a..9512a1abd87d3a0293e3d25be82f74c8b5a08674 100644 --- a/pd/src/m_imp.h +++ b/pd/src/m_imp.h @@ -64,6 +64,7 @@ struct _pdinstance int pd_dspchainsize; /* number of elements in DSP chain */ t_canvas *pd_canvaslist; /* list of all root canvases */ int pd_dspstate; /* whether DSP is on or off */ + int pd_dspstate_user; /* dsp state excluding temporary suspensions */ t_signal *pd_signals; /* list of signals used by DSP chain */ t_symbol *pd_midiin_sym; /* symbols bound to incoming MIDI... */ t_symbol *pd_sysexin_sym; diff --git a/pd/src/m_pd.c b/pd/src/m_pd.c index 4732f7cf8db5c043e7d75e84ef451cf6c42056f1..1bf74a280d2170c7c51b4dc1b0644e3f0478beb8 100644 --- a/pd/src/m_pd.c +++ b/pd/src/m_pd.c @@ -469,6 +469,7 @@ static t_pdinstance *pdinstance_donew(int useprefix) x->pd_dspchainsize = 0; x->pd_canvaslist = 0; x->pd_dspstate = 0; + x->pd_dspstate_user = 0; x->pd_midiin_sym = midi_gensym(midiprefix, "#midiin"); x->pd_sysexin_sym = midi_gensym(midiprefix, "#sysexin"); x->pd_notein_sym = midi_gensym(midiprefix, "#notein"); diff --git a/pd/src/x_interface.c b/pd/src/x_interface.c index 6724a4383e999c67cc0e62418bdcdfed5b23dd22..52faf175c23ee7466a7627ff802a805f6d9b5db5 100644 --- a/pd/src/x_interface.c +++ b/pd/src/x_interface.c @@ -535,10 +535,13 @@ void pdinfo_dir(t_pdinfo *x, t_symbol *s, int argc, t_atom *argv) info_out((t_text *)x, s, 1, at); } +/* Instead of reporting the actual value for dsp when it's temporarily + suspended, we report what it will be when dsp is resumed. This way the + user can get a meaningful value at load time. */ void pdinfo_dsp(t_pdinfo *x, t_symbol *s, int argc, t_atom *argv) { t_atom at[1]; - SETFLOAT(at, (t_float)pd_getdspstate()); + SETFLOAT(at, (t_float)(pd_this->pd_dspstate_user)); info_out((t_text *)x, s, 1, at); }