diff options
author | Miller Puckette <millerpuckette@users.sourceforge.net> | 2007-07-20 03:25:21 +0000 |
---|---|---|
committer | Miller Puckette <millerpuckette@users.sourceforge.net> | 2007-07-20 03:25:21 +0000 |
commit | 1e45c6bafc8419930958103cc1651ff86cf5d84d (patch) | |
tree | 260d94049e3302f7fc833abd7a8d3479f0631e49 /pd | |
parent | daa1933fed59113296b8e044fc370587b068aea9 (diff) |
various bug fixes.
svn path=/trunk/; revision=8186
Diffstat (limited to 'pd')
31 files changed, 440 insertions, 275 deletions
diff --git a/pd/doc/3.audio.examples/I05.compressor.pd b/pd/doc/3.audio.examples/I05.compressor.pd index 10fe3375..1acfb624 100644 --- a/pd/doc/3.audio.examples/I05.compressor.pd +++ b/pd/doc/3.audio.examples/I05.compressor.pd @@ -65,7 +65,7 @@ set 10; #X restore 42 330 pd fft-analysis; #X floatatom 57 196 0 0 500 0 - squelch-set -; #X obj 57 220 s squelch; -#N canvas 190 43 427 657 test-signal 0; +#N canvas 240 72 427 657 test-signal 0; #X obj 90 444 line~; #X obj 90 369 f; #X obj 90 524 outlet~; @@ -81,11 +81,11 @@ set 10; #X obj 117 270 t b f; #X obj 90 469 tabread4~ \$0-sample; #X text 21 28 test signal: looped sample playback; -#X obj 67 131 hip~ 5; -#X obj 67 107 adc~ 1; -#X obj 129 131 s insamprate; +#X obj 77 131 hip~ 5; +#X obj 77 107 adc~ 1; +#X obj 139 131 s insamprate; #X obj 67 70 inlet; -#X obj 129 107 samplerate~; +#X obj 139 107 samplerate~; #X obj 116 246 r \$0-samplength; #X obj 259 246 r \$0-insamprate; #X obj 67 154 tabwrite~ \$0-sample; @@ -110,14 +110,14 @@ set 10; #X connect 15 0 22 0; #X connect 16 0 15 0; #X connect 18 0 19 0; -#X connect 18 0 16 0; +#X connect 18 0 22 0; #X connect 19 0 17 0; #X connect 20 0 12 0; #X connect 21 0 11 0; #X restore 43 303 pd test-signal; #X obj 43 359 output~; #N canvas 388 86 722 350 insample 0; -#N canvas 0 0 450 300 graph1 0; +#N canvas 0 0 450 300 (subpatch) 0; #X array \$0-sample 155948 float 0; #X coords 0 1 155947 -1 400 150 1; #X restore 259 24 graph; @@ -178,7 +178,7 @@ squelch value.; #X text 295 161 change input sound; #X obj 292 259 s read-sample; #N canvas 0 110 565 454 hann-window 0; -#N canvas 0 0 450 300 graph1 0; +#N canvas 0 0 450 300 (subpatch) 0; #X array \$0-hann 1024 float 0; #X coords 0 1 1023 0 300 100 1; #X restore 82 311 graph; diff --git a/pd/doc/3.audio.examples/I06.timbre.stamp.pd b/pd/doc/3.audio.examples/I06.timbre.stamp.pd index 0fd540cd..16890499 100644 --- a/pd/doc/3.audio.examples/I06.timbre.stamp.pd +++ b/pd/doc/3.audio.examples/I06.timbre.stamp.pd @@ -129,11 +129,11 @@ with the filter input.); #X obj 117 270 t b f; #X obj 90 469 tabread4~ \$0-sample; #X text 21 28 test signal: looped sample playback; -#X obj 40 159 hip~ 5; -#X obj 40 135 adc~ 1; -#X obj 102 159 s insamprate; -#X obj 40 98 inlet; -#X obj 102 135 samplerate~; +#X obj 51 159 hip~ 5; +#X obj 51 135 adc~ 1; +#X obj 113 159 s insamprate; +#X obj 40 99 inlet; +#X obj 113 135 samplerate~; #X obj 116 246 r \$0-samplength; #X obj 191 276 r \$0-insamprate; #X obj 40 182 tabwrite~ \$0-sample; @@ -150,11 +150,11 @@ with the filter input.); #X obj 398 337 metro 1000; #X obj 499 295 t b b f; #X obj 425 263 t b f; -#X obj 348 152 hip~ 5; -#X obj 348 128 adc~ 1; +#X obj 360 152 hip~ 5; +#X obj 360 128 adc~ 1; #X obj 348 91 inlet; -#X obj 410 128 samplerate~; -#X obj 410 152 s insamprate2; +#X obj 422 128 samplerate~; +#X obj 422 152 s insamprate2; #X obj 348 175 tabwrite~ \$0-sample2; #X obj 424 239 r \$0-samplength2; #X obj 499 269 r \$0-insamprate2; @@ -180,7 +180,7 @@ with the filter input.); #X connect 15 0 22 0; #X connect 16 0 15 0; #X connect 18 0 19 0; -#X connect 18 0 16 0; +#X connect 18 0 22 0; #X connect 19 0 17 0; #X connect 20 0 12 0; #X connect 21 0 11 0; @@ -204,7 +204,7 @@ with the filter input.); #X connect 36 0 41 0; #X connect 37 0 36 0; #X connect 38 0 39 0; -#X connect 38 0 37 0; +#X connect 38 0 41 0; #X connect 39 0 40 0; #X connect 42 0 35 0; #X connect 43 0 34 0; @@ -212,7 +212,7 @@ with the filter input.); #X restore 87 415 pd test-signals; #X text 104 393 <- record ->; #N canvas 388 86 722 350 insample2 0; -#N canvas 0 0 450 300 graph1 0; +#N canvas 0 0 450 300 (subpatch) 0; #X array \$0-sample2 62079 float 0; #X coords 0 1 62078 -1 400 150 1; #X restore 298 24 graph; @@ -253,7 +253,7 @@ with the filter input.); #X connect 16 0 10 1; #X restore 334 430 pd insample2; #N canvas 388 86 722 350 insample1 0; -#N canvas 0 0 450 300 graph1 0; +#N canvas 0 0 450 300 (subpatch) 0; #X array \$0-sample 155948 float 0; #X coords 0 1 155947 -1 400 150 1; #X restore 259 24 graph; @@ -295,7 +295,7 @@ with the filter input.); #X restore 334 408 pd insample1; #X floatatom 453 432 5 0 0 0 - #0-samp2-msec -; #N canvas 0 110 565 454 hann-window 0; -#N canvas 0 0 450 300 graph1 0; +#N canvas 0 0 450 300 (subpatch) 0; #X array \$0-hann 1024 float 0; #X coords 0 1 1023 0 300 100 1; #X restore 82 311 graph; diff --git a/pd/doc/3.audio.examples/I07.phase.vocoder.pd b/pd/doc/3.audio.examples/I07.phase.vocoder.pd index 735b8cd2..d0d913b3 100644 --- a/pd/doc/3.audio.examples/I07.phase.vocoder.pd +++ b/pd/doc/3.audio.examples/I07.phase.vocoder.pd @@ -347,11 +347,11 @@ shifts the signal to the left or right depending on its argument.) #X connect 54 0 21 0; #X restore 55 480 pd fft-analysis; #N canvas 260 23 647 768 phase-tables 0; -#N canvas 0 0 450 300 graph2 0; +#N canvas 0 0 450 300 (subpatch) 0; #X array prev-imag 4096 float 0; #X coords 0 1000 4096 -1000 400 300 1; #X restore 169 326 graph; -#N canvas 0 0 450 300 graph3 0; +#N canvas 0 0 450 300 (subpatch) 0; #X array prev-real 4096 float 0; #X coords 0 500 4096 -500 400 300 1; #X restore 170 17 graph; @@ -362,9 +362,9 @@ shifts the signal to the left or right depending on its argument.) #X text 389 359 normal; #X obj 56 517 output~; #N canvas 0 110 565 454 hann-window 0; -#N canvas 0 0 450 300 graph1 0; -#X array \$0-hann 1024 float 0; -#X coords 0 1 1023 0 300 100 1; +#N canvas 0 0 450 300 (subpatch) 0; +#X array \$0-hann 2048 float 0; +#X coords 0 1 2047 0 300 100 1; #X restore 82 311 graph; #X obj 378 165 osc~; #X obj 378 190 *~ -0.5; @@ -412,9 +412,9 @@ and window-msec (analysis window size in seconds and msec).; #X connect 19 1 18 0; #X restore 440 528 pd hann-window; #N canvas 388 86 694 447 insample 0; -#N canvas 0 0 450 300 graph1 0; -#X array \$0-sample 160161 float 0; -#X coords 0 1 160160 -1 400 150 1; +#N canvas 0 0 450 300 (subpatch) 0; +#X array \$0-sample 62079 float 0; +#X coords 0 1 62078 -1 400 150 1; #X restore 281 135 graph; #X obj 28 133 r read-sample; #X obj 28 184 unpack s f; @@ -433,12 +433,12 @@ and window-msec (analysis window size in seconds and msec).; #X obj 28 381 * 1000; #X obj 28 404 s \$0-samp-msec; #X obj 66 357 r \$0-insamprate; -#X obj 29 70 hip~ 5; -#X obj 29 46 adc~ 1; +#X obj 37 68 hip~ 5; +#X obj 37 44 adc~ 1; #X obj 29 9 inlet; -#X obj 91 46 samplerate~; +#X obj 99 44 samplerate~; #X obj 29 93 tabwrite~ \$0-sample; -#X obj 91 70 s \$0-insamprate; +#X obj 99 68 s \$0-insamprate; #X msg 285 383 \; read-sample ../sound/voice.wav; #X obj 276 20 inlet; #X obj 276 42 openpanel; @@ -463,7 +463,7 @@ and window-msec (analysis window size in seconds and msec).; #X connect 18 0 22 0; #X connect 19 0 18 0; #X connect 20 0 21 0; -#X connect 20 0 19 0; +#X connect 20 0 22 0; #X connect 21 0 23 0; #X connect 25 0 26 0; #X connect 26 0 27 0; diff --git a/pd/doc/5.reference/cos~-help.pd b/pd/doc/5.reference/cos~-help.pd index ba6f918e..5e4d67b2 100644 --- a/pd/doc/5.reference/cos~-help.pd +++ b/pd/doc/5.reference/cos~-help.pd @@ -1,27 +1,29 @@ -#N canvas 134 143 768 332 12; +#N canvas 190 40 698 331 12; #X obj 112 12 cos~; #X obj 23 200 cos~; #X obj 23 249 snapshot~; #X obj 23 152 sig~; -#X floatatom 23 275 0 0 0; +#X floatatom 23 275 7 0 0 0 - - -; #X obj 23 125 * 0.01; -#X floatatom 23 98 0 0 0; +#X floatatom 23 98 0 0 0 0 - - -; #X obj 90 215 metro 500; #X obj 90 189 r metro; -#X msg 540 93 \; metro 0; -#X msg 521 39 \; pd dsp 1 \; metro 1; +#X msg 469 157 \; metro 0; +#X msg 450 103 \; pd dsp 1 \; metro 1; #X text 159 13 - COSINE WAVESHAPER; #X text 86 125 Divide by 100; #X text 71 153 convert to audio; #X text 78 100 <-- Scroll to set input value; -#X text 64 276 <-- output of the cos~ object; -#X text 291 195 see also:; -#X obj 379 197 osc~; -#X obj 423 197 tabread4~; -#X text 494 293 updated for Pd version 0.33; -#X text 608 54 <-Click to start; -#X text 609 99 <-Click to stop; -#X text 9 45 The cos~ object outputs the cosine of its signal input.; +#X text 97 275 <-- output of the cos~ object; +#X text 83 305 see also:; +#X obj 171 307 osc~; +#X obj 215 307 tabread4~; +#X text 537 118 <-Click to start; +#X text 538 163 <-Click to stop; +#X text 13 41 The cos~ object outputs the cosine of two pi times its +signal input. So -1 \, 0 \, 1 and 2 give 1 out \, 0.5 gives -1 \, and +so on.; +#X text 411 298 updated for Pd version 0.41; #X connect 1 0 2 0; #X connect 2 0 4 0; #X connect 2 0 4 0; diff --git a/pd/doc/5.reference/help-intro.pd b/pd/doc/5.reference/help-intro.pd index a7286115..23952ba8 100644 --- a/pd/doc/5.reference/help-intro.pd +++ b/pd/doc/5.reference/help-intro.pd @@ -1,4 +1,4 @@ -#N canvas 155 0 693 923 12; +#N canvas 14 5 569 440 12; #X declare; #X obj 24 150 bang; #X text 124 150 - output a bang message; @@ -295,8 +295,6 @@ to a note-on; #X obj 18 4338 append; #X text 118 4338 - add an element to a list; #X obj 18 4368 sublist; -#X text 118 4368 - get a pointer into a list which is an element of -another scalar; #X obj 14 4449 scalar; #X text 104 4448 - draw a scalar on parent; #X obj 15 4479 scope~; @@ -360,3 +358,4 @@ included in this list are messages \, atoms \, graphs \, etc. which aren't typed into object boxes but come straight off the "add" menu.) Right-click (or double-click on a Macintosh) on any object to get its "help window".; +#X text 118 4368 - get a pointer into a list within a scalar; diff --git a/pd/doc/5.reference/soundfiler-help.pd b/pd/doc/5.reference/soundfiler-help.pd index 5561bf18..c006b521 100644 --- a/pd/doc/5.reference/soundfiler-help.pd +++ b/pd/doc/5.reference/soundfiler-help.pd @@ -1,9 +1,9 @@ #N canvas 59 252 1102 576 12; -#N canvas 0 0 450 300 graph1 0; +#N canvas 0 0 450 300 (subpatch) 0; #X array array1 77971 float 0; #X coords 0 1 77971 -1 300 100 1; #X restore 71 353 graph; -#N canvas 0 0 450 300 graph1 0; +#N canvas 0 0 450 300 (subpatch) 0; #X array array2 77971 float 0; #X coords 0 1 77971 -1 300 100 1; #X restore 71 459 graph; @@ -18,23 +18,6 @@ of the three known soundfile formats the file belongs to or override all header information using the "-raw" flag.; #X text 665 52 Flags for reading:; #X text 574 68 -skip <sample frames to skip in file>; -#X text 574 87 -nframes <maximum number of sample frames to read>; -#X text 575 143 -raw <headersize> <channels> <bytespersample> <endianness> -; -#X text 594 161 This causes all header information to be ignored. Endianness -is "l" ("little") for Intel machines or "b" ("big") for Macintoshes -and SGIs. You can give "n" (natural) to take the byte order your machine -prefers.; -#X text 575 106 -resize; -#X text 575 124 -maxsize <maximum number of samples we can resize to> -; -#X text 560 226 Flags for writing:; -#X text 578 247 -wave \, -nextstep \, -aiff; -#X text 579 266 -big \, -little (nextstep only!); -#X text 578 288 -skip <number of sample frames to skip in array>; -#X text 579 310 -nframes <maximum number to write>; -#X text 580 354 -normalize; -#X text 579 332 -bytes <2 \, 3 \, or 4>; #X floatatom 11 337 0 0 0 0 - - -; #X msg 15 175 read -resize ../sound/bell.aiff array2; #X msg 17 288 write -nextstep -bytes 4 /tmp/foo3 array1 array2; @@ -44,25 +27,41 @@ prefers.; #X text 225 217 ...or even overriding everything; #X text 283 240 write a file; #X text 352 309 write stereo; -#X text 557 398 The number of channels is limited to 64; -#X text 612 433 see also:; -#X obj 606 456 tabwrite~; -#X obj 607 480 tabread4~; -#X obj 713 435 tabplay~; -#X obj 711 484 writesf~; -#X obj 712 461 readsf~; #X text 9 31 The soundfiler object reads and writes floating point arrays to binary soundfiles which may contain 2 or 3 byte fixed point or 4 byte floating point samples in wave \, aiff \, or next formats (no floating point aiff \, though.). The number of channels of the soundfile need not match the number of arrays given (extras are dropped and unsupplied channels are zeroed out.); -#X text 579 374 -rate <sample rate>; +#X text 575 123 -raw <headersize> <channels> <bytespersample> <endianness> +; +#X text 594 141 This causes all header information to be ignored. Endianness +is "l" ("little") for Intel machines or "b" ("big") for Macintoshes +and SGIs. You can give "n" (natural) to take the byte order your machine +prefers.; +#X text 575 86 -resize; +#X text 575 104 -maxsize <maximum number of samples we can resize to> +; +#X text 560 206 Flags for writing:; +#X text 578 227 -wave \, -nextstep \, -aiff; +#X text 579 246 -big \, -little (nextstep only!); +#X text 578 268 -skip <number of sample frames to skip in array>; +#X text 579 290 -nframes <maximum number to write>; +#X text 580 334 -normalize; +#X text 579 312 -bytes <2 \, 3 \, or 4>; +#X text 557 378 The number of channels is limited to 64; +#X text 612 413 see also:; +#X obj 606 436 tabwrite~; +#X obj 607 460 tabread4~; +#X obj 713 415 tabplay~; +#X obj 711 464 writesf~; +#X obj 712 441 readsf~; +#X text 579 354 -rate <sample rate>; #X text 751 539 updated for Pd version 0.37; -#X connect 2 0 22 0; +#X connect 2 0 10 0; #X connect 3 0 2 0; #X connect 4 0 2 0; #X connect 5 0 2 0; -#X connect 23 0 2 0; -#X connect 24 0 2 0; -#X connect 25 0 2 0; +#X connect 11 0 2 0; +#X connect 12 0 2 0; +#X connect 13 0 2 0; diff --git a/pd/extra/sigmund~/sigmund~.c b/pd/extra/sigmund~/sigmund~.c index 09d004cb..ad98bedc 100644 --- a/pd/extra/sigmund~/sigmund~.c +++ b/pd/extra/sigmund~/sigmund~.c @@ -181,6 +181,23 @@ static void sigmund_tweak(int npts, float *ftreal, float *ftimag, } } +static void sigmund_remask(int maxbin, int bestindex, float powmask, + float maxpower, float *maskbuf) +{ + int bin; + int bin1 = (bestindex > 52 ? bestindex-50:2); + int bin2 = (maxbin < bestindex + 50 ? bestindex + 50 : maxbin); + for (bin = bin1; bin < bin2; bin++) + { + float bindiff = bin - bestindex; + float mymask; + mymask = powmask/ (1. + bindiff * bindiff * bindiff * bindiff); + if (bindiff < 2 && bindiff > -2) + mymask = 2*maxpower; + if (mymask > maskbuf[bin]) + maskbuf[bin] = mymask; + } +} static void sigmund_getrawpeaks(int npts, float *insamps, int npeak, t_peak *peakv, int *nfound, float *power, float srate, int loud, @@ -191,16 +208,16 @@ static void sigmund_getrawpeaks(int npts, float *insamps, int npts2 = 2*npts, i, bin; int count, peakcount = 0; float *fp1, *fp2; - float *rawpow, *rawreal, *rawimag, *maskbuf; - float *bigbuf = alloca(sizeof (float ) * (2*NEGBINS + 5*npts)); + float *rawpow, *rawreal, *rawimag, *maskbuf, *powbuf; + float *bigbuf = alloca(sizeof (float ) * (2*NEGBINS + 6*npts)); int maxbin = hifreq/fperbin; - int altwind = (param3 == 1); int tweak = (param3 == 0); if (maxbin > npts - NEGBINS) maxbin = npts - NEGBINS; if (loud) post("tweak %d", tweak); maskbuf = bigbuf + npts2; - rawreal = maskbuf + npts+NEGBINS; + powbuf = maskbuf + npts; + rawreal = powbuf + npts+NEGBINS; rawimag = rawreal+npts+NEGBINS; for (i = 0; i < npts; i++) maskbuf[i] = 0; @@ -236,45 +253,34 @@ static void sigmund_getrawpeaks(int npts, float *insamps, rawimag[-2] = -rawimag[2]; rawimag[-3] = -rawimag[3]; rawimag[-4] = -rawimag[4]; - +#if 1 + for (i = 0, fp1 = rawreal, fp2 = rawimag; i < npts-1; i++, fp1++, fp2++) + { + float x1 = fp1[1] - fp1[-1], x2 = fp2[1] - fp2[-1]; + powbuf[i] = x1*x1+x2*x2; + } + powbuf[npts-1] = 0; +#endif for (peakcount = 0; peakcount < npeak; peakcount++) { float pow1, maxpower = 0, totalpower = 0, windreal, windimag, windpower, detune, pidetune, sinpidetune, cospidetune, ampcorrect, ampout, ampoutreal, ampoutimag, freqout, freqcount1, freqcount2, powmask; int bestindex = -1; + for (bin = 2, fp1 = rawreal+2, fp2 = rawimag+2; bin < maxbin; bin++, fp1++, fp2++) { - float x1, x2, a1, a2, b1, b2, thresh; - if (altwind) - { - x1 = fp1[0] - 0.5*(fp1[-2] +fp1[2]); - x2 = fp2[0] - 0.5*(fp2[-2] +fp2[2]); - a1 = fp1[4] - 0.5*(fp1[2] +fp1[6]); - a2 = fp2[2] - 0.5*(fp2[2] +fp2[6]); - b1 = fp1[-4] - 0.5*(fp1[-2] +fp1[-6]); - b2 = fp2[-4] - 0.5*(fp2[-2] +fp2[-6]); - thresh = param2 * (a1*a1+a2*a2+b1*b1+b2*b2); - } - else - { - x1 = fp1[1] - fp1[-1]; - x2 = fp2[1] - fp2[-1]; - a1 = fp1[3] - fp1[1]; - a2 = fp2[3] - fp2[1]; - b1 = fp1[-1] - fp1[-3]; - b2 = fp2[-1] - fp2[-3]; - thresh = param2 * (a1*a1+a2*a2+b1*b1+b2*b2); - } - pow1 = x1*x1+x2*x2; + pow1 = powbuf[bin]; if (pow1 > maxpower && pow1 > maskbuf[bin]) { + float thresh = param2 * (powbuf[bin-2]+powbuf[bin+2]); if (pow1 > thresh) maxpower = pow1, bestindex = bin; } totalpower += pow1; } + if (totalpower <= 0 || maxpower < 1e-10*totalpower || bestindex < 0) break; fp1 = rawreal+bestindex; @@ -284,46 +290,21 @@ static void sigmund_getrawpeaks(int npts, float *insamps, if (loud > 2) post("maxpower %f, powmask %f, param1 %f", maxpower, powmask, param1); - for (bin = 2; bin < maxbin; bin++) - { - float bindiff = bin - bestindex; - float mymask = - powmask/ (1. + bindiff * bindiff * bindiff * bindiff); - if (bindiff < 2 && bindiff > -2) - mymask = 2*maxpower; - if (mymask > maskbuf[bin]) - maskbuf[bin] = mymask; - } + sigmund_remask(maxbin, bestindex, powmask, maxpower, maskbuf); if (loud > 1) post("best index %d, total power %f", bestindex, totalpower); - if (altwind) - { - windreal = W_ALPHA * fp1[0] - (0.5 * W_BETA) * (fp1[2] + fp1[-2]); - windimag = W_ALPHA * fp2[0] - (0.5 * W_BETA) * (fp2[2] + fp2[-2]); - windpower = windreal * windreal + windimag * windimag; - detune = ( - (W_BETA*(rawreal[bestindex-2] - rawreal[bestindex+2])) * - (2.0 * W_ALPHA * rawreal[bestindex] - - W_BETA * (rawreal[bestindex-2] + rawreal[bestindex+2])) - + - (W_BETA*(rawimag[bestindex-2] - rawimag[bestindex+2])) * - (2.0 * W_ALPHA * rawimag[bestindex] - - W_BETA * (rawimag[bestindex-2] + rawimag[bestindex+2])) - ) / (4.0 * windpower); - } - else - { - windreal = fp1[1] - fp1[-1]; - windimag = fp2[1] - fp2[-1]; - windpower = windreal * windreal + windimag * windimag; - detune = ((fp1[1] * fp1[1] - fp1[-1]*fp1[-1]) - + (fp2[1] * fp2[1] - fp2[-1]*fp2[-1])) / (2 * windpower); - if (loud > 2) post("(-1) %f %f; (1) %f %f", - fp1[-1], fp2[-1], fp1[1], fp2[1]); - if (loud > 2) post("peak %f %f", - fp1[0], fp2[0]); - } + + windreal = fp1[1] - fp1[-1]; + windimag = fp2[1] - fp2[-1]; + windpower = windreal * windreal + windimag * windimag; + detune = ((fp1[1] * fp1[1] - fp1[-1]*fp1[-1]) + + (fp2[1] * fp2[1] - fp2[-1]*fp2[-1])) / (2 * windpower); + if (loud > 2) post("(-1) %f %f; (1) %f %f", + fp1[-1], fp2[-1], fp1[1], fp2[1]); + if (loud > 2) post("peak %f %f", + fp1[0], fp2[0]); + if (detune > 0.5) detune = 0.5; else if (detune < -0.5) @@ -334,9 +315,7 @@ static void sigmund_getrawpeaks(int npts, float *insamps, pidetune = PI * detune; sinpidetune = sin(pidetune); cospidetune = cos(pidetune); - if (altwind) - ampcorrect = 1.0 / window_hann_mag(pidetune, sinpidetune); - else ampcorrect = 1.0 / window_mag(pidetune, cospidetune); + ampcorrect = 1.0 / window_mag(pidetune, cospidetune); ampout = ampcorrect *sqrt(windpower); ampoutreal = ampcorrect * @@ -844,10 +823,10 @@ static void sigmund_minpower(t_sigmund *x, t_floatarg f); static void *sigmund_new(t_symbol *s, int argc, t_atom *argv) { t_sigmund *x = (t_sigmund *)pd_new(sigmund_class); + x->x_npts = NPOINTS_DEF; x->x_param1 = 0; x->x_param2 = 0.6; x->x_param3 = 0; - x->x_npts = NPOINTS_DEF; x->x_hop = HOP_DEF; x->x_mode = MODE_STREAM; x->x_npeak = NPEAK_DEF; @@ -863,7 +842,8 @@ static void *sigmund_new(t_symbol *s, int argc, t_atom *argv) x->x_trackv = 0; x->x_ntrack = 0; x->x_dopitch = x->x_donote = x->x_dotracks = 0; - + x->x_inbuf = 0; + while (argc > 0) { t_symbol *firstarg = atom_getsymbolarg(0, argc, argv); @@ -886,7 +866,7 @@ static void *sigmund_new(t_symbol *s, int argc, t_atom *argv) #endif else if (!strcmp(firstarg->s_name, "-npts") && argc > 1) { - sigmund_npts(x, atom_getfloatarg(1, argc, argv)); + x->x_npts = atom_getfloatarg(1, argc, argv); argc -= 2; argv += 2; } else if (!strcmp(firstarg->s_name, "-hop") && argc > 1) @@ -1008,21 +988,9 @@ static void *sigmund_new(t_symbol *s, int argc, t_atom *argv) } x->x_clock = clock_new(&x->x_obj.ob_pd, (t_method)sigmund_clock); - /* check parameter ranges */ - if (x->x_npts < NPOINTS_MIN) - post("sigmund~: minimum points %d", NPOINTS_MIN), - x->x_npts = NPOINTS_MIN; - if (x->x_npts != (1 << sigmund_ilog2(x->x_npts))) - post("sigmund~: adjusting analysis size to %d points", - (x->x_npts = (1 << sigmund_ilog2(x->x_npts)))); - if (x->x_hop != (1 << sigmund_ilog2(x->x_hop))) - post("sigmund~: adjusting hop size to %d points", - (x->x_hop = (1 << sigmund_ilog2(x->x_hop)))); - if (x->x_mode == MODE_STREAM) - x->x_inbuf = getbytes(sizeof(*x->x_inbuf) * x->x_npts); - else x->x_inbuf = 0; x->x_infill = 0; x->x_countdown = 0; + sigmund_npts(x, x->x_npts); notefinder_init(&x->x_notefinder); sigmund_clear(x); return (x); @@ -1158,14 +1126,25 @@ static void sigmund_param3(t_sigmund *x, t_floatarg f) static void sigmund_npts(t_sigmund *x, t_floatarg f) { - x->x_npts = f; + int nwas = x->x_npts, npts = f; /* check parameter ranges */ - if (x->x_npts < NPOINTS_MIN) + if (npts < NPOINTS_MIN) post("sigmund~: minimum points %d", NPOINTS_MIN), - x->x_npts = NPOINTS_MIN; - if (x->x_npts != (1 << sigmund_ilog2(x->x_npts))) + npts = NPOINTS_MIN; + if (npts != (1 << sigmund_ilog2(npts))) post("sigmund~: adjusting analysis size to %d points", - (x->x_npts = (1 << sigmund_ilog2(x->x_npts)))); + (npts = (1 << sigmund_ilog2(npts)))); + if (npts != nwas) + x->x_countdown = x->x_infill = 0; + if (x->x_mode == MODE_STREAM) + { + if (x->x_inbuf) + x->x_inbuf = resizebytes(x->x_inbuf, + sizeof(*x->x_inbuf) * nwas, sizeof(*x->x_inbuf) * npts); + else x->x_inbuf = getbytes(sizeof(*x->x_inbuf) * npts); + } + else x->x_inbuf = 0; + x->x_npts = npts; } static void sigmund_hop(t_sigmund *x, t_floatarg f) @@ -1261,6 +1240,8 @@ static t_int *sigmund_perform(t_int *w) float *in = (float *)(w[2]); int n = (int)(w[3]); + if (x->x_hop % n) + return (w+4); if (x->x_countdown > 0) x->x_countdown -= n; else if (x->x_infill != x->x_npts) @@ -1330,6 +1311,6 @@ void sigmund_tilde_setup(void) gensym("print"), 0); class_addmethod(sigmund_class, (t_method)sigmund_printnext, gensym("printnext"), A_FLOAT, 0); - post("sigmund version 0.02"); + post("sigmund version 0.03"); } diff --git a/pd/portaudio/pa_win_wdmks/pa_win_wdmks.c b/pd/portaudio/pa_win_wdmks/pa_win_wdmks.c index 560858b6..2c3a218a 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.18 2007-01-20 04:06:06 millerpuckette Exp $ + * $Id: pa_win_wdmks.c,v 1.19 2007-07-20 03:25:20 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 a9c331c4..33a60b0b 100644 --- a/pd/portaudio/pablio/ringbuffer.c +++ b/pd/portaudio/pablio/ringbuffer.c @@ -1,5 +1,5 @@ /* - * $Id: ringbuffer.c,v 1.17 2007-01-20 04:06:06 millerpuckette Exp $ + * $Id: ringbuffer.c,v 1.18 2007-07-20 03:25:20 millerpuckette Exp $ * ringbuffer.c * Ring Buffer utility.. * diff --git a/pd/portaudio/pablio/ringbuffer.h b/pd/portaudio/pablio/ringbuffer.h index 26bbd125..7cdcc63b 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.18 2007-01-20 04:06:06 millerpuckette Exp $ + * $Id: ringbuffer.h,v 1.19 2007-07-20 03:25:20 millerpuckette Exp $ * ringbuffer.h * Ring Buffer utility.. * diff --git a/pd/portmidi/pm_mac/pmmacosxcm.c b/pd/portmidi/pm_mac/pmmacosxcm.c index a2d0cc43..c381d10c 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.18 2007-01-20 04:06:06 millerpuckette Exp $
+ * $Id: pmmacosxcm.c,v 1.19 2007-07-20 03:25:20 millerpuckette Exp $
*/
/* Notes:
diff --git a/pd/src/configure.in b/pd/src/configure.in index a94c70eb..fb757526 100644 --- a/pd/src/configure.in +++ b/pd/src/configure.in @@ -20,6 +20,7 @@ AC_SUBST(GUINAME) AC_SUBST(GUIFLAGS) AC_SUBST(OSNUMBER) AC_SUBST(EXTERNTARGET) +AC_SUBST(ASIOSRC) dnl other defaults @@ -80,7 +81,10 @@ AC_CHECK_LIB(m, sin,PDLIB="$PDLIB -lm", dnl Checking for `pthread_create' function in -pthread AC_CHECK_LIB(pthread, pthread_create,PDLIB="$PDLIB -lpthread", - echo "pthreads required" || exit 1) + AC_CHECK_LIB(pthreadGC2, pthread_create, PDLIB="$PDLIB -lpthreadGC2", + AC_CHECK_LIB(pthreadGC1, pthread_create, PDLIB="$PDLIB -lpthreadGC1", + AC_CHECK_LIB(pthreadGC, pthread_create, PDLIB="$PDLIB -lpthreadGC", + echo "pthreads required"; exit 1)))) dnl Check for fftw package if test x$fftw == "xyes"; @@ -118,6 +122,11 @@ then fi if test $foundit == "no"; then + AC_CHECK_HEADER(tcl8.4/tcl.h, + GUIFLAGS="$GUIFLAGS -I/usr/local/include/tcl8.4";foundit=yes,) +fi +if test $foundit == "no"; +then AC_CHECK_HEADER(tcl8.3/tcl.h, GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.3";foundit=yes,) fi @@ -129,27 +138,30 @@ fi if test $foundit == "no"; then echo no tcl header found - exit -1 + echo bolding trying without... +# exit -1 fi -AC_CHECK_LIB(tcl8.7, main,, - AC_CHECK_LIB(tcl8.6, main,, +AC_CHECK_LIB(tcl85, main,, AC_CHECK_LIB(tcl8.5, main,, + AC_CHECK_LIB(tcl84, main,, AC_CHECK_LIB(tcl8.4, main,, AC_CHECK_LIB(tcl8.3, main,, AC_CHECK_LIB(tcl8.2, main,, - AC_CHECK_LIB(tcl8.0, main,,echo no tcl library found || exit 1))))))) + AC_CHECK_LIB(tcl8.0, main,, + echo no tcl library found; exit 1))))))) -AC_CHECK_LIB(tk8.7, main,, - AC_CHECK_LIB(tk8.6, main,, +AC_CHECK_LIB(tk85, main,, AC_CHECK_LIB(tk8.5, main,, + AC_CHECK_LIB(tk84, main,, AC_CHECK_LIB(tk8.4, main,, AC_CHECK_LIB(tk8.3, main,, AC_CHECK_LIB(tk8.2, main,, - AC_CHECK_LIB(tk8.0, main,,echo no tk library found || exit 1))))))) + AC_CHECK_LIB(tk8.0, main,, + echo no tk library found; exit 1))))))) -if test `uname -s` = Linux; +if test `uname -s` == Linux; then dnl Ckecking for ALSA echo .................... alsa= $alsa @@ -238,7 +250,7 @@ dnl This should be fixed so Pd can use ALSA shared libraries where appropriate. fi -if test `uname -s` = Darwin; +if test `uname -s` == Darwin; then LDFLAGS="-Wl -framework CoreAudio \ -framework AudioUnit -framework AudioToolbox \ @@ -316,6 +328,39 @@ then fi fi +# only Windows uses ASIO, for the rest, set to blank +ASIOSRC= + +if test `uname -s` == MINGW32_NT-5.0; +then + EXT=dll + MORECFLAGS="-DUSEAPI_PORTAUDIO -DPA19 -DMSW -DPA_NO_DS -DPD_INTERNAL \ + -I../portaudio/pa_common -I../portaudio/pablio \ + -mwindows -mms-bitfields "$MORECFLAGS + PDLIB=$PDLIB" -lwsock32 -lwinmm -lole32 -lstdc++" + + SYSSRC="s_audio_pa.c s_audio_pablio.c s_audio_paring.c \ + s_audio_mmio.c s_midi_mmio.c \ + ../portaudio/pa_common/pa_allocation.c \ + ../portaudio/pa_common/pa_converters.c \ + ../portaudio/pa_common/pa_cpuload.c \ + ../portaudio/pa_common/pa_dither.c \ + ../portaudio/pa_common/pa_front.c \ + ../portaudio/pa_common/pa_process.c \ + ../portaudio/pa_common/pa_skeleton.c \ + ../portaudio/pa_common/pa_stream.c \ + ../portaudio/pa_common/pa_trace.c \ + ../portaudio/pa_win/pa_win_util.c \ + ../portaudio/pa_win/pa_win_hostapis.c \ + ../portaudio/pa_win_wmme/pa_win_wmme.c" + ASIOSRC="../portaudio/pa_asio/iasiothiscallresolver.cpp \ + ../portaudio/pa_asio/pa_asio.cpp ../asio/asio.cpp \ + ../asio/asiodrivers.cpp ../asio/asiolist.cpp" + STRIPFLAG="--strip-unneeded" + GUINAME="pdtcl.dll" + GUIFLAGS= +fi + # support for jack, on either linux or darwin: if test x$jack == "xyes"; diff --git a/pd/src/d_math.c b/pd/src/d_math.c index e04a6738..44f23e3d 100644 --- a/pd/src/d_math.c +++ b/pd/src/d_math.c @@ -67,6 +67,15 @@ static void clip_setup(void) #define DUMTAB1SIZE 256 #define DUMTAB2SIZE 1024 +#ifdef MSW +#define int32 long +#endif + +#if defined(__unix__) || defined(__APPLE__) +#include <sys/types.h> +#define int32 int32_t +#endif + static float rsqrt_exptab[DUMTAB1SIZE], rsqrt_mantissatab[DUMTAB2SIZE]; static void init_rsqrt(void) @@ -75,8 +84,8 @@ static void init_rsqrt(void) for (i = 0; i < DUMTAB1SIZE; i++) { float f; - long l = (i ? (i == DUMTAB1SIZE-1 ? DUMTAB1SIZE-2 : i) : 1)<< 23; - *(long *)(&f) = l; + int32 l = (i ? (i == DUMTAB1SIZE-1 ? DUMTAB1SIZE-2 : i) : 1)<< 23; + *(int32 *)(&f) = l; rsqrt_exptab[i] = 1./sqrt(f); } for (i = 0; i < DUMTAB2SIZE; i++) diff --git a/pd/src/d_soundfile.c b/pd/src/d_soundfile.c index 56c89e07..93578e65 100644 --- a/pd/src/d_soundfile.c +++ b/pd/src/d_soundfile.c @@ -30,6 +30,10 @@ objects use Posix-like threads. */ #ifdef _LARGEFILE64_SOURCE # define open open64 # define lseek lseek64 +#define off_t __off64_t +#endif +#ifdef MSW +#define off_t long #endif /***************** soundfile header structures ************************/ @@ -369,7 +373,8 @@ int open_soundfile_via_fd(int fd, int headersize, } } /* seek past header and any sample frames to skip */ - sysrtn = lseek(fd, nchannels * bytespersamp * skipframes + headersize, 0); + sysrtn = lseek(fd, + ((off_t)nchannels) * bytespersamp * skipframes + headersize, 0); if (sysrtn != nchannels * bytespersamp * skipframes + headersize) return (-1); bytelimit -= nchannels * bytespersamp * skipframes; @@ -958,7 +963,6 @@ static t_soundfiler *soundfiler_new(void) usage: read [flags] filename table ... flags: -skip <frames> ... frames to skip in file - -nframes <frames> -onset <frames> ... onset in table to read into (NOT DONE YET) -raw <headersize channels bytes endian> -resize @@ -970,7 +974,7 @@ static void soundfiler_read(t_soundfiler *x, t_symbol *s, { int headersize = -1, channels = 0, bytespersamp = 0, bigendian = 0, resize = 0, i, j; - long skipframes = 0, nframes = 0, finalsize = 0, itemsleft, + long skipframes = 0, finalsize = 0, itemsleft, maxsize = DEFMAXSIZE, itemsread = 0, bytelimit = 0x7fffffff; int fd = -1; char endianness, *filename; @@ -990,13 +994,6 @@ static void soundfiler_read(t_soundfiler *x, t_symbol *s, goto usage; argc -= 2; argv += 2; } - else if (!strcmp(flag, "nframes")) - { - if (argc < 2 || argv[1].a_type != A_FLOAT || - ((nframes = argv[1].a_w.w_float) < 0)) - goto usage; - argc -= 2; argv += 2; - } else if (!strcmp(flag, "raw")) { if (argc < 5 || diff --git a/pd/src/g_array.c b/pd/src/g_array.c index 1b44e548..543823f6 100644 --- a/pd/src/g_array.c +++ b/pd/src/g_array.c @@ -1051,7 +1051,7 @@ static void garray_save(t_gobj *z, t_binbuf *b) chunk = ARRAYWRITECHUNKSIZE; binbuf_addv(b, "si", gensym("#A"), n2); for (i = 0; i < chunk; i++) - binbuf_addv(b, "f", ((float *)(array->a_vec))[n2+i]); + binbuf_addv(b, "f", ((t_word *)(array->a_vec))[n2+i].w_float); binbuf_addv(b, ";"); n2 += chunk; } diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c index 5a52a07a..10f897c1 100644 --- a/pd/src/g_canvas.c +++ b/pd/src/g_canvas.c @@ -1048,12 +1048,12 @@ void canvas_loadbang(t_canvas *x) or something. Anyway, we just add the 2 pixels back here; seems we have to do this for linux but not MSW; not sure about MacOS. */ -#ifdef MSW -#define HORIZBORDER 0 -#define VERTBORDER 0 -#else +#ifdef __unix__ #define HORIZBORDER 2 #define VERTBORDER 2 +#else +#define HORIZBORDER 4 +#define VERTBORDER 4 #endif static void canvas_relocate(t_canvas *x, t_symbol *canvasgeom, diff --git a/pd/src/g_rtext.c b/pd/src/g_rtext.c index d65038c1..28becbdb 100644 --- a/pd/src/g_rtext.c +++ b/pd/src/g_rtext.c @@ -439,7 +439,10 @@ void rtext_key(t_rtext *x, int keynum, t_symbol *keysym) x->x_buf = resizebytes(x->x_buf, x->x_bufsize, newsize); x->x_bufsize = newsize; - if (n == '\n' || isprint(n)) +/* at Guenter's suggestion, use 'n>31' to test wither a character might +be printable in whatever 8-bit character set we find ourselves. */ + + if (n == '\n' || n > 31) { newsize = x->x_bufsize+1; x->x_buf = resizebytes(x->x_buf, x->x_bufsize, newsize); diff --git a/pd/src/g_scalar.c b/pd/src/g_scalar.c index b6788988..76d54007 100644 --- a/pd/src/g_scalar.c +++ b/pd/src/g_scalar.c @@ -195,45 +195,50 @@ static void scalar_getrect(t_gobj *z, t_glist *owner, *yp2 = y2; } -static void scalar_select(t_gobj *z, t_glist *owner, int state) +static void scalar_drawselectrect(t_scalar *x, t_glist *glist, int state) { - t_scalar *x = (t_scalar *)z; - t_symbol *templatesym = x->sc_template; - t_template *tmpl; - t_atom at; - t_gpointer gp; - gpointer_init(&gp); - gpointer_setglist(&gp, owner, x); - SETPOINTER(&at, &gp); if (state) { int x1, y1, x2, y2; - if (tmpl = template_findbyname(templatesym)) - template_notify(tmpl, gensym("select"), 1, &at); - gpointer_unset(&gp); - - scalar_getrect(z, owner, &x1, &y1, &x2, &y2); + + scalar_getrect(&x->sc_gobj, glist, &x1, &y1, &x2, &y2); x1--; x2++; y1--; y2++; sys_vgui(".x%lx.c create line %d %d %d %d %d %d %d %d %d %d \ -width 0 -fill blue -tags select%lx\n", - glist_getcanvas(owner), x1, y1, x1, y2, x2, y2, x2, y1, x1, y1, + glist_getcanvas(glist), x1, y1, x1, y2, x2, y2, x2, y1, x1, y1, x); } else { - sys_vgui(".x%lx.c delete select%lx\n", glist_getcanvas(owner), x); - if (tmpl = template_findbyname(templatesym)) - template_notify(tmpl, gensym("deselect"), 1, &at); - + sys_vgui(".x%lx.c delete select%lx\n", glist_getcanvas(glist), x); } } +static void scalar_select(t_gobj *z, t_glist *owner, int state) +{ + t_scalar *x = (t_scalar *)z; + t_template *tmpl; + t_symbol *templatesym = x->sc_template; + t_atom at; + t_gpointer gp; + gpointer_init(&gp); + gpointer_setglist(&gp, owner, x); + SETPOINTER(&at, &gp); + if (tmpl = template_findbyname(templatesym)) + template_notify(tmpl, (state ? gensym("select") : gensym("deselect")), + 1, &at); + gpointer_unset(&gp); + scalar_drawselectrect(x, owner, state); +} + static void scalar_displace(t_gobj *z, t_glist *glist, int dx, int dy) { t_scalar *x = (t_scalar *)z; t_symbol *templatesym = x->sc_template; t_template *template = template_findbyname(templatesym); t_symbol *zz; + t_atom at[3]; + t_gpointer gp; int xonset, yonset, xtype, ytype, gotx, goty; if (!template) { @@ -252,12 +257,13 @@ static void scalar_displace(t_gobj *z, t_glist *glist, int dx, int dy) if (goty) *(t_float *)(((char *)(x->sc_vec)) + yonset) += dy * (glist_pixelstoy(glist, 1) - glist_pixelstoy(glist, 0)); + gpointer_init(&gp); + gpointer_setglist(&gp, glist, x); + SETPOINTER(&at[0], &gp); + SETFLOAT(&at[1], (float)dx); + SETFLOAT(&at[2], (float)dy); + template_notify(template, gensym("displace"), 2, at); scalar_redraw(x, glist); - if (glist_isselected(glist, z)) - { - scalar_select(z, glist, 0); - scalar_select(z, glist, 1); - } } static void scalar_activate(t_gobj *z, t_glist *owner, int state) @@ -299,6 +305,11 @@ static void scalar_vis(t_gobj *z, t_glist *owner, int vis) if (!wb) continue; (*wb->w_parentvisfn)(y, owner, x->sc_vec, template, basex, basey, vis); } + if (glist_isselected(owner, &x->sc_gobj)) + { + scalar_drawselectrect(x, owner, 0); + scalar_drawselectrect(x, owner, 1); + } sys_unqueuegui(x); } diff --git a/pd/src/g_template.c b/pd/src/g_template.c index 3d00b5dd..f5519e65 100644 --- a/pd/src/g_template.c +++ b/pd/src/g_template.c @@ -1129,7 +1129,8 @@ static void curve_vis(t_gobj *z, t_glist *glist, int i, n = x->x_npoints; t_fielddesc *f = x->x_vec; - if (!fielddesc_getfloat(&x->x_vis, template, data, 0)) + /* see comment in plot_vis() */ + if (vis && !fielddesc_getfloat(&x->x_vis, template, data, 0)) return; if (vis) { @@ -1269,7 +1270,7 @@ static int curve_click(t_gobj *z, t_glist *glist, bestn = i; } } - if (besterror > 10) + if (besterror > 6) return (0); if (doit) { @@ -1656,11 +1657,19 @@ static void plot_vis(t_gobj *z, t_glist *glist, int nelem; char *elem; t_fielddesc *xfielddesc, *yfielddesc, *wfielddesc; - + /* even if the array is "invisible", if its visibility is + set by an instance variable you have to explicitly erase it, + because the flag could earlier have been on when we were getting + drawn. Rather than look to try to find out whether we're + visible we just do the erasure. At the TK level this should + cause no action because the tag matches nobody. LATER we + might want to optimize this somehow. Ditto the "vis()" routines + for other drawing instructions. */ + if (plot_readownertemplate(x, data, template, &elemtemplatesym, &array, &linewidth, &xloc, &xinc, &yloc, &style, &vis, &scalarvis, &xfielddesc, &yfielddesc, &wfielddesc) || - ((vis == 0) && tovis) /* FIXME - why is 'tovis' flag necessary? */ + ((vis == 0) && tovis) /* see above for 'tovis' */ || array_getfields(elemtemplatesym, &elemtemplatecanvas, &elemtemplate, &elemsize, xfielddesc, yfielddesc, wfielddesc, &xonset, &yonset, &wonset)) @@ -2108,7 +2117,8 @@ static void drawnumber_vis(t_gobj *z, t_glist *glist, { t_drawnumber *x = (t_drawnumber *)z; - if (!fielddesc_getfloat(&x->x_vis, template, data, 0)) + /* see comment in plot_vis() */ + if (vis && !fielddesc_getfloat(&x->x_vis, template, data, 0)) return; if (vis) { diff --git a/pd/src/m_binbuf.c b/pd/src/m_binbuf.c index e12bad5f..69580741 100644 --- a/pd/src/m_binbuf.c +++ b/pd/src/m_binbuf.c @@ -388,7 +388,7 @@ void binbuf_restore(t_binbuf *x, int argc, t_atom *argv) } -#define MSTACKSIZE 2048 +#define MSTACKSIZE 10000 /* FIXME -- make this grow as needed */ void binbuf_print(t_binbuf *x) { diff --git a/pd/src/m_sched.c b/pd/src/m_sched.c index 82c4c5d7..bce50cd5 100644 --- a/pd/src/m_sched.c +++ b/pd/src/m_sched.c @@ -396,7 +396,7 @@ int m_scheduler( void) #endif sys_clearhist(); - if (sys_sleepgrain < 1000) + if (sys_sleepgrain < 100) sys_sleepgrain = sys_schedadvance/4; if (sys_sleepgrain < 100) sys_sleepgrain = 100; diff --git a/pd/src/makefile.in b/pd/src/makefile.in index 8b41c5bf..33ac2b99 100644 --- a/pd/src/makefile.in +++ b/pd/src/makefile.in @@ -38,6 +38,10 @@ CFLAGS = @CFLAGS@ $(ARCH_CFLAGS) $(WARN_CFLAGS) $(CPPFLAGS) $(MORECFLAGS) SYSSRC += @SYSSRC@ +ASIOSRC = @ASIOSRC@ + +ASIOOBJ = $(ASIOSRC:.cpp=.o) + SRC = g_canvas.c g_graph.c g_text.c g_rtext.c g_array.c g_template.c g_io.c \ g_scalar.c g_traversal.c g_guiconnect.c g_readwrite.c g_editor.c \ g_all_guis.c g_bang.c g_hdial.c g_hslider.c g_mycanvas.c g_numbox.c \ @@ -91,6 +95,9 @@ $(OBJ) : %.o : %.c $(GOBJ) : %.o : %.c $(CC) $(CFLAGS) $(GFLAGS) $(GINCLUDE) -c -o $(OBJ_DIR)/$*.o $*.c +$(ASIOOBJ): %.o : %.cpp + $(CXX) $(CFLAGS) $(INCLUDE) -c -o $(OBJ_DIR)/$*.o $*.cpp + pd: $(PDEXEC) gui: $(BIN_DIR)/$(GUINAME) @@ -132,6 +139,12 @@ $(BIN_DIR)/libPdTcl.dylib: $(GOBJ) $(GSRC) @executable_path/../Frameworks/Tk.framework/Versions/8.4/Tk \ ../bin/libPdTcl.dylib +# this is for Windows/MinGW (only?) +$(BIN_DIR)/pdtcl.dll: $(GOBJ) + cd $(BIN_DIR); dllwrap --export-all-symbols --output-def pdtcl.def \ + --output-lib=pdtcl.a --dllname=$(GUINAME) $(OBJ_DIR)/t_tkcmd.o $(LIB) $(GLIB) + strip --strip-unneeded $(BIN_DIR)/pdtcl.dll + externs: cd ../extra/bonk~;make @EXTERNTARGET@ cd ../extra/choice;make @EXTERNTARGET@ diff --git a/pd/src/makefile.nt b/pd/src/makefile.nt index fcc70aaa..fc624896 100644 --- a/pd/src/makefile.nt +++ b/pd/src/makefile.nt @@ -119,7 +119,7 @@ gui: ..\bin\pdtcl.dll s_entry_com.obj: s_entry.c copy s_entry.c s_entry_com.c - cl /c s_entry_com.c + cl /c -DCOMMANDVERSION s_entry_com.c del s_entry_com.c ..\bin\pd.com: s_entry_com.obj ..\bin\pd.lib diff --git a/pd/src/notes.txt b/pd/src/notes.txt index 266b2939..cc709392 100644 --- a/pd/src/notes.txt +++ b/pd/src/notes.txt @@ -17,6 +17,10 @@ turn on paMacCore_ChangeDeviceParameters for mac (pa_mac_core.h) Gnome: why don't windows pop up when clicked on? problems: +fix declare to update current patch when changed +objects on GOP don't erase if you edit the GOP while they're showing +MSTACKSIZE limitation in m_binbuf.c +add -stack option to make 'regular' stack larger TK menu on Windows says "wish" activating windows in Gnome? help browser broke on Panurge @@ -51,6 +55,7 @@ real-time spectrum grapher document ||, |, etc, better features: +clickles connection (hit 'c' key or something) messages to suppress menus&accelerators, and invisibilize Pd window machine-independent fonts callback scheduling on Mac @@ -96,13 +101,14 @@ editing: (also, a way to make multiple connections?) data: +make a 2-pass proecss for finding hot spot closes to any given click +replace list element with binbuf?? hooks for table mousing, other changes (scalars?) data to save as succession of "list" messages that textfile can store, etc. implement list field (GOP or subwindow, perhaps GOP could suppress bounds rect?) -fix blue selection rectangle to update if selected datum is redrawn data copy/paste doesn't check templates aren't changed arrays of non-existent templates crash -vget, vset traversal objects +vget, vset traversal objects, pointer == and select equivalents cursor to show (x, y) location improve typing at drawnumbers sublists should display on parent if desired? (new drawing instruction) @@ -112,6 +118,7 @@ append doesn't do symbols yet. more features: +clean out IRIX stuff "-march=pentium4 -O2 -mfpmath=sse -msse -msse2 -mmmx" ? try to improve for AMD - try "-march=athlon-xp -msse2" search for -mcpu=cpu-type in man gcc. diff --git a/pd/src/s_audio_alsa.c b/pd/src/s_audio_alsa.c index 83530de9..6733182d 100644 --- a/pd/src/s_audio_alsa.c +++ b/pd/src/s_audio_alsa.c @@ -145,7 +145,7 @@ static int alsaio_setup(t_alsa_dev *dev, int out, int *channels, int *rate, hw_params, &tmp_uint); check_error(err, "snd_pcm_hw_params_set_channels"); if (tmp_uint != (unsigned)*channels) - post("ALSA: set input channels to %d", tmp_uint); + post("ALSA: set %s channels to %d", (out?"output":"input"), tmp_uint); *channels = tmp_uint; dev->a_channels = *channels; @@ -158,10 +158,8 @@ static int alsaio_setup(t_alsa_dev *dev, int out, int *channels, int *rate, post("input sample rate %d", err); #endif - /* set the period - ie frag size */ - /* LATER try this to get a recommended period size... - right now, it trips an assertion failure in ALSA lib */ - + /* post("frag size %d, nfrags %d", frag_size, nfrags); */ + /* set "period size" */ #ifdef ALSAAPI9 err = snd_pcm_hw_params_set_period_size_near(dev->a_handle, hw_params, (snd_pcm_uframes_t)frag_size, 0); @@ -171,17 +169,6 @@ static int alsaio_setup(t_alsa_dev *dev, int out, int *channels, int *rate, hw_params, &tmp_snd_pcm_uframes, 0); #endif check_error(err, "snd_pcm_hw_params_set_period_size_near (input)"); - - /* set the number of periods - ie numfrags */ -#ifdef ALSAAPI9 - err = snd_pcm_hw_params_set_periods_near(dev->a_handle, - hw_params, nfrags, 0); -#else - tmp_uint = nfrags; - err = snd_pcm_hw_params_set_periods_near(dev->a_handle, - hw_params, &tmp_uint, 0); -#endif - check_error(err, "snd_pcm_hw_params_set_periods_near (input)"); /* set the buffer size */ #ifdef ALSAAPI9 @@ -429,7 +416,6 @@ int alsa_send_dacs(void) if (snd_pcm_status_get_avail(alsa_status) < transfersize) return SENDDACS_NO; } - /* do output */ for (iodev = 0, fp1 = sys_soundout, ch = 0; iodev < alsa_noutdev; iodev++) { diff --git a/pd/src/s_entry.c b/pd/src/s_entry.c index eb49cfc1..5cef73cc 100644 --- a/pd/src/s_entry.c +++ b/pd/src/s_entry.c @@ -3,7 +3,11 @@ that externs can link back to functions defined in pd. */ int sys_main(int argc, char **argv); -#ifdef MSW +/* + * gcc does not support the __try stuff, only MSVC. Also, MinGW allows you to + * use main() instead of WinMain(). <hans@at.or.at> + */ +#if defined(_MSC_VER) && !defined(COMMANDVERSION) #include <windows.h> #include <stdio.h> @@ -21,11 +25,11 @@ int WINAPI WinMain(HINSTANCE hInstance, } } -#else /* not MSW */ +#else /* not _MSC_VER ... */ int main(int argc, char **argv) { return (sys_main(argc, argv)); } -#endif +#endif /* _MSC_VER */ diff --git a/pd/src/s_inter.c b/pd/src/s_inter.c index 4b73e8d1..e6c69bf6 100644 --- a/pd/src/s_inter.c +++ b/pd/src/s_inter.c @@ -23,16 +23,19 @@ that didn't really belong anywhere. */ #ifdef HAVE_BSTRING_H #include <bstring.h> #endif -#ifdef MSW +#ifdef _WIN32 #include <io.h> #include <fcntl.h> #include <process.h> #include <winsock.h> #include <windows.h> +# ifdef _MSC_VER typedef int pid_t; +# endif typedef int socklen_t; #define EADDRINUSE WSAEADDRINUSE #endif + #include <stdarg.h> #include <signal.h> #include <fcntl.h> @@ -150,13 +153,15 @@ double sys_getrealtime(void) #endif } +extern int sys_nosleep; + static int sys_domicrosleep(int microsec, int pollem) { struct timeval timout; int i, didsomething = 0; t_fdpoll *fp; timout.tv_sec = 0; - timout.tv_usec = microsec; + timout.tv_usec = (sys_nosleep ? 0 : microsec); if (pollem) { fd_set readset, writeset, exceptset; @@ -1153,8 +1158,8 @@ int sys_startgui(const char *guidir) to make it timeshare with the rest of the system. (Version 0.33P2 : if there's no GUI, the watchdog pinging is done from the scheduler idle routine in this process instead.) */ - int pipe9[2], watchpid; + if (pipe(pipe9) < 0) { seteuid(getuid()); /* lose setuid priveliges */ diff --git a/pd/src/s_main.c b/pd/src/s_main.c index ebaa661b..c170aec5 100644 --- a/pd/src/s_main.c +++ b/pd/src/s_main.c @@ -81,6 +81,7 @@ static int sys_nchout = -1; static int sys_chinlist[MAXAUDIOINDEV]; static int sys_choutlist[MAXAUDIOOUTDEV]; +int sys_nosleep = 0; /* skip all "sleep" calls and spin instead */ t_sample* get_sys_soundout() { return sys_soundout; } t_sample* get_sys_soundin() { return sys_soundin; } int* get_sys_main_advance() { return &sys_main_advance; } @@ -397,6 +398,7 @@ static char *(usagemessage[]) = { "-rt or -realtime -- use real-time priority\n", "-nrt -- don't use real-time priority\n", #endif +"-nosleep -- spin, don't sleep (may lower latency on multi-CPUs)\n", }; static void sys_parsedevlist(int *np, int *vecp, int max, char *str) @@ -585,7 +587,7 @@ int sys_argparse(int argc, char **argv) } else if (!strcmp(*argv, "-sleepgrain") && (argc > 1)) { - sys_sleepgrain = 1000 * atoi(argv[1]); + sys_sleepgrain = 1000 * atof(argv[1]); argc -= 2; argv += 2; } else if (!strcmp(*argv, "-nodac")) @@ -829,6 +831,11 @@ int sys_argparse(int argc, char **argv) argc--; argv++; } #endif + else if (!strcmp(*argv, "-nosleep")) + { + sys_nosleep = 1; + argc--; argv++; + } else if (!strcmp(*argv, "-soundindev") || !strcmp(*argv, "-audioindev")) { diff --git a/pd/src/s_path.c b/pd/src/s_path.c index 14620eac..97591d4c 100644 --- a/pd/src/s_path.c +++ b/pd/src/s_path.c @@ -30,6 +30,13 @@ #include <fcntl.h> #include <ctype.h> +#ifdef _LARGEFILE64_SOURCE +# define open open64 +# define lseek lseek64 +# define fstat fstat64 +# define stat stat64 +#endif + t_namelist *sys_externlist; t_namelist *sys_searchpath; t_namelist *sys_helppath; diff --git a/pd/src/u_main.tk b/pd/src/u_main.tk index a05d145f..8c43905b 100644 --- a/pd/src/u_main.tk +++ b/pd/src/u_main.tk @@ -212,6 +212,7 @@ set untitled_number 1 set untitled_directory [pwd] set saveas_client doggy set pd_opendir $untitled_directory +set pd_savedir $untitled_directory set pd_undoaction no set pd_redoaction no set pd_undocanvas no @@ -3414,8 +3415,7 @@ proc pdtk_openpanel {target localdir} { if {$localdir == ""} { set localdir $pd_opendir } - set filename [tk_getOpenFile \ - -initialdir $localdir] + set filename [tk_getOpenFile -initialdir $localdir] if {$filename != ""} { set directory [string range $filename 0 \ [expr [string last / $filename ] - 1]] @@ -3426,11 +3426,11 @@ proc pdtk_openpanel {target localdir} { } proc pdtk_savepanel {target localdir} { + global pd_savedir if {$localdir == ""} { - set filename [tk_getSaveFile] - } else { - set filename [tk_getSaveFile -initialdir $localdir] + set localdir $pd_savedir } + set filename [tk_getSaveFile -initialdir $localdir] if {$filename != ""} { pd [concat $target callback [pdtk_enquote $filename] \;] } diff --git a/pd/src/x_list.c b/pd/src/x_list.c index 23989585..8156704a 100644 --- a/pd/src/x_list.c +++ b/pd/src/x_list.c @@ -50,6 +50,7 @@ typedef struct _alist { t_pd l_pd; /* object to point inlets to */ int l_n; /* number of items */ + int l_npointer; /* number of pointers */ t_listelem *l_vec; /* pointer to items */ } t_alist; @@ -95,7 +96,7 @@ t_class *alist_class; static void alist_init(t_alist *x) { x->l_pd = alist_class; - x->l_n = 0; + x->l_n = x->l_npointer = 0; x->l_vec = 0; } @@ -122,11 +123,16 @@ static void alist_list(t_alist *x, t_symbol *s, int argc, t_atom *argv) return; } x->l_n = argc; + x->l_npointer = 0; for (i = 0; i < argc; i++) { x->l_vec[i].l_a = argv[i]; if (x->l_vec[i].l_a.a_type == A_POINTER) + { + x->l_npointer++; gpointer_copy(x->l_vec[i].l_a.a_w.w_gpointer, &x->l_vec[i].l_p); + x->l_vec[i].l_a.a_w.w_gpointer = &x->l_vec[i].l_p; + } } } @@ -141,12 +147,17 @@ static void alist_anything(t_alist *x, t_symbol *s, int argc, t_atom *argv) return; } x->l_n = argc+1; + x->l_npointer = 0; SETSYMBOL(&x->l_vec[0].l_a, s); for (i = 0; i < argc; i++) { x->l_vec[i+1].l_a = argv[i]; if (x->l_vec[i+1].l_a.a_type == A_POINTER) + { + x->l_npointer++; gpointer_copy(x->l_vec[i+1].l_a.a_w.w_gpointer, &x->l_vec[i+1].l_p); + x->l_vec[i].l_a.a_w.w_gpointer = &x->l_vec[i].l_p; + } } } @@ -157,6 +168,29 @@ static void alist_toatoms(t_alist *x, t_atom *to) to[i] = x->l_vec[i].l_a; } + +static void alist_clone(t_alist *x, t_alist *y) +{ + int i; + y->l_pd = alist_class; + y->l_n = x->l_n; + y->l_npointer = x->l_npointer; + if (!(y->l_vec = (t_listelem *)getbytes(y->l_n * sizeof(*y->l_vec)))) + { + y->l_n = 0; + error("list_alloc: out of memory"); + } + else for (i = 0; i < x->l_n; i++) + { + y->l_vec[i].l_a = x->l_vec[i].l_a; + if (y->l_vec[i].l_a.a_type == A_POINTER) + { + gpointer_copy(y->l_vec[i].l_a.a_w.w_gpointer, &y->l_vec[i].l_p); + y->l_vec[i].l_a.a_w.w_gpointer = &y->l_vec[i].l_p; + } + } +} + static void alist_setup(void) { alist_class = class_new(gensym("list inlet"), @@ -192,8 +226,19 @@ static void list_append_list(t_list_append *x, t_symbol *s, int n, outc = x->x_alist.l_n + argc; ATOMS_ALLOCA(outv, outc); atoms_copy(argc, argv, outv); - alist_toatoms(&x->x_alist, outv+argc); - outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); + if (x->x_alist.l_npointer) + { + t_alist y; + alist_clone(&x->x_alist, &y); + alist_toatoms(&y, outv+argc); + outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); + alist_clear(&y); + } + else + { + alist_toatoms(&x->x_alist, outv+argc); + outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); + } ATOMS_FREEA(outv, outc); } @@ -205,8 +250,19 @@ static void list_append_anything(t_list_append *x, t_symbol *s, ATOMS_ALLOCA(outv, outc); SETSYMBOL(outv, s); atoms_copy(argc, argv, outv + 1); - alist_toatoms(&x->x_alist, outv + 1 + argc); - outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); + if (x->x_alist.l_npointer) + { + t_alist y; + alist_clone(&x->x_alist, &y); + alist_toatoms(&y, outv + 1 + argc); + outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); + alist_clear(&y); + } + else + { + alist_toatoms(&x->x_alist, outv + 1 + argc); + outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); + } ATOMS_FREEA(outv, outc); } @@ -251,22 +307,46 @@ static void list_prepend_list(t_list_prepend *x, t_symbol *s, t_atom *outv; int n, outc = x->x_alist.l_n + argc; ATOMS_ALLOCA(outv, outc); - alist_toatoms(&x->x_alist, outv); atoms_copy(argc, argv, outv + x->x_alist.l_n); - outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); + if (x->x_alist.l_npointer) + { + t_alist y; + alist_clone(&x->x_alist, &y); + alist_toatoms(&y, outv); + outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); + alist_clear(&y); + } + else + { + alist_toatoms(&x->x_alist, outv); + outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); + } ATOMS_FREEA(outv, outc); } + + static void list_prepend_anything(t_list_prepend *x, t_symbol *s, int argc, t_atom *argv) { t_atom *outv; int n, outc = x->x_alist.l_n + argc + 1; ATOMS_ALLOCA(outv, outc); - alist_toatoms(&x->x_alist, outv); SETSYMBOL(outv + x->x_alist.l_n, s); atoms_copy(argc, argv, outv + x->x_alist.l_n + 1); - outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); + if (x->x_alist.l_npointer) + { + t_alist y; + alist_clone(&x->x_alist, &y); + alist_toatoms(&y, outv); + outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); + alist_clear(&y); + } + else + { + alist_toatoms(&x->x_alist, outv); + outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); + } ATOMS_FREEA(outv, outc); } |