aboutsummaryrefslogtreecommitdiff
path: root/pd
diff options
context:
space:
mode:
authorMiller Puckette <millerpuckette@users.sourceforge.net>2006-08-15 04:54:15 +0000
committerMiller Puckette <millerpuckette@users.sourceforge.net>2006-08-15 04:54:15 +0000
commit067d2611b9e1041318f605091dc6e93936fa9ce5 (patch)
treedba59fccb6d070232ff0e17dbbdf1cefe752647f /pd
parent7c232a7d3a14391fd4d4f58892cf89e294c87d62 (diff)
0.40 test 01 commit ... although the "about" dialog thinks it's test02 :)
svn path=/trunk/; revision=5604
Diffstat (limited to 'pd')
-rw-r--r--pd/doc/1.manual/1.introduction.txt2
-rw-r--r--pd/doc/1.manual/x5.htm29
-rw-r--r--pd/portaudio/pa_win_wdmks/pa_win_wdmks.c2
-rw-r--r--pd/portaudio/pablio/ringbuffer.c2
-rw-r--r--pd/portaudio/pablio/ringbuffer.h2
-rw-r--r--pd/portmidi/pm_mac/pmmacosxcm.c2
-rw-r--r--pd/src/configure.in2
-rw-r--r--pd/src/d_ugen.c99
-rw-r--r--pd/src/g_array.c3
-rw-r--r--pd/src/g_canvas.c159
-rw-r--r--pd/src/g_canvas.h1
-rw-r--r--pd/src/g_editor.c7
-rw-r--r--pd/src/g_io.c24
-rw-r--r--pd/src/g_readwrite.c69
-rw-r--r--pd/src/m_binbuf.c19
-rw-r--r--pd/src/m_class.c7
-rw-r--r--pd/src/m_pd.h10
-rw-r--r--pd/src/makefile.in30
-rw-r--r--pd/src/notes.txt2
-rw-r--r--pd/src/s_audio_alsamm.c4
-rw-r--r--pd/src/s_audio_pablio.h2
-rw-r--r--pd/src/s_audio_paring.c2
-rw-r--r--pd/src/s_audio_paring.h2
-rw-r--r--pd/src/s_inter.c13
-rw-r--r--pd/src/s_loader.c67
-rw-r--r--pd/src/s_main.c34
-rw-r--r--pd/src/s_path.c281
-rw-r--r--pd/src/s_stuff.h13
-rw-r--r--pd/src/u_main.tk36
-rw-r--r--pd/src/x_arithmetic.c19
30 files changed, 612 insertions, 332 deletions
diff --git a/pd/doc/1.manual/1.introduction.txt b/pd/doc/1.manual/1.introduction.txt
index f9209702..b81bf5bb 100644
--- a/pd/doc/1.manual/1.introduction.txt
+++ b/pd/doc/1.manual/1.introduction.txt
@@ -1,4 +1,4 @@
-PD_VERSION
+Pd version 0.40-0 test 01
A real-time graphical programming environment for live interactive
computer music, Pd works on SGI machines, Microsoft Windows,
diff --git a/pd/doc/1.manual/x5.htm b/pd/doc/1.manual/x5.htm
index 7aec1cf9..064d093e 100644
--- a/pd/doc/1.manual/x5.htm
+++ b/pd/doc/1.manual/x5.htm
@@ -19,6 +19,35 @@
<P>This section tracks changes in Pd's current implementation.</P>
<H3> <A name="s2"> 5.1. release notes </A> </H3>
+<P> ------------------ 0.40 -----------------------------
+
+<P> A new object, "declare", allows patches to control where Pd looks
+for resources such as abstractions and libraries.
+
+<P> Sybmols can now be built using multiple dollar sign variables, as in
+"$1-$2.$3".
+
+<P> The switch~ object takes a "bang" message to compute one block of DSP on
+demand. Also, block sizes are no longer required to be powers of two
+(although reblocking only works between powers of two.)
+
+<P> Externs may have characters in their names that aren't part of valid
+C variable names (i.e., outsize the range a-z,A-Z,0-9, _).
+
+<P> Openpanel and savepanel take an argument to set the initial directory to
+search.
+
+<P> Support for large (>2G) soundfiles, in operating systems that offer it.
+
+<P> Text copy/paste fixed (I hope) for Macintosh
+
+<P> Intel Mac binaries. New naming scheme for externs to allow disambiguation
+(although Pd falls back to the old names for compatibility.)
+
+<P> Templates can get notified when data are selected/deselected. I want
+to provide this for mouse actions on locked canvases too, but haven't yet.
+
+<P> 6 or so patches adopted from sourceforge.
<P> ------------------ 0.39.2 --------------------------
diff --git a/pd/portaudio/pa_win_wdmks/pa_win_wdmks.c b/pd/portaudio/pa_win_wdmks/pa_win_wdmks.c
index 45c40d0d..00e54e6f 100644
--- a/pd/portaudio/pa_win_wdmks/pa_win_wdmks.c
+++ b/pd/portaudio/pa_win_wdmks/pa_win_wdmks.c
@@ -1,5 +1,5 @@
/*
- * $Id: pa_win_wdmks.c,v 1.5 2006-08-11 20:09:07 millerpuckette Exp $
+ * $Id: pa_win_wdmks.c,v 1.6 2006-08-15 04:54:15 millerpuckette Exp $
* PortAudio Windows WDM-KS interface
*
* Author: Andrew Baldwin
diff --git a/pd/portaudio/pablio/ringbuffer.c b/pd/portaudio/pablio/ringbuffer.c
index 35b2e631..b37762bd 100644
--- a/pd/portaudio/pablio/ringbuffer.c
+++ b/pd/portaudio/pablio/ringbuffer.c
@@ -1,5 +1,5 @@
/*
- * $Id: ringbuffer.c,v 1.4 2006-08-11 20:09:07 millerpuckette Exp $
+ * $Id: ringbuffer.c,v 1.5 2006-08-15 04:54:15 millerpuckette Exp $
* ringbuffer.c
* Ring Buffer utility..
*
diff --git a/pd/portaudio/pablio/ringbuffer.h b/pd/portaudio/pablio/ringbuffer.h
index 7a06c6be..a8492ae9 100644
--- a/pd/portaudio/pablio/ringbuffer.h
+++ b/pd/portaudio/pablio/ringbuffer.h
@@ -6,7 +6,7 @@ extern "C"
#endif /* __cplusplus */
/*
- * $Id: ringbuffer.h,v 1.5 2006-08-11 20:09:07 millerpuckette Exp $
+ * $Id: ringbuffer.h,v 1.6 2006-08-15 04:54:15 millerpuckette Exp $
* ringbuffer.h
* Ring Buffer utility..
*
diff --git a/pd/portmidi/pm_mac/pmmacosxcm.c b/pd/portmidi/pm_mac/pmmacosxcm.c
index 9f64a45b..0386503a 100644
--- a/pd/portmidi/pm_mac/pmmacosxcm.c
+++ b/pd/portmidi/pm_mac/pmmacosxcm.c
@@ -5,7 +5,7 @@
* and subsequent work by Andrew Zeldis and Zico Kolter
* and Roger B. Dannenberg
*
- * $Id: pmmacosxcm.c,v 1.5 2006-08-11 20:09:07 millerpuckette Exp $
+ * $Id: pmmacosxcm.c,v 1.6 2006-08-15 04:54:15 millerpuckette Exp $
*/
/* Notes:
diff --git a/pd/src/configure.in b/pd/src/configure.in
index 5dfdc557..e0571a96 100644
--- a/pd/src/configure.in
+++ b/pd/src/configure.in
@@ -251,7 +251,7 @@ then
-DUSEAPI_PORTAUDIO -DPA19 -DPA_USE_COREAUDIO"
if test `uname -r` = 7.9.0;
then
- MORECFLAGS="-Wno-error"
+ MORECFLAGS="-DPA_BIG_ENDIAN -Wno-error"
EXTERNTARGET=d_ppc
else
MORECFLAGS="-arch i386 -arch ppc -Wno-error"
diff --git a/pd/src/d_ugen.c b/pd/src/d_ugen.c
index c1dcbffc..d7cfd543 100644
--- a/pd/src/d_ugen.c
+++ b/pd/src/d_ugen.c
@@ -20,17 +20,20 @@
extern t_class *vinlet_class, *voutlet_class, *canvas_class;
t_sample *obj_findsignalscalar(t_object *x, int m);
static int ugen_loud;
+static t_int *dsp_chain;
+static int dsp_chainsize;
+
EXTERN_STRUCT _vinlet;
EXTERN_STRUCT _voutlet;
void vinlet_dspprolog(struct _vinlet *x, t_signal **parentsigs,
- int myvecsize, int phase, int period, int frequency,
+ int myvecsize, int calcsize, int phase, int period, int frequency,
int downsample, int upsample, int reblock, int switched);
void voutlet_dspprolog(struct _voutlet *x, t_signal **parentsigs,
- int myvecsize, int phase, int period, int frequency,
+ int myvecsize, int calcsize, int phase, int period, int frequency,
int downsample, int upsample, int reblock, int switched);
void voutlet_dspepilog(struct _voutlet *x, t_signal **parentsigs,
- int myvecsize, int phase, int period, int frequency,
+ int myvecsize, int calcsize, int phase, int period, int frequency,
int downsample, int upsample, int reblock, int switched);
t_int *zero_perform(t_int *w) /* zero out a vector */
@@ -104,12 +107,14 @@ static t_class *block_class;
typedef struct _block
{
t_object x_obj;
- int x_vecsize;
+ int x_vecsize; /* size of audio signals in this block */
+ int x_calcsize; /* number of samples actually to compute */
int x_overlap;
int x_phase; /* from 0 to period-1; when zero we run the block */
int x_period; /* submultiple of containing canvas */
int x_frequency; /* supermultiple of comtaining canvas */
- int x_count;
+ int x_count; /* number of times parent block has called us */
+ int x_chainonset; /* beginning of code in DSP chain */
int x_blocklength; /* length of dspchain for this block */
int x_epiloglength; /* length of epilog */
char x_switched; /* true if we're acting as a a switch */
@@ -117,7 +122,7 @@ typedef struct _block
char x_reblock; /* true if inlets and outlets are reblocking */
int x_upsample; /* upsampling-factor */
int x_downsample; /* downsampling-factor */
-
+ int x_return; /* stop right after this block (for one-shots) */
} t_block;
static void block_set(t_block *x, t_floatarg fvecsize, t_floatarg foverlap,
@@ -136,17 +141,18 @@ static void *block_new(t_floatarg fvecsize, t_floatarg foverlap,
return (x);
}
-static void block_set(t_block *x, t_floatarg fvecsize, t_floatarg foverlap,
+static void block_set(t_block *x, t_floatarg fcalcsize, t_floatarg foverlap,
t_floatarg fupsample)
{
int upsample, downsample;
- int vecsize = fvecsize;
+ int calcsize = fcalcsize;
int overlap = foverlap;
int dspstate = canvas_suspend_dsp();
+ int vecsize;
if (overlap < 1)
overlap = 1;
- if (vecsize < 0)
- vecsize = 0; /* this means we'll get it from parent later. */
+ if (calcsize < 0)
+ calcsize = 0; /* this means we'll get it from parent later. */
if (fupsample <= 0)
upsample = downsample = 1;
@@ -160,6 +166,13 @@ static void block_set(t_block *x, t_floatarg fvecsize, t_floatarg foverlap,
upsample = 1;
}
+ /* vecsize is smallest power of 2 large enough to hold calcsize */
+ if (calcsize)
+ {
+ if ((vecsize = (1 << ilog2(calcsize))) != calcsize)
+ vecsize *= 2;
+ }
+ else vecsize = 0;
if (vecsize && (vecsize != (1 << ilog2(vecsize))))
{
pd_error(x, "block~: vector size not a power of 2");
@@ -181,6 +194,7 @@ static void block_set(t_block *x, t_floatarg fvecsize, t_floatarg foverlap,
upsample = 1;
}
+ x->x_calcsize = calcsize;
x->x_vecsize = vecsize;
x->x_overlap = overlap;
x->x_upsample = upsample;
@@ -202,6 +216,21 @@ static void block_float(t_block *x, t_floatarg f)
if (x->x_switched)
x->x_switchon = (f != 0);
}
+
+static void block_bang(t_block *x)
+{
+ if (x->x_switched && !x->x_switchon)
+ {
+ t_int *ip;
+ x->x_return = 1;
+ for (ip = dsp_chain + x->x_chainonset; ip; )
+ ip = (*(t_perfroutine)(*ip))(ip);
+ x->x_return = 0;
+ }
+ else pd_error(x, "bang to block~ or on-state switch~ has no effect");
+}
+
+
#define PROLOGCALL 2
#define EPILOGCALL 2
@@ -231,6 +260,8 @@ static t_int *block_epilog(t_int *w)
{
t_block *x = (t_block *)w[1];
int count = x->x_count - 1;
+ if (x->x_return)
+ return (0);
if (!x->x_reblock)
return (w + x->x_epiloglength + EPILOGCALL);
if (count)
@@ -257,12 +288,15 @@ void block_tilde_setup(void)
A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
class_addmethod(block_class, (t_method)block_dsp, gensym("dsp"), 0);
class_addfloat(block_class, block_float);
+ class_addbang(block_class, block_bang);
}
/* ------------------ DSP call list ----------------------- */
-static t_int *dsp_chain;
-static int dsp_chainsize;
+static t_int dsp_done(t_int *w)
+{
+ return (0);
+}
void dsp_add(t_perfroutine f, int n, ...)
{
@@ -276,7 +310,7 @@ void dsp_add(t_perfroutine f, int n, ...)
for (i = 0; i < n; i++)
dsp_chain[dsp_chainsize + i] = va_arg(ap, t_int);
va_end(ap);
- dsp_chain[newsize-1] = 0;
+ dsp_chain[newsize-1] = (t_int)dsp_done;
dsp_chainsize = newsize;
}
@@ -290,7 +324,7 @@ void dsp_addv(t_perfroutine f, int n, t_int *vec)
dsp_chain[dsp_chainsize-1] = (t_int)f;
for (i = 0; i < n; i++)
dsp_chain[dsp_chainsize + i] = vec[i];
- dsp_chain[newsize-1] = 0;
+ dsp_chain[newsize-1] = (t_int)dsp_done;
dsp_chainsize = newsize;
}
@@ -299,7 +333,7 @@ void dsp_tick(void)
if (dsp_chain)
{
t_int *ip;
- for (ip = dsp_chain; *ip; ) ip = (*(t_perfroutine)(*ip))(ip);
+ for (ip = dsp_chain; ip; ) ip = (*(t_perfroutine)(*ip))(ip);
dsp_phase++;
}
}
@@ -334,7 +368,7 @@ void signal_cleanup(void)
{
signal_usedlist = sig->s_nextused;
if (!sig->s_isborrowed)
- t_freebytes(sig->s_vec, sig->s_n * sizeof (*sig->s_vec));
+ t_freebytes(sig->s_vec, sig->s_vecsize * sizeof (*sig->s_vec));
t_freebytes(sig, sizeof *sig);
}
for (i = 0; i <= MAXLOGSIG; i++)
@@ -345,7 +379,7 @@ void signal_cleanup(void)
/* mark the signal "reusable." */
void signal_makereusable(t_signal *sig)
{
- int logn = ilog2(sig->s_n);
+ int logn = ilog2(sig->s_vecsize);
#if 1
t_signal *s5;
for (s5 = signal_freeborrowed; s5; s5 = s5->s_nextfree)
@@ -395,14 +429,14 @@ void signal_makereusable(t_signal *sig)
t_signal *signal_new(int n, float sr)
{
- int logn, n2;
+ int logn, n2, vecsize = 0;
t_signal *ret, **whichlist;
t_sample *fp;
logn = ilog2(n);
if (n)
{
- if (n != (1 << logn))
- bug("signal buffer not a power of 2");
+ if ((vecsize = (1<<logn)) != n)
+ vecsize *= 2;
if (logn > MAXLOGSIG)
bug("signal buffer too large");
whichlist = signal_freelist + logn;
@@ -419,7 +453,7 @@ t_signal *signal_new(int n, float sr)
ret = (t_signal *)t_getbytes(sizeof *ret);
if (n)
{
- ret->s_vec = (t_sample *)getbytes(n * sizeof (*ret->s_vec));
+ ret->s_vec = (t_sample *)getbytes(vecsize * sizeof (*ret->s_vec));
ret->s_isborrowed = 0;
}
else
@@ -431,6 +465,7 @@ t_signal *signal_new(int n, float sr)
signal_usedlist = ret;
}
ret->s_n = n;
+ ret->s_vecsize = vecsize;
ret->s_sr = sr;
ret->s_refcount = 0;
ret->s_borrowedfrom = 0;
@@ -452,6 +487,7 @@ void signal_setborrowed(t_signal *sig, t_signal *sig2)
sig->s_borrowedfrom = sig2;
sig->s_vec = sig2->s_vec;
sig->s_n = sig2->s_n;
+ sig->s_vecsize = sig2->s_vecsize;
}
int signal_compatible(t_signal *s1, t_signal *s2)
@@ -504,7 +540,8 @@ struct _dspcontext
int dc_noutlets;
t_signal **dc_iosigs;
float dc_srate;
- int dc_vecsize;
+ int dc_vecsize; /* vector size, power of two */
+ int dc_calcsize; /* number of elements to calculate */
char dc_toplevel; /* true if "iosigs" is invalid. */
char dc_reblock; /* true if we have to reblock inlets/outlets */
char dc_switched; /* true if we're switched */
@@ -832,7 +869,7 @@ void ugen_done_graph(t_dspcontext *dc)
t_dspcontext *parent_context = dc->dc_parentcontext;
float parent_srate;
int parent_vecsize;
- int period, frequency, phase, vecsize;
+ int period, frequency, phase, vecsize, calcsize;
float srate;
int chainblockbegin; /* DSP chain onset before block prolog code */
int chainblockend; /* and after block epilog code */
@@ -886,6 +923,9 @@ void ugen_done_graph(t_dspcontext *dc)
vecsize = blk->x_vecsize;
if (vecsize == 0)
vecsize = parent_vecsize;
+ calcsize = blk->x_calcsize;
+ if (calcsize == 0)
+ calcsize = vecsize;
realoverlap = blk->x_overlap;
if (realoverlap > vecsize) realoverlap = vecsize;
downsample = blk->x_downsample;
@@ -906,7 +946,7 @@ void ugen_done_graph(t_dspcontext *dc)
if (! parent_context || (realoverlap != 1) ||
(vecsize != parent_vecsize) ||
(downsample != 1) || (upsample != 1))
- reblock = 1;
+ reblock = 1;
switched = blk->x_switched;
}
else
@@ -923,6 +963,7 @@ void ugen_done_graph(t_dspcontext *dc)
dc->dc_switched = switched;
dc->dc_srate = srate;
dc->dc_vecsize = vecsize;
+ dc->dc_calcsize = calcsize;
/* if we're reblocking or switched, we now have to create output
signals to fill in for the "borrowed" ones we have now. This
@@ -967,18 +1008,20 @@ void ugen_done_graph(t_dspcontext *dc)
if (pd_class(zz) == vinlet_class)
vinlet_dspprolog((struct _vinlet *)zz,
- dc->dc_iosigs, vecsize, dsp_phase, period, frequency,
+ dc->dc_iosigs, vecsize, calcsize, dsp_phase, period, frequency,
downsample, upsample, reblock, switched);
else if (pd_class(zz) == voutlet_class)
voutlet_dspprolog((struct _voutlet *)zz,
- outsigs, vecsize, dsp_phase, period, frequency,
+ outsigs, vecsize, calcsize, dsp_phase, period, frequency,
downsample, upsample, reblock, switched);
}
chainblockbegin = dsp_chainsize;
if (blk && (reblock || switched)) /* add the block DSP prolog */
+ {
dsp_add(block_prolog, 1, blk);
-
+ blk->x_chainonset = dsp_chainsize - 1;
+ }
/* Initialize for sorting */
for (u = dc->dc_ugenlist; u; u = u->u_next)
{
@@ -1044,7 +1087,7 @@ void ugen_done_graph(t_dspcontext *dc)
t_signal **iosigs = dc->dc_iosigs;
if (iosigs) iosigs += dc->dc_ninlets;
voutlet_dspepilog((struct _voutlet *)zz,
- iosigs, vecsize, dsp_phase, period, frequency,
+ iosigs, vecsize, calcsize, dsp_phase, period, frequency,
downsample, upsample, reblock, switched);
}
}
diff --git a/pd/src/g_array.c b/pd/src/g_array.c
index fdbb6416..95819282 100644
--- a/pd/src/g_array.c
+++ b/pd/src/g_array.c
@@ -1379,8 +1379,7 @@ static void garray_read(t_garray *x, t_symbol *filename)
return;
}
nelem = array->a_n;
- if ((filedesc = open_via_path(
- canvas_getdir(glist_getcanvas(x->x_glist))->s_name,
+ if ((filedesc = canvas_open(glist_getcanvas(x->x_glist),
filename->s_name, "", buf, &bufptr, MAXPDSTRING, 0)) < 0
|| !(fd = fdopen(filedesc, "r")))
{
diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c
index 9a5aaeef..71aa89b9 100644
--- a/pd/src/g_canvas.c
+++ b/pd/src/g_canvas.c
@@ -381,6 +381,7 @@ t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv)
env->ce_argc = canvas_newargc;
env->ce_argv = canvas_newargv;
env->ce_dollarzero = dollarzero++;
+ env->ce_path = 0;
canvas_newdirectory = &s_;
canvas_newargc = 0;
canvas_newargv = 0;
@@ -532,7 +533,7 @@ void glist_glist(t_glist *g, t_symbol *s, int argc, t_atom *argv)
otherwise it appears as a text box. */
int glist_isgraph(t_glist *x)
{
- return (x->gl_isgraph);
+ return (x->gl_isgraph|(x->gl_hidetext<<1));
}
/* This is sent from the GUI to inform a toplevel that its window has been
@@ -540,7 +541,7 @@ int glist_isgraph(t_glist *x)
static void canvas_setbounds(t_canvas *x, int x1, int y1, int x2, int y2)
{
int heightwas = y2 - y1;
- int heightchange = y2 - y1 - (x->gl_screeny2 - x->gl_screeny1);
+ int heightchange = y2 - y1 - (x->gl_screeny2 - x->gl_screeny1);
if (x->gl_screenx1 == x1 && x->gl_screeny1 == y1 &&
x->gl_screenx2 == x2 && x->gl_screeny2 == y2)
return;
@@ -1195,13 +1196,17 @@ int canvas_istable(t_canvas *x)
/* return true if the "canvas" object should be treated as a text
object. This is true for abstractions but also for "table"s... */
+/* JMZ: add a flag to gop-abstractions to hide the title */
int canvas_showtext(t_canvas *x)
{
t_atom *argv = (x->gl_obj.te_binbuf? binbuf_getvec(x->gl_obj.te_binbuf):0);
int argc = (x->gl_obj.te_binbuf? binbuf_getnatom(x->gl_obj.te_binbuf) : 0);
int isarray = (argc && argv[0].a_type == A_SYMBOL &&
argv[0].a_w.w_symbol == gensym("graph"));
- return (!isarray);
+ if(x->gl_hidetext)
+ return 0;
+ else
+ return (!isarray);
}
/* get the document containing this canvas */
@@ -1413,6 +1418,148 @@ void canvas_redrawallfortemplatecanvas(t_canvas *x, int action)
canvas_redrawallfortemplate(0, action);
}
+/* ------------------------------- declare ------------------------ */
+
+/* put "declare" objects in a patch to tell it about the environment in
+which objects should be created in this canvas. This includes directories to
+search ("-path", "-stdpath") and object libraries to load
+("-lib" and "-stdlib"). These must be set before the patch containing
+the "declare" object is filled in with its contents; so when the patch is
+saved, we throw early messages to the canvas to set the environment
+before any objects are created in it. */
+
+static t_class *declare_class;
+
+typedef struct _declare
+{
+ t_object x_obj;
+ t_canvas *x_canvas;
+ int x_useme;
+} t_declare;
+
+static void *declare_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_declare *x = (t_declare *)pd_new(declare_class);
+ x->x_useme = 1;
+ x->x_canvas = canvas_getcurrent();
+ /* LATER update environment and/or load libraries */
+ return (x);
+}
+
+static void declare_free(t_declare *x)
+{
+ x->x_useme = 0;
+ /* LATER update environment */
+}
+
+void canvas_savedeclarationsto(t_canvas *x, t_binbuf *b)
+{
+ t_gobj *y;
+
+ for (y = x->gl_list; y; y = y->g_next)
+ {
+ if (pd_class(&y->g_pd) == declare_class)
+ {
+ binbuf_addv(b, "s", gensym("#X"));
+ binbuf_addbinbuf(b, ((t_declare *)y)->x_obj.te_binbuf);
+ binbuf_addv(b, ";");
+ }
+ else if (pd_class(&y->g_pd) == canvas_class)
+ canvas_savedeclarationsto((t_canvas *)y, b);
+ }
+}
+
+static void canvas_declare(t_canvas *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i;
+ t_canvasenvironment *e = canvas_getenv(x);
+#if 0
+ startpost("declare:: %s", s->s_name);
+ postatom(argc, argv);
+ endpost();
+#endif
+ for (i = 0; i < argc; i++)
+ {
+ char strbuf[MAXPDSTRING];
+ char *flag = atom_getsymbolarg(i, argc, argv)->s_name;
+ if ((argc > i+1) && !strcmp(flag, "-path"))
+ {
+ e->ce_path = namelist_append(e->ce_path,
+ atom_getsymbolarg(i+1, argc, argv)->s_name, 0);
+ i++;
+ }
+ else if ((argc > i+1) && !strcmp(flag, "-stdpath"))
+ {
+ strncpy(strbuf, sys_libdir->s_name, MAXPDSTRING-3);
+ strbuf[MAXPDSTRING-4] = 0;
+ strcat(strbuf, "/");
+ strncpy(strbuf, atom_getsymbolarg(i+1, argc, argv)->s_name,
+ MAXPDSTRING-strlen(strbuf));
+ strbuf[MAXPDSTRING-1] = 0;
+ e->ce_path = namelist_append(e->ce_path, strbuf, 0);
+ i++;
+ }
+ else if ((argc > i+1) && !strcmp(flag, "-lib"))
+ {
+ sys_load_lib(x, atom_getsymbolarg(i+1, argc, argv)->s_name);
+ i++;
+ }
+ else if ((argc > i+1) && !strcmp(flag, "-stdlib"))
+ {
+ strncpy(strbuf, sys_libdir->s_name, MAXPDSTRING-3);
+ strbuf[MAXPDSTRING-4] = 0;
+ strcat(strbuf, "/");
+ strncpy(strbuf, atom_getsymbolarg(i+1, argc, argv)->s_name,
+ MAXPDSTRING-strlen(strbuf));
+ strbuf[MAXPDSTRING-1] = 0;
+ sys_load_lib(0, strbuf);
+ i++;
+ }
+ else post("declare: %s: unknown declaration", flag);
+ }
+}
+
+ /* utility function to read a file, looking first down the canvas's search
+ path (set with "declare" objects in the patch and recursively in calling
+ patches), then down the system one. The filename is the concatenation of
+ "name" and "ext". "Name" may be absolute, or may be relative with
+ slashes. If anything can be opened, the true directory
+ ais put in the buffer dirresult (provided by caller), which should
+ be "size" bytes. The "nameresult" pointer will be set somewhere in
+ the interior of "dirresult" and will give the file basename (with
+ slashes trimmed). If "bin" is set a 'binary' open is
+ attempted, otherwise ASCII (this only matters on Microsoft.)
+ If "x" is zero, the file is sought in the directory "." or in the
+ global path.*/
+
+int canvas_open(t_canvas *x, const char *name, const char *ext,
+ char *dirresult, char **nameresult, unsigned int size, int bin)
+{
+ t_namelist *nl, thislist;
+ int fd = -1;
+ char listbuf[MAXPDSTRING];
+ t_canvas *y;
+
+ /* first check if "name" is absolute (and if so, try to open) */
+ if (sys_open_absolute(name, ext, dirresult, nameresult, size, bin, &fd))
+ return (fd);
+
+ /* otherwise "name" is relative; start trying in directories named
+ in this and parent environments */
+ for (y = x; y; y = y->gl_owner)
+ if (y->gl_env)
+ {
+ t_namelist *nl;
+ for (nl = y->gl_env->ce_path; nl; nl = nl->nl_next)
+ {
+ if ((fd = sys_trytoopenone(nl->nl_string, name, ext,
+ dirresult, nameresult, size, bin)) >= 0)
+ return (fd);
+ }
+ }
+ return (open_via_path((x ? canvas_getdir(x)->s_name : "."), name, ext,
+ dirresult, nameresult, size, bin));
+}
/* ------------------------------- setup routine ------------------------ */
@@ -1533,6 +1680,12 @@ void g_canvas_setup(void)
class_addcreator((t_newmethod)table_new, gensym("table"),
A_DEFSYM, A_DEFFLOAT, 0);
+/*---------------------------- declare ------------------- */
+ declare_class = class_new(gensym("declare"), (t_newmethod)declare_new,
+ (t_method)declare_free, sizeof(t_declare), CLASS_NOINLET, A_GIMME, 0);
+ class_addmethod(canvas_class, (t_method)canvas_declare,
+ gensym("declare"), A_GIMME, 0);
+
/* -------------- setups from other files for canvas_class ---------------- */
g_graph_setup();
g_editor_setup();
diff --git a/pd/src/g_canvas.h b/pd/src/g_canvas.h
index 0b24d432..f1c99769 100644
--- a/pd/src/g_canvas.h
+++ b/pd/src/g_canvas.h
@@ -182,6 +182,7 @@ struct _glist
unsigned int gl_isdeleting:1; /* we're inside glist_delete -- hack! */
unsigned int gl_goprect:1; /* draw rectangle for graph-on-parent */
unsigned int gl_isgraph:1; /* show as graph on parent */
+ unsigned int gl_hidetext:1; /* hide object-name + args when doing graph on parent */
};
#define gl_gobj gl_obj.te_g
diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c
index 13346779..1bbeacbf 100644
--- a/pd/src/g_editor.c
+++ b/pd/src/g_editor.c
@@ -821,7 +821,7 @@ void canvas_setgraph(t_glist *x, int flag, int nogoprect)
canvas_fixlinesfor(x->gl_owner, &x->gl_obj);
}
}
- else if (flag && !glist_isgraph(x))
+ else if (flag)
{
if (x->gl_pixwidth <= 0)
x->gl_pixwidth = GLIST_DEFGRAPHWIDTH;
@@ -832,6 +832,7 @@ void canvas_setgraph(t_glist *x, int flag, int nogoprect)
if (x->gl_owner && !x->gl_loading && glist_isvisible(x->gl_owner))
gobj_vis(&x->gl_gobj, x->gl_owner, 0);
x->gl_isgraph = 1;
+ x->gl_hidetext = !(!(flag&2));
if (!nogoprect && !x->gl_goprect)
{
t_gobj *g;
@@ -867,7 +868,7 @@ void canvas_properties(t_glist *x)
sprintf(graphbuf,
"pdtk_canvas_dialog %%s %g %g %d %g %g %g %g %d %d %d %d\n",
0., 0.,
- 1,
+ glist_isgraph(x) ,//1,
x->gl_x1, x->gl_y1, x->gl_x2, x->gl_y2,
(int)x->gl_pixwidth, (int)x->gl_pixheight,
(int)x->gl_xmargin, (int)x->gl_ymargin);
@@ -897,7 +898,7 @@ static void canvas_donecanvasdialog(t_glist *x,
xperpix = atom_getfloatarg(0, argc, argv);
yperpix = atom_getfloatarg(1, argc, argv);
- graphme = (atom_getfloatarg(2, argc, argv) != 0);
+ graphme = (int)(atom_getfloatarg(2, argc, argv));
x1 = atom_getfloatarg(3, argc, argv);
y1 = atom_getfloatarg(4, argc, argv);
x2 = atom_getfloatarg(5, argc, argv);
diff --git a/pd/src/g_io.c b/pd/src/g_io.c
index 08eec227..eb4263d0 100644
--- a/pd/src/g_io.c
+++ b/pd/src/g_io.c
@@ -131,7 +131,7 @@ static void vinlet_dsp(t_vinlet *x, t_signal **sp)
}
else
{
- dsp_add(vinlet_perform, 3, x, outsig->s_vec, outsig->s_n);
+ dsp_add(vinlet_perform, 3, x, outsig->s_vec, outsig->s_vecsize);
x->x_read = x->x_buf;
}
}
@@ -163,9 +163,9 @@ t_int *vinlet_doprolog(t_int *w)
int inlet_getsignalindex(t_inlet *x);
/* set up prolog DSP code */
-void vinlet_dspprolog(t_vinlet *x, t_signal **parentsigs,
- int myvecsize, int phase, int period, int frequency,
- int downsample, int upsample, int reblock, int switched)
+void vinlet_dspprolog(struct _vinlet *x, t_signal **parentsigs,
+ int myvecsize, int calcsize, int phase, int period, int frequency,
+ int downsample, int upsample, int reblock, int switched)
{
t_signal *insig, *outsig;
x->x_updown.downsample = downsample;
@@ -187,7 +187,7 @@ void vinlet_dspprolog(t_vinlet *x, t_signal **parentsigs,
if (parentsigs)
{
insig = parentsigs[inlet_getsignalindex(x->x_inlet)];
- parentvecsize = insig->s_n;
+ parentvecsize = insig->s_vecsize;
re_parentvecsize = parentvecsize * upsample / downsample;
}
else
@@ -428,8 +428,8 @@ int outlet_getsignalindex(t_outlet *x);
parent, which, if "reblock" is false, will want to refer
back to whatever we see on our input during the "dsp" method
called later. */
-void voutlet_dspprolog(t_voutlet *x, t_signal **parentsigs,
- int myvecsize, int phase, int period, int frequency,
+void voutlet_dspprolog(struct _voutlet *x, t_signal **parentsigs,
+ int myvecsize, int calcsize, int phase, int period, int frequency,
int downsample, int upsample, int reblock, int switched)
{
x->x_updown.downsample=downsample;
@@ -453,7 +453,7 @@ static void voutlet_dsp(t_voutlet *x, t_signal **sp)
if (!x->x_buf) return;
insig = sp[0];
if (x->x_justcopyout)
- dsp_add_copy(insig->s_vec, x->x_directsignal->s_vec, insig->s_n);
+ dsp_add_copy(insig->s_vec, x->x_directsignal->s_vec, insig->s_n);
else if (x->x_directsignal)
{
/* if we're just going to make the signal available on the
@@ -468,9 +468,9 @@ static void voutlet_dsp(t_voutlet *x, t_signal **sp)
/* set up epilog DSP code. If we're reblocking, this is the
time to copy the samples out to the containing object's outlets.
If we aren't reblocking, there's nothing to do here. */
-void voutlet_dspepilog(t_voutlet *x, t_signal **parentsigs,
- int myvecsize, int phase, int period, int frequency, int downsample,
- int upsample, int reblock, int switched)
+void voutlet_dspepilog(struct _voutlet *x, t_signal **parentsigs,
+ int myvecsize, int calcsize, int phase, int period, int frequency,
+ int downsample, int upsample, int reblock, int switched)
{
if (!x->x_buf) return; /* this shouldn't be necesssary... */
x->x_updown.downsample=downsample;
@@ -484,7 +484,7 @@ void voutlet_dspepilog(t_voutlet *x, t_signal **parentsigs,
if (parentsigs)
{
outsig = parentsigs[outlet_getsignalindex(x->x_parentoutlet)];
- parentvecsize = outsig->s_n;
+ parentvecsize = outsig->s_vecsize;
re_parentvecsize = parentvecsize * upsample / downsample;
}
else
diff --git a/pd/src/g_readwrite.c b/pd/src/g_readwrite.c
index ae51baa9..3efb6c7e 100644
--- a/pd/src/g_readwrite.c
+++ b/pd/src/g_readwrite.c
@@ -18,7 +18,7 @@ file format as in the dialog window for data.
#include <string.h>
static t_class *declare_class;
-static void canvas_savedeclarationsto(t_canvas *x, t_binbuf *b);
+void canvas_savedeclarationsto(t_canvas *x, t_binbuf *b);
/* the following routines read "scalars" from a file into a canvas. */
@@ -621,7 +621,8 @@ static void canvas_saveto(t_canvas *x, t_binbuf *b)
x->gl_x1, x->gl_y1,
x->gl_x2, x->gl_y2,
(float)x->gl_pixwidth, (float)x->gl_pixheight,
- 1., (float)x->gl_xmargin, (float)x->gl_ymargin);
+ (float)((x->gl_hidetext)?2.:1.),
+ (float)x->gl_xmargin, (float)x->gl_ymargin);
/* otherwise write in 0.38-compatible form */
else binbuf_addv(b, "ssfffffff;", gensym("#X"), gensym("coords"),
x->gl_x1, x->gl_y1,
@@ -729,64 +730,6 @@ static void canvas_menusave(t_canvas *x)
else canvas_menusaveas(x2);
}
-/* ------------------------------- declare ------------------------ */
-
-/* put "declare" objects in a patch to tell it about the environment in
-which objects should be created in this canvas. This includes directories to
-search ("-path", "-stdpath") and object libraries to load
-("-lib" and "-stdlib"). These must be set before the patch containing
-the "declare" object is filled in with its contents; so when the patch is
-saved, we throw early messages to the canvas to set the environment
-before any objects are created in it. */
-
-
-typedef struct _declare
-{
- t_object x_obj;
- t_canvas *x_canvas;
- int x_useme;
-} t_declare;
-
-static void *declare_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_declare *x = (t_declare *)pd_new(declare_class);
- x->x_useme = 1;
- x->x_canvas = canvas_getcurrent();
- /* LATER update environment and/or load libraries */
- return (x);
-}
-
-static void declare_free(t_declare *x)
-{
- x->x_useme = 0;
- /* LATER update environment */
-}
-
-static void canvas_savedeclarationsto(t_canvas *x, t_binbuf *b)
-{
- t_gobj *y;
-
- for (y = x->gl_list; y; y = y->g_next)
- {
- if (pd_class(&y->g_pd) == declare_class)
- {
- binbuf_addv(b, "s", gensym("#X"));
- binbuf_addbinbuf(b, ((t_declare *)y)->x_obj.te_binbuf);
- binbuf_addv(b, ";");
- }
- else if (pd_class(&y->g_pd) == canvas_class)
- canvas_savedeclarationsto((t_canvas *)y, b);
- }
-}
-
-static void canvas_declare(t_canvas *x, t_symbol *s, int argc, t_atom *argv)
-{
- startpost("declare:: %s", s->s_name);
- postatom(argc, argv);
- endpost();
-}
-
-
void g_readwrite_setup(void)
{
class_addmethod(canvas_class, (t_method)glist_write,
@@ -799,15 +742,9 @@ void g_readwrite_setup(void)
gensym("savetofile"), A_SYMBOL, A_SYMBOL, 0);
class_addmethod(canvas_class, (t_method)canvas_saveto,
gensym("saveto"), A_CANT, 0);
- class_addmethod(canvas_class, (t_method)canvas_declare,
- gensym("declare"), A_GIMME, 0);
/* ------------------ from the menu ------------------------- */
class_addmethod(canvas_class, (t_method)canvas_menusave,
gensym("menusave"), 0);
class_addmethod(canvas_class, (t_method)canvas_menusaveas,
gensym("menusaveas"), 0);
-/*---------------------------- declare ------------------- */
- declare_class = class_new(gensym("declare"), (t_newmethod)declare_new,
- (t_method)declare_free, sizeof(t_declare), CLASS_NOINLET, A_GIMME, 0);
-
}
diff --git a/pd/src/m_binbuf.c b/pd/src/m_binbuf.c
index 9e96d68b..fbae4be5 100644
--- a/pd/src/m_binbuf.c
+++ b/pd/src/m_binbuf.c
@@ -757,6 +757,25 @@ int binbuf_read(t_binbuf *b, char *filename, char *dirname, int crflag)
return (0);
}
+ /* read a binbuf from a file, via the search patch of a canvas */
+int binbuf_read_via_canvas(t_binbuf *b, char *filename, t_canvas *canvas,
+ int crflag)
+{
+ int filedesc;
+ char buf[MAXPDSTRING], *bufptr;
+ if ((filedesc = canvas_open(canvas, filename, "",
+ buf, &bufptr, MAXPDSTRING, 0)) < 0)
+ {
+ error("%s: can't open", filename);
+ return (1);
+ }
+ else close (filedesc);
+ if (binbuf_read(b, bufptr, buf, crflag))
+ return (1);
+ else return (0);
+}
+
+ /* old version */
int binbuf_read_via_path(t_binbuf *b, char *filename, char *dirname,
int crflag)
{
diff --git a/pd/src/m_class.c b/pd/src/m_class.c
index 1ec13146..0737a660 100644
--- a/pd/src/m_class.c
+++ b/pd/src/m_class.c
@@ -519,13 +519,12 @@ int pd_setloadingabstraction(t_symbol *sym);
void new_anything(void *dummy, t_symbol *s, int argc, t_atom *argv)
{
t_pd *current;
- t_symbol *dir = canvas_getcurrentdir();
int fd;
char dirbuf[MAXPDSTRING], *nameptr;
if (tryingalready) return;
newest = 0;
class_loadsym = s;
- if (sys_load_lib(dir->s_name, s->s_name))
+ if (sys_load_lib(canvas_getcurrent(), s->s_name))
{
tryingalready = 1;
typedmess(dummy, s, argc, argv);
@@ -534,9 +533,9 @@ void new_anything(void *dummy, t_symbol *s, int argc, t_atom *argv)
}
class_loadsym = 0;
current = s__X.s_thing;
- if ((fd = open_via_path(dir->s_name, s->s_name, ".pd",
+ if ((fd = canvas_open(canvas_getcurrent(), s->s_name, ".pd",
dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0 ||
- (fd = open_via_path(dir->s_name, s->s_name, ".pat",
+ (fd = canvas_open(canvas_getcurrent(), s->s_name, ".pat",
dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0)
{
close (fd);
diff --git a/pd/src/m_pd.h b/pd/src/m_pd.h
index 9ad00c5d..73301138 100644
--- a/pd/src/m_pd.h
+++ b/pd/src/m_pd.h
@@ -9,7 +9,9 @@ extern "C" {
#endif
#define PD_MAJOR_VERSION 0
-#define PD_MINOR_VERSION 39
+#define PD_MINOR_VERSION 40
+#define PD_BUGFIX_VERSION 0
+#define PD_TEST_VERSION "test02"
/* old name for "MSW" flag -- we have to take it for the sake of many old
"nmakefiles" for externs, which will define NT and not MSW */
@@ -288,6 +290,8 @@ EXTERN t_atom *binbuf_getvec(t_binbuf *x);
EXTERN void binbuf_eval(t_binbuf *x, t_pd *target, int argc, t_atom *argv);
EXTERN int binbuf_read(t_binbuf *b, char *filename, char *dirname,
int crflag);
+EXTERN int binbuf_read_via_canvas(t_binbuf *b, char *filename, t_canvas *canvas,
+ int crflag);
EXTERN int binbuf_read_via_path(t_binbuf *b, char *filename, char *dirname,
int crflag);
EXTERN int binbuf_write(t_binbuf *x, char *filename, char *dir,
@@ -367,6 +371,8 @@ EXTERN t_symbol *canvas_getdir(t_glist *x);
EXTERN int sys_fontwidth(int fontsize);
EXTERN int sys_fontheight(int fontsize);
EXTERN void canvas_dataproperties(t_glist *x, t_scalar *sc, t_binbuf *b);
+EXTERN int canvas_open(t_canvas *x, const char *name, const char *ext,
+ char *dirresult, char **nameresult, unsigned int size, int bin);
/* ---------------- widget behaviors ---------------------- */
@@ -479,9 +485,9 @@ typedef struct _signal
struct _signal *s_borrowedfrom; /* signal to borrow it from */
struct _signal *s_nextfree; /* next in freelist */
struct _signal *s_nextused; /* next in used list */
+ int s_vecsize; /* allocated size of array in points */
} t_signal;
-
typedef t_int *(*t_perfroutine)(t_int *args);
EXTERN t_int *plus_perform(t_int *args);
diff --git a/pd/src/makefile.in b/pd/src/makefile.in
index ba09f7a4..d733547e 100644
--- a/pd/src/makefile.in
+++ b/pd/src/makefile.in
@@ -59,6 +59,20 @@ GSRC = t_main.c t_tkcmd.c
GOBJ = $(GSRC:.c=.o)
+# get version from m_pd.h to use in doc/1.manual/1.introduction.txt
+PD_MAJOR_VERSION := $(shell grep PD_MAJOR_VERSION m_pd.h | \
+ sed 's|^.define *PD_MAJOR_VERSION *\([0-9]*\).*|\1|' )
+PD_MINOR_VERSION := $(shell grep PD_MINOR_VERSION m_pd.h | \
+ sed 's|^.define *PD_MINOR_VERSION *\([0-9]*\).*|\1|' )
+PD_BUGFIX_VERSION := $(shell grep PD_BUGFIX_VERSION m_pd.h | \
+ sed 's|^.define *PD_BUGFIX_VERSION *\([0-9]*\).*|\1|' )
+PD_TEST_VERSION := $(shell grep PD_TEST_VERSION m_pd.h | \
+ sed 's|^.define *PD_TEST_VERSION *"\(.*\)".*|\1|' )
+PD_VERSION := $(PD_MAJOR_VERSION).$(PD_MINOR_VERSION).$(PD_BUGFIX_VERSION)
+ifneq ($(PD_TEST_VERSION),)
+ PD_VERSION := $(PD_VERSION)-$(PD_TEST_VERSION)
+endif
+
#
# ------------------ targets ------------------------------------
#
@@ -83,16 +97,19 @@ gui: $(BIN_DIR)/$(GUINAME)
pd-watchdog: $(BIN_DIR)/pd-watchdog
-$(BIN_DIR)/pd-watchdog: s_watchdog.c
+$(BIN_DIR):
+ test -d $(BIN_DIR) || mkdir -p $(BIN_DIR)
+
+$(BIN_DIR)/pd-watchdog: s_watchdog.c $(BIN_DIR)
$(CC) -O2 $(STRIPFLAG) -o $(BIN_DIR)/pd-watchdog s_watchdog.c
-$(BIN_DIR)/pdsend: u_pdsend.c
+$(BIN_DIR)/pdsend: u_pdsend.c $(BIN_DIR)
$(CC) $(CFLAGS) $(STRIPFLAG) -o $(BIN_DIR)/pdsend u_pdsend.c
-$(BIN_DIR)/pdreceive: u_pdreceive.c
+$(BIN_DIR)/pdreceive: u_pdreceive.c $(BIN_DIR)
$(CC) $(CFLAGS) $(STRIPFLAG) -o $(BIN_DIR)/pdreceive u_pdreceive.c
-$(PDEXEC): $(OBJ)
+$(PDEXEC): $(OBJ) $(BIN_DIR)
cd ../obj; $(CC) $(LDFLAGS) $(DBG_CFLAGS) -o $(PDEXEC) $(OBJ) \
$(LIB)
@@ -127,6 +144,7 @@ externs:
BINARYMODE=@binarymode@
+ABOUT_FILE=$(pddocdir)/1.manual/1.introduction.txt
install: all
install -d $(libpdbindir)
install $(BIN_DIR)/$(GUINAME) $(libpdbindir)/$(GUINAME)
@@ -146,6 +164,10 @@ install: all
install -d $(pddocdir)/7.stuff/$$dir ; \
install -p ../doc/7.stuff/$$dir/*.* $(pddocdir)/7.stuff/$$dir ; \
done
+ mv $(ABOUT_FILE) $(ABOUT_FILE).tmp
+ cat $(ABOUT_FILE).tmp | sed 's|PD_VERSION|Pd version $(PD_VERSION)|' \
+ > $(ABOUT_FILE)
+ rm $(ABOUT_FILE).tmp
cp -pr ../extra $(libpddir)/
rm -f $(libpddir)/extra/*/*.o
install -d $(DESTDIR)$(includedir)
diff --git a/pd/src/notes.txt b/pd/src/notes.txt
index f9c6126c..3f67f27c 100644
--- a/pd/src/notes.txt
+++ b/pd/src/notes.txt
@@ -34,6 +34,8 @@ document tabwrite~_start
$-expansion changed
problems:
+open_via_path call in d_soundfile.c isn't threadsafe
+Jack interface never goes idle? (Michael Berkowski, Pd list Aug 11 2006)
crashed Pd putting vec and template in wrong order in array element of struct
z.pd - list to numbox misbehaves (inlet and object but object is noinlet)
floor, ciel functions in expr misdeclared
diff --git a/pd/src/s_audio_alsamm.c b/pd/src/s_audio_alsamm.c
index 33c44755..66255932 100644
--- a/pd/src/s_audio_alsamm.c
+++ b/pd/src/s_audio_alsamm.c
@@ -216,7 +216,7 @@ int alsamm_open_audio(int rate)
/* init some structures */
for(i=0;i < ALSA_MAXDEV;i++){
alsa_indev[i].a_synced=alsa_outdev[i].a_synced=0;
- alsa_indev[i].a_channels=alsa_outdev[i].a_channels=0;
+ alsa_indev[i].a_channels=alsa_outdev[i].a_channels=-1; /* query defaults */
}
alsamm_inchannels = 0;
alsamm_outchannels = 0;
@@ -510,7 +510,7 @@ static int set_hwparams(snd_pcm_t *handle, snd_pcm_hw_params_t *params,int *chs)
if(sys_verbose)
post("Getting channels:min=%d, max= %d for request=%d",minchs,maxchs,channels);
#endif
-
+ if(channels < 0)channels=maxchs;
if(channels > maxchs)channels = maxchs;
if(channels < minchs)channels = minchs;
diff --git a/pd/src/s_audio_pablio.h b/pd/src/s_audio_pablio.h
index f98509ab..fe8cba83 100644
--- a/pd/src/s_audio_pablio.h
+++ b/pd/src/s_audio_pablio.h
@@ -7,7 +7,7 @@ extern "C"
#endif /* __cplusplus */
/*
- * $Id: s_audio_pablio.h,v 1.3 2006-08-11 20:09:07 millerpuckette Exp $
+ * $Id: s_audio_pablio.h,v 1.4 2006-08-15 04:54:15 millerpuckette Exp $
* PABLIO.h
* Portable Audio Blocking read/write utility.
*
diff --git a/pd/src/s_audio_paring.c b/pd/src/s_audio_paring.c
index 7bfc1170..b2dfd95e 100644
--- a/pd/src/s_audio_paring.c
+++ b/pd/src/s_audio_paring.c
@@ -1,5 +1,5 @@
/*
- * $Id: s_audio_paring.c,v 1.3 2006-08-11 20:09:07 millerpuckette Exp $
+ * $Id: s_audio_paring.c,v 1.4 2006-08-15 04:54:15 millerpuckette Exp $
* ringbuffer.c
* Ring Buffer utility..
*
diff --git a/pd/src/s_audio_paring.h b/pd/src/s_audio_paring.h
index 535dae76..ba720515 100644
--- a/pd/src/s_audio_paring.h
+++ b/pd/src/s_audio_paring.h
@@ -6,7 +6,7 @@ extern "C"
#endif /* __cplusplus */
/*
- * $Id: s_audio_paring.h,v 1.3 2006-08-11 20:09:07 millerpuckette Exp $
+ * $Id: s_audio_paring.h,v 1.4 2006-08-15 04:54:15 millerpuckette Exp $
* ringbuffer.h
* Ring Buffer utility..
*
diff --git a/pd/src/s_inter.c b/pd/src/s_inter.c
index 520ae882..102b0474 100644
--- a/pd/src/s_inter.c
+++ b/pd/src/s_inter.c
@@ -85,7 +85,6 @@ struct _socketreceiver
t_socketreceivefn sr_socketreceivefn;
};
-extern char pd_version[];
extern int sys_guisetportnumber;
extern char sys_font[]; /* tb: typeface */
@@ -847,6 +846,7 @@ void glob_watchdog(t_pd *dummy)
static int defaultfontshit[] = {
8, 5, 9, 10, 6, 10, 12, 7, 13, 14, 9, 17, 16, 10, 19, 24, 15, 28,
24, 15, 28};
+#define NDEFAULTFONT (sizeof(defaultfontshit)/sizeof(*defaultfontshit))
int sys_startgui(const char *guidir)
{
@@ -894,7 +894,7 @@ int sys_startgui(const char *guidir)
{
/* fake the GUI's message giving cwd and font sizes; then
skip starting the GUI up. */
- t_atom zz[19];
+ t_atom zz[NDEFAULTFONT+2];
int i;
#ifdef MSW
if (GetCurrentDirectory(MAXPDSTRING, cmdbuf) == 0)
@@ -906,9 +906,9 @@ int sys_startgui(const char *guidir)
#endif
SETSYMBOL(zz, gensym(cmdbuf));
- for (i = 1; i < 22; i++)
- SETFLOAT(zz + i, defaultfontshit[i-1]);
- SETFLOAT(zz+22,0);
+ for (i = 0; i < (int)NDEFAULTFONT; i++)
+ SETFLOAT(zz+i+1, defaultfontshit[i]);
+ SETFLOAT(zz+NDEFAULTFONT+1,0);
glob_initfromgui(0, 0, 23, zz);
}
else if (sys_guisetportnumber) /* GUI exists and sent us a port number */
@@ -1247,8 +1247,7 @@ int sys_startgui(const char *guidir)
#endif
sys_get_audio_apis(buf);
sys_get_midi_apis(buf2);
- sys_vgui("pdtk_pd_startup {%s} %s %s {%s}\n", pd_version, buf, buf2,
- sys_font);
+ sys_vgui("pdtk_pd_startup %s %s {%s}\n", buf, buf2, sys_font);
}
return (0);
diff --git a/pd/src/s_loader.c b/pd/src/s_loader.c
index a5cf38e4..19d6d530 100644
--- a/pd/src/s_loader.c
+++ b/pd/src/s_loader.c
@@ -52,18 +52,54 @@ static char sys_dllextent[] = ".d_ppc", sys_dllextent2[] = ".pd_darwin";
static char sys_dllextent[] = ".m_i386", sys_dllextent2[] = ".dll";
#endif
+ /* maintain list of loaded modules to avoid repeating loads */
+typedef struct _loadedlist
+{
+ struct _loadedlist *ll_next;
+ t_symbol *ll_name;
+} t_loadlist;
+
+static t_loadlist *sys_loaded;
+int sys_onloadlist(char *classname) /* return true if already loaded */
+{
+ t_symbol *s = gensym(classname);
+ t_loadlist *ll;
+ for (ll = sys_loaded; ll; ll = ll->ll_next)
+ if (ll->ll_name == s)
+ return (1);
+ return (0);
+}
+
+void sys_putonloadlist(char *classname) /* add to list of loaded modules */
+{
+ t_loadlist *ll = (t_loadlist *)getbytes(sizeof(*ll));
+ ll->ll_name = gensym(classname);
+ ll->ll_next = sys_loaded;
+ sys_loaded = ll;
+ post("put on list %s", classname);
+}
+
void class_set_extern_dir(t_symbol *s);
-static int sys_do_load_lib(char *dirname, char *classname)
+static int sys_do_load_lib(t_canvas *canvas, char *objectname)
{
char symname[MAXPDSTRING], filename[MAXPDSTRING], dirbuf[MAXPDSTRING],
- *nameptr, altsymname[MAXPDSTRING];
+ *classname, *nameptr, altsymname[MAXPDSTRING];
void *dlobj;
t_xxx makeout = NULL;
int i, hexmunge = 0, fd;
#ifdef MSW
HINSTANCE ntdll;
#endif
+ if (classname = strrchr(objectname, '/'))
+ classname++;
+ else classname = objectname;
+ post("classname %s", classname);
+ if (sys_onloadlist(classname))
+ {
+ post("%s: already loaded", classname);
+ return (1);
+ }
for (i = 0, nameptr = classname; i < MAXPDSTRING-7 && *nameptr; nameptr++)
{
char c = *nameptr;
@@ -93,28 +129,28 @@ static int sys_do_load_lib(char *dirname, char *classname)
strncpy(symname, "setup_", 6);
}
else strcat(symname, "_setup");
-
-#if 0
- fprintf(stderr, "lib %s %s\n", dirname, classname);
+
+#if 1
+ fprintf(stderr, "lib: %s\n", classname);
#endif
- /* try looking in the path for (classname).(sys_dllextent) ... */
- if ((fd = open_via_path(dirname, classname, sys_dllextent,
+ /* try looking in the path for (objectname).(sys_dllextent) ... */
+ if ((fd = canvas_open(canvas, objectname, sys_dllextent,
dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0)
goto gotone;
/* same, with the more generic sys_dllextent2 */
- if ((fd = open_via_path(dirname, classname, sys_dllextent2,
+ if ((fd = canvas_open(canvas, objectname, sys_dllextent2,
dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0)
goto gotone;
- /* next try (classname)/(classname).(sys_dllextent) ... */
- strncpy(filename, classname, MAXPDSTRING);
+ /* next try (objectname)/(classname).(sys_dllextent) ... */
+ strncpy(filename, objectname, MAXPDSTRING);
filename[MAXPDSTRING-2] = 0;
strcat(filename, "/");
strncat(filename, classname, MAXPDSTRING-strlen(filename));
filename[MAXPDSTRING-1] = 0;
- if ((fd = open_via_path(dirname, filename, sys_dllextent,
+ if ((fd = canvas_open(canvas, filename, sys_dllextent,
dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0)
goto gotone;
- if ((fd = open_via_path(dirname, filename, sys_dllextent2,
+ if ((fd = canvas_open(canvas, filename, sys_dllextent2,
dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0)
goto gotone;
return (0);
@@ -159,11 +195,12 @@ gotone:
}
(*makeout)();
class_set_extern_dir(&s_);
+ sys_putonloadlist(classname);
return (1);
}
/* callback type definition */
-typedef int (*loader_t)(char *dirname, char *classname);
+typedef int (*loader_t)(t_canvas *canvas, char *classname);
/* linked list of loaders */
typedef struct loader_queue {
@@ -191,13 +228,13 @@ void sys_register_loader(loader_t loader)
}
}
-int sys_load_lib(char *dirname, char *classname)
+int sys_load_lib(t_canvas *canvas, char *classname)
{
int dspstate = canvas_suspend_dsp();
int ok = 0;
loader_queue_t *q;
for(q = &loaders; q; q = q->next)
- if(ok = q->loader(dirname, classname)) break;
+ if (ok = q->loader(canvas, classname)) break;
canvas_resume_dsp(dspstate);
return ok;
}
diff --git a/pd/src/s_main.c b/pd/src/s_main.c
index 9f842fd5..50fde079 100644
--- a/pd/src/s_main.c
+++ b/pd/src/s_main.c
@@ -2,10 +2,6 @@
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-char pd_version[] = "Pd version 0.40-0test01\n";
-char pd_compiletime[] = __TIME__;
-char pd_compiledate[] = __DATE__;
-
#include "m_pd.h"
#include "m_imp.h"
#include "s_stuff.h"
@@ -26,6 +22,10 @@ char pd_compiledate[] = __DATE__;
#include <winbase.h>
#endif
+char *pd_version;
+char pd_compiletime[] = __TIME__;
+char pd_compiledate[] = __DATE__;
+
void pd_init(void);
int sys_argparse(int argc, char **argv);
void sys_findprogdir(char *progname);
@@ -33,7 +33,9 @@ int sys_startgui(const char *guipath);
int sys_rcfile(void);
int m_scheduler(void);
void sys_addhelppath(char *p);
+#ifdef USEAPI_ALSA
void alsa_adddev(char *name);
+#endif
int sys_debuglevel;
int sys_verbose;
@@ -56,7 +58,7 @@ int sys_nmidiin = -1;
int sys_midiindevlist[MAXMIDIINDEV] = {1};
int sys_midioutdevlist[MAXMIDIOUTDEV] = {1};
-char sys_font[] = "courier"; /* tb: font name */
+char sys_font[100] = "courier"; /* tb: font name */
static int sys_main_srate;
static int sys_main_advance;
@@ -221,7 +223,7 @@ void glob_initfromgui(void *dummy, t_symbol *s, int argc, t_atom *argv)
#endif
/* load dynamic libraries specified with "-lib" args */
for (nl = sys_externlist; nl; nl = nl->nl_next)
- if (!sys_load_lib(cwd, nl->nl_string))
+ if (!sys_load_lib(0, nl->nl_string))
post("%s: can't load library", nl->nl_string);
/* open patches specifies with "-open" args */
for (nl = sys_openlist; nl; nl = nl->nl_next)
@@ -242,6 +244,15 @@ void glob_initfromgui(void *dummy, t_symbol *s, int argc, t_atom *argv)
static void sys_afterargparse(void);
+static void pd_makeversion(void)
+{
+ char foo[100];
+ sprintf(foo, "Pd version %d.%d-%d%s\n",PD_MAJOR_VERSION,
+ PD_MINOR_VERSION,PD_BUGFIX_VERSION,PD_TEST_VERSION);
+ pd_version = malloc(strlen(foo+1));
+ strcpy(pd_version, foo);
+}
+
/* this is called from main() in s_entry.c */
int sys_main(int argc, char **argv)
{
@@ -259,6 +270,8 @@ int sys_main(int argc, char **argv)
if (sys_argparse(argc-1, argv+1)) /* parse cmd line */
return (1);
sys_afterargparse(); /* post-argparse settings */
+ /* build version string from defines in m_pd.h */
+ pd_makeversion();
if (sys_verbose || sys_version) fprintf(stderr, "%scompiled %s %s\n",
pd_version, pd_compiletime, pd_compiledate);
if (sys_version) /* if we were just asked our version, exit here. */
@@ -726,10 +739,11 @@ int sys_argparse(int argc, char **argv)
/* tb: font name { */
else if (!strcmp(*argv, "-typeface") && argc > 1)
{
- strcpy(sys_font,*(argv+1));
- argc -= 2;
- argv += 2;
- }
+ strncpy(sys_font,*(argv+1),sizeof(sys_font)-1);
+ sys_font[sizeof(sys_font)-1] = 0;
+ argc -= 2;
+ argv += 2;
+ }
/* } tb */
else if (!strcmp(*argv, "-verbose"))
{
diff --git a/pd/src/s_path.c b/pd/src/s_path.c
index 9d7e0798..6d4d33bf 100644
--- a/pd/src/s_path.c
+++ b/pd/src/s_path.c
@@ -170,188 +170,179 @@ void sys_setextrapath(const char *p)
#define MSWOPENFLAG(bin) 0
#endif
-/* search for a file in a specified directory, then along the globally
-defined search path, using ext as filename extension. Exception:
-if the 'name' starts with a slash or a letter, colon, and slash in MSW,
-there is no search and instead we just try to open the file literally. The
-fd is returned, the directory ends up in the "dirresult" which must be at
-least "size" bytes. "nameresult" is set to point to the filename, which
-ends up in the same buffer as dirresult. */
-
-int open_via_path(const char *dir, const char *name, const char* ext,
+ /* try to open a file in the directory "dir", named "name""ext",
+ for reading. "Name" may have slashes. The directory is copied to
+ "dirresult" which must be at least "size" bytes. "nameresult" is set
+ to point to the filename (copied elsewhere into the same buffer).
+ The "bin" flag requests opening for binary (which only makes a difference
+ on Windows). */
+
+int sys_trytoopenone(const char *dir, const char *name, const char* ext,
char *dirresult, char **nameresult, unsigned int size, int bin)
{
- t_namelist *nl, thislist;
- int fd = -1;
- char listbuf[MAXPDSTRING];
+ int fd;
+ if (strlen(dir) + strlen(name) + strlen(ext) + 4 > size)
+ return (-1);
+ strcpy(dirresult, dir);
+ if (*dirresult && dirresult[strlen(dirresult)-1] != '/')
+ strcat(dirresult, "/");
+ strcat(dirresult, name);
+ strcat(dirresult, ext);
+ sys_bashfilename(dirresult, dirresult);
+
+ DEBUG(post("looking for %s",dirresult));
+ /* see if we can open the file for reading */
+ if ((fd=open(dirresult,O_RDONLY | MSWOPENFLAG(bin))) >= 0)
+ {
+ /* in unix, further check that it's not a directory */
+#ifdef UNISTD
+ struct stat statbuf;
+ int ok = ((fstat(fd, &statbuf) >= 0) &&
+ !S_ISDIR(statbuf.st_mode));
+ if (!ok)
+ {
+ if (sys_verbose) post("tried %s; stat failed or directory",
+ dirresult);
+ close (fd);
+ fd = -1;
+ }
+ else
+#endif
+ {
+ char *slash;
+ if (sys_verbose) post("tried %s and succeeded", dirresult);
+ sys_unbashfilename(dirresult, dirresult);
+ slash = strrchr(dirresult, '/');
+ if (slash)
+ {
+ *slash = 0;
+ *nameresult = slash + 1;
+ }
+ else *nameresult = dirresult;
+ return (fd);
+ }
+ }
+ else
+ {
+ if (sys_verbose) post("tried %s and failed", dirresult);
+ }
+ return (-1);
+}
+
+ /* check if we were given an absolute pathname, if so try to open it
+ and return 1 to signal the caller to cancel any path searches */
+int sys_open_absolute(const char *name, const char* ext,
+ char *dirresult, char **nameresult, unsigned int size, int bin, int *fdp)
+{
if (name[0] == '/'
#ifdef MSW
|| (name[1] == ':' && name[2] == '/')
#endif
)
{
- thislist.nl_next = 0;
- thislist.nl_string = listbuf;
- listbuf[0] = 0;
- }
- else
- {
- thislist.nl_string = listbuf;
- thislist.nl_next = sys_searchpath;
- strncpy(listbuf, dir, MAXPDSTRING);
- listbuf[MAXPDSTRING-1] = 0;
- sys_unbashfilename(listbuf, listbuf);
+ char dirbuf[MAXPDSTRING];
+ int dirlen = (strrchr(name, '/') - name);
+ if (dirlen > MAXPDSTRING-1)
+ dirlen = MAXPDSTRING-1;
+ strncpy(dirbuf, name, dirlen);
+ dirbuf[dirlen] = 0;
+ *fdp = sys_trytoopenone(dirbuf, name+(dirlen+1), ext,
+ dirresult, nameresult, size, bin);
+ return (1);
}
+ else return (0);
+}
+
+/* search for a file in a specified directory, then along the globally
+defined search path, using ext as filename extension. The
+fd is returned, the directory ends up in the "dirresult" which must be at
+least "size" bytes. "nameresult" is set to point to the filename, which
+ends up in the same buffer as dirresult. Exception:
+if the 'name' starts with a slash or a letter, colon, and slash in MSW,
+there is no search and instead we just try to open the file literally. */
+
+/* see also canvas_openfile() which, in addition, searches down the
+canvas-specific path. */
+
+static int do_open_via_path(const char *dir, const char *name,
+ const char *ext, char *dirresult, char **nameresult, unsigned int size,
+ int bin, t_namelist *searchpath)
+{
+ t_namelist *nl;
+ int fd = -1;
+
+ /* first check if "name" is absolute (and if so, try to open) */
+ if (sys_open_absolute(name, ext, dirresult, nameresult, size, bin, &fd))
+ return (fd);
+
+ /* otherwise "name" is relative; try the directory "dir" first. */
+ if ((fd = sys_trytoopenone(dir, name, ext,
+ dirresult, nameresult, size, bin)) >= 0)
+ return (fd);
+
+ /* next go through the search path */
+ for (nl = searchpath; nl; nl = nl->nl_next)
+ if ((fd = sys_trytoopenone(nl->nl_string, name, ext,
+ dirresult, nameresult, size, bin)) >= 0)
+ return (fd);
+
+ /* next look in "extra" */
+ if (sys_usestdpath &&
+ (fd = sys_trytoopenone(pd_extrapath->nl_string, name, ext,
+ dirresult, nameresult, size, bin)) >= 0)
+ return (fd);
- /* search, first, through the search path (to which we prepended the
- current directory), then, if enabled, look in the "extra" dir */
- for (nl = &thislist; nl;
- nl = (nl->nl_next ? nl->nl_next :
- (nl == pd_extrapath ? 0 :
- (sys_usestdpath ? pd_extrapath : 0))))
- {
- if (strlen(nl->nl_string) + strlen(name) + strlen(ext) + 4 >
- size)
- continue;
- strcpy(dirresult, nl->nl_string);
- if (*dirresult && dirresult[strlen(dirresult)-1] != '/')
- strcat(dirresult, "/");
- strcat(dirresult, name);
- strcat(dirresult, ext);
- sys_bashfilename(dirresult, dirresult);
-
- DEBUG(post("looking for %s",dirresult));
- /* see if we can open the file for reading */
- if ((fd=open(dirresult,O_RDONLY | MSWOPENFLAG(bin))) >= 0)
- {
- /* in unix, further check that it's not a directory */
-#ifdef UNISTD
- struct stat statbuf;
- int ok = ((fstat(fd, &statbuf) >= 0) &&
- !S_ISDIR(statbuf.st_mode));
- if (!ok)
- {
- if (sys_verbose) post("tried %s; stat failed or directory",
- dirresult);
- close (fd);
- fd = -1;
- }
- else
-#endif
- {
- char *slash;
- if (sys_verbose) post("tried %s and succeeded", dirresult);
- sys_unbashfilename(dirresult, dirresult);
- slash = strrchr(dirresult, '/');
- if (slash)
- {
- *slash = 0;
- *nameresult = slash + 1;
- }
- else *nameresult = dirresult;
-
- return (fd);
- }
- }
- else
- {
- if (sys_verbose) post("tried %s and failed", dirresult);
- }
- }
*dirresult = 0;
*nameresult = dirresult;
return (-1);
}
-static int do_open_via_helppath(const char *realname, t_namelist *listp)
+ /* open via path, using the global search path. */
+int open_via_path(const char *dir, const char *name, const char *ext,
+ char *dirresult, char **nameresult, unsigned int size, int bin)
{
- t_namelist *nl;
- int fd = -1;
- char dirresult[MAXPDSTRING], realdir[MAXPDSTRING];
- for (nl = listp; nl; nl = nl->nl_next)
- {
- strcpy(dirresult, nl->nl_string);
- strcpy(realdir, dirresult);
- if (*dirresult && dirresult[strlen(dirresult)-1] != '/')
- strcat(dirresult, "/");
- strcat(dirresult, realname);
- sys_bashfilename(dirresult, dirresult);
-
- DEBUG(post("looking for %s",dirresult));
- /* see if we can open the file for reading */
- if ((fd=open(dirresult,O_RDONLY | MSWOPENFLAG(0))) >= 0)
- {
- /* in unix, further check that it's not a directory */
-#ifdef UNISTD
- struct stat statbuf;
- int ok = ((fstat(fd, &statbuf) >= 0) &&
- !S_ISDIR(statbuf.st_mode));
- if (!ok)
- {
- if (sys_verbose) post("tried %s; stat failed or directory",
- dirresult);
- close (fd);
- fd = -1;
- }
- else
-#endif
- {
- char *slash;
- if (sys_verbose) post("tried %s and succeeded", dirresult);
- sys_unbashfilename(dirresult, dirresult);
- close (fd);
- glob_evalfile(0, gensym((char*)realname), gensym(realdir));
- return (1);
- }
- }
- else
- {
- if (sys_verbose) post("tried %s and failed", dirresult);
- }
- }
- return (0);
+ return (do_open_via_path(dir, name, ext, dirresult, nameresult,
+ size, bin, sys_searchpath));
}
- /* LATER make this use open_via_path above. We expect the ".pd"
+ /* Open a help file using the help search path. We expect the ".pd"
suffix here, even though we have to tear it back off for one of the
search attempts. */
void open_via_helppath(const char *name, const char *dir)
{
- t_namelist *nl, thislist, *listp;
- int fd = -1;
- char dirbuf2[MAXPDSTRING], realname[MAXPDSTRING];
+ char realname[MAXPDSTRING], dirbuf[MAXPDSTRING], *basename;
+ /* make up a silly "dir" if none is supplied */
+ const char *usedir = (*dir ? dir : "./");
+ int fd;
- /* if directory is supplied, put it at head of search list. */
- if (*dir)
- {
- thislist.nl_string = dirbuf2;
- thislist.nl_next = sys_helppath;
- strncpy(dirbuf2, dir, MAXPDSTRING);
- dirbuf2[MAXPDSTRING-1] = 0;
- sys_unbashfilename(dirbuf2, dirbuf2);
- listp = &thislist;
- }
- else listp = sys_helppath;
/* 1. "objectname-help.pd" */
strncpy(realname, name, MAXPDSTRING-10);
realname[MAXPDSTRING-10] = 0;
if (strlen(realname) > 3 && !strcmp(realname+strlen(realname)-3, ".pd"))
realname[strlen(realname)-3] = 0;
strcat(realname, "-help.pd");
- if (do_open_via_helppath(realname, listp))
- return;
+ if ((fd = do_open_via_path(dir, realname, "", dirbuf, &basename,
+ MAXPDSTRING, 0, sys_helppath)) >= 0)
+ goto gotone;
+
/* 2. "help-objectname.pd" */
strcpy(realname, "help-");
strncat(realname, name, MAXPDSTRING-10);
realname[MAXPDSTRING-1] = 0;
- if (do_open_via_helppath(realname, listp))
- return;
+ if ((fd = do_open_via_path(dir, realname, "", dirbuf, &basename,
+ MAXPDSTRING, 0, sys_helppath)) >= 0)
+ goto gotone;
+
/* 3. "objectname.pd" */
- if (do_open_via_helppath(name, listp))
- return;
+ if ((fd = do_open_via_path(dir, name, "", dirbuf, &basename,
+ MAXPDSTRING, 0, sys_helppath)) >= 0)
+ goto gotone;
post("sorry, couldn't find help patch for \"%s\"", name);
return;
+gotone:
+ close (fd);
+ glob_evalfile(0, gensym((char*)realname), gensym(dirbuf));
}
diff --git a/pd/src/s_stuff.h b/pd/src/s_stuff.h
index 09e2cb55..17974833 100644
--- a/pd/src/s_stuff.h
+++ b/pd/src/s_stuff.h
@@ -9,10 +9,10 @@ in future releases. The public (stable) API is in m_pd.h. */
/* in s_path.c */
-typedef struct _namelist
+typedef struct _namelist /* element in a linked list of stored strings */
{
- struct _namelist *nl_next;
- char *nl_string;
+ struct _namelist *nl_next; /* next in list */
+ char *nl_string; /* the string */
} t_namelist;
t_namelist *namelist_append(t_namelist *listwas, const char *s, int allowdup);
@@ -24,6 +24,11 @@ extern int sys_usestdpath;
extern t_namelist *sys_externlist;
extern t_namelist *sys_searchpath;
extern t_namelist *sys_helppath;
+int sys_open_absolute(const char *name, const char* ext,
+ char *dirresult, char **nameresult, unsigned int size, int bin, int *fdp);
+int sys_trytoopenone(const char *dir, const char *name, const char* ext,
+ char *dirresult, char **nameresult, unsigned int size, int bin);
+
/* s_file.c */
@@ -46,7 +51,7 @@ extern int sys_defaultfont;
extern t_symbol *sys_libdir; /* library directory for auxilliary files */
/* s_loader.c */
-int sys_load_lib(char *dirname, char *filename);
+int sys_load_lib(t_canvas *canvas, char *filename);
/* s_audio.c */
diff --git a/pd/src/u_main.tk b/pd/src/u_main.tk
index 177e1171..3ee5505c 100644
--- a/pd/src/u_main.tk
+++ b/pd/src/u_main.tk
@@ -35,8 +35,8 @@ if {$pd_nt == 1} {
global pd_guidir
global pd_tearoff
set pd_gui2 [string range $argv0 0 [expr [string last \\ $argv0 ] - 1]]
- regsub -all \\\\ $pd_gui2 / pd_gui3
- set pd_guidir $pd_gui3/..
+ regsub -all \\\\ $pd_gui2 / pd_guidir
+ set pd_guidir [string range $pd_guidir 0 [expr [string last / $pd_guidir] - 1]]
load $pd_guidir/bin/pdtcl.dll
set pd_tearoff 1
}
@@ -203,6 +203,9 @@ pdtk_standardkeybindings .
wm title . "Pd"
. configure -menu .mbar -width 200 -height 150
+# Intercept closing the main pd window: MP 20060413:
+wm protocol . WM_DELETE_WINDOW menu_quit
+
############### set up global variables ################################
set untitled_number 1
@@ -368,8 +371,7 @@ proc menu_opentext {filename} {
while {![eof $f]} {
set bigstring [read $f 1000]
regsub -all PD_BASEDIR $bigstring $pd_guidir bigstring2
- regsub -all PD_VERSION $bigstring2 $pd_myversion bigstring3
- $name.text insert end $bigstring3
+ $name.text insert end $bigstring2
}
close $f
set doc_number [expr $doc_number + 1]
@@ -2875,6 +2877,8 @@ proc canvas_apply {id} {
global $var_canvas_yscale
set var_canvas_graphme [concat canvas_graphme_$vid]
global $var_canvas_graphme
+ set var_canvas_hidetext [concat canvas_hidetext_$vid]
+ global $var_canvas_hidetext
set var_canvas_x1 [concat canvas_x1_$vid]
global $var_canvas_x1
set var_canvas_x2 [concat canvas_x2_$vid]
@@ -2895,7 +2899,7 @@ proc canvas_apply {id} {
pd [concat $id donecanvasdialog \
[eval concat $$var_canvas_xscale] \
[eval concat $$var_canvas_yscale] \
- [eval concat $$var_canvas_graphme] \
+ [expr [eval concat $$var_canvas_graphme]+2*[eval concat $$var_canvas_hidetext]] \
[eval concat $$var_canvas_x1] \
[eval concat $$var_canvas_y1] \
[eval concat $$var_canvas_x2] \
@@ -2927,6 +2931,8 @@ proc canvas_checkcommand {id} {
global $var_canvas_yscale
set var_canvas_graphme [concat canvas_graphme_$vid]
global $var_canvas_graphme
+ set var_canvas_hidetext [concat canvas_hidetext_$vid]
+ global $var_canvas_hidetext
set var_canvas_x1 [concat canvas_x1_$vid]
global $var_canvas_x1
set var_canvas_x2 [concat canvas_x2_$vid]
@@ -2945,6 +2951,7 @@ proc canvas_checkcommand {id} {
global $var_canvas_ymargin
if { [eval concat $$var_canvas_graphme] != 0 } {
+ $id.hidetext configure -state normal
$id.xrange.entry1 configure -state normal
$id.xrange.entry2 configure -state normal
$id.xrange.entry3 configure -state normal
@@ -2975,6 +2982,7 @@ proc canvas_checkcommand {id} {
set $var_canvas_ymargin 100
}
} else {
+ $id.hidetext configure -state disabled
$id.xrange.entry1 configure -state disabled
$id.xrange.entry2 configure -state disabled
$id.xrange.entry3 configure -state disabled
@@ -3004,6 +3012,8 @@ proc pdtk_canvas_dialog {id xscale yscale graphme x1 y1 x2 y2 \
global $var_canvas_yscale
set var_canvas_graphme [concat canvas_graphme_$vid]
global $var_canvas_graphme
+ set var_canvas_hidetext [concat canvas_hidetext_$vid]
+ global $var_canvas_hidetext
set var_canvas_x1 [concat canvas_x1_$vid]
global $var_canvas_x1
set var_canvas_x2 [concat canvas_x2_$vid]
@@ -3021,10 +3031,10 @@ proc pdtk_canvas_dialog {id xscale yscale graphme x1 y1 x2 y2 \
set var_canvas_ymargin [concat canvas_ymargin_$vid]
global $var_canvas_ymargin
-
set $var_canvas_xscale $xscale
set $var_canvas_yscale $yscale
- set $var_canvas_graphme $graphme
+ set $var_canvas_graphme [expr ($graphme!=0)?1:0]
+ set $var_canvas_hidetext [expr ($graphme&2)?1:0]
set $var_canvas_x1 $x1
set $var_canvas_y1 $y1
set $var_canvas_x2 $x2
@@ -3058,6 +3068,11 @@ proc pdtk_canvas_dialog {id xscale yscale graphme x1 y1 x2 y2 \
-command [concat canvas_checkcommand $id]
pack $id.graphme -side top
+ checkbutton $id.hidetext -text {hide object name and arguments} \
+ -variable $var_canvas_hidetext -anchor w \
+ -command [concat canvas_checkcommand $id]
+ pack $id.hidetext -side top
+
frame $id.xrange
pack $id.xrange -side top
label $id.xrange.label1 -text "X range: from"
@@ -3228,10 +3243,9 @@ proc pdtk_pd_ctrlkey {name key shift} {
# seven "useful" font sizes.
# tb: user defined typefaces
-proc pdtk_pd_startup {version apilist midiapilist fontname} {
-# puts stderr [concat $version $apilist $fontname]
- global pd_myversion pd_apilist pd_midiapilist
- set pd_myversion $version
+proc pdtk_pd_startup {apilist midiapilist fontname} {
+# puts stderr [concat $apilist $midiapilist $fontname]
+ global pd_apilist pd_midiapilist
set pd_apilist $apilist
set pd_midiapilist $midiapilist
global pd_fontlist
diff --git a/pd/src/x_arithmetic.c b/pd/src/x_arithmetic.c
index eb28e0fc..224636d8 100644
--- a/pd/src/x_arithmetic.c
+++ b/pd/src/x_arithmetic.c
@@ -671,23 +671,31 @@ typedef struct _clip
t_object x_ob;
float x_f1;
float x_f2;
+ float x_f3;
} t_clip;
static void *clip_new(t_floatarg f1, t_floatarg f2)
{
t_clip *x = (t_clip *)pd_new(clip_class);
- floatinlet_new(&x->x_ob, &x->x_f1);
floatinlet_new(&x->x_ob, &x->x_f2);
+ floatinlet_new(&x->x_ob, &x->x_f3);
outlet_new(&x->x_ob, &s_float);
- x->x_f1 = f1;
- x->x_f2 = f2;
+ x->x_f2 = f1;
+ x->x_f3 = f2;
return (x);
}
+static void clip_bang(t_clip *x)
+{
+ outlet_float(x->x_ob.ob_outlet, (x->x_f1 < x->x_f2 ? x->x_f2 : (
+ x->x_f1 > x->x_f3 ? x->x_f3 : x->x_f1)));
+}
+
static void clip_float(t_clip *x, t_float f)
{
- outlet_float(x->x_ob.ob_outlet, (f < x->x_f1 ? x->x_f1 : (
- f > x->x_f2 ? x->x_f2 : f)));
+ x->x_f1 = f;
+ outlet_float(x->x_ob.ob_outlet, (x->x_f1 < x->x_f2 ? x->x_f2 : (
+ x->x_f1 > x->x_f3 ? x->x_f3 : x->x_f1)));
}
static void clip_setup(void)
@@ -695,6 +703,7 @@ static void clip_setup(void)
clip_class = class_new(gensym("clip"), (t_newmethod)clip_new, 0,
sizeof(t_clip), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
class_addfloat(clip_class, clip_float);
+ class_addbang(clip_class, clip_bang);
}
void x_arithmetic_setup(void)