[PD-cvs] SF.net SVN: pure-data:[10432] trunk/pd

millerpuckette at users.sourceforge.net millerpuckette at users.sourceforge.net
Mon Dec 8 21:14:40 CET 2008


Revision: 10432
          http://pure-data.svn.sourceforge.net/pure-data/?rev=10432&view=rev
Author:   millerpuckette
Date:     2008-12-08 20:14:40 +0000 (Mon, 08 Dec 2008)

Log Message:
-----------
0.42-0test06

Modified Paths:
--------------
    trunk/pd/doc/3.audio.examples/J07.oversampling.pd
    trunk/pd/doc/5.reference/tabread4~-help.pd
    trunk/pd/doc/7.stuff/tools/testtone.pd
    trunk/pd/extra/bonk~/bonk~.c
    trunk/pd/extra/pd~/pd~-help.pd
    trunk/pd/extra/pd~/pd~.c
    trunk/pd/extra/sigmund~/sigmund~.c
    trunk/pd/extra/stdout/stdout-help.pd
    trunk/pd/extra/stdout/stdout.c
    trunk/pd/src/d_array.c
    trunk/pd/src/d_osc.c
    trunk/pd/src/m_pd.h
    trunk/pd/src/m_sched.c
    trunk/pd/src/notes.txt
    trunk/pd/src/s_audio_alsa.c
    trunk/pd/src/s_audio_pa.c
    trunk/pd/src/s_main.c
    trunk/pd/src/u_main.tk

Removed Paths:
-------------
    trunk/pd/extra/pd~/test.pd

Modified: trunk/pd/doc/3.audio.examples/J07.oversampling.pd
===================================================================
--- trunk/pd/doc/3.audio.examples/J07.oversampling.pd	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/doc/3.audio.examples/J07.oversampling.pd	2008-12-08 20:14:40 UTC (rev 10432)
@@ -1,10 +1,5 @@
-#N canvas 343 48 578 498 12;
-#N canvas 158 4 728 420 16x 0;
-#X obj 21 151 *~ 0.064;
-#X obj 21 174 rpole~ 0.93538;
-#X obj 21 197 *~ 0.00431;
-#X obj 21 220 cpole~ 0.96559 0.05592;
-#X obj 21 246 cpole~ 0.96559 -0.05592;
+#N canvas 378 114 542 534 12;
+#N canvas 371 260 740 538 16x 0;
 #X obj 21 269 *~ 0.125;
 #X obj 21 292 rzero~ -1;
 #X obj 21 315 rzero~ -1;
@@ -13,44 +8,84 @@
 #X obj 204 29 block~ 1024 1 16;
 #X obj 21 31 inlet;
 #X obj 21 372 outlet~;
-#X text 170 151 These objects make a 3-pole \, 3-zero Butterwirth low-pass
-filter with cutoff at 15kHz (assuming 44100 sample rate.) The filter
+#X obj 20 166 rpole~ 0.87467;
+#X obj 20 143 *~ 0.12532;
+#X obj 20 189 *~ 0.01668;
+#X obj 279 358 buttercoef3;
+#X floatatom 279 282 7 0 0 0 - - -;
+#X obj 279 332 / 16;
+#X floatatom 279 488 7 0 0 0 - - -;
+#X obj 279 307 / 22050;
+#X floatatom 293 468 7 0 0 0 - - -;
+#X floatatom 308 448 7 0 0 0 - - -;
+#X floatatom 323 428 7 0 0 0 - - -;
+#X floatatom 338 408 7 0 0 0 - - -;
+#X floatatom 353 388 7 0 0 0 - - -;
+#X text 335 489 normalizer for rpole~;
+#X text 352 468 normalizer for cpole~;
+#X text 366 449 coef for rpole~;
+#X text 382 430 coef for cpole~ real part;
+#X text 413 390 coef for cpole~ imag part;
+#X text 409 408 (same \, other cpole~);
+#X obj 20 212 cpole~ 0.9293 0.10812;
+#X obj 20 238 cpole~ 0.9293 -0.10812;
+#X msg 279 257 15000;
+#X text 329 256 desired cutoff frequency;
+#X text 339 308 divide by nyquist frequency of this subpatch \, which
+is 22050*16 because of the 16-times oversampling.;
+#X text 273 225 Here is how to calculate the filter coefficients:;
+#X text 143 123 These objects make a 3-pole \, 3-zero Butterworth low-pass
+filter with cutoff at 15kHz (assuming 16x44100 sample rate). The filter
 was designed using the "buttercoef3" abstraction introduced in patch
 H13.butterworth.pd in this series.;
 #X connect 0 0 1 0;
 #X connect 1 0 2 0;
 #X connect 2 0 3 0;
-#X connect 3 0 4 0;
-#X connect 3 1 4 1;
-#X connect 4 0 5 0;
-#X connect 5 0 6 0;
-#X connect 6 0 7 0;
-#X connect 7 0 8 0;
-#X connect 8 0 12 0;
-#X connect 9 0 0 0;
-#X connect 11 0 9 0;
-#X restore 23 148 pd 16x;
-#X floatatom 23 111 7 0 0 0 - - -;
-#X obj 109 149 phasor~;
-#X obj 22 194 output~;
-#X obj 108 194 output~;
-#X obj 23 83 mtof;
-#X floatatom 23 59 3 -24 135 0 - - -;
-#X text 131 18 UPSAMPLING TO CONTROL FOLDOVER;
-#X text 56 57 <-- pitch;
-#X text 126 250 not;
-#X text 22 265 sampled;
-#X text 26 249 16x up-;
-#X text 20 293 The "pd 16x" subpatch at left contains a phasor~ object
+#X connect 3 0 7 0;
+#X connect 4 0 9 0;
+#X connect 6 0 4 0;
+#X connect 8 0 10 0;
+#X connect 9 0 8 0;
+#X connect 10 0 27 0;
+#X connect 11 0 14 0;
+#X connect 11 1 16 0;
+#X connect 11 2 17 0;
+#X connect 11 3 18 0;
+#X connect 11 4 19 0;
+#X connect 11 5 20 0;
+#X connect 12 0 15 0;
+#X connect 13 0 11 0;
+#X connect 15 0 13 0;
+#X connect 27 0 28 0;
+#X connect 27 1 28 1;
+#X connect 28 0 0 0;
+#X connect 29 0 12 0;
+#X restore 29 123 pd 16x;
+#X floatatom 29 86 7 0 0 0 - - -;
+#X obj 115 124 phasor~;
+#X obj 28 169 output~;
+#X obj 114 169 output~;
+#X obj 29 58 mtof;
+#X floatatom 29 34 3 -24 135 0 - - -;
+#X text 158 15 UPSAMPLING TO CONTROL FOLDOVER;
+#X text 62 32 <-- pitch;
+#X text 132 225 not;
+#X text 28 240 sampled;
+#X text 32 224 16x up-;
+#X text 26 268 The "pd 16x" subpatch at left contains a phasor~ object
 \, but is locally upsampled by a factor of sixteen. Without upsampling
 \, partials as low as 24 Khz. fold back over into the audible range.
 With upsampling \, the first audibly folding over partial is at almost
 700 Hz \, 29 times higher. The relevant partials will be 29 times \,
 or almost 30 dB \, quieter when upsampled.;
