Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11658/pd/src
Modified Files: d_misc.c d_ugen.c g_canvas.c g_editor.c notes.txt Log Message: Improved samplerate~ implementation.
Index: notes.txt =================================================================== RCS file: /cvsroot/pure-data/pd/src/notes.txt,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** notes.txt 19 Aug 2005 23:28:03 -0000 1.19 --- notes.txt 21 Aug 2005 14:46:18 -0000 1.20 *************** *** 1,45 **** ---------------- dolist -------------------- - done for 0.39: - At the source level, "regular" arrays and arrays withing data structures - are now the same thing. The main user-visible effect of this is that now - "arrays" may be graphed as "bezier curves". - array elements can be clicked on, etc - fixed array onset bug - rfft bug fix - bug fix in d_soundfile.c - bugfix in number2 - plot drawing instructions turn on and off - ranges in drawing instructions - select/deselect hook - unify graph properties dialogs - GOP font depends on abstraction, not parent - bug fixes, stale pointers - message "addcomma" etc - "list" object - Mac to tcl/tk 8.4.5; pd extension added automatically - bug fix writing aiff gfiles - bug fix (tcl error messages when starting open dialogs) - pointer rewind (also check if send-window documented?) - stop vis-ing subpatches of abstractions - save dirty abstractions on close - close dirty patches on quit - "find" fixed to open GOPs correctly - cheat to speed up mouse motion over arrays - fix samplerate~ to figure out blocking - thread-unsafe callbacks from sys_microsleep() - writesf -- "open" without "0" misses closing the previous file. - - ------------ 0.39 ---------
windows: modal dialogs confuse watchdog check the right-click-on-empty-canvas ! mac: ! load libraries first before opening patches on drag-and-drop
- check: - MIDI I/O for windows - blechman patch for s_inter.c - check what happens when going back and forth between graph-on-parent
doc: --- 1,11 ---- ---------------- dolist --------------------
+ test: + compile on various versions of linux windows: modal dialogs confuse watchdog check the right-click-on-empty-canvas ! MIDI I/O (inc. sysex)
doc: *************** *** 77,80 **** --- 43,47 ----
features: + integrate video into tilde objects flag to suppress printing array name above graph flag to suppress scrollbars in canvases *************** *** 110,114 **** data: data copy/paste doesn't check templates aren't changed - figure out why Pd sometimes crashes when you close example after adding fields arrays of non-existent templates crash vget, vset traversal objects --- 77,80 ---- *************** *** 120,125 **** scalar hook to catch the mouse protect against "plots" going away while you drag on them - when last drawing instruction leaves, glist_redrawitem() fails to erase it; - perhaps scalar_vis(...0) should just delete for the tag, itself?
more features: --- 86,89 ----
Index: g_editor.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/g_editor.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** g_editor.c 19 Aug 2005 23:28:03 -0000 1.11 --- g_editor.c 21 Aug 2005 14:46:17 -0000 1.12 *************** *** 1687,1691 **** return; } ! else pd_free(&x->gl_pd); } else if (force == 1) --- 1687,1696 ---- return; } ! else ! { ! sys_vgui( ! "pdtk_check {Close this window??} {.x%lx menuclose 1;\n} yes\n", ! x); ! } } else if (force == 1) *************** *** 1696,1700 **** while (x->gl_owner) x = x->gl_owner; ! canvas_menuclose(x, 0); } else if (force == 3) --- 1701,1714 ---- while (x->gl_owner) x = x->gl_owner; ! g = glist_finddirty(x); ! if (g) ! { ! canvas_vis(g, 1); ! sys_vgui( ! "pdtk_check {Discard changes to this window??} {.x%lx menuclose 2;\n} no\n", ! g); ! return; ! } ! else pd_free(&x->gl_pd); } else if (force == 3)
Index: d_ugen.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/d_ugen.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** d_ugen.c 19 Aug 2005 23:28:03 -0000 1.5 --- d_ugen.c 21 Aug 2005 14:46:17 -0000 1.6 *************** *** 248,251 **** --- 248,263 ---- }
+ void block_tilde_setup(void) + { + block_class = class_new(gensym("block~"), (t_newmethod)block_new, 0, + sizeof(t_block), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + class_addcreator((t_newmethod)switch_new, gensym("switch~"), + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + class_addmethod(block_class, (t_method)block_set, gensym("set"), + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + class_addmethod(block_class, (t_method)block_dsp, gensym("dsp"), 0); + class_addfloat(block_class, block_float); + } + /* ------------------ DSP call list ----------------------- */
*************** *** 661,665 **** t_sigoutconnect *oc, *oc2; t_class *class = pd_class(&u->u_obj->ob_pd); ! int i, n, totnsig; /* suppress creating new signals for the outputs of signal inlets and subpatchs; except in the case we're an inlet and "blocking" --- 673,677 ---- t_sigoutconnect *oc, *oc2; t_class *class = pd_class(&u->u_obj->ob_pd); ! int i, n; /* suppress creating new signals for the outputs of signal inlets and subpatchs; except in the case we're an inlet and "blocking" *************** *** 696,701 **** } } ! totnsig = u->u_nin + u->u_nout; ! insig = (t_signal **)getbytes((totnsig ? totnsig : 1) * sizeof(t_signal *)); outsig = insig + u->u_nin; for (sig = insig, uin = u->u_in, i = u->u_nin; i--; sig++, uin++) --- 708,712 ---- } } ! insig = (t_signal **)getbytes((u->u_nin + u->u_nout) * sizeof(t_signal *)); outsig = insig + u->u_nin; for (sig = insig, uin = u->u_in, i = u->u_nin; i--; sig++, uin++) *************** *** 732,740 **** (*sig)->s_refcount = uout->o_nconnect; } - /* if thre are no input or output signals, supply one fake signal so - the object can learn the sample rate and block size. Used by the - samplerate~ object. */ - if (!totnsig) - insig[0] = signal_new(dc->dc_vecsize, dc->dc_srate); /* now call the DSP scheduling routine for the ugen. This routine must fill in "borrowed" signal outputs in case it's either --- 743,746 ---- *************** *** 751,757 **** signal_makereusable(*sig); } - /* special case: no inputs or outputs: free the fake signal we made */ - if (!totnsig) - signal_makereusable(insig[0]); if (ugen_loud) { --- 757,760 ---- *************** *** 1100,1116 **** }
/* -------------------- setup routine -------------------------- */
! void d_ugen_setup(void) /* really just block_setup */ { ! block_class = class_new(gensym("block~"), (t_newmethod)block_new, 0, ! sizeof(t_block), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); ! class_addcreator((t_newmethod)switch_new, gensym("switch~"), ! A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); ! class_addmethod(block_class, (t_method)block_set, gensym("set"), ! A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); ! class_addmethod(block_class, (t_method)block_dsp, gensym("dsp"), 0); ! class_addfloat(block_class, block_float); }
--- 1103,1153 ---- }
+ /* ------------------------ samplerate~~ -------------------------- */ + + static t_class *samplerate_tilde_class; + + typedef struct _samplerate + { + t_object x_obj; + float x_sr; + t_canvas *x_canvas; + } t_samplerate; + + void *canvas_getblock(t_class *blockclass, t_canvas **canvasp); + + static void samplerate_tilde_bang(t_samplerate *x) + { + float srate = sys_getsr(); + t_canvas *canvas = x->x_canvas; + while (canvas) + { + t_block *b = (t_block *)canvas_getblock(block_class, &canvas); + if (b) + srate *= (float)(b->x_upsample) / (float)(b->x_downsample); + } + outlet_float(x->x_obj.ob_outlet, srate); + } + + static void *samplerate_tilde_new(t_symbol *s) + { + t_samplerate *x = (t_samplerate *)pd_new(samplerate_tilde_class); + outlet_new(&x->x_obj, &s_float); + x->x_canvas = canvas_getcurrent(); + return (x); + } + + static void samplerate_tilde_setup(void) + { + samplerate_tilde_class = class_new(gensym("samplerate~"), + (t_newmethod)samplerate_tilde_new, 0, sizeof(t_samplerate), 0, 0); + class_addbang(samplerate_tilde_class, samplerate_tilde_bang); + }
/* -------------------- setup routine -------------------------- */
! void d_ugen_setup(void) { ! block_tilde_setup(); ! samplerate_tilde_setup(); }
Index: d_misc.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/d_misc.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** d_misc.c 19 Aug 2005 23:28:03 -0000 1.4 --- d_misc.c 21 Aug 2005 14:46:17 -0000 1.5 *************** *** 128,173 **** }
- /* ------------------------ samplerate~~ -------------------------- */ - - static t_class *samplerate_tilde_class; - - typedef struct _samplerate - { - t_object x_obj; - float x_sr; - } t_samplerate; - - static void samplerate_tilde_bang(t_samplerate *x) - { - if (!canvas_dspstate) - { - post( - "NB: samplerate~ momentarily started DSP to learn sample rate"); - canvas_resume_dsp(1); - canvas_suspend_dsp(); - } - outlet_float(x->x_obj.ob_outlet, x->x_sr); - } - - static void samplerate_tilde_dsp(t_samplerate *x, t_signal **sp) - { - x->x_sr = sp[0]->s_sr; - } - - static void *samplerate_tilde_new(t_symbol *s) - { - t_samplerate *x = (t_samplerate *)pd_new(samplerate_tilde_class); - outlet_new(&x->x_obj, &s_float); - return (x); - } - - static void samplerate_tilde_setup(void) - { - samplerate_tilde_class = class_new(gensym("samplerate~"), - (t_newmethod)samplerate_tilde_new, 0, sizeof(t_samplerate), 0, 0); - class_addbang(samplerate_tilde_class, samplerate_tilde_bang); - class_addmethod(samplerate_tilde_class, (t_method)samplerate_tilde_dsp, - gensym("dsp"), A_CANT, 0); - }
/* ------------------------ global setup routine ------------------------- */ --- 128,131 ---- *************** *** 177,181 **** print_setup(); bang_tilde_setup(); - samplerate_tilde_setup(); }
--- 135,138 ----
Index: g_canvas.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/g_canvas.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** g_canvas.c 19 Aug 2005 23:28:03 -0000 1.10 --- g_canvas.c 21 Aug 2005 14:46:17 -0000 1.11 *************** *** 1225,1234 **** }
- static void canvas_dodsp(t_canvas *x, int toplevel, t_signal **sp); - static void canvas_dsp(t_canvas *x, t_signal **sp) - { - canvas_dodsp(x, 0, sp); - } - /* get the document containing this canvas */ t_canvas *canvas_getrootfor(t_canvas *x) --- 1225,1228 ---- *************** *** 1290,1293 **** --- 1284,1292 ---- }
+ static void canvas_dsp(t_canvas *x, t_signal **sp) + { + canvas_dodsp(x, 0, sp); + } + /* this routine starts DSP for all root canvases. */ static void canvas_start_dsp(void) *************** *** 1357,1360 **** --- 1356,1374 ---- }
+ void *canvas_getblock(t_class *blockclass, t_canvas **canvasp) + { + t_canvas *canvas = *canvasp; + t_gobj *g; + void *ret = 0; + for (g = canvas->gl_list; g; g = g->g_next) + { + if (g->g_pd == blockclass) + ret = g; + } + *canvasp = canvas->gl_owner; + return(ret); + } + + /******************* redrawing data *********************/
/* redraw all "scalars" (do this if a drawing command is changed.)