aboutsummaryrefslogtreecommitdiff
path: root/pd
diff options
context:
space:
mode:
authorMiller Puckette <millerpuckette@users.sourceforge.net>2005-05-30 03:01:38 +0000
committerMiller Puckette <millerpuckette@users.sourceforge.net>2005-05-30 03:01:38 +0000
commit47729b52cb85e8a52bf2e6bbf8ee9a810ed331e1 (patch)
treeb001d3f3bdf3539d928535e47a965c72f7044a26 /pd
parentfcba84c01167d5be4e4ed70619fda85cb63804fe (diff)
Add new portmidi and update portaudio. CHanges to makefile.nt and various
sources. Checking that I'm in sync with "help" file changes. I ended up deleting help files in extra and recreating them under the new names. svn path=/trunk/; revision=3091
Diffstat (limited to 'pd')
-rw-r--r--pd/extra/bonk~/help-bonk~.pd162
-rw-r--r--pd/extra/choice/help-choice.pd58
-rw-r--r--pd/extra/fiddle~/help-fiddle~.pd142
-rw-r--r--pd/extra/help-complex-mod~.pd26
-rw-r--r--pd/extra/help-expr.pd497
-rw-r--r--pd/extra/help-hilbert~.pd18
-rw-r--r--pd/extra/help-rev1~.pd119
-rw-r--r--pd/extra/help-rev2~.pd134
-rw-r--r--pd/extra/help-rev3~.pd136
-rw-r--r--pd/extra/loop~/help-loop~.pd74
-rw-r--r--pd/extra/lrshift~/help-rlshift~.pd29
-rw-r--r--pd/extra/pique/help-pique.pd33
-rw-r--r--pd/portmidi/Makefile77
-rw-r--r--pd/portmidi/README.txt62
-rw-r--r--pd/portmidi/portmidi.dsp124
-rw-r--r--pd/portmidi/portmidi.dsw158
-rw-r--r--pd/portmidi_osx/Makefile24
-rw-r--r--pd/portmidi_osx/README12
-rw-r--r--pd/portmidi_osx/pmdarwin.c78
-rw-r--r--pd/portmidi_osx/pminternal.h100
-rw-r--r--pd/portmidi_osx/pmmacosx.c439
-rw-r--r--pd/portmidi_osx/pmmacosx.h4
-rw-r--r--pd/portmidi_osx/pmtest.c142
-rw-r--r--pd/portmidi_osx/pmutil.c86
-rw-r--r--pd/portmidi_osx/pmutil.h44
-rw-r--r--pd/portmidi_osx/portmidi.c357
-rw-r--r--pd/portmidi_osx/portmidi.h341
-rw-r--r--pd/portmidi_osx/portmidi_osx_change_log.txt70
-rw-r--r--pd/portmidi_osx/porttime.h33
-rw-r--r--pd/portmidi_osx/ptdarwin.c58
30 files changed, 421 insertions, 3216 deletions
diff --git a/pd/extra/bonk~/help-bonk~.pd b/pd/extra/bonk~/help-bonk~.pd
deleted file mode 100644
index 5102e860..00000000
--- a/pd/extra/bonk~/help-bonk~.pd
+++ /dev/null
@@ -1,162 +0,0 @@
-#N canvas 107 94 958 626 10;
-#X obj 320 579 print;
-#X floatatom 314 501 0 0 0;
-#X obj 320 549 spigot;
-#X msg 314 471 0;
-#X msg 351 471 1;
-#X msg 442 427 bang;
-#X obj 429 518 bonk~;
-#X msg 442 244 learn 1;
-#X msg 442 304 learn 0;
-#X msg 437 486 print;
-#X obj 390 467 adc~;
-#X text 320 597 cooked;
-#X msg 565 76 \; pd dsp 1;
-#X obj 257 579 print;
-#X floatatom 251 501 0 0 0;
-#X obj 257 549 spigot;
-#X msg 251 471 0;
-#X msg 282 471 1;
-#X text 257 597 raw;
-#N canvas 366 126 600 400 synth 0;
-#X obj 112 24 r bonk-cooked;
-#X obj 112 49 unpack;
-#X obj 112 99 * 12;
-#X obj 112 124 div 7;
-#X obj 112 74 + 1;
-#X obj 112 174 mtof;
-#X obj 112 224 osc~;
-#X obj 112 249 cos~;
-#X obj 112 149 + 47;
-#X obj 209 247 line~;
-#X obj 209 272 *~;
-#X obj 209 297 lop~ 500;
-#X obj 112 274 *~;
-#X obj 103 361 dac~;
-#X obj 253 165 dbtorms;
-#X obj 253 115 * 0.5;
-#X obj 253 140 + 50;
-#X obj 211 189 f;
-#X msg 173 159 bang;
-#X obj 258 83 inlet;
-#X obj 111 307 hip~ 5;
-#X msg 34 24 0 60;
-#X obj 112 199 sig~;
-#X msg 209 222 \$1 \, 0 200;
-#X connect 0 0 1 0;
-#X connect 1 0 4 0;
-#X connect 2 0 3 0;
-#X connect 3 0 8 0;
-#X connect 4 0 2 0;
-#X connect 5 0 18 0;
-#X connect 5 0 22 0;
-#X connect 6 0 7 0;
-#X connect 7 0 12 0;
-#X connect 8 0 5 0;
-#X connect 9 0 10 0;
-#X connect 9 0 10 1;
-#X connect 10 0 11 0;
-#X connect 11 0 12 1;
-#X connect 12 0 20 0;
-#X connect 14 0 17 1;
-#X connect 15 0 16 0;
-#X connect 16 0 14 0;
-#X connect 17 0 23 0;
-#X connect 18 0 17 0;
-#X connect 19 0 15 0;
-#X connect 20 0 13 1;
-#X connect 20 0 13 0;
-#X connect 21 0 1 0;
-#X connect 22 0 6 0;
-#X connect 23 0 9 0;
-#X restore 804 86 pd synth;
-#X obj 454 549 s bonk-cooked;
-#X floatatom 804 63 0 0 0;
-#X msg 804 33 0;
-#X msg 442 274 learn 10;
-#X msg 442 334 forget;
-#X msg 442 364 write templates.txt;
-#X msg 442 394 read templates.txt;
-#X msg 835 33 90;
-#X msg 442 120 thresh 6 50;
-#X text 8 70 The Bonk object takes an audio signal input and looks
-for "attacks" defined as sharp changes in the spectral envelope of
-the incoming sound. Optionally \, and less reliably \, you can have
-Bonk check the attack against a collection of stored templates to try
-to guess which of two or more instruments was hit. Bonk is described
-theoretically in the 1998 ICMC proceedings \, reprinted on http://man104nfs.ucsd.edu/~mpuckett.
-;
-#X text 470 70 click here;
-#X text 471 83 to start DSP;
-#X text 8 191 Bonk's two outputs are the raw spectrum of the attack
-(provided as a list of 11 numbers giving the signal "loudness" in the
-11 frequency bands used) \, and the "cooked" output which gives only
-an instrument number (counting up from zero) and a "velocity". The
-instrumnent number is significant only if Bonk has a "template set"
-in memory.;
-#X text 8 368 In this patch \, after starting DSP \, you can print
-out the raw or cooked output using the two "spigots" or listen to a
-synthesizer output by raising its volume.;
-#X text 259 448 enable printout;
-#X text 705 32 output volume;
-#X text 719 50 (0-100);
-#X text 533 118 Set low and high thresholds. Signal growth must exceed
-the high one and then fall to the low one to make an attack.;
-#X text 533 151 Minimum velocity to output (quieter notes are ignored.)
-;
-#X msg 442 180 mask 4 0.7;
-#X msg 442 214 debounce 0;
-#X text 8 299 Bonk's analysis is carried out on a 256-point window
-(6 msec at 44.1 kHz) and by default the analysis period is 128 samples.
-The analysis period can be specified as Bonk's creation argument but
-must be a multiple of 64;
-#X text 532 219 Minimum time (msec) between attacks;
-#X text 532 170 Describes how energy in each frequency band masks later
-energy in the band. Here the masking is total for 4 analysis periods
-and then drops by 0.7 each period.;
-#X text 530 244 Forget all templates and start learning new ones. The
-argument gives the number of times you will hit each instrument (10
-recommended.) Turn on the output volume above for audible feedback
-as you train Bonk. "Learn 0" exits learn mode.;
-#X text 530 328 Forget the last template. In Learn mode \, use "forget"
-to erase and record over a template.;
-#X text 595 368 Write templates to a file in text-editable format.
-;
-#X text 596 398 Read templates from a file.;
-#X text 538 493 Print out all settings and templates.;
-#X msg 442 150 minvel 10;
-#X text 538 426 Poll the current spectrum via "raw" outlet \, You can
-set a very high threshold if you don't want attacks mixed in.;
-#X text 218 12 BONK - an attack detector for small percussion instruments
-;
-#X msg 634 517 print;
-#X msg 437 456 debug 0;
-#X text 538 466 turn debugging on or off.;
-#X connect 1 0 2 1;
-#X connect 2 0 0 0;
-#X connect 3 0 1 0;
-#X connect 4 0 1 0;
-#X connect 5 0 6 0;
-#X connect 6 0 15 0;
-#X connect 6 1 2 0;
-#X connect 6 1 20 0;
-#X connect 7 0 6 0;
-#X connect 8 0 6 0;
-#X connect 9 0 6 0;
-#X connect 10 0 6 0;
-#X connect 14 0 15 1;
-#X connect 15 0 13 0;
-#X connect 16 0 14 0;
-#X connect 17 0 14 0;
-#X connect 21 0 19 0;
-#X connect 22 0 21 0;
-#X connect 23 0 6 0;
-#X connect 24 0 6 0;
-#X connect 25 0 6 0;
-#X connect 26 0 6 0;
-#X connect 27 0 21 0;
-#X connect 28 0 6 0;
-#X connect 39 0 6 0;
-#X connect 40 0 6 0;
-#X connect 49 0 6 0;
-#X connect 53 0 6 0;
diff --git a/pd/extra/choice/help-choice.pd b/pd/extra/choice/help-choice.pd
deleted file mode 100644
index 0677db87..00000000
--- a/pd/extra/choice/help-choice.pd
+++ /dev/null
@@ -1,58 +0,0 @@
-#N canvas 16 5 609 600 12;
-#X obj 8 195 choice;
-#X msg 41 86 print;
-#X msg 29 63 clear;
-#X msg 8 34 add 1 0 0 \, add 0 1 0 \, add 0 0 1 \, add 1 1 1 \, add
-1 1 0;
-#X obj 77 171 pack 0 0 0;
-#X floatatom 182 125 0 0 0 0 - - -;
-#X floatatom 148 125 0 0 0 0 - - -;
-#X floatatom 115 125 0 0 0 0 - - -;
-#X obj 77 147 f;
-#X msg 77 125 bang;
-#X floatatom 8 216 0 0 0 0 - - -;
-#X obj 71 196 choice 1;
-#X floatatom 71 217 0 0 0 0 - - -;
-#X obj 76 4 choice;
-#X text 135 3 - search for a best match to an incoming list;
-#X text 19 243 The choice object holds a list of vectors \, each having
-up to ten elements. When sent a list of numbers \, it outputs the index
-of the known vector that matches most closely. The quality of the match
-is the dot product of the two vectors after normalizing them \, i.e.
-\, the vector whose direction is closest to that of the input wins.
-;
-#X text 19 340 If given a nonzero creation argument \, choice tries
-to avoid repetitious outputs by weighting less recently output vectors
-preferentially.;
-#X text 20 389 You can use this to choose interactively between a number
-of behaviors depending on their attributes. For example \, you might
-have stored a number of melodies \, of which some are syncopated \,
-some chromatic \, some are more than 100 years old \, some are bugle
-calls \, and some are Christmas carols. You could then ask to find
-a syncopated bugle call (1 \, 0 \, 0 \, 1 \, 0) and you'll get the
-thing most closely matching the request.;
-#X text 19 514 You can use numbers other than 0 and 1 to indicate relative
-strengths of the attributes \, or even use negative numbers to indicate
-opposites \, either in the incoming lists or in the stored ones.;
-#X text 320 572 updated for Pd version-0.30;
-#X text 79 62 delete all stored vectors;
-#X text 498 34 add vectors;
-#X text 94 84 debugging printout;
-#X text 69 104 tweak the numbers and hit "bang" to input a list;
-#X text 151 197 creation argument to avoid repeated outout;
-#X text 108 219 output is the index of best match \, counting from
-zero;
-#X connect 0 0 10 0;
-#X connect 1 0 0 0;
-#X connect 2 0 0 0;
-#X connect 2 0 11 0;
-#X connect 3 0 0 0;
-#X connect 3 0 11 0;
-#X connect 4 0 0 0;
-#X connect 4 0 11 0;
-#X connect 5 0 4 2;
-#X connect 6 0 4 1;
-#X connect 7 0 8 1;
-#X connect 8 0 4 0;
-#X connect 9 0 8 0;
-#X connect 11 0 12 0;
diff --git a/pd/extra/fiddle~/help-fiddle~.pd b/pd/extra/fiddle~/help-fiddle~.pd
deleted file mode 100644
index f396725a..00000000
--- a/pd/extra/fiddle~/help-fiddle~.pd
+++ /dev/null
@@ -1,142 +0,0 @@
-#N canvas 93 26 980 745 10;
-#X obj 262 522 phasor~;
-#X obj 531 616 unpack;
-#X floatatom 531 666 0 0 0 0 - - -;
-#X msg 437 449 print;
-#X obj 262 500 sig~;
-#X floatatom 262 478 0 0 0 0 - - -;
-#X obj 262 456 mtof;
-#X floatatom 262 434 0 0 0 0 - - -;
-#X floatatom 545 643 0 0 0 0 - - -;
-#X obj 531 576 route 1 2 3 4;
-#X obj 614 616 unpack;
-#X floatatom 614 666 0 0 0 0 - - -;
-#X floatatom 628 643 0 0 0 0 - - -;
-#X obj 698 616 unpack;
-#X floatatom 698 666 0 0 0 0 - - -;
-#X floatatom 712 643 0 0 0 0 - - -;
-#X obj 389 616 unpack;
-#X floatatom 389 666 0 0 0 0 - - -;
-#X floatatom 403 643 0 0 0 0 - - -;
-#X obj 334 545 *~;
-#X obj 322 394 loadbang;
-#X obj 353 522 sig~;
-#X floatatom 353 500 0 0 0 0 - - -;
-#X msg 322 478 1;
-#X msg 353 478 0;
-#X floatatom 466 666 0 0 0 0 - - -;
-#X obj 281 666 print attack;
-#X obj 190 666 print pitch;
-#X msg 555 45 \; pd dsp 1;
-#X text 460 39 click here;
-#X text 460 61 to start DSP;
-#X text 226 4 FIDDLE - pitch estimator and sinusoidal peak finder;
-#X text 8 70 The Fiddle object estimates the pitch and amplitude of
-an incoming sound \, both continuously and as a stream of discrete
-"note" events. Fiddle optionally outputs a list of detected sinusoidal
-peaks used to make the pitch determination. Fiddle is described theoretically
-in the 1998 ICMC proceedings \, reprinted on http://man104nfs.ucsd.edu/~mpuckett.
-;
-#X text 8 170 Fiddle's creation arguments specify an analysis window
-size \, the maximum polyphony (i.e. \, the number of simultaneous "pitches"
-to try to find) \, the number of peaks in the spectrum to consider
-\, and the number of peaks \, if any \, to output "raw." The outlets
-give discrete pitch (a number) \, detected attacks in the amplitude
-envelope (a bang) \, one or more voices of continuous pitch and amplitude
-\, overall amplitude \, and optionally a sequence of messages with
-the peaks.;
-#X text 8 296 The analysis hop size is half the window size so in the
-example shown here \, one analysis is done every 512 samples (11.6
-msec at 44K1) \, and the analysis uses the most recent 1024 samples
-(23.2 msec at 44K1). The minimum frequency that Fiddle will report
-is 2-1/2 cycles per analysis windows \, or about 108 Hz. (just below
-MIDI 45.);
-#X text 669 535 number of pitch outlets (1-3 \, default 1);
-#X text 669 557 number of peaks to find (1-100 \, default 20);
-#X text 669 579 number of peaks to output (default 0.);
-#X msg 441 107 amp-range 40 50;
-#X msg 439 227 reattack 100 10;
-#X msg 438 282 npartial 7;
-#X msg 438 170 vibrato 50 0.5;
-#X text 560 91 a low and high amplitude threshold: if signal amplitude
-is below the low threshold \, no pitches or peaks are output. The high
-threshold is a minimum at which "cooked" outputs may appear.;
-#X text 560 152 A period in milliseconds (50) over which the raw pitch
-may not deviate more than an interval in half-tones (0.5) from the
-average pitch to report it as a note to the "cooked" pitch outlet.
-;
-#X text 560 213 A period in milliseconds (100) over which a re-attack
-is reported if the amplitude rises more than (1) dB. The re-attack
-will result in a "bang" in the attack outlet and may give rise to repeated
-notes in the cooked pitch output.;
-#X text 142 432 test input pitch;
-#X text 330 444 test input;
-#X text 330 457 amplitude;
-#X obj 410 545 fiddle~ 1024 1 20 3;
-#X text 538 690 individual sinusoidal components;
-#X text 466 688 amplitude;
-#X text 476 703 (dB);
-#X text 389 688 raw pitch;
-#X text 376 712 and amplitude;
-#X text 364 729 (up to 3 outputs);
-#X text 287 686 bang on;
-#X text 287 708 attack;
-#X text 185 686 cooked pitch;
-#X text 202 703 output;
-#X text 545 545 ------ arguments:;
-#X msg 262 412 57;
-#X msg 440 331 auto 1;
-#X msg 440 353 auto 0;
-#X msg 439 418 bang;
-#X text 561 416 poll current values --- useful if not in auto mode
-\,;
-#X text 560 274 Higher partials are weighed less strongly than lower
-ones in determining the pitch. This specifies the number of the partial
-(7) which will be weighted half as strongly as the fundamental.;
-#X text 560 335 start and stop "auto" mode (on by default.) If off
-\, output only appears on "bang" (poll mode).;
-#X text 561 448 print out all settings;
-#X text 669 513 window size (128-2048 \, default 1024);
-#X msg 440 375 npoints 2048;
-#X text 562 384 number of points in analysis window (power of 2 \,
-128-2048);
-#X msg 439 396 npoints 1024;
-#X connect 0 0 19 0;
-#X connect 1 0 2 0;
-#X connect 1 1 8 0;
-#X connect 3 0 48 0;
-#X connect 4 0 0 0;
-#X connect 5 0 4 0;
-#X connect 6 0 5 0;
-#X connect 7 0 6 0;
-#X connect 9 0 1 0;
-#X connect 9 1 10 0;
-#X connect 9 2 13 0;
-#X connect 10 0 11 0;
-#X connect 10 1 12 0;
-#X connect 13 0 14 0;
-#X connect 13 1 15 0;
-#X connect 16 0 17 0;
-#X connect 16 1 18 0;
-#X connect 19 0 48 0;
-#X connect 20 0 60 0;
-#X connect 20 0 23 0;
-#X connect 21 0 19 1;
-#X connect 22 0 21 0;
-#X connect 23 0 22 0;
-#X connect 24 0 22 0;
-#X connect 38 0 48 0;
-#X connect 39 0 48 0;
-#X connect 40 0 48 0;
-#X connect 41 0 48 0;
-#X connect 48 0 27 0;
-#X connect 48 1 26 0;
-#X connect 48 2 16 0;
-#X connect 48 3 25 0;
-#X connect 48 4 9 0;
-#X connect 60 0 7 0;
-#X connect 61 0 48 0;
-#X connect 62 0 48 0;
-#X connect 63 0 48 0;
-#X connect 69 0 48 0;
-#X connect 71 0 48 0;
diff --git a/pd/extra/help-complex-mod~.pd b/pd/extra/help-complex-mod~.pd
deleted file mode 100644
index 9e14904d..00000000
--- a/pd/extra/help-complex-mod~.pd
+++ /dev/null
@@ -1,26 +0,0 @@
-#N canvas 136 85 600 480 12;
-#X graph graph1 0 -1 882 1 279 209 579 39;
-#X array mod-output 882 float;
-#X pop;
-#X msg 84 256 bang \; pd dsp 1;
-#X floatatom 67 56;
-#X obj 67 186 complex-mod~;
-#X obj 67 84 phasor~ 440;
-#X obj 67 115 cos~;
-#X obj 106 138 cos~;
-#X obj 106 114 -~ 0.25;
-#X floatatom 145 152;
-#X text 93 351 The complex modulator takes two signals in which it considers to be the real and imaginary part of a complex-valued signal. It then does a complex multiplication by a sinusoud to shift all frequencies up or down by any frequency shift in Hz. See also hilbert~.;
-#X obj 69 298 tabwrite~ mod-output;
-#X text 149 204 right outlet;
-#X text 151 220 gives the other;
-#X text 149 236 sideband;
-#X connect 1 0 10 0;
-#X connect 2 0 4 0;
-#X connect 3 0 10 0;
-#X connect 4 0 5 0;
-#X connect 4 0 7 0;
-#X connect 5 0 3 0;
-#X connect 6 0 3 1;
-#X connect 7 0 6 0;
-#X connect 8 0 3 2;
diff --git a/pd/extra/help-expr.pd b/pd/extra/help-expr.pd
deleted file mode 100644
index adc575fb..00000000
--- a/pd/extra/help-expr.pd
+++ /dev/null
@@ -1,497 +0,0 @@
-#N canvas 70 36 1012 579 10;
-#X text 66 10 expression evaluation family - expr \, expr~ \, fexpr~
-;
-#X text 63 239 Syntyax:;
-#X text 64 311 $f#: float input variable;
-#X text 65 326 $s#: symbol input variable;
-#X text 553 90 Used for expr~ only:;
-#X text 553 105 $v#: signal (vector) input (vector by vector evaluation)
-;
-#X text 550 164 Used for fexpr~ only:;
-#X text 550 220 $y[n]: the output value indexed by n where n has to
-satisfy 0 > n >= -vector size.;
-#X text 550 248 (the vector size can be changed by the "block~" object.)
-;
-#X text 550 179 $x#[n]: the sample from inlet # indexed by n where
-n has to satisfy 0 => n >= -vector size \, ($x# is a shorthand for
-$x#[0] \, specifying the current sample);
-#X text 63 151 expr~ is used for expression evaluaion of signal data
-on the vector by vector basis;
-#X text 63 136 expr is used for expression evaluaion of control data
-;
-#X text 67 39 For a more detailed documentaion refer to http://www.crca.ucsd.edu/~yadegari/expr.html
-;
-#X text 64 254 The syntax is very close to how expressions are written
-in C. Variables are specified as follows where the '#' stands for the
-inlet number:;
-#X text 65 297 $i#: integer input variable;
-#X text 63 179 fexpr~ is used for expression evaluaion on sample level
-data \; i.e. \, filter design. Warning: fexpr~ is very cpu intensive.
-;
-#X text 633 12 updated for Pd 0.35 test 26 and expr* 0.4;
-#X text 67 85 you can define multiple expressoins in the same object.
-semicolon is used to separates the expressions.;
-#X text 635 294 $y -> $y1[-1];
-#X text 550 263 Shorthands: $x -> $x1[0];
-#X text 635 279 $x1 -> $x1[0] $x2 -> $x2[0] .....;
-#X text 635 309 $y1 -> $y1[-1] $y2 -> $y2[-1] .....;
-#N canvas 0 0 828 385 Examples 0;
-#X obj 33 151 expr 1;
-#X floatatom 197 119 0 0 0;
-#X floatatom 33 181 0 0 0;
-#X msg 33 123 bang;
-#X obj 101 149 expr 2 + 3;
-#X msg 101 122 bang;
-#X floatatom 101 177 0 0 0;
-#X floatatom 196 177 0 0 0;
-#X obj 196 149 expr 2+$f1;
-#X floatatom 34 220 0 0 0;
-#X floatatom 34 277 0 0 0;
-#X obj 34 249 expr $f1 * $f2;
-#X floatatom 113 220 0 0 0;
-#N canvas 0 0 450 300 graph1 0;
-#X array array1 10 float 0;
-#X coords 0 10 10 0 200 150 1;
-#X restore 584 180 graph;
-#X floatatom 35 315 0 0 0;
-#X floatatom 35 371 0 0 0;
-#X floatatom 194 219 0 0 0;
-#X floatatom 194 276 0 0 0;
-#X obj 194 248 expr $s2[$f1];
-#X msg 267 220 symbol array1;
-#X obj 35 343 expr sin(2 * 3.14159 * $f1 / 360);
-#X msg 330 281 \; array1 1 4 2 8 5 6 1 4 2 8 5 6;
-#X floatatom 310 184 5 0 0;
-#X floatatom 395 186 5 0 0;
-#X floatatom 480 184 5 0 0;
-#X floatatom 310 105 5 0 0;
-#X obj 310 132 expr $f1 \; if ($f1 > 0 \, $f1 * 2 \, 0) \; if ($f1
-<= 0 \, $f1 / 2 \, 0);
-#X text 34 56 Examples of expr object;
-#X text 304 88 an example of multiple expressions and the use of 'if'
-;
-#X connect 0 0 2 0;
-#X connect 1 0 8 0;
-#X connect 3 0 0 0;
-#X connect 4 0 6 0;
-#X connect 5 0 4 0;
-#X connect 8 0 7 0;
-#X connect 9 0 11 0;
-#X connect 11 0 10 0;
-#X connect 12 0 11 1;
-#X connect 14 0 20 0;
-#X connect 16 0 18 0;
-#X connect 18 0 17 0;
-#X connect 19 0 18 1;
-#X connect 20 0 15 0;
-#X connect 25 0 26 0;
-#X connect 26 0 22 0;
-#X connect 26 1 23 0;
-#X connect 26 2 24 0;
-#X restore 307 398 pd Examples of expr;
-#N canvas 23 24 882 676 Examples 0;
-#X text -88 101 expr~ examples:;
-#X obj -24 355 print~;
-#X msg 13 334 bang;
-#X obj -24 276 sig~ 440;
-#X floatatom 49 293 0 0 0;
-#X floatatom -24 253 0 0 0;
-#X obj -24 316 expr~ $v1*$f2;
-#X obj 85 356 print~;
-#X msg 101 335 bang;
-#X floatatom 85 268 0 0 0;
-#X floatatom 158 270 0 0 0;
-#X floatatom 357 291 0 0 0;
-#X floatatom 244 267 0 0 0;
-#X obj 244 294 osc~;
-#X msg 369 47 \; pd dsp 0;
-#X msg 291 49 \; pd dsp 1;
-#X text 294 26 audio on;
-#X text 377 25 audio off;
-#X text -45 236 vector times scalar;
-#X text 87 236 vector;
-#X obj 243 354 dac~;
-#X text 241 245 frequency;
-#X text 373 273 amplitude;
-#X obj 85 315 expr~ $v1*$v2;
-#X floatatom 207 471 5 0 0;
-#X obj -40 520 tabsend~ a1;
-#N canvas 0 0 450 300 graph4 0;
-#X array a1 64 float 0;
-#X coords 0 1 63 -1 200 140 1;
-#X restore -39 542 graph;
-#X obj -40 497 expr~ max(min($v1 \, $f2/10) \, -$f2/10);
-#X text -38 123 NOTES: the first inlet of expr~ cannot be a $f1 or
-$i1 \, this may change in later releases;
-#X text -87 420 A simple limiter example;
-#X obj 356 158 vsl 15 128 0 127 0 0 empty empty empty 20 8 0 8 -262144
--1 -1 0 1;
-#X obj 243 315 expr~ $v1*$f2/128;
-#X text -82 28 make sure you turn on audio for the expr~ examples;
-#X obj -40 473 osc~ 2756.25;
-#X text 122 436 Move the value below between 0 and 10;
-#X text 126 451 to change the limiter threshold;
-#X obj 417 522 tabsend~ a2;
-#X obj 580 518 tabsend~ a3;
-#X obj 417 439 osc~ 2756.25;
-#N canvas 0 0 450 300 graph1 0;
-#X array a2 64 float 1;
-#A 0 -0.419198 -0.487122 -0.481805 -0.400382 -0.252053 -0.0571681 0.155563
-0.353314 0.504227 0.582557 0.573016 0.473664 0.296682 0.0669659 -0.18137
--0.410083 -0.582709 -0.670415 -0.656787 -0.540803 -0.337462 -0.0758923
-0.204826 0.461522 0.653623 0.74958 0.732042 0.600932 0.373867 0.0838359
--0.225617 -0.506972 -0.716061 -0.819026 -0.797803 -0.653251 -0.405409
--0.0906877 0.243486 0.545852 0.769218 0.877835 0.853191 0.697093 0.431698
-0.096368 -0.258195 -0.577642 -0.812367 -0.925245 -0.897515 -0.731894
--0.452386 -0.100793 0.269551 0.601932 0.844984 0.960659 0.930205 0.757204
-0.467199 0.103913 -0.277405 -0.618414;
-#X coords 0 1 63 -1 200 140 1;
-#X restore 347 554 graph;
-#N canvas 0 0 450 300 graph2 0;
-#X array a3 64 float 0;
-#X coords 0 1 63 -1 200 140 1;
-#X restore 569 554 graph;
-#X obj 417 473 expr~ $v1 *$v2 \; if ($v2 > 0 \, 0 \, $v1*$v2);
-#X obj 580 439 osc~ 100;
-#X connect 2 0 1 0;
-#X connect 3 0 6 0;
-#X connect 4 0 6 1;
-#X connect 5 0 3 0;
-#X connect 6 0 1 0;
-#X connect 8 0 7 0;
-#X connect 9 0 23 0;
-#X connect 10 0 23 1;
-#X connect 11 0 31 1;
-#X connect 12 0 13 0;
-#X connect 13 0 31 0;
-#X connect 23 0 7 0;
-#X connect 24 0 27 1;
-#X connect 27 0 25 0;
-#X connect 30 0 11 0;
-#X connect 31 0 20 0;
-#X connect 31 0 20 1;
-#X connect 33 0 27 0;
-#X connect 38 0 41 0;
-#X connect 41 0 36 0;
-#X connect 41 1 37 0;
-#X connect 42 0 41 1;
-#X restore 307 433 pd Examples of expr~;
-#X text 40 399 For expr examples click here ->;
-#X text 41 433 For expr~ examples click here ->;
-#X text 40 471 For fexpr~ examples click here ->;
-#N canvas 0 0 1059 688 examples 0;
-#X msg 519 84 \; pd dsp 0;
-#X msg 428 84 \; pd dsp 1;
-#X text 426 64 audio on;
-#X text 518 65 audio off;
-#X floatatom 126 304 0 0 0;
-#X floatatom 259 323 0 0 0;
-#X msg 226 283 -10;
-#X text 53 103 fexpr~ examples:;
-#X obj 125 571 print~;
-#X msg 247 552 bang;
-#X floatatom 125 475 0 0 0;
-#X obj 126 347 fexpr~ ($x1[$f2]+$x1)/2;
-#X obj 125 532 fexpr~ $x1+$y[-1];
-#X floatatom 635 366 0 0 0;
-#X floatatom 795 387 0 0 0;
-#X obj 630 456 dac~;
-#X obj 632 407 fexpr~ ($x1[$f2/1000]+$x1)/2;
-#X msg 864 317 0 10000;
-#X obj 795 368 line 0;
-#X msg 798 318 -10000;
-#X obj 120 389 dac~;
-#X text 96 227 Simple FIR filter;
-#X text 557 134 Simple FIR filter using fractional offset;
-#X msg 704 318 -10000 10000;
-#X obj 635 387 osc~ 2205;
-#X msg 644 343 1102.5;
-#X msg 862 342 0 10000;
-#X msg 796 343 -20000;
-#X msg 702 343 -20000 10000;
-#X msg 635 318 2205;
-#X msg 548 312 start;
-#X msg 550 334 stop;
-#X msg 57 284 start;
-#X msg 56 309 stop;
-#X msg 75 469 start;
-#X msg 74 494 stop;
-#X obj 491 335 loadbang;
-#X obj 18 495 loadbang;
-#X obj 1 309 loadbang;
-#X text 617 291 frequency;
-#X text 707 300 of the simple filter;
-#X msg 293 282 -20;
-#X obj 126 325 osc~ 2205;
-#X msg 156 281 1102.5;
-#X msg 110 281 2205;
-#X msg 260 282 0;
-#X text 123 445 simple accumulator defined as and an IIR filter;
-#X text 52 148 NOTE: fexpr~ could use lots of CPU power \, by default
-fexpr~ is on when it is loaded. In this page we are turning them off
-with loadbang \, so to hear them you have to turn them on explicitly.
-You can use the "start" and "stop" messages to start and stop fexpr~
-and expr~;
-#X text 706 288 index defining the frequency;
-#X text 95 240 -10 offset will fully filter audio frequency of 2205
-\, and -20 offset will filter audio at frequency of 1102.5;
-#X text 559 215 Thus \, the offset -10000 will filter audio at frequency
-of 2205 and the offset value -20000 will filter the audio at frequency
-of 1102.5.;
-#X text 558 161 When fractional offset is used \, fexpr~ determines
-indexed by linear interpolation. In the following example the offset
-value is divided by 1000 \, thus we can continuously change the offset
-without an audible click in the output.;
-#X text 288 318 If you change this value you;
-#X text 290 330 hear a click;
-#X text 51 87 make sure you turn on audio for the fexpr~ examples;
-#X text 55 -323 Used for fexpr~ only:;
-#X text 55 -267 $y[n]: the output value indexed by n where n has to
-satisfy 0 > n >= -vector size.;
-#X text 55 -239 (the vector size can be changed by the "block~" object.)
-;
-#X text 55 -308 $x#[n]: the sample from inlet # indexed by n where
-n has to satisfy 0 => n >= -vector size \, ($x# is a shorthand for
-$x#[0] \, specifying the current sample);
-#X text 140 -193 $y -> $y1[-1];
-#X text 55 -224 Shorthands: $x -> $x1[0];
-#X text 140 -208 $x1 -> $x1[0] $x2 -> $x2[0] .....;
-#X text 140 -178 $y1 -> $y1[-1] $y2 -> $y2[-1] .....;
-#X text 64 -125 fexpr~ responds to the following methods;
-#X text 66 -106 clear - clears all the previous input and output buffers
-;
-#X text 65 -92 clear x# - clears the previous values of the #th input
-;
-#X text 66 -79 clear y# - clears the previous values of the #th output
-;
-#X text 66 -33 set x# val-1 val-2 ... - sets the as many supplied values
-of the #th input;
-#X text 513 -22 e.g. \, set x2 3.4 0.4 sets x2[-1]=3.4 and x2[-2]=0.4
-;
-#X text 66 -2 set y# val-1 val-2 ... - sets the as many supplied values
-of the #th input;
-#X text 514 4 e.g. \, set y3 1.1 3.3 4.5 sets y3[-1]=1.1 y3[-2]=3.3
-and y3[-3]=4.5;
-#X text 64 -54 set val val ... - sets the first past values of each
-output;
-#X text 513 -59 e.g. \, set 0.1 2.2 0.4 sets y1[-1]=0.1 y2[-1]=2.2
-\, and y3[-1]=0.4;
-#X msg 244 475 set 4000;
-#X obj 125 504 sig~ 0.001;
-#X msg 245 498 clear;
-#X text 22 442 comment;
-#X text 14 431 1 first click the start button;
-#X text 307 494 2 click the set or the clear button;
-#X text 304 547 3 then click bang to see how set and clear work;
-#X connect 4 0 42 0;
-#X connect 5 0 11 1;
-#X connect 6 0 5 0;
-#X connect 9 0 8 0;
-#X connect 10 0 74 0;
-#X connect 11 0 20 0;
-#X connect 11 0 20 1;
-#X connect 12 0 8 0;
-#X connect 13 0 24 0;
-#X connect 14 0 16 1;
-#X connect 16 0 15 0;
-#X connect 16 0 15 1;
-#X connect 17 0 18 0;
-#X connect 18 0 14 0;
-#X connect 19 0 18 0;
-#X connect 23 0 18 0;
-#X connect 24 0 16 0;
-#X connect 25 0 13 0;
-#X connect 26 0 18 0;
-#X connect 27 0 18 0;
-#X connect 28 0 18 0;
-#X connect 29 0 13 0;
-#X connect 30 0 16 0;
-#X connect 31 0 16 0;
-#X connect 32 0 11 0;
-#X connect 33 0 11 0;
-#X connect 34 0 12 0;
-#X connect 35 0 12 0;
-#X connect 36 0 31 0;
-#X connect 37 0 35 0;
-#X connect 38 0 33 0;
-#X connect 41 0 5 0;
-#X connect 42 0 11 0;
-#X connect 43 0 4 0;
-#X connect 44 0 4 0;
-#X connect 45 0 5 0;
-#X connect 73 0 12 0;
-#X connect 74 0 12 0;
-#X connect 75 0 12 0;
-#X restore 306 472 pd examples of fexpr~;
-#X text 42 504 For using fexpr~ for solving;
-#X text 43 520 differential equations click here ->;
-#N canvas 112 22 944 449 lorenz 0;
-#X obj 176 67 v pr;
-#X obj 307 68 v r;
-#X obj 233 69 v b;
-#X floatatom 176 38 5 0 0;
-#X floatatom 307 40 5 0 0;
-#X msg 177 13 10;
-#X obj 231 10 expr 8./3;
-#X msg 128 136 set 1.2 2.3 4.4;
-#X floatatom 233 39 7 0 0;
-#X msg 75 46 stop;
-#X msg 75 67 start;
-#X floatatom 399 40 5 0 0;
-#X obj 399 69 v dt;
-#X msg 310 12 18;
-#X msg 395 13 0.01;
-#X obj 68 296 dac~;
-#X obj 128 -41 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1
--1;
-#X text 201 -41 <- turn audio on and bang here;
-#X text 463 42 <- experiment with these numbers;
-#X text 472 72 if you hear a buzz \, you have probably gone unstable
-bang on the top again;
-#X obj 489 15 line;
-#X obj 128 241 /~ 20;
-#X obj 234 238 /~ 20;
-#X obj 340 237 /~ 20;
-#X msg 484 -11 0.01 \, 0.04 5000;
-#X obj 128 185 fexpr~ $y1+(pr*$y2-pr*$y1)*dt \; $y2 +(-$y1*$y3 + r*$y1-$y2)*dt
-\; $y3+($y1*$y2 - b*$y3)*dt;
-#X obj 14 65 loadbang;
-#X text 113 -100 This is an example of how fexpr~ could be used for
-solving differential equations \, in this case the lorenz equations
-which generate chotic signals;
-#X text 361 182 Note the following shorthands:;
-#X text 360 198 $y1 -> $y1[-1] \, $y2 -> $y2[-1] \, .....;
-#X text 248 136 the 'set' commands sets the initial previous values
-;
-#X obj 128 298 tabsend~ lorenz1a;
-#X obj 234 278 tabsend~ lorenz2a;
-#X obj 339 259 tabsend~ lorenz3a;
-#N canvas 0 0 450 300 graph1 0;
-#X array lorenz1a 64 float 0;
-#X coords 0 1 63 -1 200 140 1;
-#X restore 73 437 graph;
-#N canvas 0 0 450 300 graph2 0;
-#X array lorenz2a 64 float 0;
-#X coords 0 1 63 -1 200 140 1;
-#X restore 331 435 graph;
-#N canvas 0 0 450 300 graph3 0;
-#X array lorenz3a 64 float 0;
-#X coords 0 1 63 -1 200 140 1;
-#X restore 592 436 graph;
-#X text 301 315 You can see the graphs if you scroll down;
-#X text 301 328 but the redrawings may cause clicks in the audio;
-#X connect 3 0 0 0;
-#X connect 4 0 1 0;
-#X connect 5 0 3 0;
-#X connect 6 0 8 0;
-#X connect 7 0 25 0;
-#X connect 8 0 2 0;
-#X connect 9 0 25 0;
-#X connect 10 0 25 0;
-#X connect 11 0 12 0;
-#X connect 13 0 4 0;
-#X connect 14 0 11 0;
-#X connect 16 0 5 0;
-#X connect 16 0 6 0;
-#X connect 16 0 13 0;
-#X connect 16 0 14 0;
-#X connect 16 0 7 0;
-#X connect 16 0 10 0;
-#X connect 20 0 11 0;
-#X connect 21 0 31 0;
-#X connect 21 0 15 0;
-#X connect 21 0 15 1;
-#X connect 22 0 32 0;
-#X connect 23 0 33 0;
-#X connect 24 0 20 0;
-#X connect 25 0 21 0;
-#X connect 25 1 22 0;
-#X connect 25 2 23 0;
-#X connect 26 0 9 0;
-#X restore 308 518 pd lorenz equations for audition;
-#N canvas 97 36 978 656 lorenz 0;
-#X obj 176 67 v pr;
-#X obj 307 68 v r;
-#X obj 233 69 v b;
-#X floatatom 176 38 5 0 0;
-#X floatatom 307 40 5 0 0;
-#X msg 177 13 10;
-#X obj 231 10 expr 8./3;
-#N canvas 0 0 450 300 graph1 0;
-#X array lorenz1 2048 float 0;
-#X coords 0 -1 2047 1 200 140 1;
-#X restore 82 357 graph;
-#N canvas 0 0 450 300 graph2 0;
-#X array lorenz2 2048 float 0;
-#X coords 0 -1 2047 1 200 140 1;
-#X restore 327 353 graph;
-#N canvas 0 0 450 300 graph3 0;
-#X array lorenz3 2048 float 0;
-#X coords 0 -1 2047 1 200 140 1;
-#X restore 570 347 graph;
-#X msg 128 136 set 1.2 2.3 4.4;
-#X floatatom 233 39 7 0 0;
-#X msg 75 46 stop;
-#X msg 75 67 start;
-#X floatatom 399 40 5 0 0;
-#X obj 399 69 v dt;
-#X msg 310 12 18;
-#X msg 395 13 0.01;
-#X obj 128 -41 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1
--1;
-#X text 201 -41 <- turn audio on and bang here;
-#X text 463 42 <- experiment with these numbers;
-#X text 472 72 if you hear a buzz \, you have probably gone unstable
-bang on the top again;
-#X obj 489 15 line;
-#X obj 128 241 /~ 20;
-#X obj 234 238 /~ 20;
-#X obj 340 237 /~ 20;
-#X msg 484 -11 0.01 \, 0.04 5000;
-#X obj 14 65 loadbang;
-#X text 113 -100 This is an example of how fexpr~ could be used for
-solving differential equations \, in this case the lorenz equations
-which generate chotic signals;
-#X text 361 182 Note the following shorthands:;
-#X text 360 198 $y1 -> $y1[-1] \, $y2 -> $y2[-1] \, .....;
-#X text 248 136 the 'set' commands sets the initial previous values
-;
-#X obj 128 298 tabsend~ lorenz1;
-#X obj 234 278 tabsend~ lorenz2;
-#X obj 339 259 tabsend~ lorenz3;
-#X obj 627 280 block~ 2048;
-#X text 669 133 Lorenz Equations;
-#X obj 128 185 fexpr~ $y1+pr * ($y2-$y1)*dt \; $y2 +(-$y1*$y3 + r*$y1-$y2)*dt
-\; $y3+($y1*$y2 - b*$y3)*dt;
-#X text 672 197 dZ/dt = -bZ;
-#X text 669 167 dX/dt = pr * (X - Y);
-#X text 668 147 written with 3 state variable X \, Y \, and Z;
-#X text 670 182 dY/dt = -XZ + rX - y;
-#X connect 3 0 0 0;
-#X connect 4 0 1 0;
-#X connect 5 0 3 0;
-#X connect 6 0 11 0;
-#X connect 10 0 37 0;
-#X connect 11 0 2 0;
-#X connect 12 0 37 0;
-#X connect 13 0 37 0;
-#X connect 14 0 15 0;
-#X connect 16 0 4 0;
-#X connect 17 0 14 0;
-#X connect 18 0 5 0;
-#X connect 18 0 6 0;
-#X connect 18 0 16 0;
-#X connect 18 0 17 0;
-#X connect 18 0 10 0;
-#X connect 18 0 13 0;
-#X connect 22 0 14 0;
-#X connect 23 0 32 0;
-#X connect 24 0 33 0;
-#X connect 25 0 34 0;
-#X connect 26 0 22 0;
-#X connect 27 0 12 0;
-#X connect 37 0 23 0;
-#X connect 37 1 24 0;
-#X connect 37 2 25 0;
-#X restore 308 541 pd lorenz equations for visualization;
-#X text 68 24 by Shahrokh Yadegari;
diff --git a/pd/extra/help-hilbert~.pd b/pd/extra/help-hilbert~.pd
deleted file mode 100644
index 130ec750..00000000
--- a/pd/extra/help-hilbert~.pd
+++ /dev/null
@@ -1,18 +0,0 @@
-#N canvas 156 234 600 488 12;
-#X obj 67 124 hilbert~;
-#X obj 66 85 osc~ 440;
-#X graph graph1 0 -1 882 1 279 209 579 39;
-#X array out-left 882 float;
-#X array out-right 882 float;
-#X pop;
-#X obj 67 274 tabwrite~ out-left;
-#X obj 118 248 tabwrite~ out-right;
-#X msg 137 188 bang \; pd dsp 1;
-#X floatatom 66 57;
-#X text 71 319 The Hilbert transform (the name is abused here according to computer music tradition) puts out a phase quadrature version of the input signal suitable for signal sideband modulation via complex-mod~.;
-#X connect 0 0 3 0;
-#X connect 0 1 4 0;
-#X connect 1 0 0 0;
-#X connect 5 0 3 0;
-#X connect 5 0 4 0;
-#X connect 6 0 1 0;
diff --git a/pd/extra/help-rev1~.pd b/pd/extra/help-rev1~.pd
deleted file mode 100644
index 55580bd5..00000000
--- a/pd/extra/help-rev1~.pd
+++ /dev/null
@@ -1,119 +0,0 @@
-#N canvas 55 21 1008 526 12;
-#X obj 148 439 dac~;
-#X obj 58 72 line~;
-#X msg 58 49 0 \, 10000 5;
-#X obj 58 118 cos~;
-#X msg 146 70 1;
-#X obj 146 47 loadbang;
-#X obj 58 95 clip~ 0 0.25;
-#X floatatom 173 264 0 0 0;
-#X obj 251 134 line~;
-#X obj 251 157 cos~;
-#X msg 324 54 -0.25 \, 0.25 100;
-#X obj 251 8 loadbang;
-#X msg 251 31 -0.25;
-#X obj 251 203 *~;
-#X obj 58 140 hip~ 5;
-#X floatatom 162 328 0 0 0;
-#X obj 162 373 pack 0 100;
-#X obj 162 396 line~;
-#X obj 148 416 *~;
-#X obj 162 350 dbtorms;
-#X msg 324 77 -0.25 \, 0.25 400;
-#X floatatom 324 145 0 0 0;
-#X obj 324 191 osc~ 440;
-#X obj 324 168 mtof;
-#X msg 324 31 -0.25 \, 0.25 20;
-#X obj 251 180 *~ 0.1;
-#X msg 324 100 -0.25 \, 0.25 1000;
-#X msg 324 122 -0.25 \, 0.25 2000;
-#X obj 324 226 *~;
-#X obj 342 252 *~;
-#X obj 58 439 dac~;
-#X floatatom 68 323 0 0 0;
-#X obj 68 368 pack 0 100;
-#X obj 68 391 line~;
-#X obj 58 416 *~;
-#X obj 68 346 dbtorms;
-#X msg 324 8 0;
-#X obj 308 257 *~;
-#X obj 58 26 metro 2000;
-#X floatatom 58 4 0 0 0;
-#X msg 220 265 bang;
-#X obj 284 322 env~ 32768;
-#X floatatom 284 344 0 0 0;
-#X text 166 244 1 sec;
-#X text 143 226 dB after;
-#X text 220 245 clear;
-#X text 1 51 impulse;
-#X text 362 7 tone;
-#X text 484 31 beeps;
-#X text 428 167 This is an experimental reverberator design composed
-of a series of allpass filters with exponentially growing delay times.
-Each allpass filter has a gain of 0.7. The reverb time is adjusted
-by adjusting the input gains of the allpass filters. The last unit
-is modified so that its first two "echos" mimic those of an allpass
-but its loop gain depends on reverb time.;
-#X text 430 299 Reverb time is controlled by specifying the dB gain
-(100 normal) after one second \, so that 100 corresponds to infinite
-reverb time \, 70 to two seconds \, 40 to one second \, and 0 to 0
-;
-#X text 671 499 modified for Pd version 0.30.;
-#X msg 560 34 \; pd dsp 1;
-#X text 427 475 The rev1~ module eats about 18% of my 300mHz P2 machine.
-;
-#X obj 148 289 rev1~;
-#X text 428 381 The "clear" button impolitely clears out all the delay
-lines \, You may immediately resume pumping the reverberator \, but
-the input signal should be cleanly enveloped. The output \, too \,
-must be enveloped and may not be opened until 5 msec after the "clear"
-message is sent.;
-#X connect 1 0 6 0;
-#X connect 2 0 1 0;
-#X connect 3 0 14 0;
-#X connect 4 0 1 0;
-#X connect 5 0 4 0;
-#X connect 6 0 3 0;
-#X connect 7 0 54 1;
-#X connect 8 0 9 0;
-#X connect 9 0 25 0;
-#X connect 10 0 8 0;
-#X connect 11 0 12 0;
-#X connect 12 0 8 0;
-#X connect 13 0 14 0;
-#X connect 14 0 34 0;
-#X connect 14 0 54 0;
-#X connect 15 0 19 0;
-#X connect 16 0 17 0;
-#X connect 17 0 18 1;
-#X connect 18 0 0 0;
-#X connect 19 0 16 0;
-#X connect 20 0 8 0;
-#X connect 21 0 23 0;
-#X connect 22 0 13 1;
-#X connect 22 0 28 0;
-#X connect 22 0 28 1;
-#X connect 22 0 29 0;
-#X connect 23 0 22 0;
-#X connect 24 0 8 0;
-#X connect 25 0 13 0;
-#X connect 26 0 8 0;
-#X connect 27 0 8 0;
-#X connect 28 0 29 1;
-#X connect 28 0 13 1;
-#X connect 28 0 37 0;
-#X connect 28 0 37 1;
-#X connect 29 0 13 1;
-#X connect 31 0 35 0;
-#X connect 32 0 33 0;
-#X connect 33 0 34 1;
-#X connect 34 0 30 0;
-#X connect 35 0 32 0;
-#X connect 36 0 8 0;
-#X connect 37 0 13 1;
-#X connect 38 0 2 0;
-#X connect 39 0 38 0;
-#X connect 40 0 54 2;
-#X connect 41 0 42 0;
-#X connect 54 0 18 0;
-#X connect 54 0 41 0;
diff --git a/pd/extra/help-rev2~.pd b/pd/extra/help-rev2~.pd
deleted file mode 100644
index 8f9fbaaf..00000000
--- a/pd/extra/help-rev2~.pd
+++ /dev/null
@@ -1,134 +0,0 @@
-#N canvas 167 160 766 354 12;
-#X floatatom 73 185 0 0 120 0 - - -;
-#X floatatom 106 323 0 0 120 0 - - -;
-#N canvas 0 0 539 448 tests 0;
-#X obj 67 33 inlet;
-#X obj 309 189 inlet;
-#X obj 235 207 line~;
-#X obj 235 230 cos~;
-#X obj 235 68 loadbang;
-#X msg 235 91 -0.25;
-#X obj 235 276 *~;
-#X obj 186 309 hip~ 5;
-#X floatatom 308 218 0 0 0 0 - - -;
-#X obj 308 264 osc~ 440;
-#X obj 308 241 mtof;
-#X obj 235 253 *~ 0.1;
-#X obj 308 299 *~;
-#X obj 326 325 *~;
-#X obj 292 330 *~;
-#X msg 279 150 -0.25 \, 0.25 \$1;
-#X obj 41 148 biquad~ 0 0 1 -1 0;
-#X obj 63 70 t b;
-#X obj 104 72 del 3;
-#X obj 57 101 1;
-#X obj 96 101 0;
-#X obj 41 355 outlet~;
-#X obj 279 126 inlet;
-#X obj 40 175 *~;
-#X connect 0 0 17 0;
-#X connect 1 0 8 0;
-#X connect 2 0 3 0;
-#X connect 3 0 11 0;
-#X connect 4 0 5 0;
-#X connect 5 0 2 0;
-#X connect 6 0 7 0;
-#X connect 7 0 21 0;
-#X connect 8 0 10 0;
-#X connect 9 0 6 1;
-#X connect 9 0 12 0;
-#X connect 9 0 12 1;
-#X connect 9 0 13 0;
-#X connect 10 0 9 0;
-#X connect 11 0 6 0;
-#X connect 12 0 13 1;
-#X connect 12 0 6 1;
-#X connect 12 0 14 0;
-#X connect 12 0 14 1;
-#X connect 13 0 6 1;
-#X connect 14 0 6 1;
-#X connect 15 0 2 0;
-#X connect 16 0 23 0;
-#X connect 17 0 18 0;
-#X connect 17 0 19 0;
-#X connect 18 0 20 0;
-#X connect 19 0 16 0;
-#X connect 19 0 23 1;
-#X connect 20 0 16 0;
-#X connect 20 0 23 1;
-#X connect 22 0 15 0;
-#X connect 23 0 21 0;
-#X restore 17 154 pd tests;
-#X msg 56 35 10;
-#X msg 54 62 20;
-#X msg 53 90 100;
-#X msg 52 115 500;
-#X obj 17 15 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
--1;
-#X text 37 9 impulse;
-#N canvas 0 0 450 300 output 0;
-#X obj 54 202 dac~;
-#X obj 132 119 pack 0 100;
-#X obj 132 142 line~;
-#X obj 54 165 *~;
-#X obj 132 97 dbtorms;
-#X obj 33 42 inlet~;
-#X obj 177 42 inlet;
-#X obj 177 74 clip 0 120;
-#X msg 257 133 \; pd dsp 1;
-#X obj 98 42 inlet~;
-#X obj 94 168 *~;
-#X connect 1 0 2 0;
-#X connect 2 0 3 1;
-#X connect 2 0 10 1;
-#X connect 3 0 0 0;
-#X connect 4 0 1 0;
-#X connect 5 0 3 0;
-#X connect 6 0 7 0;
-#X connect 6 0 8 0;
-#X connect 7 0 4 0;
-#X connect 9 0 10 0;
-#X connect 10 0 0 1;
-#X restore 18 324 pd output;
-#X floatatom 97 127 0 0 0 0 - - -;
-#X text 136 96 tone;
-#X text 135 112 pitch;
-#X text 114 185 level \, dB;
-#X floatatom 117 209 0 0 100 0 - - -;
-#X text 158 209 liveness \, 0-100;
-#X text 505 330 modified for Pd version 0.37;
-#X floatatom 161 235 0 0 120 0 - - -;
-#X floatatom 205 259 0 0 120 0 - - -;
-#X text 192 235 crossover frequency \, Hz.;
-#X text 238 260 HF damping \, percent;
-#X obj 30 290 rev2~ 100 90 3000 20;
-#X text 141 324 output level \, dB;
-#X text 281 8 REV2~ - a simple 1-in \, 4-out reverberator;
-#X text 95 35 tone;
-#X text 96 52 bursts;
-#X text 231 37 The creation arguments (level \, liveness \, crossover
-frequency \, HF damping) may also be supplied in four inlets as shown.
-The "liveness" (actually the internal feedback percentage) should be
-100 for infinite reverb \, 90 for longish \, and 80 for short. The
-crossover frequency and HF damping work together: at frequencies above
-crossover \, the feedback is diminished by the "damping" as a percentage.
-So zero HF damping means equal reverb time at all frequencies \, and
-100% damping means almost nothing above the crossover frequency gets
-through.;
-#X text 132 130 (60 for;
-#X text 115 150 middle C);
-#X connect 0 0 21 1;
-#X connect 1 0 9 2;
-#X connect 2 0 9 0;
-#X connect 2 0 21 0;
-#X connect 3 0 2 1;
-#X connect 4 0 2 1;
-#X connect 5 0 2 1;
-#X connect 6 0 2 1;
-#X connect 7 0 2 0;
-#X connect 10 0 2 2;
-#X connect 14 0 21 2;
-#X connect 17 0 21 3;
-#X connect 18 0 21 4;
-#X connect 21 0 9 0;
-#X connect 21 1 9 1;
diff --git a/pd/extra/help-rev3~.pd b/pd/extra/help-rev3~.pd
deleted file mode 100644
index 78ef15f5..00000000
--- a/pd/extra/help-rev3~.pd
+++ /dev/null
@@ -1,136 +0,0 @@
-#N canvas 70 263 765 380 12;
-#X floatatom 99 212 0 0 120 0 - - -;
-#X floatatom 105 340 0 0 120 0 - - -;
-#N canvas 0 0 539 448 tests 0;
-#X obj 67 33 inlet;
-#X obj 309 189 inlet;
-#X obj 235 207 line~;
-#X obj 235 230 cos~;
-#X obj 235 68 loadbang;
-#X msg 235 91 -0.25;
-#X obj 235 276 *~;
-#X obj 186 309 hip~ 5;
-#X floatatom 308 218 0 0 0 0 - - -;
-#X obj 308 264 osc~ 440;
-#X obj 308 241 mtof;
-#X obj 235 253 *~ 0.1;
-#X obj 308 299 *~;
-#X obj 326 325 *~;
-#X obj 292 330 *~;
-#X msg 279 150 -0.25 \, 0.25 \$1;
-#X obj 41 148 biquad~ 0 0 1 -1 0;
-#X obj 63 70 t b;
-#X obj 104 72 del 3;
-#X obj 57 101 1;
-#X obj 96 101 0;
-#X obj 41 355 outlet~;
-#X obj 279 126 inlet;
-#X obj 51 192 *~;
-#X connect 0 0 17 0;
-#X connect 1 0 8 0;
-#X connect 2 0 3 0;
-#X connect 3 0 11 0;
-#X connect 4 0 5 0;
-#X connect 5 0 2 0;
-#X connect 6 0 7 0;
-#X connect 7 0 21 0;
-#X connect 8 0 10 0;
-#X connect 9 0 6 1;
-#X connect 9 0 12 0;
-#X connect 9 0 12 1;
-#X connect 9 0 13 0;
-#X connect 10 0 9 0;
-#X connect 11 0 6 0;
-#X connect 12 0 13 1;
-#X connect 12 0 6 1;
-#X connect 12 0 14 0;
-#X connect 12 0 14 1;
-#X connect 13 0 6 1;
-#X connect 14 0 6 1;
-#X connect 15 0 2 0;
-#X connect 16 0 23 0;
-#X connect 17 0 18 0;
-#X connect 17 0 19 0;
-#X connect 18 0 20 0;
-#X connect 19 0 16 0;
-#X connect 19 0 23 1;
-#X connect 20 0 16 0;
-#X connect 20 0 23 1;
-#X connect 22 0 15 0;
-#X connect 23 0 21 0;
-#X restore 16 171 pd tests;
-#X msg 55 52 10;
-#X msg 53 79 20;
-#X msg 52 107 100;
-#X msg 51 132 500;
-#X obj 16 32 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
--1;
-#X text 36 26 impulse;
-#N canvas 0 0 450 300 output 0;
-#X obj 54 202 dac~;
-#X obj 132 119 pack 0 100;
-#X obj 132 142 line~;
-#X obj 54 165 *~;
-#X obj 132 97 dbtorms;
-#X obj 33 42 inlet~;
-#X obj 177 42 inlet;
-#X obj 177 74 clip 0 120;
-#X msg 257 133 \; pd dsp 1;
-#X obj 98 42 inlet~;
-#X obj 94 168 *~;
-#X connect 1 0 2 0;
-#X connect 2 0 3 1;
-#X connect 2 0 10 1;
-#X connect 3 0 0 0;
-#X connect 4 0 1 0;
-#X connect 5 0 3 0;
-#X connect 6 0 7 0;
-#X connect 6 0 8 0;
-#X connect 7 0 4 0;
-#X connect 9 0 10 0;
-#X connect 10 0 0 1;
-#X restore 17 340 pd output;
-#X floatatom 96 144 0 0 0 0 - - -;
-#X text 135 113 tone;
-#X text 134 129 pitch;
-#X text 140 212 level \, dB;
-#X floatatom 134 234 0 0 100 0 - - -;
-#X text 175 234 liveness \, 0-100;
-#X floatatom 169 258 4 0 5000 0 - - -;
-#X floatatom 204 281 0 0 100 0 - - -;
-#X text 217 256 crossover frequency \, Hz.;
-#X text 240 283 HF damping \, percent;
-#X text 140 341 output level \, dB;
-#X text 94 52 tone;
-#X text 95 69 bursts;
-#X text 131 147 (60 for;
-#X text 114 167 middle C);
-#X obj 29 307 rev3~ 100 90 3000 20;
-#X text 263 4 REV3~ - hard-core \, 2-in \, 4-out reverberator;
-#X text 236 56 The creation arguments (level \, liveness \, crossover
-frequency \, HF damping) may also be supplied in four inlets as shown.
-The "liveness" (actually the internal feedback percentage) should be
-100 for infinite reverb \, 90 for longish \, and 80 for short. The
-crossover frequency and HF damping work together: at frequencies above
-crossover \, the feedback is diminished by the "damping" as a percentage.
-So zero HF damping means equal reverb time at all frequencies \, and
-100% damping means almost nothing above the crossover frequency gets
-through.;
-#X text 236 29 (A more expensive \, presumably better \, one than rev2~.)
-;
-#X text 470 352 modified for Pd version 0.37-1;
-#X connect 0 0 25 2;
-#X connect 1 0 9 2;
-#X connect 2 0 9 0;
-#X connect 2 0 25 0;
-#X connect 3 0 2 1;
-#X connect 4 0 2 1;
-#X connect 5 0 2 1;
-#X connect 6 0 2 1;
-#X connect 7 0 2 0;
-#X connect 10 0 2 2;
-#X connect 14 0 25 3;
-#X connect 16 0 25 4;
-#X connect 17 0 25 5;
-#X connect 25 0 9 0;
-#X connect 25 1 9 1;
diff --git a/pd/extra/loop~/help-loop~.pd b/pd/extra/loop~/help-loop~.pd
deleted file mode 100644
index a445b805..00000000
--- a/pd/extra/loop~/help-loop~.pd
+++ /dev/null
@@ -1,74 +0,0 @@
-#N canvas 33 0 647 662 12;
-#X floatatom 41 204 0 0 0 0 - - -;
-#X obj 254 382 print~;
-#X msg 254 347 bang;
-#X obj 41 338 loop~;
-#X floatatom 66 279 0 0 0 0 - - -;
-#X msg 55 252 bang;
-#X obj 183 382 print~;
-#X msg 183 347 bang;
-#N canvas 0 0 450 300 graph1 0;
-#X array array2 150000 float 0;
-#X coords 0 1 150000 -1 200 150 1;
-#X restore 393 464 graph;
-#X msg 393 622 \; array2 resize 150000;
-#X obj 25 613 soundfiler;
-#X obj 16 453 tabread4~ array2;
-#X obj 16 407 *~;
-#X obj 16 522 dac~;
-#X obj 16 499 hip~ 5;
-#X obj 62 411 samphold~;
-#X obj 16 430 +~;
-#X floatatom 96 303 0 0 0 0 - - -;
-#X obj 96 326 *~ 1000;
-#X msg 43 568 read ../doc/sound/bell.aiff array2;
-#X msg 43 591 read ../doc/sound/vocal.aiff array2;
-#X msg 47 229 set 0.5;
-#X text 95 196 left signal input is transposition (1 is normal \, 2
-is up an octave \, etc);
-#X text 82 4 loop~ - phase generator for looping samplers;
-#X text 116 228 set phase (0 to 1);
-#X text 104 253 reset phase to 0;
-#X text 104 278 right signal input is window size in samples;
-#X text 134 302 here's how to handle onsets;
-#X obj 16 476 *~;
-#X floatatom 167 432 0 0 0 0 - - -;
-#X obj 167 501 line~;
-#X obj 167 455 dbtorms;
-#X obj 167 478 pack 0 50;
-#X text 201 431 output level 0-100;
-#X text 187 326 print outputs;
-#X text 33 32 loop~ takes input signals to set a window size and transposition
-\, and outputs a phase and a sampled window size. The window size only
-changes at phase zero crossings and the phase output is adjusted so
-that changing window size doesn't change the transposition.;
-#X text 33 112 You can send "bang" or "set" message to force the phase
-to zero--you should mute the output before doing so. This may be desirable
-if you've set a large window size but then want to decrease it without
-waiting for the next phase crossing.;
-#X connect 0 0 3 0;
-#X connect 2 0 1 0;
-#X connect 3 0 6 0;
-#X connect 3 0 12 0;
-#X connect 3 0 15 1;
-#X connect 3 1 1 0;
-#X connect 3 1 12 1;
-#X connect 4 0 3 1;
-#X connect 5 0 3 0;
-#X connect 7 0 6 0;
-#X connect 11 0 28 0;
-#X connect 12 0 16 0;
-#X connect 14 0 13 0;
-#X connect 14 0 13 1;
-#X connect 15 0 16 1;
-#X connect 16 0 11 0;
-#X connect 17 0 18 0;
-#X connect 18 0 15 0;
-#X connect 19 0 10 0;
-#X connect 20 0 10 0;
-#X connect 21 0 3 0;
-#X connect 28 0 14 0;
-#X connect 29 0 31 0;
-#X connect 30 0 28 1;
-#X connect 31 0 32 0;
-#X connect 32 0 30 0;
diff --git a/pd/extra/lrshift~/help-rlshift~.pd b/pd/extra/lrshift~/help-rlshift~.pd
deleted file mode 100644
index cdfd8830..00000000
--- a/pd/extra/lrshift~/help-rlshift~.pd
+++ /dev/null
@@ -1,29 +0,0 @@
-#N canvas 143 0 673 325 12;
-#X msg 268 277 bang;
-#X obj 244 303 print~;
-#X msg 185 278 bang;
-#X obj 161 304 print~;
-#X text 53 117 click here first;
-#X msg 72 270 bang;
-#X obj 48 296 print~;
-#X text 162 222 shift left;
-#X text 243 224 shift right;
-#X obj 161 252 lrshift~ 1;
-#X obj 244 251 lrshift~ -1;
-#X text 39 37 Acting at whatever vector size the window is running at \, lrshift~ shifts samples to the left (toward the beginning sample) or to the right. The argument gives the direction and the amount of the shift. The rightmost (or leftmost) samples are set to zero.;
-#X graph graph2 0 0 63 1 448 258 648 118;
-#X array shiftin 64 float;
-#X pop;
-#X obj 47 11 rlshift~;
-#X text 115 11 -- shift signal vector elements left or right;
-#X msg 54 138 \; pd dsp 1 \; shiftin 1 1;
-#X obj 48 204 tabreceive~ shiftin;
-#X text 525 308 Updated for Pd 0.31.;
-#X connect 0 0 1 0;
-#X connect 2 0 3 0;
-#X connect 5 0 6 0;
-#X connect 9 0 3 0;
-#X connect 10 0 1 0;
-#X connect 16 0 6 0;
-#X connect 16 0 9 0;
-#X connect 16 0 10 0;
diff --git a/pd/extra/pique/help-pique.pd b/pd/extra/pique/help-pique.pd
deleted file mode 100644
index 1689c95b..00000000
--- a/pd/extra/pique/help-pique.pd
+++ /dev/null
@@ -1,33 +0,0 @@
-#N canvas 143 0 729 407 12;
-#X obj 47 11 pique;
-#X text 105 12 -- find peaks in an FFT spectrum;
-#X obj 214 174 rfft~;
-#X obj 131 129 osc~ 2000;
-#X graph graph2 0 -64 63 64 519 179 719 39;
-#X array fft-real 64 float;
-#X pop;
-#X graph graph3 0 -64 63 64 519 327 719 187;
-#X array fft-imag 64 float;
-#X pop;
-#X obj 214 215 tabwrite~ fft-real;
-#X obj 245 240 tabwrite~ fft-imag;
-#X obj 315 158 metro 1000;
-#X obj 315 116 loadbang;
-#X msg 315 138 1;
-#X obj 91 349 pique;
-#X msg 91 322 64 fft-real fft-imag 10;
-#X obj 91 376 print;
-#X obj 205 132 osc~ 5000;
-#X text 25 37 pique takes unwindowed FFT analyses as input (they should be stored in arrays) and outputs a list of peaks \, giving their peak number \, frequency \, amplitude \, and phase (as a cosine/sine pair.);
-#X text 13 289 message argumnets: number of FFT points \, fft real part \, fft imaginary part \, maximum number of peaks to report.;
-#X text 578 387 updated for Pd 0.31.;
-#X connect 2 0 6 0;
-#X connect 2 1 7 0;
-#X connect 3 0 2 0;
-#X connect 8 0 6 0;
-#X connect 8 0 7 0;
-#X connect 9 0 10 0;
-#X connect 10 0 8 0;
-#X connect 11 0 13 0;
-#X connect 12 0 11 0;
-#X connect 14 0 2 0;
diff --git a/pd/portmidi/Makefile b/pd/portmidi/Makefile
new file mode 100644
index 00000000..7a87606d
--- /dev/null
+++ b/pd/portmidi/Makefile
@@ -0,0 +1,77 @@
+# MAKEFILE FOR PORTMIDI AND PORTTIME
+
+
+# For debugging, define PM_CHECK_ERRORS
+PMFLAGS = -DPM_CHECK_ERRORS
+# Otherwise do not define PM_CHECK_ERRORS
+# PMFLAGS =
+
+# Use this for linux alsa (0.9x) version
+versions = pm_linux/pmlinuxalsa.o
+ALSALIB = -lasound
+VFLAGS = -DPMALSA
+
+# Use this for null (a dummy implementation for no Midi I/O:
+# versions = pmlinuxnull.o
+# ALSALIB =
+# VFLAGS = -DPMNULL
+
+pmlib = pm_linux/libportmidi.a
+
+ptlib = porttime/libporttime.a
+
+CC = gcc $(VFLAGS) $(PMFLAGS) -g -Ipm_common -Iporttime
+
+pmobjects = pm_common/pmutil.o $(versions) pm_linux/pmlinux.o \
+ pm_common/portmidi.o pm_linux/pmlinuxalsa.o
+
+ptobjects = porttime/porttime.o porttime/ptlinux.o
+
+current: all
+
+all: $(pmlib) $(ptlib) pm_test/test pm_test/sysex pm_test/midithread \
+ pm_test/latency pm_test/midithru
+
+$(pmlib): Makefile $(pmobjects)
+ ar -cr $(pmlib) $(pmobjects)
+
+$(ptlib): Makefile $(ptobjects)
+ ar -cr $(ptlib) $(ptobjects)
+
+pm_linux/pmlinuxalsa.o: Makefile pm_linux/pmlinuxalsa.c pm_linux/pmlinuxalsa.h
+ $(CC) -c pm_linux/pmlinuxalsa.c -o pm_linux/pmlinuxalsa.o
+
+pm_test/test: Makefile pm_test/test.o $(pmlib) $(ptlib)
+ $(CC) pm_test/test.c -o pm_test/test $(pmlib) $(ptlib) $(ALSALIB)
+
+pm_test/sysex: Makefile pm_test/sysex.o $(pmlib) $(ptlib)
+ $(CC) pm_test/sysex.c -o pm_test/sysex $(pmlib) $(ptlib) $(ALSALIB)
+
+pm_test/midithread: Makefile pm_test/midithread.o $(pmlib) $(ptlib)
+ $(CC) pm_test/midithread.c -o pm_test/midithread \
+ $(pmlib) $(ptlib) $(ALSALIB)
+
+pm_test/latency: Makefile $(ptlib) pm_test/latency.o
+ $(CC) pm_test/latency.c -o pm_test/latency $(pmlib) $(ptlib) \
+ $(ALSALIB) -lpthread -lm
+
+pm_test/midithru: Makefile $(ptlib) pm_test/midithru.o
+ $(CC) pm_test/midithru.c -o pm_test/midithru $(pmlib) $(ptlib) \
+ $(ALSALIB) -lpthread -lm
+
+porttime/ptlinux.o: Makefile porttime/ptlinux.c
+ $(CC) -c porttime/ptlinux.c -o porttime/ptlinux.o
+
+clean:
+ rm -f *.o *~ core* */*.o */*~ */core* pm_test/*/pm_dll.dll
+ rm -f *.opt *.ncb *.plg pm_win/Debug/pm_dll.lib pm_win/Release/pm_dll.lib
+ rm -f pm_test/*.opt pm_test/*.ncb
+
+cleaner: clean
+
+cleanest: cleaner
+ rm -f $(pmlib) $(ptlib) pm_test/test pm_test/sysex pm_test/midithread
+ rm -f pm_test/latency pm_test/midithru
+
+backup: cleanest
+ cd ..; zip -r portmidi.zip portmidi
diff --git a/pd/portmidi/README.txt b/pd/portmidi/README.txt
new file mode 100644
index 00000000..76412efd
--- /dev/null
+++ b/pd/portmidi/README.txt
@@ -0,0 +1,62 @@
+README for PortMidi
+Roger Dannenberg
+6 April 2003
+revised May 2004
+
+For Windows, please see also README_WIN.txt and debugging_dlls.txt
+in pm_win.
+
+For Linux, please see also README_LINUX.txt in pm_linux.
+
+POINTERS VS DEVICE NUMBERS
+
+When you open a MIDI port, PortMidi allocates a structure to
+maintain the state of the open device. Since every device is
+also listed in a table, you might think it would be simpler to
+use the table index rather than a pointer to identify a device.
+This would also help with error checking (it's hard to make
+sure a pointer is valid). PortMidi's design parallels that of
+PortAudio.
+
+ERROR HANDLING
+
+Error handling turned out to be much more complicated than expected.
+PortMidi functions return error codes that the caller can check.
+In addition, errors may occur asynchronously due to MIDI input. In
+this case, the error code is transferred to the next call to
+Pm_Read or Pm_Write. Furthermore, an error can arise during a MIDI THRU
+operation that is also invoked as a side effect of polling for input.
+
+Ordinarily, the caller checks for an error code. If the error is
+system-dependent, pmHostError is returned and the caller can
+call Pm_GetHostErrorText to get a text description of the error.
+
+Host errors are recorded in the system-specific data allocated for
+each open MIDI port. However, if an error occurs on open or close,
+we cannot store the error with the device because there will be
+no device data (assuming PortMidi cleans up after devices that
+are not open). For open and close, we will store the host error
+in a global variable. The PortMidi is smart enough to look here
+first when the user asks for ErrorText.
+
+Because output to a MIDI Thru stream can be invoked as a side-effect
+of a MIDI read operation, some errors normally associated with
+writing MIDI can be returned from Pm_Read.
+
+DEBUGGING
+
+If you are building a console application for research, we suggest
+compiling with the option PM_CHECK_ERRORS. This will insert a
+check for error return values at the end of each PortMidi
+function. If an error is encountered, a text message is printed
+using printf(), the user is asked to type ENTER, and then exit(-1)
+is called to clean up and terminate the program.
+
+You should not use PM_CHECK_ERRORS if printf() does not work
+(e.g. this is not a console application under Windows, or there
+is no visible console on some other OS), and you should not use
+PM_CHECK_ERRORS if you intend to recover from errors rather than
+abruptly terminate the program.
+
+The Windows version (and perhaps others) also offers a DEBUG
+compile-time option. See README_WIN.txt.
diff --git a/pd/portmidi/portmidi.dsp b/pd/portmidi/portmidi.dsp
new file mode 100644
index 00000000..699cc120
--- /dev/null
+++ b/pd/portmidi/portmidi.dsp
@@ -0,0 +1,124 @@
+# Microsoft Developer Studio Project File - Name="portmidi" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=portmidi - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "portmidi.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "portmidi.mak" CFG="portmidi - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "portmidi - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "portmidi - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "portmidi - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "pm_win\Release"
+# PROP Intermediate_Dir "pm_win\Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "pm_common" /I "porttime" /I "pm_win" /D "WIN32" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF "$(CFG)" == "portmidi - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "pm_win\Debug"
+# PROP Intermediate_Dir "pm_win\Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "pm_common" /I "porttime" /I "pm_win" /D "_LIB" /D "DEBUG" /D "PM_CHECK_ERRORS" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "USE_DLL_FOR_CLEANUP" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ENDIF
+
+# Begin Target
+
+# Name "portmidi - Win32 Release"
+# Name "portmidi - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\pm_common\pmutil.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\pm_win\pmwin.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\pm_win\pmwinmm.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\pm_common\portmidi.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\pm_common\pminternal.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\pm_common\pmutil.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\pm_win\pmwinmm.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\pm_common\portmidi.h
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/pd/portmidi/portmidi.dsw b/pd/portmidi/portmidi.dsw
new file mode 100644
index 00000000..1ccfb5bf
--- /dev/null
+++ b/pd/portmidi/portmidi.dsw
@@ -0,0 +1,158 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "latency"=.\PM_TEST\latency.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name portmidi
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name porttime
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "midithread"=.\pm_test\midithread.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name pm_dll
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name portmidi
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name porttime
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "midithru"=.\pm_test\midithru.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name pm_dll
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name portmidi
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name porttime
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "pm_dll"=.\pm_win\pm_dll.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "portmidi"=.\portmidi.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name porttime
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "porttime"=.\porttime\porttime.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "sysex"=.\pm_test\sysex.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name pm_dll
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name portmidi
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name porttime
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "test"=.\pm_test\test.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name pm_dll
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name portmidi
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name porttime
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/pd/portmidi_osx/Makefile b/pd/portmidi_osx/Makefile
deleted file mode 100644
index d8667355..00000000
--- a/pd/portmidi_osx/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-CC = cc
-CFLAGS = -Wmost
-LDFLAGS = -framework Carbon -framework CoreMIDI
-OBJS = ptdarwin.o pmutil.o pmmacosx.o pmdarwin.o portmidi.o
-LIBS =
-
-all: libportmidi.a pmtest
-
-libportmidi.a: portmidi.h porttime.h pminternal.h $(OBJS)
- rm -f libportmidi.a
- ar rv libportmidi.a $(OBJS)
- ranlib libportmidi.a
-
-pmtest: pmtest.c libportmidi.a
- $(CC) $(CFLAGS) pmtest.c $(OBJS) -o pmtest $(LDFLAGS) $(LIBS)
-
-pmmacosx.o: pmmacosx.c portmidi.h pminternal.h pmmacosx.h porttime.h
-pmdarwin.o: pmdarwin.c portmidi.h pmmacosx.h
-pmutil.o: pmutil.c portmidi.h pmutil.h pminternal.h
-portmidi.o: portmidi.c portmidi.h pminternal.h
-ptdarwin.o: ptdarwin.c porttime.h portmidi.h
-
-clean:
- rm -f pmtest *.o
diff --git a/pd/portmidi_osx/README b/pd/portmidi_osx/README
deleted file mode 100644
index d8a47719..00000000
--- a/pd/portmidi_osx/README
+++ /dev/null
@@ -1,12 +0,0 @@
-PortMidi for MacOS X / Darwin
-Jon Parise <jparise@cmu.edu>
-$Date: 2005-05-18 04:28:50 $
-
-This is the MacOS X / Darwin port of the PortMidi library from the Carnegie
-Mellon Computer Music Group. It is based on the Apple CoreAudio MIDI
-interface.
-
-This port was finished in early 2002. At this point, I consider the code
-base complete.
-
-- Jon
diff --git a/pd/portmidi_osx/pmdarwin.c b/pd/portmidi_osx/pmdarwin.c
deleted file mode 100644
index 01863368..00000000
--- a/pd/portmidi_osx/pmdarwin.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * PortMidi OS-dependent interface for Darwin (MacOS X)
- * Jon Parise <jparise@cmu.edu>
- *
- * $Id: pmdarwin.c,v 1.8 2005-05-18 04:28:50 millerpuckette Exp $
- *
- * CHANGE LOG:
- * 03Jul03 - X. J. Scott (xjs):
- * - Pm_GetDefaultInputDeviceID() and Pm_GetDefaultOutputDeviceID()
- * now return id of first input and output devices in system,
- * rather than returning 0 as before.
- * This fix enables valid default port values to be returned.
- * 0 is returned if no such device is found.
- */
-
-/*
- * This file only needs to implement pm_init(), which calls various
- * routines to register the available midi devices. This file must
- * be separate from the main portmidi.c file because it is system
- * dependent, and it is separate from, say, pmwinmm.c, because it
- * might need to register devices for winmm, directx, and others.
- */
-
-#include <stdlib.h>
-#include "portmidi.h"
-#include "pmmacosx.h"
-
-PmError pm_init(void) // xjs added void
-{
- return pm_macosx_init();
-}
-
-PmError pm_term(void) // xjs added void
-{
- return pm_macosx_term();
-}
-
-/* Pm_GetDefaultInputDeviceID() - return input with lowest id # (xjs)
- */
-PmDeviceID Pm_GetDefaultInputDeviceID()
-{
- int i;
- int device_count;
- const PmDeviceInfo *deviceInfo;
-
- device_count = Pm_CountDevices();
- for (i = 0; i < device_count; i++) {
- deviceInfo = Pm_GetDeviceInfo(i);
- if (deviceInfo->input)
- return i;
- }
-
- return 0;
-};
-
-/* Pm_GetDefaultOutputDeviceID() - return output with lowest id # (xjs)
-*/
-PmDeviceID Pm_GetDefaultOutputDeviceID()
-{
- int i;
- int device_count;
- const PmDeviceInfo *deviceInfo;
-
- device_count = Pm_CountDevices();
- for (i = 0; i < device_count; i++) {
- deviceInfo = Pm_GetDeviceInfo(i);
- if (deviceInfo->output)
- return i;
- }
-
- return 0;
-};
-
-
-void *pm_alloc(size_t s) { return malloc(s); }
-
-void pm_free(void *ptr) { free(ptr); }
-
diff --git a/pd/portmidi_osx/pminternal.h b/pd/portmidi_osx/pminternal.h
deleted file mode 100644
index 2a92e16d..00000000
--- a/pd/portmidi_osx/pminternal.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* pminternal.h -- header for interface implementations */
-
-/* this file is included by files that implement library internals */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/types.h>
-
-/* these are defined in system-specific file */
-void *pm_alloc(size_t s);
-void pm_free(void *ptr);
-
-struct pm_internal_struct;
-
-/* these do not use PmInternal because it is not defined yet... */
-typedef PmError (*pm_write_fn)(struct pm_internal_struct *midi,
- PmEvent *buffer, long length);
-typedef PmError (*pm_open_fn)(struct pm_internal_struct *midi,
- void *driverInfo);
-typedef PmError (*pm_abort_fn)(struct pm_internal_struct *midi);
-typedef PmError (*pm_close_fn)(struct pm_internal_struct *midi);
-
-typedef struct {
- pm_write_fn write;
- pm_open_fn open;
- pm_abort_fn abort;
- pm_close_fn close;
-} pm_fns_node, *pm_fns_type;
-
-/* when open fails, the dictionary gets this set of functions: */
-extern pm_fns_node pm_none_dictionary;
-
-typedef struct {
- PmDeviceInfo pub;
- void *descriptor; /* system-specific data to open device */
- pm_fns_type dictionary;
-} descriptor_node, *descriptor_type;
-
-
-#define pm_descriptor_max 32
-extern descriptor_node descriptors[pm_descriptor_max];
-extern int descriptor_index;
-
-
-typedef unsigned long (*time_get_proc_type)(void *time_info);
-
-typedef struct pm_internal_struct {
- short write_flag; /* MIDI_IN, or MIDI_OUT */
- int device_id; /* which device is open (index to descriptors) */
- PmTimeProcPtr time_proc; /* where to get the time */
- void *time_info; /* pass this to get_time() */
- PmEvent *buffer; /* input or output buffer */
- long buffer_len; /* how big is the buffer */
- long latency; /* time delay in ms between timestamps and actual output */
- /* set to zero to get immediate, simple blocking output */
- /* if latency is zero, timestamps will be ignored */
- int overflow; /* set to non-zero if input is dropped */
- int flush; /* flag to drop incoming sysex data because of overflow */
- int sysex_in_progress; /* use for overflow management */
- struct pm_internal_struct *thru;
- PmTimestamp last_msg_time; /* timestamp of last message */
- long head;
- long tail;
- pm_fns_type dictionary; /* implementation functions */
- void *descriptor; /* system-dependent state */
-} PmInternal;
-
-
-typedef struct {
- long head;
- long tail;
- long len;
- long msg_size;
- long overflow;
- char *buffer;
-} PmQueueRep;
-
-
-PmError pm_init(void); /* defined in a system-specific file */
-PmError pm_term(void); /* defined in a system-specific file */
-int pm_in_device(int n, char *interf, char *device);
-int pm_out_device(int n, char *interf, char *device);
-PmError none_write(PmInternal *midi, PmEvent *buffer, long length);
-PmError pm_success_fn(PmInternal *midi);
-PmError pm_fail_fn(PmInternal *midi);
-long pm_in_poll(PmInternal *midi);
-long pm_out_poll(PmInternal *midi);
-
-PmError pm_add_device(char *interf, char *name, int input, void *descriptor,
- pm_fns_type dictionary);
-
-void pm_enqueue(PmInternal *midi, PmEvent *event);
-
-
-#ifdef __cplusplus
-}
-#endif
-
diff --git a/pd/portmidi_osx/pmmacosx.c b/pd/portmidi_osx/pmmacosx.c
deleted file mode 100644
index 57e3ed7f..00000000
--- a/pd/portmidi_osx/pmmacosx.c
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- * Platform interface to the MacOS X CoreMIDI framework
- *
- * Jon Parise <jparise@cmu.edu>
- *
- * $Id: pmmacosx.c,v 1.8 2005-05-18 04:28:50 millerpuckette Exp $
- *
- * 27Jun02 XJS (X. J. Scott)
- * - midi_length():
- * fixed bug that gave bad lengths for system messages
- *
- * / pm_macosx_init():
- * Now allocates the device names. This fixes bug before where
- * it assigned same string buffer on stack to all devices.
- * - pm_macosx_term(), deleteDeviceName():
- * devices strings allocated during pm_macosx_init() are deallocated.
- *
- * + pm_macosx_init(), newDeviceName():
- * registering kMIDIPropertyManufacturer + kMIDIPropertyModel + kMIDIPropertyName
- * for name strings instead of just name.
- *
- * / pm_macosx_init(): unsigned i to quiet compiler griping
- * - get_timestamp():
- * no change right here but type of Pt_Time() was altered in porttime.h
- * so it matches type PmTimeProcPtr in assignment in this function.
- * / midi_write():
- * changed unsigned to signed to stop compiler griping
- */
-
-#include "portmidi.h"
-#include "pminternal.h"
-#include "porttime.h"
-#include "pmmacosx.h"
-
-#include <stdio.h>
-#include <string.h>
-
-#include <CoreServices/CoreServices.h>
-#include <CoreMIDI/MIDIServices.h>
-
-#define PM_DEVICE_NAME_LENGTH 64
-
-#define PACKET_BUFFER_SIZE 1024
-
-static MIDIClientRef client = NULL; /* Client handle to the MIDI server */
-static MIDIPortRef portIn = NULL; /* Input port handle */
-static MIDIPortRef portOut = NULL; /* Output port handle */
-
-extern pm_fns_node pm_macosx_in_dictionary;
-extern pm_fns_node pm_macosx_out_dictionary;
-
-static char * newDeviceName(MIDIEndpointRef endpoint);
-static void deleteDeviceName(char **szDeviceName_p);
-
-static int
-midi_length(long msg)
-{
- int status, high, low;
- static int high_lengths[] = {
- 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00 through 0x70 */
- 3, 3, 3, 3, 2, 2, 3, 1 /* 0x80 through 0xf0 */
- };
- static int low_lengths[] = {
- 1, 1, 3, 2, 1, 1, 1, 1, /* 0xf0 through 0xf8 */
- 1, 1, 1, 1, 1, 1, 1, 1 /* 0xf9 through 0xff */
- };
-
- status = msg & 0xFF;
- high = status >> 4;
- low = status & 15;
-// return (high != 0xF0) ? high_lengths[high] : low_lengths[low];
- return (high != 0x0F) ? high_lengths[high] : low_lengths[low]; // fixed 6/27/03, xjs
-}
-
-static PmTimestamp
-get_timestamp(PmInternal *midi)
-{
- PmTimeProcPtr time_proc;
-
- /* Set the time procedure accordingly */
- time_proc = midi->time_proc;
- if (time_proc == NULL) {
- time_proc = Pt_Time;
- }
-
- return (*time_proc)(midi->time_info);
-}
-
-/* called when MIDI packets are received */
-static void
-readProc(const MIDIPacketList *newPackets, void *refCon, void *connRefCon)
-{
- PmInternal *midi;
- PmEvent event;
- MIDIPacket *packet;
- unsigned int packetIndex;
-
- /* Retrieve the context for this connection */
- midi = (PmInternal *) connRefCon;
-
- packet = (MIDIPacket *) &newPackets->packet[0];
- for (packetIndex = 0; packetIndex < newPackets->numPackets; packetIndex++) {
-
- /* Build the PmMessage for the PmEvent structure */
- switch (packet->length) {
- case 1:
- event.message = Pm_Message(packet->data[0], 0, 0);
- break;
- case 2:
- event.message = Pm_Message(packet->data[0], packet->data[1], 0);
- break;
- case 3:
- event.message = Pm_Message(packet->data[0], packet->data[1],
- packet->data[2]);
- break;
- default:
- /* Skip packets that are too large to fit in a PmMessage */
- continue;
- }
-
- /* Set the timestamp and dispatch this message */
- event.timestamp = get_timestamp(midi);
- pm_enqueue(midi, &event);
-
- /* Advance to the next packet in the packet list */
- packet = MIDIPacketNext(packet);
- }
-}
-
-static PmError
-midi_in_open(PmInternal *midi, void *driverInfo)
-{
- MIDIEndpointRef endpoint;
-
- endpoint = (MIDIEndpointRef) descriptors[midi->device_id].descriptor;
- if (endpoint == NULL) {
- return pmInvalidDeviceId;
- }
-
- if (MIDIPortConnectSource(portIn, endpoint, midi) != noErr) {
- return pmHostError;
- }
-
- return pmNoError;
-}
-
-static PmError
-midi_in_close(PmInternal *midi)
-{
- MIDIEndpointRef endpoint;
-
- endpoint = (MIDIEndpointRef) descriptors[midi->device_id].descriptor;
- if (endpoint == NULL) {
- return pmInvalidDeviceId;
- }
-
- if (MIDIPortDisconnectSource(portIn, endpoint) != noErr) {
- return pmHostError;
- }
-
- return pmNoError;
-}
-
-static PmError
-midi_out_open(PmInternal *midi, void *driverInfo)
-{
- /*
- * MIDISent() only requires an output port (portOut) and a valid MIDI
- * endpoint (which we've already created and stored in the PmInternal
- * structure). Therefore, no additional work needs to be done here to
- * open the device for output.
- */
-
- return pmNoError;
-}
-
-static PmError
-midi_out_close(PmInternal *midi)
-{
- return pmNoError;
-}
-
-static PmError
-midi_abort(PmInternal *midi)
-{
- return pmNoError;
-}
-
-static PmError
-midi_write(PmInternal *midi, PmEvent *events, long length)
-{
- Byte packetBuffer[PACKET_BUFFER_SIZE];
- MIDIEndpointRef endpoint;
- MIDIPacketList *packetList;
- MIDIPacket *packet;
- MIDITimeStamp timestamp;
- PmTimeProcPtr time_proc;
- PmEvent event;
- unsigned int pm_time;
- long eventIndex; // xjs: long instead of unsigned int, to match type of 'length' which compares against it
- unsigned int messageLength;
- Byte message[3];
-
- endpoint = (MIDIEndpointRef) descriptors[midi->device_id].descriptor;
- if (endpoint == NULL) {
- return pmInvalidDeviceId;
- }
-
- /* Make sure the packetBuffer is large enough */
- if (length > PACKET_BUFFER_SIZE) {
- return pmHostError;
- }
-
- /*
- * Initialize the packet list. Each packet contains bytes that are to
- * be played at the same time.
- */
- packetList = (MIDIPacketList *) packetBuffer;
- if ((packet = MIDIPacketListInit(packetList)) == NULL) {
- return pmHostError;
- }
-
- /* Set the time procedure accordingly */
- time_proc = midi->time_proc;
- if (time_proc == NULL) {
- time_proc = Pt_Time;
- }
-
- /* Extract the event data and pack it into the message buffer */
- for (eventIndex = 0; eventIndex < length; eventIndex++) {
- event = events[eventIndex];
-
- /* Compute the timestamp */
- pm_time = (*time_proc)(midi->time_info);
- timestamp = pm_time + midi->latency;
-
- messageLength = midi_length(event.message);
- message[0] = Pm_MessageStatus(event.message);
- message[1] = Pm_MessageData1(event.message);
- message[2] = Pm_MessageData2(event.message);
-
- /* Add this message to the packet list */
- packet = MIDIPacketListAdd(packetList, sizeof(packetBuffer), packet,
- timestamp, messageLength, message);
- if (packet == NULL) {
- return pmHostError;
- }
- }
-
- if (MIDISend(portOut, endpoint, packetList) != noErr) {
- return pmHostError;
- }
-
- return pmNoError;
-}
-
-/* newDeviceName() -- create a string that describes a MIDI endpoint device
- * deleteDeviceName() -- dispose of string created.
- *
- * Concatenates manufacturer, model and name of endpoint and returns
- * within freshly allocated space, to be registered in pm_add_device().
- *
- * 27Jun03: XJS -- extracted and extended from pm_macosx_init().
- * 11Nov03: XJS -- safely handles cases where any string properties are
- * not present, such as is the case with the virtual ports created
- * by many programs.
- */
-
-static char * newDeviceName(MIDIEndpointRef endpoint)
-{
- CFStringEncoding defaultEncoding;
- CFStringRef deviceCFString;
- char manufBuf[PM_DEVICE_NAME_LENGTH];
- char modelBuf[PM_DEVICE_NAME_LENGTH];
- char nameBuf[PM_DEVICE_NAME_LENGTH];
- char manufModelNameBuf[PM_DEVICE_NAME_LENGTH * 3 + 1];
- char *szDeviceName;
- size_t length;
- OSStatus iErr;
-
- /* Determine the default system character encording */
-
- defaultEncoding = CFStringGetSystemEncoding();
-
- /* Get the manufacturer, model and name of this device and combine into one string. */
-
- iErr = MIDIObjectGetStringProperty(endpoint, kMIDIPropertyManufacturer, &deviceCFString);
- if (noErr == iErr) {
- CFStringGetCString(deviceCFString, manufBuf, sizeof(manufBuf), defaultEncoding);
- CFRelease(deviceCFString);
- }
- else
- strcpy(manufBuf, "<undef. manuf>");
-
- iErr = MIDIObjectGetStringProperty(endpoint, kMIDIPropertyModel, &deviceCFString);
- if (noErr == iErr) {
- CFStringGetCString(deviceCFString, modelBuf, sizeof(modelBuf), defaultEncoding);
- CFRelease(deviceCFString);
- }
- else
- strcpy(modelBuf, "<undef. model>");
-
- iErr = MIDIObjectGetStringProperty(endpoint, kMIDIPropertyName, &deviceCFString);
- if (noErr == iErr) {
- CFStringGetCString(deviceCFString, nameBuf, sizeof(nameBuf), defaultEncoding);
- CFRelease(deviceCFString);
- }
- else
- strcpy(nameBuf, "<undef. name>");
-
- sprintf(manufModelNameBuf, "%s %s: %s", manufBuf, modelBuf, nameBuf);
- length = strlen(manufModelNameBuf);
-
- /* Allocate a new string and return. */
-
- szDeviceName = (char *)pm_alloc(length + 1);
- strcpy(szDeviceName, manufModelNameBuf);
-
- return szDeviceName;
-}
-
-static void deleteDeviceName(char **szDeviceName_p)
-{
- pm_free(*szDeviceName_p);
- *szDeviceName_p = NULL;
- return;
-}
-
-pm_fns_node pm_macosx_in_dictionary = {
- none_write,
- midi_in_open,
- midi_abort,
- midi_in_close
-};
-
-pm_fns_node pm_macosx_out_dictionary = {
- midi_write,
- midi_out_open,
- midi_abort,
- midi_out_close
-};
-
-PmError
-pm_macosx_init(void)
-{
- OSStatus status;
- ItemCount numDevices, numInputs, numOutputs;
- MIDIEndpointRef endpoint;
- unsigned int i; // xjs, unsigned
- char *szDeviceName;
-
- /* Determine the number of MIDI devices on the system */
- numDevices = MIDIGetNumberOfDevices();
- numInputs = MIDIGetNumberOfSources();
- numOutputs = MIDIGetNumberOfDestinations();
-
- /* Return prematurely if no devices exist on the system */
- if (numDevices <= 0) {
- return pmHostError;
- }
-
-
- /* Iterate over the MIDI input devices */
- for (i = 0; i < numInputs; i++) {
- endpoint = MIDIGetSource(i);
- if (endpoint == NULL) {
- continue;
- }
-
- /* Get the manufacturer, model and name of this device and combine into one string. */
- szDeviceName = newDeviceName(endpoint); // xjs
-
- /* Register this device with PortMidi */
- // xjs: szDeviceName is allocated memory since each has to be different and is not copied in pm_add_device()
- pm_add_device("CoreMIDI", szDeviceName, TRUE, (void *)endpoint,
- &pm_macosx_in_dictionary);
- }
-
- /* Iterate over the MIDI output devices */
- for (i = 0; i < numOutputs; i++) {
- endpoint = MIDIGetDestination(i);
- if (endpoint == NULL) {
- continue;
- }
-
- /* Get the manufacturer & model of this device */
- szDeviceName = newDeviceName(endpoint); // xjs
-
- /* Register this device with PortMidi */
- pm_add_device("CoreMIDI", szDeviceName, FALSE, (void *)endpoint, // xjs, szDeviceName (as above)
- &pm_macosx_out_dictionary);
-
- }
-
- /* Initialize the client handle */
- status = MIDIClientCreate(CFSTR("PortMidi"), NULL, NULL, &client);
- if (status != noErr) {
- fprintf(stderr, "Could not initialize client: %d\n", (int)status);
- return pmHostError;
- }
-
- /* Create the input port */
- status = MIDIInputPortCreate(client, CFSTR("Input port"), readProc, NULL,
- &portIn);
- if (status != noErr) {
- fprintf(stderr, "Could not create input port: %d\n", (int)status);
- return pmHostError;
- }
-
- /* Create the output port */
- status = MIDIOutputPortCreate(client, CFSTR("Output port"), &portOut);
- if (status != noErr) {
- fprintf(stderr, "Could not create output port: %d\n", (int)status);
- return pmHostError;
- }
-
- return pmNoError;
-}
-
-PmError
-pm_macosx_term(void)
-{
- int i;
- int device_count;
- const PmDeviceInfo *deviceInfo;
-
- /* release memory allocated for device names */
- device_count = Pm_CountDevices();
- for (i = 0; i < device_count; i++) {
- deviceInfo = Pm_GetDeviceInfo(i);
- deleteDeviceName((char **)&deviceInfo->name);
- }
-
- if (client != NULL) MIDIClientDispose(client);
- if (portIn != NULL) MIDIPortDispose(portIn);
- if (portOut != NULL) MIDIPortDispose(portOut);
-
- return pmNoError;
-}
diff --git a/pd/portmidi_osx/pmmacosx.h b/pd/portmidi_osx/pmmacosx.h
deleted file mode 100644
index 15e9551d..00000000
--- a/pd/portmidi_osx/pmmacosx.h
+++ /dev/null
@@ -1,4 +0,0 @@
-/* system-specific definitions */
-
-PmError pm_macosx_init(void);
-PmError pm_macosx_term(void);
diff --git a/pd/portmidi_osx/pmtest.c b/pd/portmidi_osx/pmtest.c
deleted file mode 100644
index 6e590fd5..00000000
--- a/pd/portmidi_osx/pmtest.c
+++ /dev/null
@@ -1,142 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "portmidi.h"
-#include "porttime.h"
-#include "pminternal.h"
-
-#define LATENCY 0
-#define NUM_ECHOES 10
-
-int
-main()
-{
- int i = 0;
- int n = 0;
- PmStream *midi_in;
- PmStream *midi_out;
- PmError err;
- char line[80];
- PmEvent buffer[NUM_ECHOES];
- int transpose;
- int delay;
- int status, data1, data2;
- int statusprefix;
-
-
- Pm_Initialize(); // xjs
-
- /* always start the timer before you start midi */
- Pt_Start(1, 0, 0); /* start a timer with millisecond accuracy */
-
- printf("%d midi ports found...\n", Pm_CountDevices()); // xjs
- for (i = 0; i < Pm_CountDevices(); i++) {
- const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
- printf("%d: %s, %s", i, info->interf, info->name);
- if (info->input) printf(" (input)");
- if (info->output) printf(" (output)");
- printf("\n");
- }
-
- /* OPEN INPUT DEVICE */
-
- printf("Type input number: ");
- while (n != 1) {
- n = scanf("%d", &i);
- gets(line);
- }
-
- err = Pm_OpenInput(&midi_in, i, NULL, 100, NULL, NULL, NULL);
- if (err) {
- printf("could not open midi device: %s\n", Pm_GetErrorText(err));
- exit(1);
- }
- printf("Midi Input opened.\n");
-
- /* OPEN OUTPUT DEVICE */
-
- printf("Type output number: ");
- n = 0;
- while (n != 1) {
- n = scanf("%d", &i);
- gets(line);
- }
-
- err = Pm_OpenOutput(&midi_out, i, NULL, 0, NULL, NULL, LATENCY);
- if (err) {
- printf("could not open midi device: %s\n", Pm_GetErrorText(err));
- exit(1);
- }
- printf("Midi Output opened with %d ms latency.\n", LATENCY);
-
-
-
- /* Get input from user for parameters */
- printf("Type number of milliseconds for echoes: ");
- n = 0;
- while (n != 1) {
- n = scanf("%d", &delay);
- gets(line);
- }
-
- printf("Type number of semitones to transpose up: ");
- n = 0;
- while (n != 1) {
- n = scanf("%d", &transpose);
- gets(line);
- }
-
- printf("delay %d, tranpose %d\n", delay, transpose); // xjs
-
-
- /* loop, echoing input back transposed with multiple taps */
-
- printf("Press C2 on the keyboard (2 octaves below middle C) to quit.\nWaiting for MIDI input...\n");
-
- do {
- err = Pm_Read(midi_in, buffer, 1);
- if (err == 0) continue; /* no bytes read. */
-
- /* print a hash mark for each event read. */
- printf("#");
- fflush(stdout);
-
- status = Pm_MessageStatus(buffer[0].message);
- data1 = Pm_MessageData1(buffer[0].message);
- data2 = Pm_MessageData2(buffer[0].message);
- statusprefix = status >> 4;
-
- /* ignore messages other than key-down and key-up */
- if ((statusprefix != 0x9) && (statusprefix != 0x8)) continue;
-
- printf("\nReceived key message = %X %X %X, at time %ld\n", status, data1, data2, buffer[0].timestamp);
- fflush(stdout);
-
- /* immediately send the echoes to PortMIDI (note that only the echoes are to be transposed) */
- for (i = 1; i < NUM_ECHOES; i++) {
- buffer[i].message = Pm_Message(status, data1 + transpose, data2 >> i);
- buffer[i].timestamp = buffer[0].timestamp + (i * delay);
- }
- Pm_Write(midi_out, buffer, NUM_ECHOES);
- } while (data1 != 36); /* quit when C2 is pressed */
-
- printf("Key C2 pressed. Exiting...\n");
- fflush(stdout);
-
- Pt_Stop(); // xjs
-
- /* Give the echoes time to finish before quitting. */
- sleep(((NUM_ECHOES * delay) / 1000) + 1);
-
- Pm_Close(midi_in);
- Pm_Close(midi_out);
-
- Pm_Terminate(); // xjs
-
- printf("Done.\n");
- return 0;
-}
-
-
-
diff --git a/pd/portmidi_osx/pmutil.c b/pd/portmidi_osx/pmutil.c
deleted file mode 100644
index f3582a42..00000000
--- a/pd/portmidi_osx/pmutil.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/* pmutil.c -- some helpful utilities for building midi
- applications that use PortMidi
- */
-#include "stdlib.h"
-#include "memory.h"
-#include "portmidi.h"
-#include "pmutil.h"
-#include "pminternal.h"
-
-
-PmQueue *Pm_QueueCreate(long num_msgs, long bytes_per_msg)
-{
- PmQueueRep *queue = (PmQueueRep *) malloc(sizeof(PmQueueRep));
- if (!queue) return NULL;
- queue->len = num_msgs * bytes_per_msg;
- queue->buffer = malloc(queue->len);
- if (!queue->buffer) {
- free(queue);
- return NULL;
- }
- queue->head = 0;
- queue->tail = 0;
- queue->msg_size = bytes_per_msg;
- queue->overflow = FALSE;
- return queue;
-}
-
-
-PmError Pm_QueueDestroy(PmQueue *q)
-{
- PmQueueRep *queue = (PmQueueRep *) q;
- if (!queue || !queue->buffer) return pmBadPtr;
- free(queue->buffer);
- free(queue);
- return pmNoError;
-}
-
-
-PmError Pm_Dequeue(PmQueue *q, void *msg)
-{
- long head;
- PmQueueRep *queue = (PmQueueRep *) q;
- if (queue->overflow) {
- queue->overflow = FALSE;
- return pmBufferOverflow;
- }
- head = queue->head; /* make sure this is written after access */
- if (head == queue->tail) return 0;
- memcpy(msg, queue->buffer + head, queue->msg_size);
- head += queue->msg_size;
- if (head == queue->len) head = 0;
- queue->head = head;
- return 1; /* success */
-}
-
-
-/* source should not enqueue data if overflow is set */
-/**/
-PmError Pm_Enqueue(PmQueue *q, void *msg)
-{
- PmQueueRep *queue = (PmQueueRep *) q;
- long tail = queue->tail;
- memcpy(queue->buffer + tail, msg, queue->msg_size);
- tail += queue->msg_size;
- if (tail == queue->len) tail = 0;
- if (tail == queue->head) {
- queue->overflow = TRUE;
- /* do not update tail, so message is lost */
- return pmBufferOverflow;
- }
- queue->tail = tail;
- return pmNoError;
-}
-
-
-int Pm_QueueFull(PmQueue *q)
-{
- PmQueueRep *queue = (PmQueueRep *) q;
- long tail = queue->tail;
- tail += queue->msg_size;
- if (tail == queue->len) {
- tail = 0;
- }
- return (tail == queue->head);
-}
-
diff --git a/pd/portmidi_osx/pmutil.h b/pd/portmidi_osx/pmutil.h
deleted file mode 100644
index b6268ed3..00000000
--- a/pd/portmidi_osx/pmutil.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* pmutil.h -- some helpful utilities for building midi
- applications that use PortMidi
- */
-
-typedef void PmQueue;
-
-/*
- A single-reader, single-writer queue is created by
- Pm_QueueCreate(), which takes the number of messages and
- the message size as parameters. The queue only accepts
- fixed sized messages. Returns NULL if memory cannot be allocated.
-
- Pm_QueueDestroy() destroys the queue and frees its storage.
- */
-
-PmQueue *Pm_QueueCreate(long num_msgs, long bytes_per_msg);
-PmError Pm_QueueDestroy(PmQueue *queue);
-
-/*
- Pm_Dequeue() removes one item from the queue, copying it into msg.
- Returns 1 if successful, and 0 if the queue is empty.
- Returns pmBufferOverflow and clears the overflow flag if
- the flag is set.
- */
-PmError Pm_Dequeue(PmQueue *queue, void *msg);
-
-
-/*
- Pm_Enqueue() inserts one item into the queue, copying it from msg.
- Returns pmNoError if successful and pmBufferOverflow if the queue was
- already full. If pmBufferOverflow is returned, the overflow flag is set.
- */
-PmError Pm_Enqueue(PmQueue *queue, void *msg);
-
-
-/*
- Pm_QueueFull() returns non-zero if the queue is full
- Pm_QueueEmpty() returns non-zero if the queue is empty
-
- Either condition may change immediately because a parallel
- enqueue or dequeue operation could be in progress.
- */
-int Pm_QueueFull(PmQueue *queue);
-#define Pm_QueueEmpty(m) (m->head == m->tail)
diff --git a/pd/portmidi_osx/portmidi.c b/pd/portmidi_osx/portmidi.c
deleted file mode 100644
index c8883303..00000000
--- a/pd/portmidi_osx/portmidi.c
+++ /dev/null
@@ -1,357 +0,0 @@
-#include "stdlib.h"
-#include "portmidi.h"
-#include "pminternal.h"
-
-#define is_empty(midi) ((midi)->tail == (midi)->head)
-
-static int pm_initialized = FALSE;
-
-int descriptor_index = 0;
-descriptor_node descriptors[pm_descriptor_max];
-
-
-/* pm_add_device -- describe interface/device pair to library
- *
- * This is called at initialization time, once for each
- * interface (e.g. DirectSound) and device (e.g. SoundBlaster 1)
- * The strings are retained but NOT COPIED, so do not destroy them!
- *
- * returns pmInvalidDeviceId if device memory is exceeded
- * otherwise returns pmNoError
- *
- */
-
-PmError pm_add_device(char *interf, char *name, int input,
- void *descriptor, pm_fns_type dictionary)
-{
- if (descriptor_index >= pm_descriptor_max) {
- return pmInvalidDeviceId;
- }
- descriptors[descriptor_index].pub.interf = interf;
- descriptors[descriptor_index].pub.name = name;
- descriptors[descriptor_index].pub.input = input;
- descriptors[descriptor_index].pub.output = !input;
- descriptors[descriptor_index].descriptor = descriptor;
- descriptors[descriptor_index].dictionary = dictionary;
- descriptor_index++;
- return pmNoError;
-}
-
-
-PmError Pm_Initialize( void )
-{
- if (!pm_initialized) {
- PmError err = pm_init(); /* defined by implementation specific file */
- if (err) return err;
- pm_initialized = TRUE;
- }
- return pmNoError;
-}
-
-
-PmError Pm_Terminate( void )
-{
- PmError err = pmNoError;
- if (pm_initialized) {
- err = pm_term(); /* defined by implementation specific file */
- /* note that even when pm_term() fails, we mark portmidi as
- not initialized */
- pm_initialized = FALSE;
- }
- return err;
-}
-
-
-int Pm_CountDevices( void )
-{
- PmError err = Pm_Initialize();
- if (err) return err;
-
- return descriptor_index;
-}
-
-
-const PmDeviceInfo* Pm_GetDeviceInfo( PmDeviceID id )
-{
- PmError err = Pm_Initialize();
- if (err) return NULL;
-
- if (id >= 0 && id < descriptor_index) {
- return &descriptors[id].pub;
- }
- return NULL;
-}
-
-
-/* failure_fn -- "noop" function pointer */
-/**/
-PmError failure_fn(PmInternal *midi)
-{
- return pmBadPtr;
-}
-
-
-/* pm_success_fn -- "noop" function pointer */
-/**/
-PmError pm_success_fn(PmInternal *midi)
-{
- return pmNoError;
-}
-
-
-PmError none_write(PmInternal *midi, PmEvent *buffer, long length)
-{
- return length; /* if we return 0, caller might get into a loop */
-}
-
-PmError pm_fail_fn(PmInternal *midi)
-{
- return pmBadPtr;
-}
-
-static PmError none_open(PmInternal *midi, void *driverInfo)
-{
- return pmBadPtr;
-}
-
-#define none_abort pm_fail_fn
-
-#define none_close pm_fail_fn
-
-
-pm_fns_node pm_none_dictionary = {
- none_write, none_open,
- none_abort, none_close };
-
-
-/* Pm_Read -- read up to length longs from source into buffer */
-/*
- * returns number of longs actually read, or error code
- When the reader wants data:
- if overflow_flag:
- do not get anything
- empty the buffer (read_ptr = write_ptr)
- clear overflow_flag
- return pmBufferOverflow
- get data
- return number of messages
-
-
- */
-PmError Pm_Read( PortMidiStream *stream, PmEvent *buffer, long length)
-{
- PmInternal *midi = (PmInternal *) stream;
- int n = 0;
- long head = midi->head;
- while (head != midi->tail && n < length) {
- *buffer++ = midi->buffer[head++];
- if (head == midi->buffer_len) head = 0;
- n++;
- }
- midi->head = head;
- if (midi->overflow) {
- midi->head = midi->tail;
- midi->overflow = FALSE;
- return pmBufferOverflow;
- }
- return n;
-}
-
-
-PmError Pm_Poll( PortMidiStream *stream )
-{
- PmInternal *midi = (PmInternal *) stream;
- return midi->head != midi->tail;
-}
-
-
-PmError Pm_Write( PortMidiStream *stream, PmEvent *buffer, long length)
-{
- PmInternal *midi = (PmInternal *) stream;
- return (*midi->dictionary->write)(midi, buffer, length);
-}
-
-
-PmError Pm_WriteShort( PortMidiStream *stream, long when, long msg)
-{
- PmEvent event;
- event.timestamp = when;
- event.message = msg;
- return Pm_Write(stream, &event, 1);
-}
-
-
-PmError Pm_OpenInput( PortMidiStream** stream,
- PmDeviceID inputDevice,
- void *inputDriverInfo,
- long bufferSize,
- PmTimeProcPtr time_proc,
- void *time_info,
- PmStream *thru)
-{
- PmInternal *midi;
-
- PmError err = Pm_Initialize();
- if (err) return err;
-
- if (inputDevice < 0 || inputDevice >= descriptor_index) {
- return pmInvalidDeviceId;
- }
-
- if (!descriptors[inputDevice].pub.input) {
- return pmInvalidDeviceId;
- }
-
- midi = (PmInternal *) malloc(sizeof(PmInternal));
- *stream = midi;
- if (!midi) return pmInsufficientMemory;
-
- midi->head = 0;
- midi->tail = 0;
- midi->dictionary = &pm_none_dictionary;
- midi->overflow = FALSE;
- midi->flush = FALSE;
- midi->sysex_in_progress = FALSE;
- midi->buffer_len = bufferSize;
- midi->buffer = (PmEvent *) pm_alloc(sizeof(PmEvent) * midi->buffer_len);
- if (!midi->buffer) return pmInsufficientMemory;
- midi->latency = 0;
- midi->thru = thru;
- midi->time_proc = time_proc;
- midi->time_info = time_info;
- midi->device_id = inputDevice;
- midi->dictionary = descriptors[inputDevice].dictionary;
- midi->write_flag = FALSE;
- err = (*midi->dictionary->open)(midi, inputDriverInfo);
- if (err) {
- pm_free(midi->buffer);
- *stream = NULL;
- }
- return err;
-}
-
-
-PmError Pm_OpenOutput( PortMidiStream** stream,
- PmDeviceID outputDevice,
- void *outputDriverInfo,
- long bufferSize,
- PmTimeProcPtr time_proc,
- void *time_info,
- long latency )
-{
- PmInternal *midi;
-
- PmError err = Pm_Initialize();
- if (err) return err;
-
- if (outputDevice < 0 || outputDevice >= descriptor_index) {
- return pmInvalidDeviceId;
- }
-
- if (!descriptors[outputDevice].pub.output) {
- return pmInvalidDeviceId;
- }
-
- midi = (PmInternal *) pm_alloc(sizeof(PmInternal));
- *stream = midi;
- if (!midi) return pmInsufficientMemory;
-
- midi->head = 0;
- midi->tail = 0;
- midi->buffer_len = bufferSize;
- midi->buffer = NULL;
- midi->device_id = outputDevice;
- midi->dictionary = descriptors[outputDevice].dictionary;
- midi->time_proc = time_proc;
- midi->time_info = time_info;
- midi->latency = latency;
- midi->write_flag = TRUE;
- err = (*midi->dictionary->open)(midi, outputDriverInfo);
- if (err) {
- *stream = NULL;
- pm_free(midi); // Fixed by Ning Hu, Sep.2001
- }
- return err;
-}
-
-
-PmError Pm_Abort( PortMidiStream* stream )
-{
- PmInternal *midi = (PmInternal *) stream;
- return (*midi->dictionary->abort)(midi);
-}
-
-PmError Pm_Close( PortMidiStream *stream )
-{
- PmInternal *midi = (PmInternal *) stream;
- return (*midi->dictionary->close)(midi);
-}
-
-
-const char *Pm_GetErrorText( PmError errnum )
-{
- const char *msg;
-
- switch(errnum)
- {
- case pmNoError: msg = "Success"; break;
- case pmHostError: msg = "Host error."; break;
- case pmInvalidDeviceId: msg = "Invalid device ID."; break;
- case pmInsufficientMemory: msg = "Insufficient memory."; break;
- case pmBufferTooSmall: msg = "Buffer too small."; break;
- case pmBadPtr: msg = "Bad pointer."; break;
- case pmInternalError: msg = "Internal PortMidi Error."; break;
- default: msg = "Illegal error number."; break;
- }
- return msg;
-}
-
-
-long pm_next_time(PmInternal *midi)
-{
- return midi->buffer[midi->head].timestamp;
-}
-
-
-/* source should not enqueue data if overflow is set */
-/*
- When producer has data to enqueue:
- if buffer is full:
- set overflow_flag and flush_flag
- return
- else if overflow_flag:
- return
- else if flush_flag:
- if sysex message is in progress:
- return
- else:
- clear flush_flag
- // fall through to enqueue data
- enqueue the data
-
- */
-void pm_enqueue(PmInternal *midi, PmEvent *event)
-{
- long tail = midi->tail;
- midi->buffer[tail++] = *event;
- if (tail == midi->buffer_len) tail = 0;
- if (tail == midi->head || midi->overflow) {
- midi->overflow = TRUE;
- midi->flush = TRUE;
- return;
- }
- if (midi->flush) {
- if (midi->sysex_in_progress) return;
- else midi->flush = FALSE;
- }
- midi->tail = tail;
-}
-
-
-int pm_queue_full(PmInternal *midi)
-{
- long tail = midi->tail + 1;
- if (tail == midi->buffer_len) tail = 0;
- return tail == midi->head;
-}
-
diff --git a/pd/portmidi_osx/portmidi.h b/pd/portmidi_osx/portmidi.h
deleted file mode 100644
index 1264b6f5..00000000
--- a/pd/portmidi_osx/portmidi.h
+++ /dev/null
@@ -1,341 +0,0 @@
-#ifndef PORT_MIDI_H
-#define PORT_MIDI_H
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/*
- * PortMidi Portable Real-Time Audio Library
- * PortMidi API Header File
- * Latest version available at: http://www.cs.cmu.edu/~music/portmidi/
- *
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- * Copyright (c) 2001 Roger B. Dannenberg
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * Any person wishing to distribute modifications to the Software is
- * requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
-/* CHANGELOG FOR PORTMIDI -- THIS VERSION IS 1.0
- *
- * 21Jan02 RBD Added tests in Pm_OpenInput() and Pm_OpenOutput() to
- * prevent opening an input as output and vice versa.
- * Added comments and documentation.
- * Implemented Pm_Terminate().
- *
- * 27Jun03 X. J. Scott (XJS)
- * - Adding void arg to Pm_GetHostError() to stop compiler gripe.
- */
-
-#ifndef FALSE
- #define FALSE 0
-#endif
-#ifndef TRUE
- #define TRUE 1
-#endif
-
-
-typedef enum {
- pmNoError = 0,
-
- pmHostError = -10000,
- pmInvalidDeviceId, /* out of range or
- output device when input is requested or
- input device when output is requested */
- //pmInvalidFlag,
- pmInsufficientMemory,
- pmBufferTooSmall,
- pmBufferOverflow,
- pmBadPtr,
- pmInternalError
-} PmError;
-
-/*
- Pm_Initialize() is the library initialisation function - call this before
- using the library.
-*/
-
-PmError Pm_Initialize( void );
-
-/*
- Pm_Terminate() is the library termination function - call this after
- using the library.
-*/
-
-PmError Pm_Terminate( void );
-
-/*
- Return host specific error number. All host-specific errors are translated
- to the single error class pmHostError. To find out the original error
- number, call Pm_GetHostError().
- This can be called after a function returns a PmError equal to pmHostError.
-*/
-int Pm_GetHostError( void ); /* xjs - void param to stop compiler gripe */
-
-/*
- Translate the error number into a human readable message.
-*/
-const char *Pm_GetErrorText( PmError errnum );
-
-
-/*
- Device enumeration mechanism.
-
- Device ids range from 0 to Pm_CountDevices()-1.
-
- Devices may support input, output or both. Device 0 is always the "default"
- device. Other platform specific devices are specified by positive device
- ids.
-*/
-
-typedef int PmDeviceID;
-#define pmNoDevice -1
-
-typedef struct {
- int structVersion;
- char const *interf;
- char const *name;
- int input; /* true iff input is available */
- int output; /* true iff output is available */
-} PmDeviceInfo;
-
-
-int Pm_CountDevices( void );
-/*
- Pm_GetDefaultInputDeviceID(), Pm_GetDefaultOutputDeviceID()
-
- Return the default device ID or pmNoDevice if there is no devices.
- The result can be passed to Pm_OpenMidi().
-
- On the PC, the user can specify a default device by
- setting an environment variable. For example, to use device #1.
-
- set PM_RECOMMENDED_OUTPUT_DEVICE=1
-
- The user should first determine the available device ID by using
- the supplied application "pm_devs".
-*/
-PmDeviceID Pm_GetDefaultInputDeviceID( void );
-PmDeviceID Pm_GetDefaultOutputDeviceID( void );
-
-/*
- PmTimestamp is used to represent a millisecond clock with arbitrary
- start time. The type is used for all MIDI timestampes and clocks.
-*/
-
-typedef long PmTimestamp;
-
-/* TRUE if t1 before t2? */
-#define PmBefore(t1,t2) ((t1-t2) < 0)
-
-
-/*
- Pm_GetDeviceInfo() returns a pointer to a PmDeviceInfo structure
- referring to the device specified by id.
- If id is out of range the function returns NULL.
-
- The returned structure is owned by the PortMidi implementation and must
- not be manipulated or freed. The pointer is guaranteed to be valid
- between calls to Pm_Initialize() and Pm_Terminate().
-*/
-
-const PmDeviceInfo* Pm_GetDeviceInfo( PmDeviceID id );
-
-
-/*
- A single PortMidiStream is a descriptor for an open MIDI device.
-*/
-
-typedef void PortMidiStream;
-#define PmStream PortMidiStream
-
-typedef PmTimestamp (*PmTimeProcPtr)(void *time_info);
-
-
-/*
- Pm_Open() opens a device; for either input or output.
-
- Port is the address of a PortMidiStream pointer which will receive
- a pointer to the newly opened stream.
-
- inputDevice is the id of the device used for input (see PmDeviceID above.)
-
- inputDriverInfo is a pointer to an optional driver specific data structure
- containing additional information for device setup or handle processing.
- inputDriverInfo is never required for correct operation. If not used
- inputDriverInfo should be NULL.
-
- outputDevice is the id of the device used for output (see PmDeviceID above.)
-
- outputDriverInfo is a pointer to an optional driver specific data structure
- containing additional information for device setup or handle processing.
- outputDriverInfo is never required for correct operation. If not used
- outputDriverInfo should be NULL.
-
- latency is the delay in milliseconds applied to timestamps to determine
- when the output should actually occur.
-
- time_proc is a pointer to a procedure that returns time in milliseconds. It
- may be NULL, in which case a default millisecond timebase is used.
-
- time_info is a pointer passed to time_proc.
-
- thru points to a PmMidi descriptor opened for output; Midi input will be
- copied to this output. To disable Midi thru, use NULL.
-
- return value:
- Upon success Pm_Open() returns PmNoError and places a pointer to a
- valid PortMidiStream in the stream argument.
- If a call to Pm_Open() fails a nonzero error code is returned (see
- PMError above) and the value of port is invalid.
-
-*/
-
-PmError Pm_OpenInput( PortMidiStream** stream,
- PmDeviceID inputDevice,
- void *inputDriverInfo,
- long bufferSize,
- PmTimeProcPtr time_proc,
- void *time_info,
- PmStream* thru );
-
-
-PmError Pm_OpenOutput( PortMidiStream** stream,
- PmDeviceID outputDevice,
- void *outputDriverInfo,
- long bufferSize,
- PmTimeProcPtr time_proc,
- void *time_info,
- long latency );
-
-
-/*
- Pm_Abort() terminates outgoing messages immediately
- */
-PmError Pm_Abort( PortMidiStream* stream );
-
-/*
- Pm_Close() closes a midi stream, flushing any pending buffers.
-*/
-
-PmError Pm_Close( PortMidiStream* stream );
-
-
-/*
- Pm_Message() encodes a short Midi message into a long word. If data1
- and/or data2 are not present, use zero. The port parameter is the
- index of the Midi port if the device supports more than one.
-
- Pm_MessagePort(), Pm_MessageStatus(), Pm_MessageData1(), and
- Pm_MessageData2() extract fields from a long-encoded midi message.
-*/
-
-#define Pm_Message(status, data1, data2) \
- ((((data2) << 16) & 0xFF0000) | \
- (((data1) << 8) & 0xFF00) | \
- ((status) & 0xFF))
-
-#define Pm_MessageStatus(msg) ((msg) & 0xFF)
-#define Pm_MessageData1(msg) (((msg) >> 8) & 0xFF)
-#define Pm_MessageData2(msg) (((msg) >> 16) & 0xFF)
-
-/* All midi data comes in the form of PmEvent structures. A sysex
- message is encoded as a sequence of PmEvent structures, with each
- structure carrying 4 bytes of the message, i.e. only the first
- PmEvent carries the status byte.
-
- When receiving sysex messages, the sysex message is terminated
- by either an EOX status byte (anywhere in the 4 byte message) or
- by a non-real-time status byte in the low order byte of message.
- If you get a non-real-time status byte, it means the sysex message
- was somehow truncated. It is permissible to interleave real-time
- messages within sysex messages.
- */
-
-typedef long PmMessage;
-
-typedef struct {
- PmMessage message;
- PmTimestamp timestamp;
-} PmEvent;
-
-
-/*
- Pm_Read() retrieves midi data into a buffer, and returns the number
- of events read. Result is a non-negative number unless an error occurs,
- in which case a PmError value will be returned.
-
- Buffer Overflow
-
- The problem: if an input overflow occurs, data will be lost, ultimately
- because there is no flow control all the way back to the data source.
- When data is lost, the receiver should be notified and some sort of
- graceful recovery should take place, e.g. you shouldn't resume receiving
- in the middle of a long sysex message.
-
- With a lock-free fifo, which is pretty much what we're stuck with to
- enable portability to the Mac, it's tricky for the producer and consumer
- to synchronously reset the buffer and resume normal operation.
-
- Solution: the buffer managed by PortMidi will be flushed when an overflow
- occurs. The consumer (Pm_Read()) gets an error message (pmBufferOverflow)
- and ordinary processing resumes as soon as a new message arrives. The
- remainder of a partial sysex message is not considered to be a "new
- message" and will be flushed as well.
-
-*/
-
-PmError Pm_Read( PortMidiStream *stream, PmEvent *buffer, long length );
-
-/*
- Pm_Poll() tests whether input is available, returning TRUE, FALSE, or
- an error value.
-*/
-
-PmError Pm_Poll( PortMidiStream *stream);
-
-/*
- Pm_Write() writes midi data from a buffer. This may contain short
- messages or sysex messages that are converted into a sequence of PmEvent
- structures. Use Pm_WriteSysEx() to write a sysex message stored as a
- contiguous array of bytes.
-*/
-
-PmError Pm_Write( PortMidiStream *stream, PmEvent *buffer, long length );
-
-/*
- Pm_WriteShort() writes a timestamped non-system-exclusive midi message.
-*/
-
-PmError Pm_WriteShort( PortMidiStream *stream, PmTimestamp when, long msg);
-
-/*
- Pm_WriteSysEx() writes a timestamped system-exclusive midi message.
-*/
-PmError Pm_WriteSysEx( PortMidiStream *stream, PmTimestamp when, char *msg);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* PORT_MIDI_H */
diff --git a/pd/portmidi_osx/portmidi_osx_change_log.txt b/pd/portmidi_osx/portmidi_osx_change_log.txt
deleted file mode 100644
index 80640c3b..00000000
--- a/pd/portmidi_osx/portmidi_osx_change_log.txt
+++ /dev/null
@@ -1,70 +0,0 @@
-PortMIDI changes of 27 June 2003 by X. J. Scott
-
-pmdarwin.c
-----------
-- added void parameter list to pm_init and pm_term
- (to remove a compiler warning)
-- Pm_GetDefaultInputDeviceID() and Pm_GetDefaultOutputDeviceID()
- now return id of first input and output devices in system,
- rather than returning 0 as before.
- This fix enables valid default port values to be returned.
- 0 is returned if no such device is found.
-
-ptdarwin.c
-----------
-- added void parameter list to Pt_Stop and Pt_Started
- (to remove a compiler warning)
-- added void *time_info parameter list to Pt_time
- -> since Pt_Time is assigned in pmmacosx.c:get_timestamp() to
- a variable of type PMTimeProcPtr, which requires this signature.
-
-porttime.h
-----------
-- added void parameter list to Pt_Stop and Pt_Started
-- added void *time_info parameter list to Pt_time
-
-pmmacosx.c
-----------
-- midi_length():
- fixed bug that gave bad lengths for system messages
- [note that the F5 message may be an issue for someone
- to deal with later since the MIDITimePiece interface appopriated
- the F5 for a two byte long CableSelectID - this usage
- and length differ from the MIDI standard.]
-
-/ pm_macosx_init():
- Now allocates the device names. This fixes bug before where
- it assigned same string buffer on stack to all devices.
-- pm_macosx_term(), deleteDeviceName():
- devices strings allocated during pm_macosx_init() are deallocated.
-
-+ pm_macosx_init(), newDeviceName():
- registering kMIDIPropertyManufacturer + kMIDIPropertyModel +
- kMIDIPropertyName for name strings instead of just name.
-
-/ pm_macosx_init():
- unsigned i to quiet compiler griping
-- get_timestamp():
- no change right here but type of Pt_Time() was altered in porttime.h
- so it matches type PmTimeProcPtr in assignment in this function.
-/ midi_write():
- changed unsigned to signed to stop compiler griping
-
-portmidi.h
-----------
-- Added void arg to Pm_GetHostError() to stop compiler gripe.
-
-pmtest.c
----------
-- Added Initialize and Terminate calls so that it doesn't
- fail the 2nd time the test is run.
-
------
-
-PortMIDI changes of 11 Nov 2003 by X. J. Scott
-
-pmmacosx.c
-----------
-- Handles ports that don't have the full set of property strings.
- This fixes bug where crash would occur if a virtual port was present.
-
diff --git a/pd/portmidi_osx/porttime.h b/pd/portmidi_osx/porttime.h
deleted file mode 100644
index fb57fe7d..00000000
--- a/pd/portmidi_osx/porttime.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* porttime.h -- portable interface to millisecond timer
- *
- * 27Jun02 XJS - altered type of Pt_Time() (in porttime.h & portmidi.c) so it matches PmTimeProcPtr
- */
-
-/* Should there be a way to choose the source of time here? */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-typedef enum {
- ptNoError = 0,
- ptHostError = -10000,
- ptAlreadyStarted,
- ptAlreadyStopped
-} PtError;
-
-
-typedef long PtTimestamp;
-
-typedef int (PtCallback)( PtTimestamp timestamp, void *userData );
-
-
-PtError Pt_Start(int resolution, PtCallback *callback, void *userData);
-PtError Pt_Stop(void); // xjs, added void
-int Pt_Started(void); // xjs, added void
-PtTimestamp Pt_Time(void *time_info); /* xjs - added void *time_info so this f() is a PmTimeProcPtr, defined in portmidi.h */
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/pd/portmidi_osx/ptdarwin.c b/pd/portmidi_osx/ptdarwin.c
deleted file mode 100644
index be34eb6b..00000000
--- a/pd/portmidi_osx/ptdarwin.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Portable timer implementation for Darwin / MacOS X
- *
- * Jon Parise <jparise@cmu.edu>
- *
- * $Id: ptdarwin.c,v 1.8 2005-05-18 04:28:50 millerpuckette Exp $
- */
-
-#include <stdio.h>
-#include <sys/time.h>
-#include "porttime.h"
-
-#define TRUE 1
-#define FALSE 0
-
-static int time_started_flag = FALSE;
-static struct timeval time_offset;
-
-PtError Pt_Start(int resolution, PtCallback *callback, void *userData)
-{
- struct timezone tz;
-
- if (callback) printf("error in porttime: callbacks not implemented\n");
- time_started_flag = TRUE;
- gettimeofday(&time_offset, &tz);
-
- return ptNoError;
-}
-
-
-PtError Pt_Stop(void) // xjs added void
-{
- time_started_flag = FALSE;
- return ptNoError;
-}
-
-
-int Pt_Started(void) // xjs added void
-{
- return time_started_flag;
-}
-
-
-PtTimestamp Pt_Time(void *time_info) // xjs added void *time_info
-{
- long seconds, milliseconds;
- struct timeval now;
- struct timezone tz;
-
- gettimeofday(&now, &tz);
- seconds = now.tv_sec - time_offset.tv_sec;
- milliseconds = (now.tv_usec - time_offset.tv_usec) / 1000;
-
- return (seconds * 1000 + milliseconds);
-}
-
-
-