-#X text 21 403 A third-order Butterworth filter is used inside the
+#X text 27 378 A third-order Butterworth filter is used inside the
 "pd 16x" subpatch - without that \, the internal signal would fold
 over as it gets downsampled at the outlet~ object.;
-#X text 324 464 Updated for Pd version 0.39;
+#X text 312 507 Updated for Pd version 0.42;
+#X text 26 430 You can trade off cutoff frequency with foldover. Here
+\, the filter is set for a cutoff of 15 kHz. Lowering it to 7500 Hz
+would further reduce foldover by 18 dB at the expense of losing energy
+in the range 7500-15000 Hz.;
 #X connect 0 0 3 0;
 #X connect 0 0 3 1;
 #X connect 1 0 0 0;

Modified: trunk/pd/doc/5.reference/tabread4~-help.pd
===================================================================
--- trunk/pd/doc/5.reference/tabread4~-help.pd	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/doc/5.reference/tabread4~-help.pd	2008-12-08 20:14:40 UTC (rev 10432)
@@ -1,30 +1,28 @@
-#N canvas 59 33 814 475 10;
-#X obj 11 228 tabread4~ array99;
-#X text 21 207 signal input x(n);
-#X msg 727 51 \; pd dsp 0;
-#X graph graph1 0 -1 9 1 514 373 764 173;
-#X array array99 10 float 0;
-#X pop;
+#N canvas 323 179 845 474 12;
+#X obj 11 249 tabread4~ array99;
+#N canvas 0 0 450 300 (subpatch) 0;
+#X array array99 10 float 3;
+#A 0 -0.5 -0.5 -0.5 0.5 0.5 0.5 0 0 0 0;
+#X coords 0 1 10 -1 250 200 1;
+#X restore 561 167 graph;
 #X text 127 21 4-point-interpolating table lookup;
-#X obj 11 316 snapshot~;
-#X obj 30 290 metro 200;
+#X obj 11 337 snapshot~;
+#X obj 30 311 metro 200;
 #X obj 11 124 sig~;
-#X floatatom 11 98 0 0 0;
-#X obj 30 264 r readout;
-#X floatatom 11 342 0 0 0;
-#X msg 452 50 \; readout 1 \; array99 resize 10 \; array99 0 -0.5 -0.5
--0.5 0.5 0.5 0.5 \; pd dsp 1 \;;
-#X text 49 94 incoming signal is index. Indices should range from 1
+#X floatatom 11 98 6 0 10 0 - - -;
+#X obj 30 285 r readout;
+#X floatatom 11 363 0 0 0 0 - - -;
+#X text 59 92 incoming signal is index. Indices should range from 1
 to (size-2) so that the 4-point interpolation is meaningful. You can
 shift-drag the number box to see the effect of interpolation.;
-#X msg 34 158 set array99;
-#X text 116 158 "set" message permits you to switch between arrays
+#X msg 23 161 set array99;
+#X text 113 160 "set" message permits you to switch between arrays
 ;
-#X text 139 228 creation argument initializes array name;
-#X text 5 392 see also the "array" tutorial in section 2 of the Pd
+#X text 139 249 creation argument initializes array name;
+#X text 11 403 see also the "array" tutorial in section 2 of the Pd
 documentation \, and these objects:;
 #X obj 47 21 tabread4~;
-#X text 509 27 click here to test;
+#X text 563 16 click here to test;
 #X obj 12 442 tabwrite~;
 #X obj 157 442 tabread;
 #X obj 216 442 tabwrite;
@@ -32,12 +30,19 @@
 #X obj 346 442 tabreceive~;
 #X text 7 58 Tabread4~ is used to build samplers and other table lookup
 algorithms. The interpolation scheme is 4-point polynomial.;
-#X text 616 460 updated for Pd version 0.29;
 #X obj 83 442 tabplay~;
-#X connect 0 0 5 0;
-#X connect 5 0 10 0;
+#X text 626 451 updated for Pd version 0.42;
+#X msg 582 40 \; readout 1 \; pd dsp 1 \;;
+#X floatatom 111 190 3 0 10 0 - - -;
+#X text 19 205 signal input;
+#X text 138 183 inlet sets onset into table. You can use this to improve
+the accuracy of indexing into the array. See B15.tabread4~-onset.pd
+for details.;
+#X connect 0 0 3 0;
+#X connect 3 0 8 0;
+#X connect 4 0 3 0;
+#X connect 5 0 0 0;
 #X connect 6 0 5 0;
-#X connect 7 0 0 0;
-#X connect 8 0 7 0;
-#X connect 9 0 6 0;
-#X connect 13 0 0 0;
+#X connect 7 0 4 0;
+#X connect 10 0 0 0;
+#X connect 25 0 0 1;

Modified: trunk/pd/doc/7.stuff/tools/testtone.pd
===================================================================
--- trunk/pd/doc/7.stuff/tools/testtone.pd	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/doc/7.stuff/tools/testtone.pd	2008-12-08 20:14:40 UTC (rev 10432)
@@ -86,7 +86,7 @@
 #X connect 4 0 3 0;
 #X restore 459 298 pd more;
 #X obj 399 135 tgl 20 0 tone-hipass set-tone-hipass input-hipass 25
-10 0 12 -262144 -1 -1 1 1;
+10 0 12 -262144 -1 -1 0 1;
 #X obj 185 117 tgl 20 0 tone-ch3 tone-ch3 3 5 -8 0 12 -262144 -1 -1
 1 1;
 #X obj 210 117 tgl 20 0 tone-ch4 tone-ch4 4 5 -8 0 12 -262144 -1 -1
@@ -112,7 +112,7 @@
 #X obj 51 174 vradio 15 1 0 2 tone-type tone-type-set empty 0 -6 0
 8 -262144 -1 -1 1;
 #X obj 51 104 vradio 15 1 0 3 tone-radio tone-radio-set empty 0 -6
-0 8 -262144 -1 -1 2;
+0 8 -262144 -1 -1 0;
 #X obj 460 193 adc~;
 #X obj 459 240 print~;
 #X obj 468 217 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
@@ -123,7 +123,7 @@
 1 1;
 #X obj 308 117 tgl 20 0 tone-ch8 tone-ch8 8 5 -8 0 12 -262144 -1 -1
 1 1;
-#N canvas 233 399 903 462 audio 0;
+#N canvas 233 399 321 422 audio 0;
 #X obj 25 303 s~ tone-mon;
 #X obj 25 277 line~;
 #X obj 25 249 pack 0 50;

Modified: trunk/pd/extra/bonk~/bonk~.c
===================================================================
--- trunk/pd/extra/bonk~/bonk~.c	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/extra/bonk~/bonk~.c	2008-12-08 20:14:40 UTC (rev 10432)
@@ -1,7 +1,7 @@
 /*
  ###########################################################################
  # bonk~ - a Max/MSP external
- # by miller puckette and ted appel
+ # by miller puckette and ted apel
  # http://crca.ucsd.edu/~msp/
  # Max/MSP port by barry threw
  # http://www.barrythrew.com
@@ -911,7 +911,7 @@
                      h->h_before, h->h_countup);
         }
         post("filter details (frequencies are in units of %.2f-Hz. bins):",
-             x->x_sr);
+             x->x_sr/x->x_npoints);
         for (j = 0; j < x->x_nfilters; j++)
             post("%2d  cf %.2f  bw %.2f  nhops %d hop %d skip %d npoints %d",
                  j, 

Modified: trunk/pd/extra/pd~/pd~-help.pd
===================================================================
--- trunk/pd/extra/pd~/pd~-help.pd	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/extra/pd~/pd~-help.pd	2008-12-08 20:14:40 UTC (rev 10432)
@@ -1,20 +1,75 @@
-#N canvas 353 325 450 300 10;
-#X msg 52 86 foo bar baz;
-#X obj 209 52 osc~ 440;
-#X obj 74 211 env~ 8192;
-#X floatatom 77 243 5 0 0 0 - - -;
-#X obj 285 204 r a;
-#X obj 281 232 print a;
-#X msg 315 81 \; pd dsp 1;
-#X obj 70 166 pd~ test.pd;
-#X msg 66 20 pd~ stop;
-#X msg 77 42 pd~ start;
-#X msg 86 61 pd~ restart;
-#X connect 0 0 7 0;
-#X connect 1 0 7 0;
-#X connect 2 0 3 0;
-#X connect 4 0 5 0;
-#X connect 7 0 2 0;
-#X connect 8 0 7 0;
-#X connect 9 0 7 0;
-#X connect 10 0 7 0;
+#N canvas 12 0 566 872 12;
+#X msg 31 406 foo bar baz;
+#X obj 189 466 osc~ 440;
+#X obj 127 645 env~ 8192;
+#X floatatom 127 694 5 0 0 0 - - -;
+#X msg 434 807 \; pd dsp 1;
+#X msg 24 332 pd~ stop;
+#X obj 127 670 i;
+#X obj 241 643 env~ 8192;
+#X floatatom 241 693 5 0 0 0 - - -;
+#X obj 241 669 i;
+#X obj 123 489 *~;
+#X obj 158 490 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
+1;
+#X obj 189 490 *~;
+#X obj 224 491 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
+1;
+#X obj 434 781 loadbang;
+#X obj 14 691 print x;
+#X msg 15 309 pd~ start pd~-subprocess.pd;
+#X obj 14 532 pd~ -ninsig 2 -noutsig 2 -fifo 20;
+#X obj 37 20 pd~;
+#X text 69 22 - run a pd sub-process;
+#X text 27 57 The pd~ object starts and manages a Pd sub-process that
+can communicate with the super-process (this one) via audio channels
+and/or Pd messages. In this way you can take advantage of multi-core
+CPUs \, and/or use Pd features from within Max (if you're using the
+Max version of pd~).;
+#X text 24 251 Sending a new "start" message will stop the sub-process
+and start a new one. If you just want to stop the sub-process \, send
+"stop".;
+#X text 33 353 Any message besides "pd~" is sent to the sub-process.
+For instance \, the message below sends "bar baz" to any object in
+the sub-process named "foo" \, such as a "receive" object.;
+#X text 43 430 Audio signals appear in adc~ objects in the sub-process.
+The sub-process doesn't open real audio devices.;
+#X text 281 473 Creation args:;
+#X text 265 490 -insig <n> sets input audio channels;
+#X text 266 508 -outsig <n> sets output channels;
+#X text 269 542 -fifo <n> sets round-trip delay in blocks;
+#X text 272 559 -pddir <s> sets Pd directory \, e.g. \,;
+#X text 299 574 .../Pd-0.42.app/Contents/Resources;
+#X text 272 590 -scheddir <s> sets scheduler dir \, e.g. \,;
+#X text 297 607 .../.../Resources/extra/pd~;
+#X text 267 524 -sr <n> sets sample rate;
+#X text 20 716 The first outlet reports messages the sub-process sends
+us via "stdout" objects. Any other outlets are signals corresponding
+to "dac~" objects in the sub-process.;
+#X text 10 784 ATTENTION: DSP must be running in this process for the
+sub-process to run. This is because its clock is slaved to audio I/O
+it gets from us!;
+#X text 359 849 Updated for Pd version 0.42.;
+#X text 24 138 Messages with "pd~" selector control the sub-process.
+"pd~ start" takes as arguments any startup arguments you wish to send
+the sub-process. For example \, specify "-nogui" to stop the sub-process's
+GUI from appearing. You don't have to specify the number of channels
+in and out \, since that's set by creation arguments below. Audio config
+arguments arguments (-audiobuf \, -audiodev \, etc.) are ignored.;
+#X connect 0 0 17 0;
+#X connect 1 0 10 0;
+#X connect 1 0 12 0;
+#X connect 2 0 6 0;
+#X connect 5 0 17 0;
+#X connect 6 0 3 0;
+#X connect 7 0 9 0;
+#X connect 9 0 8 0;
+#X connect 10 0 17 0;
+#X connect 11 0 10 1;
+#X connect 12 0 17 1;
+#X connect 13 0 12 1;
+#X connect 14 0 4 0;
+#X connect 16 0 17 0;
+#X connect 17 0 15 0;
+#X connect 17 1 2 0;
+#X connect 17 2 7 0;

Modified: trunk/pd/extra/pd~/pd~.c
===================================================================
--- trunk/pd/extra/pd~/pd~.c	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/extra/pd~/pd~.c	2008-12-08 20:14:40 UTC (rev 10432)
@@ -70,14 +70,13 @@
 #ifdef PD
     t_object x_obj;
     t_clock *x_clock;
+    t_outlet *x_outlet1;        /* for messages back from subproc */
+    t_canvas *x_canvas;
 #endif /* PD */
 #ifdef MSP
     t_pxobject x_obj;
-    void *obex;
-    void *x_cookedout;
+    void *x_outlet1;
     void *x_clock;
-    short x_vol;
-        
 #endif /* MSP */
     FILE *x_infd;
     FILE *x_outfd;
@@ -91,7 +90,6 @@
     float x_sr;
     t_symbol *x_pddir;
     t_symbol *x_schedlibdir;
-    char *x_pdargs;
     t_sample **x_insig;
     t_sample **x_outsig;
 } t_pd_tilde;
@@ -168,7 +166,8 @@
 }
 
 static void pd_tilde_donew(t_pd_tilde *x, char *pddir, char *schedlibdir,
-    char *pdargs, int ninsig, int noutsig, int fifo, float samplerate)
+    char *patchdir, char *pdargs, int ninsig, int noutsig, int fifo,
+    float samplerate)
 {
     int i, pid, pipe1[2], pipe2[2];
     char cmdbuf[MAXPDSTRING], pdexecbuf[MAXPDSTRING], schedbuf[MAXPDSTRING];
@@ -197,8 +196,9 @@
             goto fail1;
         }       
     }
-    snprintf(cmdbuf, MAXPDSTRING, "%s -schedlib %s/pdsched %s\n",
-        pdexecbuf, schedlibdir, pdargs);
+    snprintf(cmdbuf, MAXPDSTRING,
+"%s -schedlib %s/pdsched -path %s -inchannels %d -outchannels %d -r %g %s\n",
+        pdexecbuf, schedlibdir, patchdir, ninsig, noutsig, samplerate, pdargs);
 #if 0
 #ifdef PD
     fprintf(stderr, "%s", cmdbuf);
@@ -368,25 +368,53 @@
 static void pd_tilde_pdtilde(t_pd_tilde *x, t_symbol *s,
     int argc, t_atom *argv)
 {
-    t_symbol *sel = ((argc > 0 && argv->a_type == A_SYMBOL) ? argv->a_w.w_symbol : gensym("?"));
+    t_symbol *sel = ((argc > 0 && argv->a_type == A_SYMBOL) ?
+        argv->a_w.w_symbol : gensym("?"));
+    char *patchdir;
     if (sel == gensym("start"))
     {
-        if (!x->x_infd)
-            pd_tilde_donew(x, x->x_pddir->s_name, x->x_schedlibdir->s_name,
-                x->x_pdargs, x->x_ninsig, x->x_noutsig, x->x_fifo, x->x_sr);
-    }
-    else if (sel == gensym("stop"))
-    {
+        char pdargstring[MAXPDSTRING];
         if (x->x_infd)
             pd_tilde_close(x);
+        pdargstring[0] = 0;
+        argc--; argv++;
+#ifdef PD
+        while (argc--)
+        {
+            atom_string(argv++, pdargstring + strlen(pdargstring), 
+                MAXPDSTRING - strlen(pdargstring));
+            if (strlen(pdargstring) < MAXPDSTRING-1)
+                strcat(pdargstring, " ");
+        }
+        patchdir = canvas_getdir(x->x_canvas)->s_name;
+#endif
+#ifdef MAX
+        while (argc--)
+        {
+            if (argv->a_type == A_SYM)
+                strncat(pdargstring, argv->a_w.w_sym->s_name,
+                    MAXPDSTRING - strlen(pdargstring)-3);
+            else if (argv->a_type == A_LONG)
+                snprintf(pdargstring+strlen(pdargstring),
+                    MAXPDSTRING - strlen(pdargstring)-3, "%ld",
+                        argv->a_w.w_long);
+            else if (argv->a_type == A_FLOAT)
+                snprintf(pdargstring+strlen(pdargstring),
+                    MAXPDSTRING - strlen(pdargstring)-3, "%f",
+                        argv->a_w.w_float);
+            strcat(pdargstring, " ");
+            argv++;
+        }
+        patchdir = ".";
+#endif
+        pd_tilde_donew(x, x->x_pddir->s_name, x->x_schedlibdir->s_name,
+            patchdir, pdargstring, x->x_ninsig, x->x_noutsig, x->x_fifo,
+                x->x_sr);
     }
-    else if (sel == gensym("restart"))
+    else if (sel == gensym("stop"))
     {
         if (x->x_infd)
             pd_tilde_close(x);
-        if (!x->x_infd)
-            pd_tilde_donew(x, x->x_pddir->s_name, x->x_schedlibdir->s_name,
-                x->x_pdargs, x->x_ninsig, x->x_noutsig, x->x_fifo, x->x_sr);
     }
     else ERROR "pd~: unknown control message: %s", sel->s_name);
 }
@@ -398,7 +426,6 @@
 #endif
     pd_tilde_close(x);
     clock_free(x->x_clock);
-    free(x->x_pdargs);
 }
 
 /* -------------------------- Pd glue ------------------------- */
@@ -420,19 +447,11 @@
     {
         if (vec[i].a_type == A_SEMI)
         {
-            if (i > messstart + 1)
-            {
-                t_pd *whom;
-                if (vec[messstart].a_type != A_SYMBOL)
-                    bug("pd_tilde_tick");
-                else if (!(whom = vec[messstart].a_w.w_symbol->s_thing))
-                    ERROR "%s: no such object",
-                        vec[messstart].a_w.w_symbol->s_name);
-                else if (vec[messstart+1].a_type == A_SYMBOL)
-                    typedmess(whom, vec[messstart+1].a_w.w_symbol,
-                        i-messstart-2, vec+(messstart+2));
-                else pd_list(whom, 0, i-messstart-1, vec+(messstart+1));
-            }
+            if (i > messstart && vec[messstart].a_type == A_SYMBOL)
+                outlet_anything(x->x_outlet1, vec[messstart].a_w.w_symbol,
+                    i-(messstart+1), vec+(messstart+1));
+            else if (i > messstart)
+                outlet_list(x->x_outlet1, 0, i-messstart, vec+messstart);
             messstart = i+1;
         }
     }
@@ -468,8 +487,7 @@
     t_sample **g;
     t_symbol *pddir = sys_guidir,
         *scheddir = gensym(class_gethelpdir(pd_tilde_class));
-    char pdargstring[MAXPDSTRING];
-    fprintf(stderr, "pd %s, sched %s\n", pddir->s_name, scheddir->s_name);
+    /* fprintf(stderr, "pd %s, sched %s\n", pddir->s_name, scheddir->s_name); */
     while (argc > 0)
     {
         t_symbol *firstarg = atom_getsymbolarg(0, argc, argv);
@@ -505,24 +523,15 @@
         }
         else break;
     }
-#if 0
-        {
-            pd_error(x,
-"usage: pd~ [-sr #] [-ninsig #] [-noutsig #] [-fifo #] [-pddir <>]");
-            post(
-"... [-scheddir <>] [pd-argument...]");
-            argc = 0;
-        }
-#endif
-    
-    pdargstring[0] = 0;
-    while (argc--)
+
+    if (argc)
     {
-        atom_string(argv++, pdargstring + strlen(pdargstring), 
-            MAXPDSTRING - strlen(pdargstring));
-        if (strlen(pdargstring) < MAXPDSTRING-1)
-            strcat(pdargstring, " ");
+        pd_error(x,
+"usage: pd~ [-sr #] [-ninsig #] [-noutsig #] [-fifo #] [-pddir <>]");
+        post(
+"... [-scheddir <>]");
     }
+
     x->x_clock = clock_new(x, (t_method)pd_tilde_tick);
     x->x_insig = (t_sample **)getbytes(ninsig * sizeof(*x->x_insig));
     x->x_outsig = (t_sample **)getbytes(noutsig * sizeof(*x->x_outsig));
@@ -532,15 +541,15 @@
     x->x_sr = sr;
     x->x_pddir = pddir;
     x->x_schedlibdir = scheddir;
-    x->x_pdargs = malloc(strlen(pdargstring)+1);
     x->x_infd = 0;
     x->x_outfd = 0;
     x->x_outfd = 0;
     x->x_childpid = -1;
     x->x_msgbuf = 0;
-    strcpy(x->x_pdargs, pdargstring);
+    x->x_canvas = canvas_getcurrent();
     for (j = 1, g = x->x_insig; j < ninsig; j++, g++)
         inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+    x->x_outlet1 = outlet_new(&x->x_obj, 0);
     for (j = 0, g = x->x_outsig; j < noutsig; j++, g++)
         outlet_new(&x->x_obj, &s_signal);
     signal(SIGPIPE, SIG_IGN);
@@ -556,7 +565,7 @@
     class_addmethod(pd_tilde_class, (t_method)pd_tilde_dsp, gensym("dsp"), 0);
     class_addmethod(pd_tilde_class, (t_method)pd_tilde_pdtilde, gensym("pd~"), A_GIMME, 0);
     class_addanything(pd_tilde_class, pd_tilde_anything);
-    post("pd~ version 0.1");
+    post("pd~ version 0.2");
 }
 #endif
 
@@ -651,7 +660,8 @@
 
     class_register(CLASS_BOX, c);
     pd_tilde_class = c;
-        return (0);
+    post("pd~ version 0.2");
+    return (0);
 }
 
 static void *pd_tilde_new(t_symbol *s, long ac, t_atom *av)
@@ -659,7 +669,6 @@
     int ninsig = 2, noutsig = 2, fifo = 5, j;
     float sr = sys_getsr();
     t_symbol *pddir = gensym("."), *scheddir = gensym(".");
-    char pdargstring[MAXPDSTRING];
     t_pd_tilde *x;
 
     if (x = (t_pd_tilde *)object_alloc(pd_tilde_class))
@@ -705,30 +714,17 @@
         }
         if (scheddir == gensym(".") && pddir != gensym("."))
         {
-            char *pds = pddir->s_name;
+            char *pds = pddir->s_name, scheddirstring[MAXPDSTRING];
             int l = strlen(pds);
             if (l >= 4 && (!strcmp(pds+l-3, "bin") || !strcmp(pds+l-4, "bin/")))
-                snprintf(pdargstring, MAXPDSTRING, "%s/../extra/pd~", pds);
-            else snprintf(pdargstring, MAXPDSTRING, "%s/extra/pd~", pds);
-            scheddir = gensym(pdargstring);
+                snprintf(scheddirstring, MAXPDSTRING, "%s/../extra/pd~", pds);
+            else snprintf(scheddirstring, MAXPDSTRING, "%s/extra/pd~", pds);
+            scheddir = gensym(scheddirstring);
         }
-        pdargstring[0] = 0;
-        while (ac--)
-        {
-            char buf[80];
-            if (av->a_type == A_SYM)
-                strncat(pdargstring, av->a_w.w_sym->s_name, MAXPDSTRING - strlen(pdargstring)-3);
-            else if (av->a_type == A_LONG)
-                snprintf(pdargstring+strlen(pdargstring), MAXPDSTRING - strlen(pdargstring)-3, "%ld",
-                    av->a_w.w_long);
-            else if (av->a_type == A_FLOAT)
-                snprintf(pdargstring+strlen(pdargstring), MAXPDSTRING - strlen(pdargstring)-3, "%f",
-                    av->a_w.w_float);
-            strcat(pdargstring, " ");
-            av++;
-        }
-        post("pd~: pddir %s scheddir %s args %s",
-            pddir->s_name, scheddir->s_name, pdargstring);
+        if (ac)
+            post("pd~: warning: ignoring extra arguments");
+        post("pd~: pddir %s scheddir %s",
+            pddir->s_name, scheddir->s_name);
         dsp_setup((t_pxobject *)x, ninsig);
         for (j = 0; j < noutsig; j++)
             outlet_new((t_pxobject *)x, "signal");
@@ -741,13 +737,11 @@
         x->x_sr = sr;
         x->x_pddir = pddir;
         x->x_schedlibdir = scheddir;
-        x->x_pdargs = malloc(strlen(pdargstring)+1);
         x->x_infd = 0;
         x->x_outfd = 0;
         x->x_outfd = 0;
         x->x_childpid = -1;
         x->x_msgbuf = 0;
-        strcpy(x->x_pdargs, pdargstring);
     }
     return (x);
 }

Deleted: trunk/pd/extra/pd~/test.pd
===================================================================
--- trunk/pd/extra/pd~/test.pd	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/extra/pd~/test.pd	2008-12-08 20:14:40 UTC (rev 10432)
@@ -1,29 +0,0 @@
-#N canvas 643 132 450 300 10;
-#X obj 65 58 r foo;
-#X obj 62 100 print foo;
-#X obj 244 59 adc~;
-#X obj 238 102 env~ 8192;
-#X floatatom 236 140 5 0 0 0 - - -;
-#X obj 145 130 osc~ 440;
-#X obj 287 204 stdout;
-#X msg 307 153 a b c;
-#X msg 307 42 \; pd dsp 1;
-#X floatatom 238 173 5 0 0 0 - - -;
-#X msg 149 34 a b c;
-#X obj 62 157 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
--1;
-#X obj 44 187 del 1000;
-#X obj 26 249 print bang;
-#X obj 59 219 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
--1;
-#X obj 155 234 dac~ 1 2 3 4;
-#X obj 168 189 sig~ 0.5;
-#X connect 0 0 1 0;
-#X connect 2 0 3 0;
-#X connect 3 0 4 0;
-#X connect 4 0 9 0;
-#X connect 7 0 6 0;
-#X connect 10 0 1 0;
-#X connect 11 0 12 0;
-#X connect 12 0 13 0;
-#X connect 12 0 14 0;

Modified: trunk/pd/extra/sigmund~/sigmund~.c
===================================================================
--- trunk/pd/extra/sigmund~/sigmund~.c	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/extra/sigmund~/sigmund~.c	2008-12-08 20:14:40 UTC (rev 10432)
@@ -363,7 +363,7 @@
 #define PITCHUNCERTAINTY 0.3
 #define HALFTONEINC 0.059
 #define SUBHARMONICS 16
-#define DBPERHALFTONE 0.5
+#define DBPERHALFTONE 0.0
 
 static void sigmund_getpitch(int npeak, t_peak *peakv, float *freqp,
     float npts, float srate, int loud)
@@ -405,8 +405,6 @@
     for (i = 0; i < nsalient; i++)
     {
         t_peak *thispeak = bigpeaks[i];
-        float pitchuncertainty =
-            4 * PITCHUNCERTAINTY * fperbin / (HALFTONEINC * thispeak->p_freq);
         float weightindex = (48./LOG2) *
             log(thispeak->p_freq/(2.*fperbin));
         float loudness = sqrt(thispeak->p_amp);
@@ -415,8 +413,8 @@
         {
             float subindex = weightindex -
                 (48./LOG2) * log(j + 1.);
-            int loindex = subindex - pitchuncertainty;
-            int hiindex = subindex + pitchuncertainty + 1;
+            int loindex = subindex - 0.5;
+            int hiindex = loindex+2;
             if (hiindex < 0)
                 break;
             if (hiindex >= npit)
@@ -424,7 +422,7 @@
             if (loindex < 0)
                 loindex = 0;
             for (k = loindex; k <= hiindex; k++)
-                weights[k] += loudness * 4. / (4. + j);
+                weights[k] += loudness * 6. / (6. + j);
         }
         sumweight += loudness;
     }
@@ -441,29 +439,35 @@
         freq = 0;
         goto done;
     }
-    for (i = bestbin+1; i < npit; i++)
+    if (bestbin > 0 && bestbin < npit-1)
     {
-        if (weights[i] < bestweight)
-            break;
-        bestbin += 0.5;
+        int ibest = bestbin;
+        bestbin += (weights[ibest+1] - weights[ibest-1]) /
+            (weights[ibest+1] +  weights[ibest] + weights[ibest-1]);
     }
     freq = 2*fperbin * exp((LOG2/48.)*bestbin);
-
     for (sumamp = sumweight = sumfreq = 0, i = 0; i < nsalient; i++)
     {
         t_peak *thispeak = bigpeaks[i];
-        float thisloudness = sqrt(thispeak->p_amp);
+        float thisloudness = thispeak->p_amp;
         float thisfreq = thispeak->p_freq;
         float harmonic = thisfreq/freq;
         float intpart = (int)(0.5 + harmonic);
-        float inharm = freq * (harmonic - intpart);
-        if (harmonic < 1)
-            continue;
-        if (inharm < 0.25*fperbin && inharm > -0.25*fperbin)
+        float inharm = harmonic - intpart;
+#if 0
+        if (loud)
+            post("freq %f intpart %f inharm %f", freq, intpart, inharm);
+#endif
+        if (intpart >= 1 && intpart <= 16 &&
+            inharm < 0.015 * intpart && inharm > - (0.015 * intpart))
         {
             float weight = thisloudness * intpart;
             sumweight += weight;
             sumfreq += weight*thisfreq/intpart;
+#if 0
+            if (loud)
+                post("weight %f freq %f", weight, thisfreq);
+#endif
         }
     }
     if (sumweight > 0)
@@ -1457,7 +1461,7 @@
     dsp_setup((t_pxobject *)x, 1);
     object_obex_store(x, gensym("dumpout"), outlet_new(x, NULL));
     
-    for (i = 0; i < ac; i++)    FIXME
+    for (i = 0; i < ac; i++)
         if (av[i].a_type == A_SYM)
     {
         char *s = av[i].a_w.w_sym->s_name;

Modified: trunk/pd/extra/stdout/stdout-help.pd
===================================================================
--- trunk/pd/extra/stdout/stdout-help.pd	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/extra/stdout/stdout-help.pd	2008-12-08 20:14:40 UTC (rev 10432)
@@ -1,13 +1,19 @@
-#N canvas 110 37 789 525 10;
-#X msg 84 147 walk the dog;
-#X msg 91 169 1;
-#X msg 90 215 flush;
-#X obj 84 240 stdout;
-#X text 472 410 updated for Pd version 0.42;
+#N canvas 121 60 488 321 12;
+#X msg 126 203 walk the dog;
+#X msg 117 156 1;
+#X obj 117 240 stdout;
+#X text 269 287 updated for Pd version 0.42;
 #X obj 14 13 stdout;
 #X text 67 14 - write messages to standard output;
-#X msg 96 192 1 2;
-#X connect 0 0 3 0;
-#X connect 1 0 3 0;
-#X connect 2 0 3 0;
-#X connect 7 0 3 0;
+#X msg 122 179 1 2;
+#X obj 119 291 pd~;
+#X text 44 291 see also:;
+#X text 34 39 Sends messages to Pd's standard output. This is useful
+in conjunction with the pd~ object \, which starts a pd sub-process.
+Messages sent to the sub-process standard output appear on the output
+of the pd~ object in the owning process. This might also be useful
+in other situations. Note that there's no corresponding "stdin" object
+- there seems to be no one canonical way such a thing should act.;
+#X connect 0 0 2 0;
+#X connect 1 0 2 0;
+#X connect 6 0 2 0;

Modified: trunk/pd/extra/stdout/stdout.c
===================================================================
--- trunk/pd/extra/stdout/stdout.c	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/extra/stdout/stdout.c	2008-12-08 20:14:40 UTC (rev 10432)
@@ -37,7 +37,7 @@
     printf("%s;\n", msgbuf);
 }
 
-static void stdout_flush(t_stdout *x)
+static void stdout_free(t_stdout *x)
 {
     fflush(stdout);
 }
@@ -45,7 +45,6 @@
 void stdout_setup(void)
 {
     stdout_class = class_new(gensym("stdout"), (t_newmethod)stdout_new,
-        (t_method)stdout_flush, sizeof(t_stdout), 0, 0);
-    class_addmethod(stdout_class, (t_method)stdout_flush, gensym("flush"), 0);
+        (t_method)stdout_free, sizeof(t_stdout), 0, 0);
     class_addanything(stdout_class, stdout_anything);
 }

Modified: trunk/pd/src/d_array.c
===================================================================
--- trunk/pd/src/d_array.c	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/src/d_array.c	2008-12-08 20:14:40 UTC (rev 10432)
@@ -373,6 +373,7 @@
     t_word *x_vec;
     t_symbol *x_arrayname;
     t_float x_f;
+    t_float x_onset;
 } t_tabread4_tilde;
 
 static void *tabread4_tilde_new(t_symbol *s)
@@ -381,7 +382,9 @@
     x->x_arrayname = s;
     x->x_vec = 0;
     outlet_new(&x->x_obj, gensym("signal"));
+    floatinlet_new(&x->x_obj, &x->x_onset);
     x->x_f = 0;
+    x->x_onset = 0;
     return (x);
 }
 
@@ -393,6 +396,7 @@
     int n = (int)(w[4]);    
     int maxindex;
     t_word *buf = x->x_vec, *wp;
+    double onset = x->x_onset;
     int i;
     
     maxindex = x->x_npoints - 3;
@@ -417,7 +421,7 @@
 
     for (i = 0; i < n; i++)
     {
-        t_sample findex = *in++;
+        double findex = *in++ + onset;
         int index = findex;
         t_sample frac,  a,  b,  c,  d, cminusb;
         static int count;
@@ -431,8 +435,6 @@
         b = wp[0].w_float;
         c = wp[1].w_float;
         d = wp[2].w_float;
-        /* if (!i && !(count++ & 1023))
-            post("fp = %lx,  shit = %lx,  b = %f",  fp, buf->b_shit,  b); */
         cminusb = c-b;
         *out++ = b + frac * (
             cminusb - 0.1666667f * (1.-frac) * (

Modified: trunk/pd/src/d_osc.c
===================================================================
--- trunk/pd/src/d_osc.c	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/src/d_osc.c	2008-12-08 20:14:40 UTC (rev 10432)
@@ -86,7 +86,7 @@
     t_float *in = (t_float *)(w[2]);
     t_float *out = (t_float *)(w[3]);
     int n = (int)(w[4]);
-    double dphase = x->x_phase + UNITBIT32;
+    double dphase = x->x_phase + (double)UNITBIT32;
     union tabfudge tf;
     int normhipart;
     float conv = x->x_conv;

Modified: trunk/pd/src/m_pd.h
===================================================================
--- trunk/pd/src/m_pd.h	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/src/m_pd.h	2008-12-08 20:14:40 UTC (rev 10432)
@@ -11,7 +11,7 @@
 #define PD_MAJOR_VERSION 0
 #define PD_MINOR_VERSION 42
 #define PD_BUGFIX_VERSION 0
-#define PD_TEST_VERSION "test5"
+#define PD_TEST_VERSION "test6"
 
 /* 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 */

Modified: trunk/pd/src/m_sched.c
===================================================================
--- trunk/pd/src/m_sched.c	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/src/m_sched.c	2008-12-08 20:14:40 UTC (rev 10432)
@@ -450,11 +450,11 @@
                 if (!(idlecount & 31))
                 {
                     static double idletime;
-                                        if (sched_useaudio != SCHED_AUDIO_POLL)
-                                        {
-                                                bug("m_pollingscheduler\n");
-                                                return;
-                                        }
+                    if (sched_useaudio != SCHED_AUDIO_POLL)
+                    {
+                            bug("m_pollingscheduler\n");
+                            return;
+                    }
                         /* on 32nd idle, start a clock watch;  every
                         32 ensuing idles, check it */
                     if (idlecount == 32)
@@ -566,6 +566,15 @@
     return (0);
 }
 
+int m_batchmain(void)
+{
+    sys_time_per_dsp_tick = (TIMEUNITPERSEC) *
+        ((double)sys_schedblocksize) / sys_dacsr;
+    while (sys_quit != SYS_QUIT_QUIT)
+        sched_tick(sys_time + sys_time_per_dsp_tick);
+    return (0);
+}
+
 /* ------------ thread locking ------------------- */
 
 #ifdef THREAD_LOCKING

Modified: trunk/pd/src/notes.txt
===================================================================
--- trunk/pd/src/notes.txt	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/src/notes.txt	2008-12-08 20:14:40 UTC (rev 10432)
@@ -15,6 +15,8 @@
 Gnome: why don't windows pop up when clicked on?
 
 problems:
+if .pdsettings asks for an alsa device out of range, dialog
+  comes up with empty list
 find asdf$1 (e.g.) doesn't work
 check real-time gaps in writesf~
 fix declare to update current patch when changed

Modified: trunk/pd/src/s_audio_alsa.c
===================================================================
--- trunk/pd/src/s_audio_alsa.c	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/src/s_audio_alsa.c	2008-12-08 20:14:40 UTC (rev 10432)
@@ -25,6 +25,7 @@
 #include <sched.h>
 #include <sys/mman.h>
 #include "s_audio_alsa.h"
+#include <endian.h>
 
 /* Defines */
 #define DEBUG(x) x
@@ -117,17 +118,33 @@
     if (err < 0)
         return (-1);
     check_error(err, "snd_pcm_hw_params_set_access");
+#if 0       /* enable this to print out which formats are available */
+    {
+        int i;
+        for (i = 0; i <= SND_PCM_FORMAT_LAST; i++)
+            fprintf(stderr, "%d -> %d\n",
+                i, snd_pcm_hw_params_test_format(dev->a_handle, hw_params, i));
+    }
+#endif
         /* Try to set 32 bit format first */
     err = snd_pcm_hw_params_set_format(dev->a_handle,
         hw_params, SND_PCM_FORMAT_S32);
     if (err < 0)
     {
         /* fprintf(stderr,
-            "PD-ALSA: 32 bit format not available - using 16\n"); */
+            "PD-ALSA: 32 bit format not available - trying 24\n"); */
         err = snd_pcm_hw_params_set_format(dev->a_handle, hw_params,
-                                           SND_PCM_FORMAT_S16);
-        check_error(err, "snd_pcm_hw_params_set_format");
-        dev->a_sampwidth = 2;
+            SND_PCM_FORMAT_S24_3LE);
+        if (err < 0)
+        {
+            /* fprintf(stderr,
+                "PD-ALSA: 32/24 bit format not available - using 16\n"); */
+            err = snd_pcm_hw_params_set_format(dev->a_handle, hw_params,
+                SND_PCM_FORMAT_S16);
+            check_error(err, "snd_pcm_hw_params_set_format");
+            dev->a_sampwidth = 2;
+        }
+        else dev->a_sampwidth = 3;
     }
     else dev->a_sampwidth = 4;
 
@@ -426,19 +443,44 @@
         if (alsa_outdev[iodev].a_sampwidth == 4)
         {
             for (i = 0; i < chans; i++, ch++, fp1 += DEFDACBLKSIZE)
-                for (j = ch, k = DEFDACBLKSIZE, fp2 = fp1; k--;
+                for (j = i, k = DEFDACBLKSIZE, fp2 = fp1; k--;
                      j += thisdevchans, fp2++)
             {
                 float s1 = *fp2 * INT32_MAX;
                 ((t_alsa_sample32 *)alsa_snd_buf)[j] = CLIP32(s1);
             } 
             for (; i < thisdevchans; i++, ch++)
-                for (j = ch, k = DEFDACBLKSIZE; k--; j += thisdevchans)
+                for (j = i, k = DEFDACBLKSIZE; k--; j += thisdevchans)
                     ((t_alsa_sample32 *)alsa_snd_buf)[j] = 0;
         }
-        else
+        else if (alsa_outdev[iodev].a_sampwidth == 3)
         {
             for (i = 0; i < chans; i++, ch++, fp1 += DEFDACBLKSIZE)
+                for (j = i, k = DEFDACBLKSIZE, fp2 = fp1; k--;
+                     j += thisdevchans, fp2++)
+            {
+                int s = *fp2 * 8388352.;
+                if (s > 8388351)
+                    s = 8388351;
+                else if (s < -8388351)
+                    s = -8388351;
+#if BYTE_ORDER == LITTLE_ENDIAN                                             
+                ((char *)(alsa_snd_buf))[3*j] = (s & 255);
+                ((char *)(alsa_snd_buf))[3*j+1] = ((s>>8) & 255);
+                ((char *)(alsa_snd_buf))[3*j+2] = ((s>>16) & 255);
+#else
+                fprintf(stderr("big endian 24-bit not supported");
+#endif
+            }
+            for (; i < thisdevchans; i++, ch++)
+                for (j = i, k = DEFDACBLKSIZE; k--; j += thisdevchans)
+                    ((char *)(alsa_snd_buf))[3*j] = 
+                    ((char *)(alsa_snd_buf))[3*j+1] = 
+                    ((char *)(alsa_snd_buf))[3*j+2] = 0;
+        }
+        else        /* 16 bit samples */
+        {
+            for (i = 0; i < chans; i++, ch++, fp1 += DEFDACBLKSIZE)
                 for (j = ch, k = DEFDACBLKSIZE, fp2 = fp1; k--;
                      j += thisdevchans, fp2++)
             {
@@ -525,6 +567,23 @@
                         * (1./ INT32_MAX);
             }
         }
+        else if (alsa_indev[iodev].a_sampwidth == 3)
+        {
+#if BYTE_ORDER == LITTLE_ENDIAN                                             
+            for (i = 0; i < chans; i++, ch++, fp1 += DEFDACBLKSIZE)
+            {
+                for (j = ch, k = DEFDACBLKSIZE, fp2 = fp1; k--;
+                     j += thisdevchans, fp2++)
+                    *fp2 = ((float) (
+                        (((unsigned char *)alsa_snd_buf)[3*j] << 8)
+                        | (((unsigned char *)alsa_snd_buf)[3*j+1] << 16)
+                        | (((unsigned char *)alsa_snd_buf)[3*j+2] << 24)))
+                        * (1./ INT32_MAX);
+            }
+#else
+                fprintf(stderr("big endian 24-bit not supported");
+#endif
+        }
         else
         {
             for (i = 0; i < chans; i++, ch++, fp1 += DEFDACBLKSIZE)

Modified: trunk/pd/src/s_audio_pa.c
===================================================================
--- trunk/pd/src/s_audio_pa.c	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/src/s_audio_pa.c	2008-12-08 20:14:40 UTC (rev 10432)
@@ -11,6 +11,7 @@
 #include "s_stuff.h"
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <portaudio.h>
 #include "s_audio_pablio.h"
 
@@ -29,6 +30,34 @@
 
 int pa_foo;
 
+static void pa_init(void)
+{
+    static int initialized;
+    if (!initialized)
+    {
+        /* Initialize PortAudio  */
+        /* for some reason Pa_Initialize(0 closes file descriptor 1.
+        As a workaround, dup it to another number and dup2 it back
+        afterward. */
+        int newfd = dup(1);
+        int err = Pa_Initialize();
+        if (newfd >= 0)
+        {
+            dup2(newfd, 1);
+            close(newfd);
+        }
+        if ( err != paNoError ) 
+        {
+            fprintf( stderr,
+                "Error number %d occured initializing portaudio\n",
+                err); 
+            fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
+            return;
+        }
+        initialized = 1;
+    }
+}
+
 static int pa_lowlevel_callback(const void *inputBuffer,
     void *outputBuffer, unsigned long framesPerBuffer,
     const PaStreamCallbackTimeInfo *outTime, PaStreamCallbackFlags myflags, 
@@ -155,25 +184,11 @@
     int indeviceno, int outdeviceno, t_audiocallback callbackfn)
 {
     PaError err;
-    static int initialized;
     int j, devno, pa_indev = 0, pa_outdev = 0;
     
     pa_callback = callbackfn;
     /* fprintf(stderr, "open callback %d\n", (callbackfn != 0)); */
-    if (!initialized)
-    {
-        /* Initialize PortAudio  */
-        int err = Pa_Initialize();
-        if ( err != paNoError ) 
-        {
-            fprintf( stderr,
-                "Error number %d occured initializing portaudio\n",
-                err); 
-            fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
-            return (1);
-        }
-        initialized = 1;
-    }
+    pa_init();
     /* post("in %d out %d rate %d device %d", inchans, outchans, rate, deviceno); */
     if (inchans > MAX_PA_CHANS)
     {
@@ -349,7 +364,7 @@
     int      numDevices;
     const    PaDeviceInfo *pdi;
     PaError  err;
-    Pa_Initialize();
+    pa_init();
     numDevices = Pa_GetDeviceCount();
     if( numDevices < 0 )
     {
@@ -390,7 +405,7 @@
     int i, nin = 0, nout = 0, ndev;
     *canmulti = 1;  /* one dev each for input and output */
 
-    Pa_Initialize();
+    pa_init();
     ndev = Pa_GetDeviceCount();
     for (i = 0; i < ndev; i++)
     {

Modified: trunk/pd/src/s_main.c
===================================================================
--- trunk/pd/src/s_main.c	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/src/s_main.c	2008-12-08 20:14:40 UTC (rev 10432)
@@ -35,6 +35,7 @@
 int sys_startgui(const char *guipath);
 int sys_rcfile(void);
 int m_mainloop(void);
+int m_batchmain(void);
 void sys_addhelppath(char *p);
 #ifdef USEAPI_ALSA
 void alsa_adddev(char *name);
@@ -75,6 +76,7 @@
 
 int sys_externalschedlib;
 char sys_externalschedlibname[MAXPDSTRING];
+static int sys_batch;
 int sys_extraflags;
 char sys_extraflagsstring[MAXPDSTRING];
 int sys_run_scheduler(const char *externalschedlibname,
@@ -299,6 +301,8 @@
     if (sys_externalschedlib)
         return (sys_run_scheduler(sys_externalschedlibname,
             sys_extraflagsstring));
+    else if (sys_batch)
+        return (m_batchmain());
     else
     {
             /* open audio and MIDI */
@@ -394,6 +398,7 @@
 "-nosleep         -- spin, don't sleep (may lower latency on multi-CPUs)\n",
 "-schedlib <file> -- plug in external scheduler\n",
 "-extraflags <s>  -- string argument to send schedlib\n",
+"-batch           -- run off-line as a batch process\n",
 };
 
 static void sys_parsedevlist(int *np, int *vecp, int max, char *str)
@@ -828,6 +833,12 @@
             argv += 2;
             argc -= 2;
         }
+        else if (!strcmp(*argv, "-batch"))
+        {
+            sys_batch = 1;
+            sys_printtostderr = sys_nogui = 1;
+            argc--; argv++;
+        }
 #ifdef UNISTD
         else if (!strcmp(*argv, "-rt") || !strcmp(*argv, "-realtime"))
         {

Modified: trunk/pd/src/u_main.tk
===================================================================
--- trunk/pd/src/u_main.tk	2008-12-08 13:33:46 UTC (rev 10431)
+++ trunk/pd/src/u_main.tk	2008-12-08 20:14:40 UTC (rev 10432)
@@ -4449,7 +4449,7 @@
         set fieldname [lindex $ddd_fields $x 0]
         set $varname [lindex $ddd_fields $x 1]
         frame $id.frame$x
-        pack $id.frame$x -side top
+        pack $id.frame$x -side top -anchor e
         label $id.frame$x.label -text $fieldname
         entry $id.frame$x.entry -textvariable $varname -width 20
         bind $id.frame$x.entry <KeyPress-Return> [concat ddd_ok $id]


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Pd-cvs mailing list