aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2003-08-29 13:53:51 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2003-08-29 13:53:51 +0000
commitde86cb7754d773a2dba3ae92eb0dfc4cb9d77cbd (patch)
treeb84e943785318f49e99423980235c207d2f2435c
parentfbc6df8b8cfcf9603df93b02e0625067feebb6f1 (diff)
imported latest version 1.4 direct from Olaf
svn path=/trunk/externals/maxlib/; revision=898
-rw-r--r--help/help-allow.pd21
-rw-r--r--help/help-arraycopy.pd62
-rw-r--r--help/help-deny.pd20
-rw-r--r--help/help-listfifo.pd26
-rw-r--r--help/help-maxlib.pd188
-rw-r--r--help/help-nchange.pd31
-rw-r--r--help/help-remote.pd4
-rw-r--r--help/help-sync.pd53
-rw-r--r--src/allow.c112
-rw-r--r--src/arbran.c11
-rw-r--r--src/arraycopy.c283
-rw-r--r--src/average.c17
-rw-r--r--src/beat.c18
-rw-r--r--src/beta.c18
-rw-r--r--src/bilex.c14
-rw-r--r--src/borax.c18
-rw-r--r--src/cauchy.c11
-rw-r--r--src/chord.c17
-rw-r--r--src/delta.c18
-rw-r--r--src/deny.c114
-rw-r--r--src/dist.c17
-rw-r--r--src/divide.c17
-rw-r--r--src/divmod.c17
-rw-r--r--src/edge.c17
-rw-r--r--src/expo.c14
-rw-r--r--src/fifo.c17
-rw-r--r--src/gauss.c15
-rw-r--r--src/gestalt.c18
-rw-r--r--src/history.c23
-rw-r--r--src/ignore.c22
-rw-r--r--src/iso.c54
-rw-r--r--src/lifo.c21
-rw-r--r--src/limit.c14
-rw-r--r--src/linear.c14
-rw-r--r--src/listfifo.c109
-rw-r--r--src/listfunnel.c17
-rw-r--r--src/match.c12
-rw-r--r--src/minus.c20
-rw-r--r--src/mlife.c25
-rw-r--r--src/multi.c20
-rw-r--r--src/nchange.c205
-rw-r--r--src/netclient.c24
-rw-r--r--src/netdist.c32
-rw-r--r--src/netrec.c28
-rw-r--r--src/netserver.c33
-rw-r--r--src/nroute.c22
-rw-r--r--src/pitch.c17
-rw-r--r--src/plus.c19
-rw-r--r--src/poisson.c14
-rw-r--r--src/pong.c21
-rw-r--r--src/pulse.c51
-rw-r--r--src/remote.c18
-rw-r--r--src/rewrap.c20
-rw-r--r--src/rhythm.c22
-rw-r--r--src/scale.c15
-rw-r--r--src/score.c26
-rw-r--r--src/speedlim.c14
-rw-r--r--src/split.c18
-rw-r--r--src/step.c19
-rw-r--r--src/subst.c23
-rw-r--r--src/sync.c294
-rw-r--r--src/temperature.c20
-rw-r--r--src/tilt.c22
-rw-r--r--src/timebang.c37
-rw-r--r--src/triang.c13
-rw-r--r--src/unroute.c19
-rw-r--r--src/urn.c12
-rw-r--r--src/velocity.c17
-rw-r--r--src/weibull.c13
-rw-r--r--src/wrap.c17
70 files changed, 2352 insertions, 292 deletions
diff --git a/help/help-allow.pd b/help/help-allow.pd
new file mode 100644
index 0000000..084d52f
--- /dev/null
+++ b/help/help-allow.pd
@@ -0,0 +1,21 @@
+#N canvas 358 305 554 308 12;
+#X text 24 17 allow :: lets only 'allowed' floats or symbols through
+;
+#X text 97 34 written by Olaf Matthes <olaf.matthes@gmx.de>;
+#X msg 125 65 cat;
+#X msg 147 97 dog;
+#X msg 157 126 bird;
+#X floatatom 82 269 5 0 0 0 - - -;
+#X symbolatom 151 246 10 0 0 0 - - -;
+#X obj 114 156 symbol \$1;
+#X floatatom 40 81 5 0 0 0 - - -;
+#X obj 82 217 route float symbol;
+#X obj 82 189 allow 17 cat dog 23;
+#X connect 2 0 7 0;
+#X connect 3 0 7 0;
+#X connect 4 0 7 0;
+#X connect 7 0 10 0;
+#X connect 8 0 10 0;
+#X connect 9 0 5 0;
+#X connect 9 1 6 0;
+#X connect 10 0 9 0;
diff --git a/help/help-arraycopy.pd b/help/help-arraycopy.pd
new file mode 100644
index 0000000..6963c69
--- /dev/null
+++ b/help/help-arraycopy.pd
@@ -0,0 +1,62 @@
+#N canvas 140 43 934 584 12;
+#N canvas 0 0 450 300 graph1 0;
+#X array array1 20 float 1;
+#A 0 0 0 0.342857 0.542857 0.6 -0.442857 -0.485714 0.0142858 -0.428571
+-0.114286 0.0857143 -0.2 -0.214285 0.314285 -0.157143 -0.314285 -0.142857
+-0.0428571 0.114286 -0.685713;
+#X coords 0 1 19 -1 200 140 1;
+#X restore 680 27 graph;
+#N canvas 0 0 450 300 graph2 0;
+#X array array2 20 float 1;
+#A 0 -0.214286 -0.171429 0.1 0.614286 0.757143 0.757143 0.542857 0.2
+-0.0285714 -0.271429 -0.414286 -0.514286 -0.528571 -0.485714 -0.371429
+-0.157143 0.214286 0.557143 0.714286 0.757143;
+#X coords 0 1 19 -1 200 140 1;
+#X restore 681 196 graph;
+#N canvas 0 0 450 300 graph3 0;
+#X array array3 20 float 1;
+#A 0 1.86265e-009 1.86265e-009 1.86265e-009 1.86265e-009 1.86265e-009
+-0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857 -0.0142857
+-0.0142857 -0.0285714 -0.0285714 -0.0285714 -0.0285714 -0.0142857 -0.0142857
+-0.0142857;
+#X coords 0 1 19 -1 200 140 1;
+#X restore 680 371 graph;
+#X obj 22 500 arraycopy array3;
+#X text 339 402 set the destination array;
+#X text 41 1 arraycopy :: copy data from one array to another;
+#X text 146 22 written by Olaf Matthes <olaf.matthes@gmx.de>;
+#X msg 22 109 copy array1;
+#X msg 43 139 copy array1 10 15;
+#X text 131 109 copy the whole array;
+#X text 200 140 copy from value 10 to 15;
+#X msg 60 169 copy array1 10 +5;
+#X text 217 170 copy from value 10 the next 5 values;
+#X msg 85 359 print \$1;
+#X obj 85 333 tgl 20 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
+;
+#X text 116 334 switch console printout on/off;
+#X text 281 202 copy from value 10 to 15;
+#X msg 73 201 copy array1 10 15 array2;
+#X text 280 222 into array2 (starting at 0);
+#X text 322 251 copy from value 10 to 15;
+#X text 321 271 into array2 starting at 4;
+#X msg 92 250 copy array1 10 15 array2 4;
+#X msg 368 454 array3;
+#X msg 86 414 bang;
+#X text 137 412 perform last copy;
+#X text 137 429 operation again;
+#X text 20 537 creation argument: initial destination array to copy
+data to;
+#X obj 200 502 symbol;
+#X msg 339 428 array2;
+#X connect 7 0 3 0;
+#X connect 8 0 3 0;
+#X connect 11 0 3 0;
+#X connect 13 0 3 0;
+#X connect 14 0 13 0;
+#X connect 17 0 3 0;
+#X connect 21 0 3 0;
+#X connect 22 0 27 0;
+#X connect 23 0 3 0;
+#X connect 27 0 3 1;
+#X connect 28 0 27 0;
diff --git a/help/help-deny.pd b/help/help-deny.pd
new file mode 100644
index 0000000..9ca4a29
--- /dev/null
+++ b/help/help-deny.pd
@@ -0,0 +1,20 @@
+#N canvas 358 305 556 310 12;
+#X text 97 34 written by Olaf Matthes <olaf.matthes@gmx.de>;
+#X msg 125 65 cat;
+#X msg 147 97 dog;
+#X msg 157 126 bird;
+#X floatatom 82 269 5 0 0 0 - - -;
+#X symbolatom 151 246 10 0 0 0 - - -;
+#X obj 114 156 symbol \$1;
+#X floatatom 40 81 5 0 0 0 - - -;
+#X obj 82 217 route float symbol;
+#X obj 82 189 deny 17 cat dog 23;
+#X text 32 18 deny :: blocks 'denyed' floats or symbols;
+#X connect 1 0 6 0;
+#X connect 2 0 6 0;
+#X connect 3 0 6 0;
+#X connect 6 0 9 0;
+#X connect 7 0 9 0;
+#X connect 8 0 4 0;
+#X connect 8 1 5 0;
+#X connect 9 0 8 0;
diff --git a/help/help-listfifo.pd b/help/help-listfifo.pd
new file mode 100644
index 0000000..a40a609
--- /dev/null
+++ b/help/help-listfifo.pd
@@ -0,0 +1,26 @@
+#N canvas 476 153 456 307 12;
+#X floatatom 104 231 5 0 0 0 - - -;
+#X msg 38 46 bang;
+#X text 146 152 fifo <size>;
+#X obj 38 152 listfifo 10;
+#X text 42 14 listfifo :: first in first out buffer for lists;
+#X obj 104 187 unpack f f;
+#X floatatom 179 230 5 0 0 0 - - -;
+#X obj 38 263 print listfifo_output;
+#X text 204 185 output of listfifo;
+#X msg 66 76 17.3 23;
+#X obj 166 101 pack f f;
+#X floatatom 166 70 5 0 0 0 - - -;
+#X floatatom 225 70 5 0 0 0 - - -;
+#X msg 84 125 \$1 \$2;
+#X text 83 46 hit to get next number out of the fifo;
+#X connect 1 0 3 0;
+#X connect 3 0 5 0;
+#X connect 3 0 7 0;
+#X connect 5 0 0 0;
+#X connect 5 1 6 0;
+#X connect 9 0 3 0;
+#X connect 10 0 13 0;
+#X connect 11 0 10 0;
+#X connect 12 0 10 1;
+#X connect 13 0 3 0;
diff --git a/help/help-maxlib.pd b/help/help-maxlib.pd
index 663c605..dfe8564 100644
--- a/help/help-maxlib.pd
+++ b/help/help-maxlib.pd
@@ -1,73 +1,119 @@
-#N canvas 70 3 889 647 12;
-#X obj 290 277 average;
-#X obj 19 171 beat;
-#X obj 19 196 borax;
-#X obj 19 146 chord;
-#X obj 472 491 dist;
-#X obj 290 172 divide;
-#X obj 290 146 divmod;
-#X obj 606 171 fifo;
-#X obj 290 303 history;
-#X obj 17 496 ignore;
-#X obj 17 470 iso;
-#X obj 605 145 lifo;
-#X obj 290 329 match;
-#X obj 290 197 minus;
-#X obj 609 261 mlife;
-#X obj 290 224 multi;
-#X obj 472 516 netdist;
-#X obj 19 272 pitch;
-#X obj 290 251 plus;
-#X obj 17 418 pulse;
-#X obj 472 542 remote;
-#X obj 19 221 rhythm;
-#X obj 19 246 score array01;
-#X obj 17 444 speedlim;
-#X obj 17 522 step;
-#X obj 609 236 subst;
-#X text 30 27 maxlib 0.8 :: Music Analysis eXtensions LIBrary;
+#N canvas 11 6 1106 717 12;
+#X obj 274 260 average;
+#X obj 18 150 beat;
+#X obj 18 175 borax;
+#X obj 18 125 chord;
+#X obj 15 551 dist;
+#X obj 274 155 divide;
+#X obj 274 129 divmod;
+#X obj 599 149 fifo;
+#X obj 274 286 history;
+#X obj 601 503 ignore;
+#X obj 601 477 iso;
+#X obj 598 123 lifo;
+#X obj 274 312 match;
+#X obj 274 180 minus;
+#X obj 600 257 mlife;
+#X obj 274 207 multi;
+#X obj 15 576 netdist;
+#X obj 18 251 pitch;
+#X obj 274 234 plus;
+#X obj 601 425 pulse;
+#X obj 15 600 remote;
+#X obj 18 200 rhythm;
+#X obj 18 225 score array01;
+#X obj 601 451 speedlim;
+#X obj 601 529 step;
+#X obj 600 232 subst;
#X text 140 44 written by Olaf Matthes <olaf.matthes@gmx.de>;
-#X text 139 61 download at http://www.akustische-kunst.de/puredata/maxlib
+#X text 71 125 chord detection;
+#X text 68 150 beat tracking;
+#X text 77 201 beat detection;
+#X text 72 176 music analysis;
+#X text 135 225 score following;
+#X text 72 251 pitch information;
+#X text 19 94 MUSIC / MIDI ANALYSIS;
+#X text 274 93 MATH;
+#X text 341 130 calculate / and %;
+#X text 339 155 / for several inputs;
+#X text 333 235 + for several inputs;
+#X text 333 207 * for several inputs;
+#X text 337 181 - for several inputs;
+#X text 345 259 average of last N values;
+#X text 346 285 average over last N seconds;
+#X text 329 312 match input to list of numbers;
+#X text 601 399 TIME;
+#X text 678 452 lets input through every N milliseconds;
+#X text 640 479 play sequence of MIDI notes;
+#X text 662 504 ignore too fast changing input;
+#X text 63 550 send to list of receive objects;
+#X text 84 574 same for netreceive;
+#X text 74 599 send to one receive object;
+#X text 597 96 BUFFER;
+#X text 648 531 a line object that steps;
+#X text 599 208 OTHER / EXPERIMENTAL;
+#X text 657 231 self-similar substitution;
+#X text 656 257 cellular automaton;
+#X obj 274 338 scale;
+#X text 656 425 a 'better' metro;
+#X obj 601 555 history;
+#X obj 601 581 velocity;
+#X text 670 555 average over last N milliseconds;
+#X text 677 581 velocity of input in digits per second;
+#X obj 15 624 netrec;
+#X text 74 625 netreceive with extra info about sender;
+#X obj 274 364 delta;
+#X text 139 61 download at http://www.akustische-kunst.org/puredata/maxlib
;
-#X text 72 146 chord detection;
-#X text 69 171 beat tracking;
-#X text 78 222 beat detection;
-#X text 73 197 music analysis;
-#X text 136 246 score following;
-#X text 73 272 pitch information;
-#X text 20 115 MUSIC / MIDI ANALYSIS;
-#X text 290 110 MATH;
-#X text 357 147 calculate / and %;
-#X text 355 172 / for several inputs;
-#X text 349 252 + for several inputs;
-#X text 349 224 * for several inputs;
-#X text 353 198 - for several inputs;
-#X text 361 276 average of last N values;
-#X text 362 302 average over last N seconds;
-#X text 345 329 match input to list of numbers;
-#X text 17 392 TIME;
-#X text 94 445 lets input through every N milliseconds;
-#X text 56 472 play sequence of MIDI notes;
-#X text 78 497 ignore too fast changing input;
-#X text 469 459 CONTROL;
-#X text 520 490 send to list of receive objects;
-#X text 541 514 same for netreceive;
-#X text 531 541 send to one receive object;
-#X text 604 118 BUFFER;
-#X text 650 145 last in first out;
-#X text 653 171 first in first out;
-#X text 64 524 a line object that steps;
-#X text 606 204 OTHER / EXPERIMENTAL;
-#X text 666 235 self-similar substitution;
-#X text 665 261 cellular automaton;
-#X obj 290 355 scale;
-#X text 344 356 scale input to outpur range;
-#X text 72 418 a 'better' metro;
-#X obj 17 548 history;
-#X obj 17 574 velocity;
-#X text 86 548 average over last N milliseconds;
-#X text 93 574 velocity of input in digits per second;
-#X obj 472 569 netrec;
-#X text 531 570 netreceive with extra info about sender;
-#X obj 290 381 delta;
-#X text 344 381 calculate 1st or 2nd order difference;
+#X obj 599 174 listfifo;
+#X text 677 173 first in first out for lists;
+#X text 646 148 first in first out for floats;
+#X text 643 123 last in first out for floats;
+#X obj 600 607 sync;
+#X text 645 609 extended trigger object;
+#X text 328 338 scale input to output range;
+#X text 13 528 (REMOTE)CONTROL;
+#X obj 16 649 netserver;
+#X obj 16 676 netclient;
+#X text 103 654 bidirectional communication;
+#X text 112 669 (client / server based);
+#X obj 274 392 wrap;
+#X obj 274 419 rewrap;
+#X text 320 392 warp a number in a range;
+#X text 337 420 warp it back and forth;
+#X text 30 26 maxlib 1.3 :: Music Analysis eXtensions LIBrary;
+#X text 328 364 calculate 1st or 2nd order diff.;
+#X text 600 288 RANDOM;
+#X obj 600 312 gauss;
+#X obj 600 337 poisson;
+#X obj 666 312 linear;
+#X obj 666 337 bilex;
+#X obj 736 311 expo;
+#X obj 785 311 beta;
+#X obj 834 312 cauchy;
+#X obj 737 338 arbran array01 array02;
+#X obj 18 278 gestalt;
+#X obj 18 303 edge;
+#X text 56 306 detect rising/falling edge;
+#X text 84 278 'gestalt' of music;
+#X obj 599 365 urn;
+#X text 632 366 urn selection model;
+#X obj 601 635 timebang;
+#X text 680 635 send a bang at given time of day;
+#X obj 15 390 split;
+#X obj 15 439 unroute;
+#X text 81 440 opposit to route;
+#X text 67 392 split according to range;
+#X obj 15 463 limit;
+#X text 63 464 limiter for floats;
+#X obj 15 415 nroute;
+#X text 69 416 r. according to Nth elem.;
+#X text 24 363 ROUTING / CHECKING;
+#X obj 600 661 pong;
+#X obj 18 330 tilt;
+#X obj 600 686 temperature;
+#X text 698 687 amount of input changes per time;
+#X text 646 662 a bouncing ball model;
+#X text 66 333 meassure tilt of input;
+#X obj 16 489 listfunnel;
+#X text 107 490 Max's funnel for lists;
diff --git a/help/help-nchange.pd b/help/help-nchange.pd
new file mode 100644
index 0000000..cfcf00b
--- /dev/null
+++ b/help/help-nchange.pd
@@ -0,0 +1,31 @@
+#N canvas 271 238 519 310 12;
+#X obj 30 213 nchange f;
+#X obj 371 215 nchange l;
+#X msg 367 144 bla foo dog;
+#X msg 387 169 bla foo 23;
+#X msg 348 121 bla foo dog 17;
+#X obj 200 214 nchange s;
+#X obj 200 185 symbol;
+#X msg 200 126 dog;
+#X msg 216 153 cat;
+#X obj 162 15 change;
+#X obj 371 253 print list;
+#X obj 200 255 print symbol;
+#X msg 30 152 0;
+#X msg 43 180 1;
+#X obj 30 257 print float;
+#X text 100 34 written by Olaf Matthes <olaf.matthes@gmx.de>;
+#X text 12 15 nchange :: a 'new';
+#X text 22 77 The creation argument specifies whether nchange works
+for floats \, symbols or lists.;
+#X connect 0 0 14 0;
+#X connect 1 0 10 0;
+#X connect 2 0 1 0;
+#X connect 3 0 1 0;
+#X connect 4 0 1 0;
+#X connect 5 0 11 0;
+#X connect 6 0 5 0;
+#X connect 7 0 6 0;
+#X connect 8 0 6 0;
+#X connect 12 0 0 0;
+#X connect 13 0 0 0;
diff --git a/help/help-remote.pd b/help/help-remote.pd
index 54a7caf..6ee5b8f 100644
--- a/help/help-remote.pd
+++ b/help/help-remote.pd
@@ -1,4 +1,4 @@
-#N canvas 472 309 456 306 12;
+#N canvas 472 309 567 308 12;
#X text 9 9 remote :: send data to any receive object;
#X obj 32 224 remote;
#X obj 216 222 receive bla;
@@ -11,6 +11,8 @@
#X text 253 91 with data of any type;
#X text 89 26 written by Olaf Matthes <olaf.matthes@gmx.de>;
#X msg 61 147 foo five is 2 more than 3;
+#X msg 294 146 \; bla 17.3 23;
+#X text 296 168 this does the same...;
#X connect 2 0 4 0;
#X connect 3 0 5 0;
#X connect 6 0 1 0;
diff --git a/help/help-sync.pd b/help/help-sync.pd
new file mode 100644
index 0000000..d82521e
--- /dev/null
+++ b/help/help-sync.pd
@@ -0,0 +1,53 @@
+#N canvas 142 53 830 657 12;
+#X text 78 16 sync :: extended trigger object based;
+#X text 143 35 on sync from jMax;
+#X floatatom 18 485 5 0 0 0 - - -;
+#X floatatom 39 457 5 0 0 0 - - -;
+#X floatatom 61 433 5 0 0 0 - - -;
+#X floatatom 18 124 5 0 0 0 - - -;
+#X floatatom 39 152 5 0 0 0 - - -;
+#X floatatom 61 177 5 0 0 0 - - -;
+#X msg 205 143 mode any;
+#X msg 187 116 mode all;
+#X msg 216 169 mode left;
+#X msg 229 198 mode right;
+#X msg 243 226 mode none;
+#X text 295 142 any input triggers the outputs;
+#X text 305 169 trigger output when left inlet changes;
+#X text 325 199 trigger output when right inlet changes;
+#X text 333 228 never trigger output;
+#X obj 18 404 sync 3;
+#X text 146 415 the creation argument determines the number of inlets
+/ outlets sync will have.;
+#X obj 149 462 sync 23 17.3;
+#X text 147 490 alternatively it's possible to specify the number of
+inlets / outlets by giving initial values for every outlet. these values
+will be output in case no input has been received in the corresponding
+inlet until the time when the output is triggered.;
+#X text 274 116 all inputs have to change to trigger output (default)
+;
+#X msg 223 270 trigger 2;
+#X msg 230 335 require 1;
+#X text 324 320 additionally another input can be defined to be required
+for the trigger event to take place. i.e. the second inlet (inlet #1)
+from the left must have been changed since the last triggering occured.
+;
+#X text 324 265 use this message to make the n-th input (counting from
+0 to <number of inputs - 1>) a triggering input. only one input at
+a time can be triggering!;
+#X text 212 90 the easy way:;
+#X msg 228 299 trigger 1;
+#X connect 5 0 17 0;
+#X connect 6 0 17 1;
+#X connect 7 0 17 2;
+#X connect 8 0 17 0;
+#X connect 9 0 17 0;
+#X connect 10 0 17 0;
+#X connect 11 0 17 0;
+#X connect 12 0 17 0;
+#X connect 17 0 2 0;
+#X connect 17 1 3 0;
+#X connect 17 2 4 0;
+#X connect 22 0 17 0;
+#X connect 23 0 17 0;
+#X connect 27 0 17 0;
diff --git a/src/allow.c b/src/allow.c
new file mode 100644
index 0000000..c5d57ac
--- /dev/null
+++ b/src/allow.c
@@ -0,0 +1,112 @@
+/* ---------------------------- allow --------------------------------------- */
+/* */
+/* Lets only floats/symbols through that are allowed to do so. */
+/* Written by Olaf Matthes <olaf.matthes@gmx.de> */
+/* Get source at http://www.akustische-kunst.org/puredata/maxlib/ */
+/* */
+/* This program is free software; you can redistribute it and/or */
+/* modify it under the terms of the GNU General Public License */
+/* as published by the Free Software Foundation; either version 2 */
+/* of the License, or (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program; if not, write to the Free Software */
+/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+/* */
+/* Based on PureData by Miller Puckette and others. */
+/* */
+/* ---------------------------------------------------------------------------- */
+
+#include "m_pd.h"
+#include <string.h>
+
+static char *version = "allow v0.1, written by Olaf Matthes <olaf.matthes@gmx.de>";
+
+typedef struct allow
+{
+ t_object x_obj;
+ t_outlet *x_out;
+ t_atom *x_elem; // list of elemets that are allowed to pass
+ t_int x_numelem; // the number of elemetns in our allow-list
+} t_allow;
+
+ /* we got a symbol... */
+static void allow_symbol(t_allow *x, t_symbol *s)
+{
+ int i;
+ for(i = 0; i < x->x_numelem; i++)
+ {
+ if(x->x_elem[i].a_type == A_SYMBOL) // compare with all symbols in our list
+ if(atom_getsymbolarg(i, x->x_numelem, x->x_elem) == s)
+ {
+ outlet_symbol(x->x_out, s);
+ return;
+ }
+ }
+}
+
+ /* we got a float... */
+static void allow_float(t_allow *x, t_floatarg f)
+{
+ int i;
+ for(i = 0; i < x->x_numelem; i++)
+ {
+ if(x->x_elem[i].a_type == A_FLOAT) // compare with all floats in our list
+ if(atom_getfloatarg(i, x->x_numelem, x->x_elem) == f)
+ {
+ outlet_float(x->x_out, f);
+ return;
+ }
+ }
+}
+
+static t_class *allow_class;
+
+static void allow_free(t_allow *x)
+{
+ freebytes(x->x_elem, x->x_numelem*sizeof(t_atom));
+}
+
+static void *allow_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_allow *x = (t_allow *)pd_new(allow_class);
+
+ x->x_numelem = argc; // get the number of elements
+ x->x_elem = getbytes(argc*sizeof(t_atom));
+ memcpy(x->x_elem, argv, argc*sizeof(t_atom));
+
+ x->x_out = outlet_new(&x->x_obj, gensym("anything"));
+
+ // post("allow: got %d elements", x->x_numelem);
+
+ return (x);
+}
+
+#ifndef MAXLIB
+void allow_setup(void)
+{
+ /* the object's class: */
+ allow_class = class_new(gensym("allow"), (t_newmethod)allow_new,
+ (t_method)allow_free, sizeof(t_allow), 0, A_GIMME, 0);
+#else
+void maxlib_allow_setup(void)
+{
+ /* the object's class: */
+ allow_class = class_new(gensym("maxlib_allow"), (t_newmethod)allow_new,
+ (t_method)allow_free, sizeof(t_allow), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)allow_new, gensym("allow"), A_GIMME, 0);
+#endif
+ class_addsymbol(allow_class, allow_symbol);
+ class_addfloat(allow_class, allow_float);
+#ifndef MAXLIB
+ class_sethelpsymbol(allow_class, gensym("help-allow.pd"));
+ post(version);
+#else
+ class_sethelpsymbol(allow_class, gensym("maxlib/help-allow.pd"));
+#endif
+} \ No newline at end of file
diff --git a/src/arbran.c b/src/arbran.c
index c37dee4..b4e4b2c 100644
--- a/src/arbran.c
+++ b/src/arbran.c
@@ -164,14 +164,25 @@ static void *rand_arbran_new(t_symbol *s1, t_symbol *s2)
return (x);
}
+#ifndef MAXLIB
void arbran_setup(void)
{
rand_arbran_class = class_new(gensym("arbran"), (t_newmethod)rand_arbran_new, 0,
sizeof(t_rand_arbran), 0, A_SYMBOL, A_SYMBOL, 0);
+#else
+void maxlib_arbran_setup(void)
+{
+ rand_arbran_class = class_new(gensym("maxlib_arbran"), (t_newmethod)rand_arbran_new, 0,
+ sizeof(t_rand_arbran), 0, A_SYMBOL, A_SYMBOL, 0);
+#endif
class_addbang(rand_arbran_class, rand_arbran_bang);
class_addmethod(rand_arbran_class, (t_method)rand_arbran_pdfscale, gensym("pdfscale"), 0);
class_addmethod(rand_arbran_class, (t_method)rand_arbran_setarrays, gensym("set"), A_SYMBOL, A_SYMBOL, 0);
#ifndef MAXLIB
+ class_sethelpsymbol(rand_arbran_class, gensym("help-arbran.pd"));
post(version);
+#else
+ class_addcreator((t_newmethod)rand_arbran_new, gensym("arbran"), A_SYMBOL, A_SYMBOL, 0);
+ class_sethelpsymbol(rand_arbran_class, gensym("maxlib/help-arbran.pd"));
#endif
}
diff --git a/src/arraycopy.c b/src/arraycopy.c
new file mode 100644
index 0000000..cc36913
--- /dev/null
+++ b/src/arraycopy.c
@@ -0,0 +1,283 @@
+/* ------------------------- arraycopy --------------------------------------- */
+/* */
+/* Copy data from one array to another . */
+/* Written by Olaf Matthes <olaf.matthes@gmx.de> */
+/* Get source at http://www.akustische-kunst.org/puredata/maxlib/ */
+/* */
+/* This program is free software; you can redistribute it and/or */
+/* modify it under the terms of the GNU General Public License */
+/* as published by the Free Software Foundation; either version 2 */
+/* of the License, or (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program; if not, write to the Free Software */
+/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+/* */
+/* Based on PureData by Miller Puckette and others. */
+/* */
+/* ---------------------------------------------------------------------------- */
+
+#include "m_pd.h"
+#include <stdlib.h>
+
+static char *version = "arraycopy v0.2, written by Olaf Matthes <olaf.matthes@gmx.de>";
+
+typedef struct arraycopy
+{
+ t_object x_obj;
+ t_symbol *x_destarray;
+ t_symbol *x_sourcearray;
+ t_garray *x_destbuf;
+ t_garray *x_sourcebuf;
+ t_int x_start;
+ t_int x_end;
+ t_int x_pos;
+ short x_print;
+} t_arraycopy;
+
+ /* choose the destination array to copy to */
+static void arraycopy_setdestarray(t_arraycopy *x, t_symbol *s)
+{
+ t_garray *b;
+
+ if ((b = (t_garray *)pd_findbyclass(s, garray_class)))
+ {
+ // post("arraycopy: destination array set to \"%s\"", s->s_name);
+ x->x_destbuf = b;
+ } else {
+ post("arraycopy: no array \"%s\" (error %d)", s->s_name, b);
+ x->x_destbuf = 0;
+ }
+}
+
+static void arraycopy_setdest(t_arraycopy *x, t_symbol *s)
+{
+ x->x_destarray = s;
+ arraycopy_setdestarray(x, x->x_destarray);
+}
+
+ /* choose the source array to copy from */
+static void arraycopy_setsourcearray(t_arraycopy *x, t_symbol *s)
+{
+ t_garray *b;
+
+ if ((b = (t_garray *)pd_findbyclass(s, garray_class)))
+ {
+ // post("arraycopy: source array set to \"%s\"", s->s_name);
+ x->x_sourcebuf = b;
+ } else {
+ post("arraycopy: no array \"%s\" (error %d)", s->s_name, b);
+ x->x_sourcebuf = 0;
+ }
+}
+
+ /* this is the routine that actually does the copying */
+ /* get's called directly when we get a 'bang' */
+static void arraycopy_docopy(t_arraycopy *x)
+{
+ t_garray *b; /* make local copy of array */
+ t_float *tab; /* the content itselfe */
+ t_int items, i;
+ t_garray *A;
+ int npoints;
+ t_float *vec;
+
+ if(!x->x_destarray)
+ {
+ post("arraycopy: no destination array specified");
+ return;
+ }
+ if(!x->x_sourcearray)
+ {
+ post("arraycopy: no source array specified");
+ return;
+ }
+
+ A = x->x_destbuf;
+
+ if ((b = (t_garray *)pd_findbyclass(x->x_sourcearray, garray_class)))
+ {
+ // post("arraycopy: source array set to \"%s\"", x->x_sourcearray->s_name);
+ } else {
+ post("arraycopy: no array \"%s\" (error %d)", x->x_sourcearray->s_name, b);
+ return;
+ }
+
+ // read from our array
+ if (!garray_getfloatarray(b, &items, &tab))
+ {
+ post("arraycopy: couldn't read from source array!");
+ return;
+ }
+
+ if (!(A = (t_garray *)pd_findbyclass(x->x_destarray, garray_class)))
+ error("arraycopy: %s: no such array", x->x_destarray->s_name);
+ else if (!garray_getfloatarray(A, &npoints, &vec))
+ error("arraycopy: %s: bad template ", x->x_destarray->s_name);
+ else
+ {
+ if(x->x_start > items) // check start point
+ {
+ post("arraycopy: source start point out of range for the array given");
+ return;
+ }
+ if(x->x_end) // end point is specified
+ {
+ if(x->x_end > items) // check start point
+ {
+ post("arraycopy: source end point out of range for the array given");
+ x->x_end = items;
+ }
+ }
+ else x->x_end = items;
+
+ if(x->x_pos)
+ vec += x->x_pos;
+
+ for(i = x->x_start; i < x->x_end; i++)
+ {
+ *vec++ = tab[i];
+ }
+ garray_redraw(A);
+ if(x->x_print)post("arraycopy: copied %d values from array \"%s\" to array \"%s\"",
+ x->x_end-x->x_start, x->x_sourcearray->s_name, x->x_destarray->s_name);
+ }
+}
+
+static void arraycopy_list(t_arraycopy *x, t_symbol *s, int argc, t_atom *argv)
+{
+ if(argc > 1) {
+ x->x_sourcearray = atom_getsymbolarg(0, argc, argv);
+ x->x_destarray = atom_getsymbolarg(1, argc, argv);
+ }
+}
+
+static void arraycopy_source(t_arraycopy *x, t_symbol *s)
+{
+ x->x_sourcearray = s;
+ x->x_start = x->x_end = x->x_pos = 0;
+ arraycopy_docopy(x);
+}
+
+static void arraycopy_print(t_arraycopy *x, t_floatarg f)
+{
+ if(f)
+ x->x_print = 1;
+ else
+ x->x_print = 0;
+}
+
+static void arraycopy_copy(t_arraycopy *x, t_symbol *s, int argc, t_atom *argv)
+{
+ if(argc == 1) // source array name supplied
+ {
+ x->x_sourcearray = atom_getsymbolarg(0, argc, argv);
+ x->x_start = x->x_end = x->x_pos = 0;
+ }
+ else if(argc == 2) // array name and start point supplied
+ {
+ x->x_sourcearray = atom_getsymbolarg(0, argc, argv);
+ x->x_start = atom_getfloatarg(1, argc, argv);
+ x->x_end = x->x_pos = 0;
+ }
+ else if(argc == 3) // arrayname and start & end point supplied
+ {
+ x->x_sourcearray = atom_getsymbolarg(0, argc, argv);
+ x->x_start = atom_getfloatarg(1, argc, argv);
+ if(argv[2].a_type == A_FLOAT) // real position
+ {
+ x->x_end = atom_getfloatarg(2, argc, argv);
+ }
+ else // offset given
+ {
+ t_symbol *offset = atom_getsymbolarg(2, argc, argv);
+ x->x_end = (t_int)atoi(offset->s_name) + x->x_start;
+ }
+ x->x_pos = 0;
+ }
+ else if(argc == 4) // as above & dest. array
+ {
+ x->x_sourcearray = atom_getsymbolarg(0, argc, argv);
+ x->x_start = atom_getfloatarg(1, argc, argv);
+ if(argv[2].a_type == A_FLOAT) // real position
+ {
+ x->x_end = atom_getfloatarg(2, argc, argv);
+ }
+ else // offset given
+ {
+ t_symbol *offset = atom_getsymbolarg(2, argc, argv);
+ x->x_end = (t_int)atoi(offset->s_name) + x->x_start;
+ }
+ x->x_destarray = atom_getsymbolarg(3, argc, argv);
+ arraycopy_setdestarray(x, x->x_destarray);
+ x->x_pos = 0;
+ }
+ else if(argc == 5) // as above & dest. array & pos. in dest.
+ {
+ x->x_sourcearray = atom_getsymbolarg(0, argc, argv);
+ x->x_start = atom_getfloatarg(1, argc, argv);
+ if(argv[2].a_type == A_FLOAT) // real position
+ {
+ x->x_end = atom_getfloatarg(2, argc, argv);
+ }
+ else // offset given
+ {
+ t_symbol *offset = atom_getsymbolarg(2, argc, argv);
+ x->x_end = (t_int)atoi(offset->s_name) + x->x_start;
+ }
+ x->x_destarray = atom_getsymbolarg(3, argc, argv);
+ arraycopy_setdestarray(x, x->x_destarray);
+ x->x_pos = atom_getfloatarg(4, argc, argv);
+ }
+ else post("arraycopy: copy: wrong number of arguments");
+
+ arraycopy_docopy(x);
+}
+
+static t_class *arraycopy_class;
+
+static void *arraycopy_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_arraycopy *x = (t_arraycopy *)pd_new(arraycopy_class);
+
+ if (argc > 0) {
+ x->x_destarray = atom_getsymbolarg(0, argc, argv);
+ arraycopy_setdestarray(x, x->x_destarray);
+ }
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("symbol"), gensym("dest"));
+ x->x_start = x->x_end = x->x_pos = x->x_print = 0;
+ return (x);
+}
+
+#ifndef MAXLIB
+void arraycopy_setup(void)
+{
+ /* the object's class: */
+ arraycopy_class = class_new(gensym("arraycopy"), (t_newmethod)arraycopy_new,
+ 0, sizeof(t_arraycopy), 0, A_GIMME, 0);
+#else
+void maxlib_arraycopy_setup(void)
+{
+ /* the object's class: */
+ arraycopy_class = class_new(gensym("maxlib_arraycopy"), (t_newmethod)arraycopy_new,
+ 0, sizeof(t_arraycopy), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)arraycopy_new, gensym("arraycopy"), A_GIMME, 0);
+#endif
+ class_addmethod(arraycopy_class, (t_method)arraycopy_copy, gensym("copy"), A_GIMME, 0);
+ class_addmethod(arraycopy_class, (t_method)arraycopy_print, gensym("print"), A_FLOAT, 0);
+ class_addmethod(arraycopy_class, (t_method)arraycopy_setdest, gensym("dest"), A_SYMBOL, 0);
+ class_addsymbol(arraycopy_class, arraycopy_source);
+ class_addbang(arraycopy_class, arraycopy_docopy);
+ // class_addlist(arraycopy_class, arraycopy_list);
+#ifndef MAXLIB
+ class_sethelpsymbol(arraycopy_class, gensym("help-arraycopy.pd"));
+ post(version);
+#else
+ class_sethelpsymbol(arraycopy_class, gensym("maxlib/help-arraycopy.pd"));
+#endif
+} \ No newline at end of file
diff --git a/src/average.c b/src/average.c
index f38772c..781f9d5 100644
--- a/src/average.c
+++ b/src/average.c
@@ -171,21 +171,32 @@ static void *average_new(t_floatarg f)
x->x_inpointer = 0;
x->x_average = 0;
x->x_mode = 0;
-#ifndef MAXLIB
- post(version);
-#endif
return (void *)x;
}
+#ifndef MAXLIB
void average_setup(void)
{
average_class = class_new(gensym("average"), (t_newmethod)average_new,
(t_method)average_free, sizeof(t_average), 0, A_DEFFLOAT, 0);
+#else
+void maxlib_average_setup(void)
+{
+ average_class = class_new(gensym("maxlib_average"), (t_newmethod)average_new,
+ (t_method)average_free, sizeof(t_average), 0, A_DEFFLOAT, 0);
+#endif
class_addmethod(average_class, (t_method)average_reset, gensym("reset"), 0);
class_addmethod(average_class, (t_method)average_linear, gensym("linear"), 0);
class_addmethod(average_class, (t_method)average_geometric, gensym("geometric"), 0);
class_addmethod(average_class, (t_method)average_weight, gensym("weight"), 0);
class_addfloat(average_class, average_float);
class_addmethod(average_class, (t_method)average_index, gensym("index"), A_FLOAT, 0);
+#ifndef MAXLIB
+ post(version);
+ class_sethelpsymbol(average_class, gensym("help-average.pd"));
+#else
+ class_addcreator((t_newmethod)average_new, gensym("average"), A_DEFFLOAT, 0);
+ class_sethelpsymbol(average_class, gensym("maxlib/help-average.pd"));
+#endif
}
diff --git a/src/beat.c b/src/beat.c
index 8a225e6..3ca552c 100644
--- a/src/beat.c
+++ b/src/beat.c
@@ -372,22 +372,32 @@ static void *beat_new(t_floatarg f)
x->x_band_percent = 4; /* allow 4% 'jitter' by default */
if(f)x->x_band_percent = (t_int)f;
-#ifndef MAXLIB
- post(version);
-#endif
post("beat: band percentage set to %d", x->x_band_percent);
return (void *)x;
}
+#ifndef MAXLIB
void beat_setup(void)
{
beat_class = class_new(gensym("beat"), (t_newmethod)beat_new,
(t_method)beat_free, sizeof(t_beat), 0, A_DEFFLOAT, 0);
- class_addcreator((t_newmethod)beat_new, gensym("max.beat"), A_DEFFLOAT, 0);
+#else
+void maxlib_beat_setup(void)
+{
+ beat_class = class_new(gensym("maxlib_beat"), (t_newmethod)beat_new,
+ (t_method)beat_free, sizeof(t_beat), 0, A_DEFFLOAT, 0);
+#endif
class_addfloat(beat_class, beat_float);
class_addmethod(beat_class, (t_method)beat_ft1, gensym("ft1"), A_FLOAT, 0);
class_addmethod(beat_class, (t_method)beat_reset, gensym("reset"), 0);
class_addmethod(beat_class, (t_method)beat_print, gensym("print"), 0);
+#ifndef MAXLIB
+ class_sethelpsymbol(beat_class, gensym("help-beat.pd"));
+ post(version);
+#else
+ class_addcreator((t_newmethod)beat_new, gensym("beat"), A_DEFFLOAT, 0);
+ class_sethelpsymbol(beat_class, gensym("maxlib/help-beat.pd"));
+#endif
}
diff --git a/src/beta.c b/src/beta.c
index bb965aa..ebc7a14 100644
--- a/src/beta.c
+++ b/src/beta.c
@@ -1,6 +1,6 @@
-/* ---------------------------- rand_beta ----------------------------------- */
+/* ---------------------------- rand_beta ------------------------------------- */
/* */
-/* rand_beta generates a beta distributed random variable. */
+/* rand_beta generates a beta distributed random variable. */
/* Written by Olaf Matthes (olaf.matthes@gmx.de) */
/* Based on code found in Dodge/Jerse "Computer Music" */
/* Get source at http://www.akustische-kunst.org/puredata/maxlib/ */
@@ -86,12 +86,22 @@ static void rand_beta_bang(t_rand_beta *x)
outlet_float(x->x_obj.ob_outlet, y1/sum);
}
+#ifndef MAXLIB
void beta_setup(void)
{
rand_beta_class = class_new(gensym("beta"), (t_newmethod)rand_beta_new, 0,
sizeof(t_rand_beta), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
class_addbang(rand_beta_class, rand_beta_bang);
-#ifndef MAXLIB
+ class_sethelpsymbol(rand_beta_class, gensym("help-beta.pd"));
post(version);
-#endif
}
+#else
+void maxlib_beta_setup(void)
+{
+ rand_beta_class = class_new(gensym("maxlib_beta"), (t_newmethod)rand_beta_new, 0,
+ sizeof(t_rand_beta), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addbang(rand_beta_class, rand_beta_bang);
+ class_addcreator((t_newmethod)rand_beta_new, gensym("beta"), A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_sethelpsymbol(rand_beta_class, gensym("maxlib/help-beta.pd"));
+}
+#endif \ No newline at end of file
diff --git a/src/bilex.c b/src/bilex.c
index ca2afd3..ed7484f 100644
--- a/src/bilex.c
+++ b/src/bilex.c
@@ -70,12 +70,22 @@ static void rand_bilex_bang(t_rand_bilex *x)
outlet_float(x->x_obj.ob_outlet, s*log(u)/l);
}
+#ifndef MAXLIB
void bilex_setup(void)
{
rand_bilex_class = class_new(gensym("bilex"), (t_newmethod)rand_bilex_new, 0,
sizeof(t_rand_bilex), 0, A_DEFFLOAT, 0);
class_addbang(rand_bilex_class, rand_bilex_bang);
-#ifndef MAXLIB
+ class_sethelpsymbol(rand_bilex_class, gensym("help-bilex.pd"));
post(version);
-#endif
}
+#else
+void maxlib_bilex_setup(void)
+{
+ rand_bilex_class = class_new(gensym("maxlib_bilex"), (t_newmethod)rand_bilex_new, 0,
+ sizeof(t_rand_bilex), 0, A_DEFFLOAT, 0);
+ class_addbang(rand_bilex_class, rand_bilex_bang);
+ class_addcreator((t_newmethod)rand_bilex_new, gensym("bilex"), A_DEFFLOAT, 0);
+ class_sethelpsymbol(rand_bilex_class, gensym("maxlib/help-bilex.pd"));
+}
+#endif
diff --git a/src/borax.c b/src/borax.c
index 151f269..a5143a9 100644
--- a/src/borax.c
+++ b/src/borax.c
@@ -209,20 +209,30 @@ static void *borax_new(void)
x->x_timecount = 0;
x->x_timeval = 0;
-#ifndef MAXLIB
- post(version);
-#endif
return (void *)x;
}
+#ifndef MAXLIB
void borax_setup(void)
{
borax_class = class_new(gensym("borax"), (t_newmethod)borax_new,
0, sizeof(t_borax), 0, 0);
+#else
+void maxlib_borax_setup(void)
+{
+ borax_class = class_new(gensym("maxlib_borax"), (t_newmethod)borax_new,
+ 0, sizeof(t_borax), 0, 0);
+#endif
class_addmethod(borax_class, (t_method)borax_reset, gensym("reset"), 0);
class_addmethod(borax_class, (t_method)borax_ft1, gensym("ft1"), A_FLOAT, 0);
class_addmethod(borax_class, (t_method)borax_reset, gensym("ft2"), A_GIMME, 0);
class_addfloat(borax_class, borax_float);
-
+#ifndef MAXLIB
+ class_sethelpsymbol(borax_class, gensym("help-borax.pd"));
+ post(version);
+#else
+ class_addcreator((t_newmethod)borax_new, gensym("borax"), 0);
+ class_sethelpsymbol(borax_class, gensym("maxlib/help-borax.pd"));
+#endif
}
diff --git a/src/cauchy.c b/src/cauchy.c
index 82592e3..7d85321 100644
--- a/src/cauchy.c
+++ b/src/cauchy.c
@@ -69,12 +69,21 @@ static void rand_cauchy_bang(t_rand_cauchy *x)
outlet_float(x->x_obj.ob_outlet, x->x_alpha*tan(u));
}
+#ifndef MAXLIB
void cauchy_setup(void)
{
rand_cauchy_class = class_new(gensym("cauchy"), (t_newmethod)rand_cauchy_new, 0,
sizeof(t_rand_cauchy), 0, A_DEFFLOAT, 0);
class_addbang(rand_cauchy_class, rand_cauchy_bang);
-#ifndef MAXLIB
+ class_sethelpsymbol(rand_cauchy_class, gensym("help-cauchy.pd"));
post(version);
+#else
+void maxlib_cauchy_setup(void)
+{
+ rand_cauchy_class = class_new(gensym("maxlib_cauchy"), (t_newmethod)rand_cauchy_new, 0,
+ sizeof(t_rand_cauchy), 0, A_DEFFLOAT, 0);
+ class_addbang(rand_cauchy_class, rand_cauchy_bang);
+ class_addcreator((t_newmethod)rand_cauchy_new, gensym("cauchy"), A_DEFFLOAT, 0);
+ class_sethelpsymbol(rand_cauchy_class, gensym("maxlib/help-cauchy.pd"));
#endif
}
diff --git a/src/chord.c b/src/chord.c
index 3244686..f0dc4a3 100644
--- a/src/chord.c
+++ b/src/chord.c
@@ -1785,17 +1785,28 @@ static void *chord_new(t_floatarg f)
if(x->x_split == 0)x->x_split = 128;
for(i = 0; i < MAX_POLY; i++)x->x_alloctable[i] = -1;
-#ifndef MAXLIB
- post(version);
-#endif
return (void *)x;
}
+#ifndef MAXLIB
void chord_setup(void)
{
chord_class = class_new(gensym("chord"), (t_newmethod)chord_new,
0, sizeof(t_chord), 0, A_DEFFLOAT, 0);
+#else
+void maxlib_chord_setup(void)
+{
+ chord_class = class_new(gensym("maxlib_chord"), (t_newmethod)chord_new,
+ 0, sizeof(t_chord), 0, A_DEFFLOAT, 0);
+#endif
class_addfloat(chord_class, chord_float);
class_addmethod(chord_class, (t_method)chord_ft1, gensym("ft1"), A_FLOAT, 0);
+#ifndef MAXLIB
+ class_sethelpsymbol(chord_class, gensym("help-chord.pd"));
+ post(version);
+#else
+ class_addcreator((t_newmethod)chord_new, gensym("chord"), A_DEFFLOAT, 0);
+ class_sethelpsymbol(chord_class, gensym("maxlib/help-chord.pd"));
+#endif
}
diff --git a/src/delta.c b/src/delta.c
index 2a509e5..7bbe19f 100644
--- a/src/delta.c
+++ b/src/delta.c
@@ -110,18 +110,30 @@ static void *delta_new(t_floatarg f)
x->x_clearflag = 1;
x->x_delta = 0;
-#ifndef MAXLIB
- post(version);
-#endif
return (void *)x;
}
+#ifndef MAXLIB
void delta_setup(void)
{
delta_class = class_new(gensym("delta"), (t_newmethod)delta_new,
0, sizeof(t_delta), 0, A_DEFFLOAT, 0);
+#else
+void maxlib_delta_setup(void)
+{
+ delta_class = class_new(gensym("maxlib_delta"), (t_newmethod)delta_new,
+ 0, sizeof(t_delta), 0, A_DEFFLOAT, 0);
+#endif
class_addfloat(delta_class, delta_float);
class_addbang(delta_class, (t_method)delta_bang);
class_addmethod(delta_class, (t_method)delta_clear, gensym("clear"), 0);
+ class_sethelpsymbol(delta_class, gensym("maxlib/help-delta.pd"));
+#ifndef MAXLIB
+ class_sethelpsymbol(delta_class, gensym("help-delta.pd"));
+ post(version);
+#else
+ class_addcreator((t_newmethod)delta_new, gensym("delta"), A_DEFFLOAT, 0);
+ class_sethelpsymbol(delta_class, gensym("maxlib/help-delta.pd"));
+#endif
}
diff --git a/src/deny.c b/src/deny.c
new file mode 100644
index 0000000..9d0ef35
--- /dev/null
+++ b/src/deny.c
@@ -0,0 +1,114 @@
+/* ---------------------------- deny --------------------------------------- */
+/* */
+/* Lets only floats/symbols through that are denyed to do so. */
+/* Written by Olaf Matthes <olaf.matthes@gmx.de> */
+/* Get source at http://www.akustische-kunst.org/puredata/maxlib/ */
+/* */
+/* This program is free software; you can redistribute it and/or */
+/* modify it under the terms of the GNU General Public License */
+/* as published by the Free Software Foundation; either version 2 */
+/* of the License, or (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program; if not, write to the Free Software */
+/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+/* */
+/* Based on PureData by Miller Puckette and others. */
+/* */
+/* ---------------------------------------------------------------------------- */
+
+#include "m_pd.h"
+#include <string.h>
+
+static char *version = "deny v0.1, written by Olaf Matthes <olaf.matthes@gmx.de>";
+
+typedef struct deny
+{
+ t_object x_obj;
+ t_outlet *x_out;
+ t_atom *x_elem; // list of elemets that are denyed to pass
+ t_int x_numelem; // the number of elemetns in our deny-list
+} t_deny;
+
+ /* we got a symbol... */
+static void deny_symbol(t_deny *x, t_symbol *s)
+{
+ int i, deny = 0;
+ for(i = 0; i < x->x_numelem; i++)
+ {
+ if(x->x_elem[i].a_type == A_SYMBOL) // compare with all symbols in our list
+ if(atom_getsymbolarg(i, x->x_numelem, x->x_elem) == s)
+ {
+ deny = 1;
+ return;
+ }
+ }
+ if(!deny)outlet_symbol(x->x_out, s);
+}
+
+ /* we got a float... */
+static void deny_float(t_deny *x, t_floatarg f)
+{
+ int i, deny = 0;
+ for(i = 0; i < x->x_numelem; i++)
+ {
+ if(x->x_elem[i].a_type == A_FLOAT) // compare with all floats in our list
+ if(atom_getfloatarg(i, x->x_numelem, x->x_elem) == f)
+ {
+ deny = 1; // input is in deny-list
+ return;
+ }
+ }
+ if(!deny)outlet_float(x->x_out, f);
+}
+
+static t_class *deny_class;
+
+static void deny_free(t_deny *x)
+{
+ freebytes(x->x_elem, x->x_numelem*sizeof(t_atom));
+}
+
+static void *deny_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_deny *x = (t_deny *)pd_new(deny_class);
+
+ x->x_numelem = argc; // get the number of elements
+ x->x_elem = getbytes(argc*sizeof(t_atom));
+ memcpy(x->x_elem, argv, argc*sizeof(t_atom));
+
+ x->x_out = outlet_new(&x->x_obj, gensym("anything"));
+
+ // post("deny: got %d elements", x->x_numelem);
+
+ return (x);
+}
+
+#ifndef MAXLIB
+void deny_setup(void)
+{
+ /* the object's class: */
+ deny_class = class_new(gensym("deny"), (t_newmethod)deny_new,
+ (t_method)deny_free, sizeof(t_deny), 0, A_GIMME, 0);
+#else
+void maxlib_deny_setup(void)
+{
+ /* the object's class: */
+ deny_class = class_new(gensym("maxlib_deny"), (t_newmethod)deny_new,
+ (t_method)deny_free, sizeof(t_deny), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)deny_new, gensym("deny"), A_GIMME, 0);
+#endif
+ class_addsymbol(deny_class, deny_symbol);
+ class_addfloat(deny_class, deny_float);
+#ifndef MAXLIB
+ class_sethelpsymbol(deny_class, gensym("help-deny.pd"));
+ post(version);
+#else
+ class_sethelpsymbol(deny_class, gensym("maxlib/help-deny.pd"));
+#endif
+} \ No newline at end of file
diff --git a/src/dist.c b/src/dist.c
index da62d1f..e04e317 100644
--- a/src/dist.c
+++ b/src/dist.c
@@ -243,16 +243,20 @@ static void *dist_new(t_symbol *s, int argc, t_atom *argv)
x->x_sym[i] = atom_getsymbolarg(i, argc, argv);
x->x_rec++;
}
-#ifndef MAXLIB
- post(version);
-#endif
return (x);
}
+#ifndef MAXLIB
void dist_setup(void)
{
dist_class = class_new(gensym("dist"), (t_newmethod)dist_new, 0,
sizeof(t_dist), 0, A_GIMME, 0);
+#else
+void maxlib_dist_setup(void)
+{
+ dist_class = class_new(gensym("maxlib_dist"), (t_newmethod)dist_new, 0,
+ sizeof(t_dist), 0, A_GIMME, 0);
+#endif
class_addcreator((t_newmethod)dist_new, gensym("d"), A_GIMME, 0);
class_addbang(dist_class, dist_bang);
class_addfloat(dist_class, dist_float);
@@ -265,4 +269,11 @@ void dist_setup(void)
class_addmethod(dist_class, (t_method)dist_print, gensym("print"), 0);
class_addmethod(dist_class, (t_method)dist_send, gensym("send"), A_GIMME, 0);
class_addanything(dist_class, dist_anything);
+#ifndef MAXLIB
+ class_sethelpsymbol(dist_class, gensym("help-dist.pd"));
+ post(version);
+#else
+ class_addcreator((t_newmethod)dist_new, gensym("dist"), A_GIMME, 0);
+ class_sethelpsymbol(dist_class, gensym("maxlib/help-dist.pd"));
+#endif
}
diff --git a/src/divide.c b/src/divide.c
index 40e5360..2a3bf10 100644
--- a/src/divide.c
+++ b/src/divide.c
@@ -82,18 +82,29 @@ static void *divide_new(t_symbol *s, t_int argc, t_atom* argv)
}
x->x_numvalues = i;
-#ifndef MAXLIB
- post(version);
-#endif
return (void *)x;
}
+#ifndef MAXLIB
void divide_setup(void)
{
divide_class = class_new(gensym("divide"), (t_newmethod)divide_new,
0, sizeof(t_divide), 0, A_GIMME, 0);
+#else
+void maxlib_divide_setup(void)
+{
+ divide_class = class_new(gensym("maxlib_divide"), (t_newmethod)divide_new,
+ 0, sizeof(t_divide), 0, A_GIMME, 0);
+#endif
class_addfloat(divide_class, divide_float);
class_addmethod(divide_class, (t_method)divide_ft1, gensym("ft1"), A_FLOAT, 0);
class_addbang(divide_class, (t_method)divide_bang);
+#ifndef MAXLIB
+ class_sethelpsymbol(divide_class, gensym("help-divide.pd"));
+ post(version);
+#else
+ class_addcreator((t_newmethod)divide_new, gensym("divide"), A_GIMME, 0);
+ class_sethelpsymbol(divide_class, gensym("maxlib/help-divide.pd"));
+#endif
}
diff --git a/src/divmod.c b/src/divmod.c
index f84862c..ee552e7 100644
--- a/src/divmod.c
+++ b/src/divmod.c
@@ -72,18 +72,29 @@ static void *divmod_new(t_floatarg fl, t_floatarg fr)
x->x_rightvalue = fr;
x->x_leftvalue = fl;
-#ifndef MAXLIB
- post(version);
-#endif
return (void *)x;
}
+#ifndef MAXLIB
void divmod_setup(void)
{
divmod_class = class_new(gensym("divmod"), (t_newmethod)divmod_new,
0, sizeof(t_divmod), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
+#else
+void maxlib_divmod_setup(void)
+{
+ divmod_class = class_new(gensym("maxlib_divmod"), (t_newmethod)divmod_new,
+ 0, sizeof(t_divmod), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
+#endif
class_addfloat(divmod_class, divmod_float);
class_addmethod(divmod_class, (t_method)divmod_ft1, gensym("ft1"), A_FLOAT, 0);
class_addbang(divmod_class, (t_method)divmod_bang);
+#ifndef MAXLIB
+ class_sethelpsymbol(divmod_class, gensym("help-divmod.pd"));
+ post(version);
+#else
+ class_addcreator((t_newmethod)divmod_new, gensym("divmod"), A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_sethelpsymbol(divmod_class, gensym("maxlib/help-divmod.pd"));
+#endif
}
diff --git a/src/edge.c b/src/edge.c
index 308ee59..0f067a8 100644
--- a/src/edge.c
+++ b/src/edge.c
@@ -57,19 +57,26 @@ static void *edge_new(t_floatarg f)
x->x_lastval = f;
-#ifndef MAXLIB
- post(version);
-#endif
return (void *)x;
}
+#ifndef MAXLIB
void edge_setup(void)
{
edge_class = class_new(gensym("edge"), (t_newmethod)edge_new,
0, sizeof(t_edge), 0, A_DEFFLOAT, 0);
class_addfloat(edge_class, edge_float);
-#ifndef MAXLIB
+ class_sethelpsymbol(edge_class, gensym("help-edge.pd"));
+ post(version);
+}
#else
-#endif
+void maxlib_edge_setup(void)
+{
+ edge_class = class_new(gensym("maxlib_edge"), (t_newmethod)edge_new,
+ 0, sizeof(t_edge), 0, A_DEFFLOAT, 0);
+ class_addfloat(edge_class, edge_float);
+ class_addcreator((t_newmethod)edge_new, gensym("edge"), A_DEFFLOAT, 0);
+ class_sethelpsymbol(edge_class, gensym("maxlib/help-edge.pd"));
}
+#endif
diff --git a/src/expo.c b/src/expo.c
index f9c7844..7100417 100644
--- a/src/expo.c
+++ b/src/expo.c
@@ -65,12 +65,22 @@ static void rand_expo_bang(t_rand_expo *x)
outlet_float(x->x_obj.ob_outlet, -log(u)/l);
}
+#ifndef MAXLIB
void expo_setup(void)
{
rand_expo_class = class_new(gensym("expo"), (t_newmethod)rand_expo_new, 0,
sizeof(t_rand_expo), 0, A_DEFFLOAT, 0);
class_addbang(rand_expo_class, rand_expo_bang);
-#ifndef MAXLIB
+ class_sethelpsymbol(rand_expo_class, gensym("help-expo.pd"));
post(version);
-#endif
}
+#else
+void maxlib_expo_setup(void)
+{
+ rand_expo_class = class_new(gensym("maxlib_expo"), (t_newmethod)rand_expo_new, 0,
+ sizeof(t_rand_expo), 0, A_DEFFLOAT, 0);
+ class_addbang(rand_expo_class, rand_expo_bang);
+ class_addcreator((t_newmethod)rand_expo_new, gensym("expo"), A_DEFFLOAT, 0);
+ class_sethelpsymbol(rand_expo_class, gensym("maxlib/help-expo.pd"));
+}
+#endif \ No newline at end of file
diff --git a/src/fifo.c b/src/fifo.c
index 5cfab84..c0f73be 100644
--- a/src/fifo.c
+++ b/src/fifo.c
@@ -70,16 +70,27 @@ static void *fifo_new(t_floatarg n)
x->getal = (t_float *)getbytes(x->size * sizeof(t_float));
x->out = outlet_new(&x->d_ob, gensym("float"));
-#ifndef MAXLIB
- post(version);
-#endif
return (x);
}
+#ifndef MAXLIB
void fifo_setup(void)
{
fifo_class = class_new(gensym("fifo"), (t_newmethod)fifo_new,
(t_method)fifo_free, sizeof(t_fifo), 0, A_DEFFLOAT, 0);
class_addfloat(fifo_class, fifo_int);
class_addbang(fifo_class, fifo_bang);
+ class_sethelpsymbol(fifo_class, gensym("help-fifo.pd"));
+ post(version);
+}
+#else
+void maxlib_fifo_setup(void)
+{
+ fifo_class = class_new(gensym("maxlib_fifo"), (t_newmethod)fifo_new,
+ (t_method)fifo_free, sizeof(t_fifo), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)fifo_new, gensym("fifo"), A_DEFFLOAT, 0);
+ class_addfloat(fifo_class, fifo_int);
+ class_addbang(fifo_class, fifo_bang);
+ class_sethelpsymbol(fifo_class, gensym("maxlib/help-fifo.pd"));
}
+#endif \ No newline at end of file
diff --git a/src/gauss.c b/src/gauss.c
index ec81e70..2a441c4 100644
--- a/src/gauss.c
+++ b/src/gauss.c
@@ -66,12 +66,23 @@ static void rand_gauss_bang(t_rand_gauss *x)
outlet_float(x->x_obj.ob_outlet, x->x_sigma*scale*(sum-halfN)+x->x_mu);
}
+#ifndef MAXLIB
void gauss_setup(void)
{
rand_gauss_class = class_new(gensym("gauss"), (t_newmethod)rand_gauss_new, 0,
sizeof(t_rand_gauss), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
class_addbang(rand_gauss_class, rand_gauss_bang);
-#ifndef MAXLIB
+ class_sethelpsymbol(rand_gauss_class, gensym("help-gauss.pd"));
post(version);
-#endif
}
+#else
+void maxlib_gauss_setup(void)
+{
+ rand_gauss_class = class_new(gensym("maxlib_gauss"), (t_newmethod)rand_gauss_new, 0,
+ sizeof(t_rand_gauss), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)rand_gauss_new, gensym("gauss"), A_DEFFLOAT, 0);
+ class_addbang(rand_gauss_class, rand_gauss_bang);
+ class_sethelpsymbol(rand_gauss_class, gensym("maxlib/help-gauss.pd"));
+}
+#endif
+
diff --git a/src/gestalt.c b/src/gestalt.c
index cd07969..650efdb 100644
--- a/src/gestalt.c
+++ b/src/gestalt.c
@@ -91,12 +91,10 @@ static void *gestalt_new(t_floatarg f)
x->x_reftime = f;
if(x->x_reftime < 1) x->x_reftime = 1;
-#ifndef MAXLIB
- post(version);
-#endif
return (void *)x;
}
+#ifndef MAXLIB
void gestalt_setup(void)
{
gestalt_class = class_new(gensym("gestalt"), (t_newmethod)gestalt_new,
@@ -104,5 +102,19 @@ void gestalt_setup(void)
class_addfloat(gestalt_class, gestalt_float);
class_addmethod(gestalt_class, (t_method)gestalt_ft1, gensym("ft1"), A_FLOAT, 0);
class_addmethod(gestalt_class, (t_method)gestalt_ft2, gensym("ft2"), A_FLOAT, 0);
+ class_sethelpsymbol(gestalt_class, gensym("help-gestalt.pd"));
+ post(version);
+}
+#else
+void maxlib_gestalt_setup(void)
+{
+ gestalt_class = class_new(gensym("maxlib_gestalt"), (t_newmethod)gestalt_new,
+ 0, sizeof(t_gestalt), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)gestalt_new, gensym("gestalt"), A_DEFFLOAT, 0);
+ class_addfloat(gestalt_class, gestalt_float);
+ class_addmethod(gestalt_class, (t_method)gestalt_ft1, gensym("ft1"), A_FLOAT, 0);
+ class_addmethod(gestalt_class, (t_method)gestalt_ft2, gensym("ft2"), A_FLOAT, 0);
+ class_sethelpsymbol(gestalt_class, gensym("maxlib/help-gestalt.pd"));
}
+#endif
diff --git a/src/history.c b/src/history.c
index 8221ad3..4f93b89 100644
--- a/src/history.c
+++ b/src/history.c
@@ -236,12 +236,11 @@ static void *history_new(t_floatarg f)
x->x_average = 0;
x->x_mode = 0;
clock_delay(x->x_clock, 0);
-#ifndef MAXLIB
- post(version);
-#endif
+
return (void *)x;
}
+#ifndef MAXLIB
void history_setup(void)
{
history_class = class_new(gensym("history"), (t_newmethod)history_new,
@@ -252,5 +251,21 @@ void history_setup(void)
class_addmethod(history_class, (t_method)history_weight, gensym("weight"), 0);
class_addfloat(history_class, history_float);
class_addmethod(history_class, (t_method)history_time, gensym("time"), A_FLOAT, 0);
+ class_sethelpsymbol(history_class, gensym("help-history.pd"));
+ post(version);
}
-
+#else
+void maxlib_history_setup(void)
+{
+ history_class = class_new(gensym("maxlib_history"), (t_newmethod)history_new,
+ (t_method)history_free, sizeof(t_history), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)history_new, gensym("history"), A_DEFFLOAT, 0);
+ class_addmethod(history_class, (t_method)history_reset, gensym("reset"), 0);
+ class_addmethod(history_class, (t_method)history_linear, gensym("linear"), 0);
+ class_addmethod(history_class, (t_method)history_geometric, gensym("geometric"), 0);
+ class_addmethod(history_class, (t_method)history_weight, gensym("weight"), 0);
+ class_addfloat(history_class, history_float);
+ class_addmethod(history_class, (t_method)history_time, gensym("time"), A_FLOAT, 0);
+ class_sethelpsymbol(history_class, gensym("maxlib/help-history.pd"));
+}
+#endif
diff --git a/src/ignore.c b/src/ignore.c
index d428e50..3e3c0e7 100644
--- a/src/ignore.c
+++ b/src/ignore.c
@@ -24,9 +24,6 @@
#include "m_pd.h"
-#define MAX_ARG 16 /* maximum number of items to ignore */
-#define IN_SIZE 32 /* size of array that stores the incoming values */
-
static char *version = "ignore v0.1, written by Olaf Matthes <olaf.matthes@gmx.de>";
typedef struct ignore
@@ -90,16 +87,13 @@ static void *ignore_new(t_floatarg f)
x->x_outfloat = outlet_new(&x->x_ob, gensym("float"));
x->x_clock = clock_new(x, (t_method)ignore_tick);
-#ifndef MAXLIB
- post(version);
-#endif
-
x->x_time = (t_int)f;
x->x_lastinput = 0;
return (void *)x;
}
+#ifndef MAXLIB
void ignore_setup(void)
{
ignore_class = class_new(gensym("ignore"), (t_newmethod)ignore_new,
@@ -107,5 +101,19 @@ void ignore_setup(void)
class_addmethod(ignore_class, (t_method)ignore_reset, gensym("reset"), 0);
class_addmethod(ignore_class, (t_method)ignore_time, gensym("time"), A_FLOAT, 0);
class_addfloat(ignore_class, ignore_float);
+ class_sethelpsymbol(ignore_class, gensym("help-ignore.pd"));
+ post(version);
+}
+#else
+void maxlib_ignore_setup(void)
+{
+ ignore_class = class_new(gensym("maxlib_ignore"), (t_newmethod)ignore_new,
+ (t_method)ignore_free, sizeof(t_ignore), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)ignore_new, gensym("ignore"), A_DEFFLOAT, 0);
+ class_addmethod(ignore_class, (t_method)ignore_reset, gensym("reset"), 0);
+ class_addmethod(ignore_class, (t_method)ignore_time, gensym("time"), A_FLOAT, 0);
+ class_addfloat(ignore_class, ignore_float);
+ class_sethelpsymbol(ignore_class, gensym("maxlib/help-ignore.pd"));
}
+#endif
diff --git a/src/iso.c b/src/iso.c
index f335c63..b206bb4 100644
--- a/src/iso.c
+++ b/src/iso.c
@@ -1,6 +1,27 @@
-/* iso.c ---- queue up pitch and attack point series */
-/* by Charlie Baker (baker@foxtrot.ccmrc.ucsb.edu) */
-/* Pd port by Olaf Matthes <olaf.matthes@gmx.de> */
+/* ---------------------------- iso ------------------------------------------- */
+/* */
+/* Queue up pitch and attack point series. */
+/* Written by Olaf Matthes (olaf.matthes@gmx.de) */
+/* Based on iso for Max by Charlie Baker (baker@foxtrot.ccmrc.ucsb.edu). */
+/* Get source at http://www.akustische-kunst.org/puredata/maxlib/ */
+/* */
+/* This program is free software; you can redistribute it and/or */
+/* modify it under the terms of the GNU General Public License */
+/* as published by the Free Software Foundation; either version 2 */
+/* of the License, or (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program; if not, write to the Free Software */
+/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+/* */
+/* Based on PureData by Miller Puckette and others. */
+/* */
+/* ---------------------------------------------------------------------------- */
#include "m_pd.h"
#include <stdio.h>
@@ -148,9 +169,7 @@ static void *iso_new(void) {
x->pitches[0] = 60;
x->atks[0] = 500;
x->duty = 1.0;
-#ifndef MAXLIB
- post(version);
-#endif
+
return (x); /* always return a copy of the created object */
}
@@ -159,6 +178,7 @@ static void iso_free(t_iso *x) {
clock_free(x->iso_clock);
}
+#ifndef MAXLIB
void iso_setup(void) {
iso_class = class_new(gensym("iso"), (t_newmethod)iso_new,
@@ -174,4 +194,26 @@ void iso_setup(void) {
class_addmethod(iso_class, (t_method)iso_hook, gensym("hook"), A_FLOAT, 0);
class_addbang(iso_class, iso_bang);
class_addlist(iso_class, iso_pitch);
+ class_sethelpsymbol(iso_class, gensym("help-iso.pd"));
+ post(version);
}
+#else
+void maxlib_iso_setup(void) {
+
+ iso_class = class_new(gensym("maxlib_iso"), (t_newmethod)iso_new,
+ (t_method)iso_free, sizeof(t_iso), 0, 0);
+ class_addcreator((t_newmethod)iso_new, gensym("iso"), 0);
+ class_addmethod(iso_class, (t_method)iso_duty, gensym("duty"), A_FLOAT, 0);
+ class_addmethod(iso_class, (t_method)iso_list, gensym("attack"), A_GIMME, 0);
+ class_addmethod(iso_class, (t_method)iso_start, gensym("start"), A_GIMME, 0);
+ class_addmethod(iso_class, (t_method)iso_stop, gensym("stop"), 0);
+ class_addmethod(iso_class, (t_method)iso_pause, gensym("pause"), 0);
+ class_addmethod(iso_class, (t_method)iso_loop, gensym("loop"), 0);
+ class_addmethod(iso_class, (t_method)iso_unloop, gensym("unloop"), 0);
+ class_addmethod(iso_class, (t_method)iso_resume, gensym("resume"), 0);
+ class_addmethod(iso_class, (t_method)iso_hook, gensym("hook"), A_FLOAT, 0);
+ class_addbang(iso_class, iso_bang);
+ class_addlist(iso_class, iso_pitch);
+ class_sethelpsymbol(iso_class, gensym("maxlib/help-iso.pd"));
+}
+#endif
diff --git a/src/lifo.c b/src/lifo.c
index b219fed..d2983e4 100644
--- a/src/lifo.c
+++ b/src/lifo.c
@@ -20,7 +20,7 @@
/* */
/* Based on PureData by Miller Puckette and others. */
/* */
-/* Fifi-code based St. Rainstick fifi.c for Max, */
+/* Fifi-code based St. Rainstick fifo.c for Max, */
/* copyright St. Rainstick, Amsterdam 1995 */
/* */
/* ---------------------------------------------------------------------------- */
@@ -78,12 +78,11 @@ static void *lifo_new(t_floatarg n)
x->count = 0;
x->getal = (t_float *)getbytes(x->size * sizeof(t_float));
x->out = outlet_new(&x->d_ob, gensym("float"));
-#ifndef MAXLIB
- post(version);
-#endif
+
return (x);
}
+#ifndef MAXLIB
void lifo_setup(void)
{
lifo_class = class_new(gensym("lifo"), (t_newmethod)lifo_new,
@@ -91,4 +90,18 @@ void lifo_setup(void)
class_addfloat(lifo_class, lifo_int);
class_addbang(lifo_class, lifo_bang);
class_addmethod(lifo_class, (t_method)lifo_clear, gensym("clear"), 0);
+ class_sethelpsymbol(lifo_class, gensym("help-lifo.pd"));
+ post(version);
+}
+#else
+void maxlib_lifo_setup(void)
+{
+ lifo_class = class_new(gensym("maxlib_lifo"), (t_newmethod)lifo_new,
+ (t_method)lifo_free, sizeof(t_lifo), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)lifo_new, gensym("lifo"), A_DEFFLOAT, 0);
+ class_addfloat(lifo_class, lifo_int);
+ class_addbang(lifo_class, lifo_bang);
+ class_addmethod(lifo_class, (t_method)lifo_clear, gensym("clear"), 0);
+ class_sethelpsymbol(lifo_class, gensym("maxlib/help-lifo.pd"));
}
+#endif \ No newline at end of file
diff --git a/src/limit.c b/src/limit.c
index e4d22e2..9d14f1d 100644
--- a/src/limit.c
+++ b/src/limit.c
@@ -98,20 +98,28 @@ static void *limit_new(t_floatarg fol, t_floatarg foh, t_floatarg fr)
x->x_ratio = fr;
x->x_f = 0;
-#ifndef MAXLIB
- post(version);
-#endif
return (void *)x;
}
+#ifndef MAXLIB
void limit_setup(void)
{
limit_class = class_new(gensym("limit"), (t_newmethod)limit_new,
0, sizeof(t_limit), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+#else
+void maxlib_limit_setup(void)
+{
+ limit_class = class_new(gensym("maxlib_limit"), (t_newmethod)limit_new,
+ 0, sizeof(t_limit), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)limit_new, gensym("limit"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+#endif
class_addfloat(limit_class, limit_float);
class_addbang(limit_class, limit_bang);
#ifndef MAXLIB
+ class_sethelpsymbol(limit_class, gensym("help-limit.pd"));
+ post(version);
#else
+ class_sethelpsymbol(limit_class, gensym("maxlib/help-limit.pd"));
#endif
}
diff --git a/src/linear.c b/src/linear.c
index 1f86c7d..a5869a2 100644
--- a/src/linear.c
+++ b/src/linear.c
@@ -60,12 +60,22 @@ static void rand_linear_bang(t_rand_linear *x)
outlet_float(x->x_obj.ob_outlet, u1);
}
+#ifndef MAXLIB
void linear_setup(void)
{
rand_linear_class = class_new(gensym("linear"), (t_newmethod)rand_linear_new, 0,
sizeof(t_rand_linear), 0, A_DEFFLOAT, 0);
class_addbang(rand_linear_class, rand_linear_bang);
-#ifndef MAXLIB
+ class_sethelpsymbol(rand_linear_class, gensym("help-linear.pd"));
post(version);
-#endif
}
+#else
+void maxlib_linear_setup(void)
+{
+ rand_linear_class = class_new(gensym("maxlib_linear"), (t_newmethod)rand_linear_new, 0,
+ sizeof(t_rand_linear), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)rand_linear_new, gensym("linear"), A_DEFFLOAT, 0);
+ class_addbang(rand_linear_class, rand_linear_bang);
+ class_sethelpsymbol(rand_linear_class, gensym("maxlib/help-linear.pd"));
+}
+#endif \ No newline at end of file
diff --git a/src/listfifo.c b/src/listfifo.c
new file mode 100644
index 0000000..dda9eeb
--- /dev/null
+++ b/src/listfifo.c
@@ -0,0 +1,109 @@
+/* ---------------------------- listfifo -------------------------------------- */
+/* */
+/* Fifo buffer of lists, empties itselfe on every bang (in order of coming in) */
+/* Written by Olaf Matthes (olaf.matthes@gmx.de) */
+/* Get source at http://www.akustische-kunst.org/puredata/maxlib/ */
+/* */
+/* This program is free software; you can redistribute it and/or */
+/* modify it under the terms of the GNU General Public License */
+/* as published by the Free Software Foundation; either version 2 */
+/* of the License, or (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program; if not, write to the Free Software */
+/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+/* */
+/* Based on PureData by Miller Puckette and others. */
+/* */
+/* ---------------------------------------------------------------------------- */
+
+#include "m_pd.h"
+
+#define MAX_ELEM 256 /* maximum number of list elements to pass on */
+
+static char *version = "listfifo v0.1, written by Olaf Matthes <olaf.matthes@gmx.de>";
+
+typedef struct listfifo
+{
+ t_object d_ob;
+ t_atom *getal; /* stores the list values */
+ t_int *getsize; /* stores the number of elements in list */
+ t_int count, end, size;
+ t_outlet *out;
+
+}t_listfifo;
+
+static t_class *listfifo_class;
+
+static void listfifo_list(t_listfifo *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i;
+ if(argc > MAX_ELEM)
+ {
+ post("listfifo: to many arguments in list, ignored");
+ return;
+ }
+ for(i = 0; i < argc; i++)
+ x->getal[(x->count * MAX_ELEM) + i] = argv[i];
+ x->getsize[x->count] = argc;
+ x->count = (x->count + 1) % x->size;
+ // post("got %d elements", argc);
+}
+
+static void listfifo_bang(t_listfifo *x)
+{
+ // post("count = %d, end = %d", x->count, x->end);
+ if (x->end != x->count){
+ outlet_list(x->out, NULL, x->getsize[x->end], x->getal+(x->end * MAX_ELEM));
+ x->end = (x->end + 1) % x->size;
+ }
+}
+
+static void listfifo_free(t_listfifo *x)
+{
+ freebytes(x->getsize, x->size * sizeof(t_int));
+ freebytes(x->getal, x->size * sizeof(t_float) * MAX_ELEM);
+}
+
+static void *listfifo_new(t_floatarg n)
+{
+ int i;
+
+ t_listfifo *x = (t_listfifo *)pd_new(listfifo_class);
+ if (n<10) n = 10;
+ x->size = (t_int)n;
+ x->end = 0;
+ x->count = 0;
+ x->getsize = (t_int *)getbytes(x->size * sizeof(t_int));
+ x->getal = (t_atom *)getbytes(x->size * sizeof(t_atom) * MAX_ELEM);
+ x->out = outlet_new(&x->d_ob, gensym("list"));
+
+ return (x);
+}
+
+#ifndef MAXLIB
+void listfifo_setup(void)
+{
+ listfifo_class = class_new(gensym("listfifo"), (t_newmethod)listfifo_new,
+ (t_method)listfifo_free, sizeof(t_listfifo), 0, A_DEFFLOAT, 0);
+ class_addbang(listfifo_class, listfifo_bang);
+ class_addlist(listfifo_class, listfifo_list);
+ class_sethelpsymbol(listfifo_class, gensym("help-listfifo.pd"));
+ post(version);
+}
+#else
+void maxlib_listfifo_setup(void)
+{
+ listfifo_class = class_new(gensym("maxlib_listfifo"), (t_newmethod)listfifo_new,
+ (t_method)listfifo_free, sizeof(t_listfifo), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)listfifo_new, gensym("listfifo"), A_DEFFLOAT, 0);
+ class_addbang(listfifo_class, listfifo_bang);
+ class_addlist(listfifo_class, listfifo_list);
+ class_sethelpsymbol(listfifo_class, gensym("maxlib/help-listfifo.pd"));
+}
+#endif \ No newline at end of file
diff --git a/src/listfunnel.c b/src/listfunnel.c
index a31b4ee..d9ba656 100644
--- a/src/listfunnel.c
+++ b/src/listfunnel.c
@@ -65,17 +65,28 @@ static void *listfunnel_new(void)
t_listfunnel *x = (t_listfunnel *)pd_new(listfunnel_class);
x->x_outlet = outlet_new(&x->x_ob, gensym("float"));
-#ifndef MAXLIB
- post(version);
-#endif
return (void *)x;
}
+#ifndef MAXLIB
void listfunnel_setup(void)
{
listfunnel_class = class_new(gensym("listfunnel"), (t_newmethod)listfunnel_new,
0, sizeof(t_listfunnel), 0, 0, 0);
class_addfloat(listfunnel_class, listfunnel_float);
class_addlist(listfunnel_class, listfunnel_list);
+ class_sethelpsymbol(listfunnel_class, gensym("help-listfunnel.pd"));
+ post(version);
}
+#else
+void maxlib_listfunnel_setup(void)
+{
+ listfunnel_class = class_new(gensym("maxlib_listfunnel"), (t_newmethod)listfunnel_new,
+ 0, sizeof(t_listfunnel), 0, 0, 0);
+ class_addcreator((t_newmethod)listfunnel_new, gensym("listfunnel"), 0);
+ class_addfloat(listfunnel_class, listfunnel_float);
+ class_addlist(listfunnel_class, listfunnel_list);
+ class_sethelpsymbol(listfunnel_class, gensym("maxlib/help-listfunnel.pd"));
+}
+#endif
diff --git a/src/match.c b/src/match.c
index 6fb7933..623ca87 100644
--- a/src/match.c
+++ b/src/match.c
@@ -29,11 +29,9 @@
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-/* LATER compare with match.c from max sdk */
#include <string.h>
#include "m_pd.h"
-// #include "hammer.h"
#define MATCH_INISIZE 16 /* LATER rethink */
@@ -250,10 +248,18 @@ static void *match_new(t_symbol *s, int ac, t_atom *av)
return (x);
}
+#ifndef MAXLIB
void match_setup(void)
{
match_class = class_new(gensym("match"), (t_newmethod)match_new,
(t_method)match_free, sizeof(t_match), 0, A_GIMME, 0);
+#else
+void maxlib_match_setup(void)
+{
+ match_class = class_new(gensym("maxlib_match"), (t_newmethod)match_new,
+ (t_method)match_free, sizeof(t_match), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)match_new, gensym("match"), A_GIMME, 0);
+#endif
class_addfloat(match_class, match_float);
class_addsymbol(match_class, match_symbol);
class_addlist(match_class, match_list);
@@ -261,6 +267,8 @@ void match_setup(void)
class_addmethod(match_class, (t_method)match_set, gensym("set"), A_GIMME, 0);
class_addmethod(match_class, (t_method)match_clear, gensym("clear"), 0);
#ifndef MAXLIB
+ class_sethelpsymbol(match_class, gensym("help-match.pd"));
#else
+ class_sethelpsymbol(match_class, gensym("maxlib/help-match.pd"));
#endif
}
diff --git a/src/minus.c b/src/minus.c
index 17db861..596ee10 100644
--- a/src/minus.c
+++ b/src/minus.c
@@ -82,12 +82,11 @@ static void *minus_new(t_symbol *s, t_int argc, t_atom* argv)
x->x_minusvalue[i] = atom_getfloatarg(i, argc, argv);
}
x->x_numvalues = i;
-#ifndef MAXLIB
- post(version);
-#endif
+
return (void *)x;
}
+#ifndef MAXLIB
void minus_setup(void)
{
minus_class = class_new(gensym("minus"), (t_newmethod)minus_new,
@@ -95,5 +94,18 @@ void minus_setup(void)
class_addfloat(minus_class, minus_float);
class_addmethod(minus_class, (t_method)minus_ft1, gensym("ft1"), A_FLOAT, 0);
class_addbang(minus_class, (t_method)minus_bang);
+ class_sethelpsymbol(minus_class, gensym("help-minus.pd"));
+ post(version);
}
-
+#else
+void maxlib_minus_setup(void)
+{
+ minus_class = class_new(gensym("maxlib_minus"), (t_newmethod)minus_new,
+ 0, sizeof(t_minus), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)minus_new, gensym("minus"), A_GIMME, 0);
+ class_addfloat(minus_class, minus_float);
+ class_addmethod(minus_class, (t_method)minus_ft1, gensym("ft1"), A_FLOAT, 0);
+ class_addbang(minus_class, (t_method)minus_bang);
+ class_sethelpsymbol(minus_class, gensym("maxlib/help-minus.pd"));
+}
+#endif
diff --git a/src/mlife.c b/src/mlife.c
index 66243ef..47960dd 100644
--- a/src/mlife.c
+++ b/src/mlife.c
@@ -460,9 +460,6 @@ static void *ml_new(t_floatarg size, t_floatarg view_start, t_floatarg view_size
post("mlife: INTSIZE=%ld, LONGSIZE=%ld", (long)INTSIZE, (long)LONGSIZE);
#endif
-#ifndef MAXLIB
- post(version);
-#endif
post("mlife: defaults are: lo=%ld, hi=%ld, nset=%ld", (long)DEFAULT_DIE_LO, (long)DEFAULT_DIE_HI, DEFAULT_N_SIZE);
return(mlp); // always return a copy of the created object
@@ -479,6 +476,7 @@ static void ml_free(t_maxlife *mlp)
freeobject(mlp->out[i]); */
}
+#ifndef MAXLIB
void mlife_setup(void)
{
mlife_class = class_new(gensym("mlife"), (t_newmethod)ml_new,
@@ -493,4 +491,25 @@ void mlife_setup(void)
class_addmethod(mlife_class, (t_method)ml_display, gensym("display"), 0);
class_addfloat(mlife_class, ml_int);
class_addbang(mlife_class, ml_bang);
+ class_sethelpsymbol(mlife_class, gensym("help-mlife.pd"));
+ post(version);
+}
+#else
+void maxlib_mlife_setup(void)
+{
+ mlife_class = class_new(gensym("maxlib_mlife"), (t_newmethod)ml_new,
+ (t_method)ml_free, sizeof(t_maxlife), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)ml_new, gensym("mlife"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(mlife_class, (t_method)ml_randfill, gensym("randfill"), 0);
+ class_addmethod(mlife_class, (t_method)ml_fill, gensym("fill"), A_FLOAT, 0);
+ class_addmethod(mlife_class, (t_method)ml_set_die_lo, gensym("lo"), A_FLOAT, 0);
+ class_addmethod(mlife_class, (t_method)ml_set_die_hi, gensym("hi"), A_FLOAT, 0);
+ class_addmethod(mlife_class, (t_method)ml_set_neighbourhood, gensym("nset"), A_FLOAT, 0);
+ class_addmethod(mlife_class, (t_method)ml_randseed, gensym("randseed"), A_FLOAT, 0);
+ class_addmethod(mlife_class, (t_method)ml_seed, gensym("seed"), A_FLOAT, A_FLOAT, 0);
+ class_addmethod(mlife_class, (t_method)ml_display, gensym("display"), 0);
+ class_addfloat(mlife_class, ml_int);
+ class_addbang(mlife_class, ml_bang);
+ class_sethelpsymbol(mlife_class, gensym("maxlib/help-mlife.pd"));
}
+#endif \ No newline at end of file
diff --git a/src/multi.c b/src/multi.c
index 543ffa3..2f5db67 100644
--- a/src/multi.c
+++ b/src/multi.c
@@ -81,12 +81,11 @@ static void *multi_new(t_symbol *s, t_int argc, t_atom* argv)
x->x_multivalue[i] = atom_getfloatarg(i, argc, argv);;
}
x->x_numvalues = i;
-#ifndef MAXLIB
- post(version);
-#endif
+
return (void *)x;
}
+#ifndef MAXLIB
void multi_setup(void)
{
multi_class = class_new(gensym("multi"), (t_newmethod)multi_new,
@@ -94,5 +93,18 @@ void multi_setup(void)
class_addfloat(multi_class, multi_float);
class_addmethod(multi_class, (t_method)multi_ft1, gensym("ft1"), A_FLOAT, 0);
class_addbang(multi_class, (t_method)multi_bang);
+ class_sethelpsymbol(multi_class, gensym("help-multi.pd"));
+ post(version);
}
-
+#else
+void maxlib_multi_setup(void)
+{
+ multi_class = class_new(gensym("maxlib_multi"), (t_newmethod)multi_new,
+ 0, sizeof(t_multi), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)multi_new, gensym("multi"), A_GIMME, 0);
+ class_addfloat(multi_class, multi_float);
+ class_addmethod(multi_class, (t_method)multi_ft1, gensym("ft1"), A_FLOAT, 0);
+ class_addbang(multi_class, (t_method)multi_bang);
+ class_sethelpsymbol(multi_class, gensym("maxlib/help-multi.pd"));
+}
+#endif
diff --git a/src/nchange.c b/src/nchange.c
new file mode 100644
index 0000000..a7e7eb5
--- /dev/null
+++ b/src/nchange.c
@@ -0,0 +1,205 @@
+/* ------------------------- ignore ------------------------------------------- */
+/* */
+/* A 'new' change object for more than just floats. */
+/* Written by Olaf Matthes <olaf.matthes@gmx.de> */
+/* Get source at http://www.akustische-kunst.org/puredata/maxlib/ */
+/* */
+/* This program is free software; you can redistribute it and/or */
+/* modify it under the terms of the GNU General Public License */
+/* as published by the Free Software Foundation; either version 2 */
+/* of the License, or (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program; if not, write to the Free Software */
+/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+/* */
+/* Based on PureData by Miller Puckette and others. */
+/* */
+/* ---------------------------------------------------------------------------- */
+
+#define A_LIST 254;
+#define A_ANYTHING 255;
+
+#include "m_pd.h"
+
+// #include <string.h>
+// #include <stdio.h>
+
+/* -------------------------- nchange ------------------------------ */
+static char *version = "nchange v0.1, written by Olaf Matthes <olaf.matthes@gmx.de>";
+
+static t_class *nchange_class;
+
+typedef struct _nchange
+{
+ t_object x_obj;
+ t_atom x_a[256];
+ int x_c;
+ int x_type;
+} t_nchange;
+
+static void *nchange_new(t_symbol *s)
+{
+ int i;
+
+ t_nchange *x = (t_nchange *)pd_new(nchange_class);
+
+ if(s == gensym("s"))
+ {
+ x->x_type = A_SYMBOL;
+ outlet_new(&x->x_obj, &s_symbol);
+ }
+ else if(s == gensym("f"))
+ {
+ x->x_type = A_FLOAT;
+ outlet_new(&x->x_obj, &s_float);
+ }
+ else if(s == gensym("l"))
+ {
+ x->x_type = A_LIST;
+ outlet_new(&x->x_obj, &s_list);
+ }
+ else
+ {
+ x->x_type = A_ANYTHING;
+ outlet_new(&x->x_obj, &s_anything);
+ }
+
+ return (x);
+}
+
+static void nchange_bang(t_nchange *x)
+{
+ if (x->x_type == A_FLOAT)
+ outlet_float(x->x_obj.ob_outlet, x->x_a->a_w.w_float);
+ else if (x->x_type == A_SYMBOL)
+ outlet_symbol(x->x_obj.ob_outlet, x->x_a->a_w.w_symbol);
+ else
+ outlet_list(x->x_obj.ob_outlet, NULL, x->x_c, x->x_a);
+}
+
+static void nchange_float(t_nchange *x, t_float f)
+{
+ if (x->x_type == A_FLOAT)
+ {
+ if (f != x->x_a->a_w.w_float)
+ {
+ // x->x_f = f;
+ SETFLOAT(x->x_a, f);
+ outlet_float(x->x_obj.ob_outlet, x->x_a->a_w.w_float);
+ }
+ }
+}
+
+static void nchange_symbol(t_nchange *x, t_symbol *s)
+{
+ if (x->x_type == A_SYMBOL)
+ {
+ if (s != x->x_a->a_w.w_symbol)
+ {
+ // x->x_s = s;
+ SETSYMBOL(x->x_a, s);
+ outlet_symbol(x->x_obj.ob_outlet, x->x_a->a_w.w_symbol);
+ }
+ }
+}
+
+static void nchange_list(t_nchange *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i, change = 0;
+ int c = argc;
+
+ if(c == x->x_c) // same number of elements
+ for (i = 0; i < c; i++)
+ {
+ /* if(x->x_a[i].a_type != argv[i].a_type)
+ {
+ change = 1;
+ break;
+ } */
+ if (x->x_a[i].a_type == A_FLOAT)
+ {
+ if (argv[i].a_type != A_FLOAT || x->x_a[i].a_w.w_float != argv[i].a_w.w_float)
+ {
+ change = 1;
+ break;
+ }
+ }
+ else if (x->x_a[i].a_type == A_SYMBOL)
+ {
+ if (argv[i].a_type != A_SYMBOL || x->x_a[i].a_w.w_symbol != argv[i].a_w.w_symbol)
+ {
+ change = 1;
+ break;
+ }
+ }
+ }
+ else change = 1; // different number of elems.
+
+ if (change)
+ {
+ x->x_c = c;
+ for (i = 0; i < c; i++) // same new list
+ {
+ x->x_a[i] = argv[i];
+ }
+ outlet_list(x->x_obj.ob_outlet, s, argc, argv);
+ }
+}
+
+static void nchange_set(t_nchange *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i;
+
+ if (x->x_type == A_SYMBOL)
+ {
+ SETSYMBOL(x->x_a, argv->a_w.w_symbol);
+ }
+ else if (x->x_type == A_FLOAT)
+ {
+ SETFLOAT(x->x_a, argv->a_w.w_float);
+ }
+ else // list or anything
+ {
+ x->x_c = argc;
+ for (i = 0; i < argc; i++)
+ {
+ x->x_a[i] = argv[i];
+ }
+ }
+}
+
+#ifndef MAXLIB
+void nchange_setup(void)
+{
+ nchange_class = class_new(gensym("nchange"), (t_newmethod)nchange_new, 0,
+ sizeof(t_nchange), 0, A_SYMBOL, 0);
+ class_addbang(nchange_class, nchange_bang);
+ class_addfloat(nchange_class, nchange_float);
+ class_addsymbol(nchange_class, nchange_symbol);
+ class_addlist(nchange_class, nchange_list);
+ class_addanything(nchange_class, nchange_list);
+ class_addmethod(nchange_class, (t_method)nchange_set, gensym("set"), A_GIMME, 0);
+ class_sethelpsymbol(nchange_class, gensym("help-nchange.pd"));
+ post(version);
+}
+#else
+void maxlib_nchange_setup(void)
+{
+ nchange_class = class_new(gensym("maxlib_nchange"), (t_newmethod)nchange_new, 0,
+ sizeof(t_nchange), 0, A_SYMBOL, 0);
+ class_addcreator((t_newmethod)nchange_new, gensym("nchange"), A_SYMBOL, 0);
+ class_addbang(nchange_class, nchange_bang);
+ class_addfloat(nchange_class, nchange_float);
+ class_addsymbol(nchange_class, nchange_symbol);
+ class_addlist(nchange_class, nchange_list);
+ class_addanything(nchange_class, nchange_list);
+ class_addmethod(nchange_class, (t_method)nchange_set, gensym("set"), A_GIMME, 0);
+ class_sethelpsymbol(nchange_class, gensym("maxlib/help-nchange.pd"));
+}
+#endif \ No newline at end of file
diff --git a/src/netclient.c b/src/netclient.c
index 6e71e59..406ae19 100644
--- a/src/netclient.c
+++ b/src/netclient.c
@@ -29,7 +29,7 @@
#include <sys/types.h>
#include <string.h>
#include <pthread.h>
-#if defined(UNIX) || defined(unix)
+#ifdef UNIX
#include <sys/socket.h>
#include <sys/errno.h>
#include <netinet/in.h>
@@ -71,7 +71,7 @@ static void sys_sockerror(char *s)
int err = WSAGetLastError();
if (err == 10054) return;
#endif
-#if defined(UNIX) || defined(unix)
+#ifdef UNIX
int err = errno;
#endif
post("%s: %s (%d)\n", s, strerror(err), err);
@@ -79,7 +79,7 @@ static void sys_sockerror(char *s)
static void sys_closesocket(int fd) {
-#if defined(UNIX) || defined(unix)
+#ifdef UNIX
close(fd);
#endif
#ifdef NT
@@ -334,6 +334,7 @@ static void netclient_free(t_netclient *x)
clock_free(x->x_clock);
}
+#ifndef MAXLIB
void netclient_setup(void)
{
netclient_class = class_new(gensym("netclient"), (t_newmethod)netclient_new,
@@ -344,4 +345,21 @@ void netclient_setup(void)
class_addmethod(netclient_class, (t_method)netclient_send, gensym("send"), A_GIMME, 0);
class_addmethod(netclient_class, (t_method)netclient_rcv, gensym("receive"), 0);
class_addmethod(netclient_class, (t_method)netclient_rcv, gensym("rcv"), 0);
+ class_sethelpsymbol(netclient_class, gensym("help-netclient.pd"));
+ post(version);
}
+#else
+void maxlib_netclient_setup(void)
+{
+ netclient_class = class_new(gensym("maxlib_netclient"), (t_newmethod)netclient_new,
+ (t_method)netclient_free,
+ sizeof(t_netclient), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)netclient_new, gensym("netclient"), A_DEFFLOAT, 0);
+ class_addmethod(netclient_class, (t_method)netclient_connect, gensym("connect"), A_SYMBOL, A_FLOAT, 0);
+ class_addmethod(netclient_class, (t_method)netclient_disconnect, gensym("disconnect"), 0);
+ class_addmethod(netclient_class, (t_method)netclient_send, gensym("send"), A_GIMME, 0);
+ class_addmethod(netclient_class, (t_method)netclient_rcv, gensym("receive"), 0);
+ class_addmethod(netclient_class, (t_method)netclient_rcv, gensym("rcv"), 0);
+ class_sethelpsymbol(netclient_class, gensym("maxlib/help-netclient.pd"));
+}
+#endif \ No newline at end of file
diff --git a/src/netdist.c b/src/netdist.c
index 0c7e55c..a585734 100644
--- a/src/netdist.c
+++ b/src/netdist.c
@@ -29,7 +29,7 @@
#include <sys/types.h>
#include <string.h>
#include <pthread.h>
-#if defined(UNIX) || defined(unix)
+#ifdef UNIX
#include <sys/socket.h>
#include <sys/errno.h>
#include <netinet/in.h>
@@ -67,7 +67,7 @@ static void sys_sockerror(char *s)
int err = WSAGetLastError();
if (err == 10054) return;
#endif
-#if defined(UNIX) || defined(unix)
+#ifdef UNIX
int err = errno;
#endif
post("%s: %s (%d)\n", s, strerror(err), err);
@@ -75,7 +75,7 @@ static void sys_sockerror(char *s)
static void sys_closesocket(int fd) {
-#if defined(UNIX) || defined(unix)
+#ifdef UNIX
close(fd);
#endif
#ifdef NT
@@ -98,10 +98,8 @@ static void *netdist_new(t_floatarg udpflag)
for(i = 0; i < MAX_REC; i++)x->x_fd[i] = -1;
x->x_numconnect = -1;
x->x_protocol = (udpflag != 0 ? SOCK_DGRAM : SOCK_STREAM);
-#ifndef MAXLIB
- post(version);
-#endif
- /* prepare child thread */
+
+ /* prepare child thread */
if(pthread_attr_init(&x->x_threadattr) < 0)
post("netdist: warning: could not prepare child thread" );
if(pthread_attr_setdetachstate(&x->x_threadattr, PTHREAD_CREATE_DETACHED) < 0)
@@ -288,6 +286,7 @@ static void netdist_free(t_netdist *x)
clock_free(x->x_clock);
}
+#ifndef MAXLIB
void netdist_setup(void)
{
netdist_class = class_new(gensym("netdist"), (t_newmethod)netdist_new,
@@ -297,7 +296,20 @@ void netdist_setup(void)
class_addmethod(netdist_class, (t_method)netdist_send, gensym("send"), A_GIMME, 0);
class_addmethod(netdist_class, (t_method)netdist_clear, gensym("clear"), 0);
class_addmethod(netdist_class, (t_method)netdist_print, gensym("print"), 0);
+ class_sethelpsymbol(netdist_class, gensym("help-netdist.pd"));
+ post(version);
}
-
-
-
+#else
+void maxlib_netdist_setup(void)
+{
+ netdist_class = class_new(gensym("maxlib_netdist"), (t_newmethod)netdist_new,
+ (t_method)netdist_free, sizeof(t_netdist), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)netdist_new, gensym("netdist"), A_DEFFLOAT, 0);
+ class_addmethod(netdist_class, (t_method)netdist_connect, gensym("connect"), A_SYMBOL, A_FLOAT, 0);
+ class_addmethod(netdist_class, (t_method)netdist_disconnect, gensym("disconnect"), A_SYMBOL, A_FLOAT, 0);
+ class_addmethod(netdist_class, (t_method)netdist_send, gensym("send"), A_GIMME, 0);
+ class_addmethod(netdist_class, (t_method)netdist_clear, gensym("clear"), 0);
+ class_addmethod(netdist_class, (t_method)netdist_print, gensym("print"), 0);
+ class_sethelpsymbol(netdist_class, gensym("maxlib/help-netdist.pd"));
+}
+#endif
diff --git a/src/netrec.c b/src/netrec.c
index d409140..c747736 100644
--- a/src/netrec.c
+++ b/src/netrec.c
@@ -22,14 +22,11 @@
/* */
/* ---------------------------------------------------------------------------- */
+#ifndef PD_0_36
#include "m_pd.h"
-
-#if defined(PD_VERSION) && (PD_MAJOR_VERSION >= 0 && PD_MINOR_VERSION > 36)
-#include <m_imp.h>
-#include <s_stuff.h>
-#else
-#include "m_imp.h"
+#include "s_stuff.h"
#endif
+#include "m_imp.h"
#include <sys/types.h>
#include <stdarg.h>
@@ -38,7 +35,7 @@
#include <errno.h>
#include <string.h>
#include <stdio.h>
-#if defined(UNIX) || defined(unix)
+#ifdef UNIX
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
@@ -416,9 +413,7 @@ static void *netrec_new(t_symbol *compatflag,
x->x_nconnections = 0;
x->x_udp = udp;
for(i = 0; i < MAX_CONNECT; i++)x->x_fd[i] = -1;
-#ifndef MAXLIB
- post(version);
-#endif
+
return (x);
}
@@ -433,9 +428,22 @@ static void netrec_free(t_netrec *x)
binbuf_free(inbinbuf);
}
+#ifndef MAXLIB
void netrec_setup(void)
{
netrec_class = class_new(gensym("netrec"),(t_newmethod)netrec_new, (t_method)netrec_free,
sizeof(t_netrec), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFSYM, 0);
class_addmethod(netrec_class, (t_method)netrec_print, gensym("print"), 0);
+ class_sethelpsymbol(netrec_class, gensym("help-netrec.pd"));
+ post(version);
+}
+#else
+void maxlib_netrec_setup(void)
+{
+ netrec_class = class_new(gensym("maxlib_netrec"),(t_newmethod)netrec_new, (t_method)netrec_free,
+ sizeof(t_netrec), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFSYM, 0);
+ class_addcreator((t_newmethod)netrec_new, gensym("netrec"), A_DEFFLOAT, A_DEFFLOAT, A_DEFSYM, 0);
+ class_addmethod(netrec_class, (t_method)netrec_print, gensym("print"), 0);
+ class_sethelpsymbol(netrec_class, gensym("maxlib/help-netrec.pd"));
}
+#endif \ No newline at end of file
diff --git a/src/netserver.c b/src/netserver.c
index 71447b4..c8e22f6 100644
--- a/src/netserver.c
+++ b/src/netserver.c
@@ -23,14 +23,11 @@
/* */
/* ---------------------------------------------------------------------------- */
-#include <m_pd.h>
-#if defined(PD_VERSION) && (PD_MAJOR_VERSION >= 0 && PD_MINOR_VERSION > 36)
-#include <m_imp.h>
-#include <s_stuff.h>
-#else
-#include <m_imp.h>
+#ifndef PD_0_36
+#include "m_pd.h"
+#include "s_stuff.h"
#endif
-
+#include "m_imp.h"
#include <sys/types.h>
#include <stdarg.h>
@@ -40,7 +37,7 @@
#include <string.h>
#include <stdio.h>
#include <pthread.h>
-#if defined(UNIX) || defined(unix)
+#ifdef UNIX
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
@@ -541,9 +538,7 @@ static void *netserver_new(t_floatarg fportno)
x->x_connectsocket = sockfd;
x->x_nconnections = 0;
for(i = 0; i < MAX_CONNECT; i++)x->x_fd[i] = -1;
-#ifndef MAXLIB
- post(version);
-#endif
+
return (x);
}
@@ -563,6 +558,7 @@ static void netserver_free(t_netserver *x)
binbuf_free(inbinbuf);
}
+#ifndef MAXLIB
void netserver_setup(void)
{
netserver_class = class_new(gensym("netserver"),(t_newmethod)netserver_new, (t_method)netserver_free,
@@ -571,4 +567,19 @@ void netserver_setup(void)
class_addmethod(netserver_class, (t_method)netserver_send, gensym("send"), A_GIMME, 0);
class_addmethod(netserver_class, (t_method)netserver_client_send, gensym("client"), A_GIMME, 0);
class_addmethod(netserver_class, (t_method)netserver_broadcast, gensym("broadcast"), A_GIMME, 0);
+ class_sethelpsymbol(netserver_class, gensym("help-netserver.pd"));
+ post(version);
+}
+#else
+void maxlib_netserver_setup(void)
+{
+ netserver_class = class_new(gensym("maxlib_netserver"),(t_newmethod)netserver_new, (t_method)netserver_free,
+ sizeof(t_netserver), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)netserver_new, gensym("netserver"), A_DEFFLOAT, 0);
+ class_addmethod(netserver_class, (t_method)netserver_print, gensym("print"), 0);
+ class_addmethod(netserver_class, (t_method)netserver_send, gensym("send"), A_GIMME, 0);
+ class_addmethod(netserver_class, (t_method)netserver_client_send, gensym("client"), A_GIMME, 0);
+ class_addmethod(netserver_class, (t_method)netserver_broadcast, gensym("broadcast"), A_GIMME, 0);
+ class_sethelpsymbol(netserver_class, gensym("maxlib/help-netserver.pd"));
}
+#endif \ No newline at end of file
diff --git a/src/nroute.c b/src/nroute.c
index 5836ed7..c8c94c5 100644
--- a/src/nroute.c
+++ b/src/nroute.c
@@ -124,10 +124,6 @@ static void *nroute_new(t_symbol *s, int argc, t_atom *argv)
t_nroute *x = (t_nroute *)pd_new(nroute_class);
t_proxy *inlet = (t_proxy *)pd_new(proxy_class); /* for the proxy inlet */
-#ifndef MAXLIB
- post(version);
-#endif
-
inlet->x = x; /* make x visible to the proxy inlets */
x->pos = 1;
@@ -150,14 +146,23 @@ static void *nroute_new(t_symbol *s, int argc, t_atom *argv)
x->out2 = outlet_new(&x->x_obj, gensym("list"));
return (x);
}
-
+
+#ifndef MAXLIB
void nroute_setup(void)
{
/* the object's class: */
nroute_class = class_new(gensym("nroute"), (t_newmethod)nroute_new,
0, sizeof(t_nroute), 0, A_GIMME, 0);
+#else
+void maxlib_nroute_setup(void)
+{
+ /* the object's class: */
+ nroute_class = class_new(gensym("maxlib_nroute"), (t_newmethod)nroute_new,
+ 0, sizeof(t_nroute), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)nroute_new, gensym("nroute"), A_GIMME, 0);
+#endif
/* a class for the proxy inlet: */
- proxy_class = class_new(gensym("proxy"), NULL, NULL, sizeof(t_proxy),
+ proxy_class = class_new(gensym("maxlib_nroute_proxy"), NULL, NULL, sizeof(t_proxy),
CLASS_PD|CLASS_NOINLET, A_NULL);
class_addmethod(nroute_class, (t_method)nroute_setpos, gensym("right"), A_FLOAT, 0);
@@ -166,6 +171,9 @@ void nroute_setup(void)
class_addanything(nroute_class, nroute_any);
class_addanything(proxy_class, nroute_setmatch);
#ifndef MAXLIB
+ class_sethelpsymbol(nroute_class, gensym("help-nroute.pd"));
+ post(version);
#else
+ class_sethelpsymbol(nroute_class, gensym("maxlib/help-nroute.pd"));
#endif
-}
+} \ No newline at end of file
diff --git a/src/pitch.c b/src/pitch.c
index bd95e1e..95fac90 100644
--- a/src/pitch.c
+++ b/src/pitch.c
@@ -90,16 +90,25 @@ static void *pitch_new(t_floatarg f)
x->x_lastpitch = f;
-#ifndef MAXLIB
- post(version);
-#endif
return (void *)x;
}
+#ifndef MAXLIB
void pitch_setup(void)
{
pitch_class = class_new(gensym("pitch"), (t_newmethod)pitch_new,
0, sizeof(t_pitch), 0, A_DEFFLOAT, 0);
class_addfloat(pitch_class, pitch_float);
+ class_sethelpsymbol(pitch_class, gensym("help-pitch.pd"));
+ post(version);
}
-
+#else
+void maxlib_pitch_setup(void)
+{
+ pitch_class = class_new(gensym("maxlib_pitch"), (t_newmethod)pitch_new,
+ 0, sizeof(t_pitch), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)pitch_new, gensym("pitch"), A_DEFFLOAT, 0);
+ class_addfloat(pitch_class, pitch_float);
+ class_sethelpsymbol(pitch_class, gensym("maxlib/help-pitch.pd"));
+}
+#endif \ No newline at end of file
diff --git a/src/plus.c b/src/plus.c
index 3fdf93b..b34ffbf 100644
--- a/src/plus.c
+++ b/src/plus.c
@@ -82,12 +82,10 @@ static void *plus_new(t_symbol *s, t_int argc, t_atom* argv)
}
x->x_numvalues = i;
-#ifndef MAXLIB
- post(version);
-#endif
return (void *)x;
}
+#ifndef MAXLIB
void plus_setup(void)
{
plus_class = class_new(gensym("plus"), (t_newmethod)plus_new,
@@ -95,5 +93,18 @@ void plus_setup(void)
class_addfloat(plus_class, plus_float);
class_addmethod(plus_class, (t_method)plus_ft1, gensym("ft1"), A_FLOAT, 0);
class_addbang(plus_class, (t_method)plus_bang);
+ class_sethelpsymbol(plus_class, gensym("help-plus.pd"));
+ post(version);
}
-
+#else
+void maxlib_plus_setup(void)
+{
+ plus_class = class_new(gensym("maxlib_plus"), (t_newmethod)plus_new,
+ 0, sizeof(t_plus), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)plus_new, gensym("plus"), A_GIMME, 0);
+ class_addfloat(plus_class, plus_float);
+ class_addmethod(plus_class, (t_method)plus_ft1, gensym("ft1"), A_FLOAT, 0);
+ class_addbang(plus_class, (t_method)plus_bang);
+ class_sethelpsymbol(plus_class, gensym("maxlib/help-plus.pd"));
+}
+#endif \ No newline at end of file
diff --git a/src/poisson.c b/src/poisson.c
index ce4e7bc..d7164ef 100644
--- a/src/poisson.c
+++ b/src/poisson.c
@@ -70,12 +70,22 @@ static void rand_poisson_bang(t_rand_poisson *x)
outlet_float(x->x_obj.ob_outlet, n);
}
+#ifndef MAXLIB
void poisson_setup(void)
{
rand_poisson_class = class_new(gensym("poisson"), (t_newmethod)rand_poisson_new, 0,
sizeof(t_rand_poisson), 0, A_DEFFLOAT, 0);
class_addbang(rand_poisson_class, rand_poisson_bang);
-#ifndef MAXLIB
+ class_sethelpsymbol(rand_poisson_class, gensym("help-poisson.pd"));
post(version);
-#endif
}
+#else
+void maxlib_poisson_setup(void)
+{
+ rand_poisson_class = class_new(gensym("maxlib_poisson"), (t_newmethod)rand_poisson_new, 0,
+ sizeof(t_rand_poisson), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)rand_poisson_new, gensym("poisson"), A_DEFFLOAT, 0);
+ class_addbang(rand_poisson_class, rand_poisson_bang);
+ class_sethelpsymbol(rand_poisson_class, gensym("maxlib/help-poisson.pd"));
+}
+#endif \ No newline at end of file
diff --git a/src/pong.c b/src/pong.c
index 2ff3109..c2deb50 100644
--- a/src/pong.c
+++ b/src/pong.c
@@ -1,6 +1,6 @@
/* --------------------------- pong ------------------------------------------ */
/* */
-/* Route input according to Nth element. */
+/* A virtual bouncing ball. */
/* Written by Olaf Matthes <olaf.matthes@gmx.de> */
/* Based on pong (for Max) version 1.5 written by Richard Dudas. */
/* Get source at http://www.akustische-kunst.org/puredata/maxlib/ */
@@ -253,10 +253,6 @@ static void *pong_new(t_floatarg n)
{
t_pong *x = (t_pong *)pd_new(pong_class);
-#ifndef MAXLIB
- post(version);
-#endif
-
x->p_klok = clock_new(x, (t_method)pong_tick);
inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("dist")); // distance
@@ -299,11 +295,19 @@ static void *pong_new(t_floatarg n)
return (x);
}
-
+
+#ifndef MAXLIB
void pong_setup(void)
{
pong_class = class_new(gensym("pong"), (t_newmethod)pong_new,
0, sizeof(t_pong), 0, A_DEFFLOAT, 0);
+#else
+void maxlib_pong_setup(void)
+{
+ pong_class = class_new(gensym("maxlib_pong"), (t_newmethod)pong_new,
+ 0, sizeof(t_pong), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)pong_new, gensym("pong"), A_DEFFLOAT, 0);
+#endif
/* method handlers for inlets */
class_addmethod(pong_class, (t_method)pong_initdist, gensym("dist"), A_FLOAT, 0);
class_addmethod(pong_class, (t_method)pong_initvel, gensym("velo"), A_FLOAT, 0);
@@ -320,6 +324,9 @@ void pong_setup(void)
class_addfloat(pong_class, pong_onoff);
class_addbang(pong_class, pong_bang);
#ifndef MAXLIB
+ class_sethelpsymbol(pong_class, gensym("help-pong.pd"));
+ post(version);
#else
+ class_sethelpsymbol(pong_class, gensym("maxlib/help-pong.pd"));
#endif
-}
+} \ No newline at end of file
diff --git a/src/pulse.c b/src/pulse.c
index fc5ca96..afa133c 100644
--- a/src/pulse.c
+++ b/src/pulse.c
@@ -1,13 +1,35 @@
+/* --------------------------- pong ------------------------------------------ */
+/* */
+/* A more accurate replacement for the tempo object. */
+/* Written by Olaf Matthes <olaf.matthes@gmx.de> */
+/* Based on pulse for Max written by James McCartney. */
+/* Get source at http://www.akustische-kunst.org/puredata/maxlib/ */
+/* */
+/* This program is free software; you can redistribute it and/or */
+/* modify it under the terms of the GNU General Public License */
+/* as published by the Free Software Foundation; either version 2 */
+/* of the License, or (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program; if not, write to the Free Software */
+/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+/* */
+/* Based on PureData by Miller Puckette and others. */
+/* */
+/* ---------------------------------------------------------------------------- */
+
/* pulse.c ---- a more accurate replacement for the tempo object */
/* updated for CW 68K / PPC summer 96 -RD */
/* written for Max by James McCartney */
-/* ported to Pd by Olaf Matthes <olaf.matthes@gmx.de> */
#include "m_pd.h"
#include <stdio.h>
-#define MAXSIZE 32
-
static char *version = "pulse v0.1b, written by James McCartney for Max <james@clyde.as.utexas.edu>\n"
" ported to Pd by Olaf Matthes <olaf.matthes@gmx.de>";
@@ -244,12 +266,11 @@ static void *pulse_new(t_floatarg t, t_floatarg n, t_floatarg d, t_floatarg b)
x->p_changenumer = 0;
x->p_changedenom = 0;
x->p_onoff = 0;
-#ifndef MAXLIB
- post(version);
-#endif
+
return (x); /* always return a copy of the created object */
}
+#ifndef MAXLIB
void pulse_setup(void)
{
pulse_class = class_new(gensym("pulse"), (t_newmethod)pulse_new,
@@ -260,5 +281,21 @@ void pulse_setup(void)
class_addmethod(pulse_class, (t_method)pulse_tempo, gensym("tempo"), A_FLOAT, 0);
class_addfloat(pulse_class, pulse_onoff);
class_addbang(pulse_class, pulse_bang);
+ class_sethelpsymbol(pulse_class, gensym("help-pulse.pd"));
+ post(version);
}
-
+#else
+void maxlib_pulse_setup(void)
+{
+ pulse_class = class_new(gensym("maxlib_pulse"), (t_newmethod)pulse_new,
+ (t_method)pulse_free, sizeof(Pulse), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)pulse_new, gensym("pulse"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(pulse_class, (t_method)pulse_beat, gensym("beat"), A_FLOAT, 0);
+ class_addmethod(pulse_class, (t_method)pulse_denom, gensym("denom"), A_FLOAT, 0);
+ class_addmethod(pulse_class, (t_method)pulse_numer, gensym("numer"), A_FLOAT, 0);
+ class_addmethod(pulse_class, (t_method)pulse_tempo, gensym("tempo"), A_FLOAT, 0);
+ class_addfloat(pulse_class, pulse_onoff);
+ class_addbang(pulse_class, pulse_bang);
+ class_sethelpsymbol(pulse_class, gensym("maxlib/help-pulse.pd"));
+}
+#endif \ No newline at end of file
diff --git a/src/remote.c b/src/remote.c
index 85a38b6..d4c5771 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -28,7 +28,7 @@
#include <stdio.h>
#define MAX_REC 64 /* maximum number of receive objects */
-#define MAX_ARG 32 /* maximum number of arguments to pass on */
+#define MAX_ARG 64 /* maximum number of arguments to pass on */
static char *version = "remote v0.2, written by Olaf Matthes <olaf.matthes@gmx.de>";
@@ -84,15 +84,25 @@ static void *remote_new(t_symbol *s)
if(x->x_prefix) x->x_prepend = 1;
else x->x_prepend = 0;
-#ifndef MAXLIB
- post(version);
-#endif
return (x);
}
+#ifndef MAXLIB
void remote_setup(void)
{
remote_class = class_new(gensym("remote"), (t_newmethod)remote_new, 0,
sizeof(t_remote), 0, A_DEFSYM, 0);
class_addanything(remote_class, remote_anything);
+ class_sethelpsymbol(remote_class, gensym("help-remote.pd"));
+ post(version);
+}
+#else
+void maxlib_remote_setup(void)
+{
+ remote_class = class_new(gensym("maxlib_remote"), (t_newmethod)remote_new, 0,
+ sizeof(t_remote), 0, A_DEFSYM, 0);
+ class_addcreator((t_newmethod)remote_new, gensym("remote"), A_DEFSYM, 0);
+ class_addanything(remote_class, remote_anything);
+ class_sethelpsymbol(remote_class, gensym("maxlib/help-remote.pd"));
}
+#endif \ No newline at end of file
diff --git a/src/rewrap.c b/src/rewrap.c
index f15b8dc..b8d3242 100644
--- a/src/rewrap.c
+++ b/src/rewrap.c
@@ -127,12 +127,10 @@ static void *rewrap_new(t_floatarg fmin, t_floatarg fmax)
x->x_min = fmin;
rewrap_b(x, fmax);
-#ifndef MAXLIB
- post(version);
-#endif
return (void *)x;
}
+#ifndef MAXLIB
void rewrap_setup(void)
{
rewrap_class = class_new(gensym("rewrap"), (t_newmethod)rewrap_new,
@@ -140,8 +138,18 @@ void rewrap_setup(void)
class_addfloat(rewrap_class, rewrap_float);
class_addmethod(rewrap_class, (t_method)rewrap_a, gensym("a"), A_FLOAT, 0);
class_addmethod(rewrap_class, (t_method)rewrap_b, gensym("b"), A_FLOAT, 0);
-#ifndef MAXLIB
+ class_sethelpsymbol(rewrap_class, gensym("help-rewrap.pd"));
+ post(version);
+}
#else
-#endif
+void maxlib_rewrap_setup(void)
+{
+ rewrap_class = class_new(gensym("maxlib_rewrap"), (t_newmethod)rewrap_new,
+ 0, sizeof(t_rewrap), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)rewrap_new, gensym("rewrap"), A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addfloat(rewrap_class, rewrap_float);
+ class_addmethod(rewrap_class, (t_method)rewrap_a, gensym("a"), A_FLOAT, 0);
+ class_addmethod(rewrap_class, (t_method)rewrap_b, gensym("b"), A_FLOAT, 0);
+ class_sethelpsymbol(rewrap_class, gensym("maxlib/help-rewrap.pd"));
}
-
+#endif \ No newline at end of file
diff --git a/src/rhythm.c b/src/rhythm.c
index cd9d6e2..7796a61 100644
--- a/src/rhythm.c
+++ b/src/rhythm.c
@@ -297,9 +297,6 @@ static void *rhythm_new(t_floatarg f)
rhythm_reset(x);
-#ifndef MAXLIB
- post(version);
-#endif
if(f == 1)
{
x->x_model = 1; /* Toiviainen model */
@@ -314,15 +311,30 @@ static void *rhythm_new(t_floatarg f)
return (void *)x;
}
+#ifndef MAXLIB
void rhythm_setup(void)
{
rhythm_class = class_new(gensym("rhythm"), (t_newmethod)rhythm_new,
(t_method)rhythm_free, sizeof(t_rhythm), 0, A_DEFFLOAT, 0);
- class_addcreator((t_newmethod)rhythm_new, gensym("max.rhythm"), A_DEFFLOAT, 0);
class_addfloat(rhythm_class, rhythm_float);
class_addmethod(rhythm_class, (t_method)rhythm_ft1, gensym("ft1"), A_FLOAT, 0);
class_addmethod(rhythm_class, (t_method)rhythm_model, gensym("model"), A_FLOAT, 0);
class_addmethod(rhythm_class, (t_method)rhythm_reset, gensym("reset"), 0);
class_addmethod(rhythm_class, (t_method)rhythm_print, gensym("print"), 0);
+ class_sethelpsymbol(rhythm_class, gensym("help-rhythm.pd"));
+ post(version);
}
-
+#else
+void maxlib_rhythm_setup(void)
+{
+ rhythm_class = class_new(gensym("maxlib_rhythm"), (t_newmethod)rhythm_new,
+ (t_method)rhythm_free, sizeof(t_rhythm), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)rhythm_new, gensym("rhythm"), A_DEFFLOAT, 0);
+ class_addfloat(rhythm_class, rhythm_float);
+ class_addmethod(rhythm_class, (t_method)rhythm_ft1, gensym("ft1"), A_FLOAT, 0);
+ class_addmethod(rhythm_class, (t_method)rhythm_model, gensym("model"), A_FLOAT, 0);
+ class_addmethod(rhythm_class, (t_method)rhythm_reset, gensym("reset"), 0);
+ class_addmethod(rhythm_class, (t_method)rhythm_print, gensym("print"), 0);
+ class_sethelpsymbol(rhythm_class, gensym("maxlib/help-rhythm.pd"));
+}
+#endif
diff --git a/src/scale.c b/src/scale.c
index 4fbfaec..4d72485 100644
--- a/src/scale.c
+++ b/src/scale.c
@@ -112,20 +112,27 @@ static void *scale_new(t_floatarg fil, t_floatarg fih, t_floatarg fol, t_floatar
x->x_logcoeff = flc;
x->x_f = 0;
-#ifndef MAXLIB
- post(version);
-#endif
return (void *)x;
}
+#ifndef MAXLIB
void scale_setup(void)
{
scale_class = class_new(gensym("scale"), (t_newmethod)scale_new,
0, sizeof(t_scale), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
class_addfloat(scale_class, scale_float);
class_addbang(scale_class, scale_bang);
-#ifndef MAXLIB
+ class_sethelpsymbol(scale_class, gensym("help-scale.pd"));
+ post(version);
#else
+void maxlib_scale_setup(void)
+{
+ scale_class = class_new(gensym("maxlib_scale"), (t_newmethod)scale_new,
+ 0, sizeof(t_scale), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)scale_new, gensym("scale"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addfloat(scale_class, scale_float);
+ class_addbang(scale_class, scale_bang);
+ class_sethelpsymbol(scale_class, gensym("maxlib/help-scale.pd"));
#endif
}
diff --git a/src/score.c b/src/score.c
index 80722ac..0f96229 100644
--- a/src/score.c
+++ b/src/score.c
@@ -255,9 +255,7 @@ static void *score_new(t_symbol *s, t_floatarg fskipindex, t_floatarg fskiptime)
x->x_inreset = inlet_new(&x->x_ob, &x->x_ob.ob_pd, gensym("bang"), gensym("reset"));
x->x_outindex = outlet_new(&x->x_ob, gensym("float"));
x->x_outerror = outlet_new(&x->x_ob, gensym("float"));
-#ifndef MAXLIB
- post(version);
-#endif
+
x->x_sym = s; /* get name of array */
score_set(x,x->x_sym); /* set array */
if(!fskipindex)fskipindex = 2;
@@ -276,6 +274,7 @@ static void *score_new(t_symbol *s, t_floatarg fskipindex, t_floatarg fskiptime)
return (void *)x;
}
+#ifndef MAXLIB
void score_setup(void)
{
score_class = class_new(gensym("score"), (t_newmethod)score_new,
@@ -288,6 +287,23 @@ void score_setup(void)
class_addmethod(score_class, (t_method)score_reset, gensym("reset"), A_GIMME, 0);
class_addmethod(score_class, (t_method)score_set, gensym("set"), A_SYMBOL, 0);
class_addfloat(score_class, score_float);
-
+ class_sethelpsymbol(score_class, gensym("help-score.pd"));
+ post(version);
}
-
+#else
+void maxlib_score_setup(void)
+{
+ score_class = class_new(gensym("maxlib_score"), (t_newmethod)score_new,
+ (t_method)score_free, sizeof(t_score), 0, A_SYMBOL, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)score_new, gensym("score"), A_SYMBOL, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(score_class, (t_method)score_reset, gensym("reset"), 0);
+ class_addmethod(score_class, (t_method)score_resume, gensym("resume"), 0);
+ class_addmethod(score_class, (t_method)score_start, gensym("start"), A_GIMME, 0);
+ class_addmethod(score_class, (t_method)score_stop, gensym("stop"), 0);
+ class_addmethod(score_class, (t_method)score_ft1, gensym("ft1"), A_FLOAT, 0);
+ class_addmethod(score_class, (t_method)score_reset, gensym("reset"), A_GIMME, 0);
+ class_addmethod(score_class, (t_method)score_set, gensym("set"), A_SYMBOL, 0);
+ class_addfloat(score_class, score_float);
+ class_sethelpsymbol(score_class, gensym("maxlib/help-score.pd"));
+}
+#endif \ No newline at end of file
diff --git a/src/speedlim.c b/src/speedlim.c
index 3055166..c4a4385 100644
--- a/src/speedlim.c
+++ b/src/speedlim.c
@@ -27,16 +27,16 @@
/* Based on PureData by Miller Puckette and others. */
/* */
/* ---------------------------------------------------------------------------- */
+
/* this is the original copyright notice: */
+
/* Copyright (c) 1997-2002 Miller Puckette and others.
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-/* LATER 'clock' method */
#include <string.h>
#include "m_pd.h"
-// #include "hammer.h"
#define SPEEDLIM_INISIZE 32 /* LATER rethink */
#define SPEEDLIM_MAXSIZE 256 /* not used */
@@ -209,10 +209,18 @@ static void *speedlim_new(t_floatarg f)
return (x);
}
+#ifndef MAXLIB
void speedlim_setup(void)
{
speedlim_class = class_new(gensym("speedlim"), (t_newmethod)speedlim_new,
(t_method)speedlim_free, sizeof(t_speedlim), 0, A_DEFFLOAT, 0);
+#else
+void maxlib_speedlim_setup(void)
+{
+ speedlim_class = class_new(gensym("maxlib_speedlim"), (t_newmethod)speedlim_new,
+ (t_method)speedlim_free, sizeof(t_speedlim), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)speedlim_new, gensym("speedlim"), A_DEFFLOAT, 0);
+#endif
class_addbang(speedlim_class, speedlim_bang);
class_addfloat(speedlim_class, speedlim_float);
class_addsymbol(speedlim_class, speedlim_symbol);
@@ -220,6 +228,8 @@ void speedlim_setup(void)
class_addanything(speedlim_class, speedlim_anything);
class_addmethod(speedlim_class, (t_method)speedlim_ft1, gensym("ft1"), A_FLOAT, 0);
#ifndef MAXLIB
+ class_sethelpsymbol(speedlim_class, gensym("help-speedlim.pd"));
#else
+ class_sethelpsymbol(speedlim_class, gensym("maxlib/help-speedlim.pd"));
#endif
}
diff --git a/src/split.c b/src/split.c
index 3a0d822..93f3a3d 100644
--- a/src/split.c
+++ b/src/split.c
@@ -71,19 +71,25 @@ static void *split_new(t_floatarg fmin, t_floatarg fmax)
x->x_min = fmin;
x->x_max = fmax;
-#ifndef MAXLIB
- post(version);
-#endif
return (void *)x;
}
+#ifndef MAXLIB
void split_setup(void)
{
split_class = class_new(gensym("split"), (t_newmethod)split_new,
0, sizeof(t_split), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
class_addfloat(split_class, split_float);
-#ifndef MAXLIB
+ class_sethelpsymbol(split_class, gensym("help-split.pd"));
+ post(version);
+}
#else
-#endif
+void maxlib_split_setup(void)
+{
+ split_class = class_new(gensym("maxlib_split"), (t_newmethod)split_new,
+ 0, sizeof(t_split), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)split_new, gensym("split"), A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addfloat(split_class, split_float);
+ class_sethelpsymbol(split_class, gensym("maxlib/help-split.pd"));
}
-
+#endif
diff --git a/src/step.c b/src/step.c
index 8886ecb..819a157 100644
--- a/src/step.c
+++ b/src/step.c
@@ -149,12 +149,10 @@ static void *step_new(t_floatarg f, t_floatarg step, t_floatarg grain)
outlet_new(&x->x_obj, gensym("float"));
inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft2"));
-#ifndef MAXLIB
- post(version);
-#endif
return (x);
}
+#ifndef MAXLIB
void step_setup(void)
{
step_class = class_new(gensym("step"), (t_newmethod)step_new,
@@ -163,4 +161,19 @@ void step_setup(void)
class_addmethod(step_class, (t_method)step_ft2, gensym("ft2"), A_FLOAT, 0);
class_addmethod(step_class, (t_method)step_stop, gensym("stop"), 0);
class_addfloat(step_class, (t_method)step_float);
+ class_sethelpsymbol(step_class, gensym("help-step.pd"));
+ post(version);
+}
+#else
+void maxlib_step_setup(void)
+{
+ step_class = class_new(gensym("maxlib_step"), (t_newmethod)step_new,
+ (t_method)step_free, sizeof(t_step), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)step_new, gensym("step"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(step_class, (t_method)step_ft1, gensym("ft1"), A_FLOAT, 0);
+ class_addmethod(step_class, (t_method)step_ft2, gensym("ft2"), A_FLOAT, 0);
+ class_addmethod(step_class, (t_method)step_stop, gensym("stop"), 0);
+ class_addfloat(step_class, (t_method)step_float);
+ class_sethelpsymbol(step_class, gensym("maxlib/help-step.pd"));
}
+#endif \ No newline at end of file
diff --git a/src/subst.c b/src/subst.c
index 0a4acf4..f473d53 100644
--- a/src/subst.c
+++ b/src/subst.c
@@ -366,9 +366,6 @@ static void *subst_new(t_symbol *s, int argc, t_atom *argv)
long i;
t_symbol *sym;
t_subst *x = (t_subst *)pd_new(subst_class);
-#ifndef MAXLIB
- post(version);
-#endif
// read in order...
x->x_order = 3;
if(argc == 1)
@@ -391,8 +388,10 @@ static void *subst_new(t_symbol *s, int argc, t_atom *argv)
static void subst_free(t_subst *x)
{
+ /* nothing to do */
}
+#ifndef MAXLIB
void subst_setup(void)
{
subst_class = class_new(gensym("subst"), (t_newmethod)subst_new,
@@ -404,4 +403,22 @@ void subst_setup(void)
class_addmethod(subst_class, (t_method)subst_display, gensym("display"), 0);
class_addlist(subst_class, subst_list);
class_addbang(subst_class, subst_bang);
+ class_sethelpsymbol(subst_class, gensym("help-subst.pd"));
+ post(version);
+}
+#else
+void maxlib_subst_setup(void)
+{
+ subst_class = class_new(gensym("maxlib_subst"), (t_newmethod)subst_new,
+ (t_method)subst_free, sizeof(t_subst), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)subst_new, gensym("subst"), A_GIMME, 0);
+ class_addmethod(subst_class, (t_method)subst_set_order, gensym("order"), A_FLOAT, 0);
+ class_addmethod(subst_class, (t_method)subst_intv, gensym("interval"), A_FLOAT, 0);
+ class_addmethod(subst_class, (t_method)subst_set, gensym("set"), A_SYMBOL, 0);
+ class_addmethod(subst_class, (t_method)subst_load, gensym("load"), A_SYMBOL, 0);
+ class_addmethod(subst_class, (t_method)subst_display, gensym("display"), 0);
+ class_addlist(subst_class, subst_list);
+ class_addbang(subst_class, subst_bang);
+ class_sethelpsymbol(subst_class, gensym("maxlib/help-subst.pd"));
}
+#endif \ No newline at end of file
diff --git a/src/sync.c b/src/sync.c
new file mode 100644
index 0000000..21e05f9
--- /dev/null
+++ b/src/sync.c
@@ -0,0 +1,294 @@
+/* ------------------------- sync ------------------------------------------- */
+/* */
+/* syncronises outputs depending on inputs. */
+/* Written by Olaf Matthes <olaf.matthes@gmx.de> */
+/* Based on 'sync' from jMax. */
+/* Get source at http://www.akustische-kunst.org/puredata/maxlib/ */
+/* */
+/* This program is free software; you can redistribute it and/or */
+/* modify it under the terms of the GNU General Public License */
+/* as published by the Free Software Foundation; either version 2 */
+/* of the License, or (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program; if not, write to the Free Software */
+/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+/* */
+/* Based on PureData by Miller Puckette and others. */
+/* */
+/* ---------------------------------------------------------------------------- */
+
+#include "m_pd.h"
+#include <stdio.h>
+#include <math.h>
+
+#define SYNC_MAX_SIZE (sizeof(unsigned int) * 8)
+
+static char *version = "sync v0.1, written by Olaf Matthes <olaf.matthes@gmx.de>\n"
+ " based on sync from jMax";
+
+typedef struct sync
+{
+ t_object x_ob;
+ t_float x_min; /* low border of input range */
+ t_float x_max; /* high border of input range */
+ t_outlet *x_outlet[SYNC_MAX_SIZE];
+
+ t_int x_n;
+ unsigned int x_trigger; /* control bits: trigger on input at given inlets */
+ unsigned int x_require; /* control bits: require input on given inlets */
+ unsigned int x_reset; /* control bits: reset memory of given inputs after on each input */
+ unsigned int x_wait; /* status bits: wait for input at given inlet before output */
+ t_atom x_a[SYNC_MAX_SIZE];
+ enum {mode_all, mode_select} mode;
+} t_sync;
+
+typedef struct proxy
+{
+ t_object obj;
+ t_int index; /* number of proxy inlet(s) */
+ t_sync *x; /* we'll put the other struct in here */
+} t_proxy;
+
+static void sync_output(t_sync *x)
+{
+ int i;
+
+ for(i=x->x_n-1; i>=0; i--)
+ if(x->x_a[i].a_type != A_SEMI)
+ outlet_list(x->x_outlet[i], NULL, 1, x->x_a + i);
+}
+
+static void sync_input(t_proxy *p, t_symbol *s, int ac, t_atom *at)
+{
+ t_sync *x = (t_sync *)(p->x);
+ int winlet = p->index;
+
+ if(ac)
+ {
+ unsigned int bit = 1 << winlet;
+
+ x->x_a[winlet] = at[0];
+
+ x->x_wait &= ~bit;
+
+ if(!x->x_wait && (x->x_trigger & bit))
+ {
+ sync_output(x);
+ x->x_wait |= x->x_reset & x->x_require;
+ }
+ }
+}
+
+static void sync_float_input(t_proxy *p, t_floatarg f)
+{
+ t_sync *x = (t_sync *)(p->x);
+ int winlet = p->index;
+
+ {
+ unsigned int bit = 1 << winlet;
+
+ SETFLOAT(x->x_a + winlet, f);
+
+ x->x_wait &= ~bit;
+
+ if(!x->x_wait && (x->x_trigger & bit))
+ {
+ sync_output(x);
+ x->x_wait |= x->x_reset & x->x_require;
+ }
+ }
+}
+
+static void sync_set_bits(unsigned int *bits, int n, t_atom *at, int sign)
+{
+ if(at->a_type == A_SYMBOL)
+ {
+ t_symbol *mode = atom_getsymbol(at);
+
+ if(mode == gensym("all"))
+ *bits = (1 << n) - 1;
+ else if(mode == gensym("none"))
+ *bits = 0;
+ }
+ else if(at->a_type == A_FLOAT)
+ {
+ int in = (int)atom_getfloat(at) * sign;
+
+ if(in >= 0 && in < n)
+ *bits = 1 << in;
+ }
+ else if(at->a_type == A_GIMME)
+ {
+ int size = n;
+ int i;
+
+ *bits = 0;
+
+ for(i=0; i<size; i++)
+ {
+ if(at[i].a_type == A_FLOAT)
+ {
+ int in = atom_getfloatarg(i, size, at) * sign;
+
+ if(in >= 0 && in < n)
+ *bits |= 1 << in;
+ }
+ }
+ }
+}
+
+static void sync_set_trigger(t_sync *x, t_symbol *s, int ac, t_atom *at)
+{
+ sync_set_bits(&x->x_trigger, x->x_n, at, 1);
+}
+
+static void sync_set_require(t_sync *x, t_symbol *s, int ac, t_atom *at)
+{
+ unsigned int once = 0;
+
+ sync_set_bits(&x->x_require, x->x_n, at, 1);
+ sync_set_bits(&once, x->x_n, at, -1);
+
+ x->x_reset = ~once;
+ x->x_wait = x->x_require | once;
+}
+
+static void sync_set_mode(t_sync *x, t_symbol *mode)
+{
+ if(mode == gensym("any"))
+ {
+ x->x_trigger = (1 << x->x_n) - 1;
+ x->x_reset = 0;
+ x->x_require = 0;
+ }
+ else if(mode == gensym("all"))
+ x->x_trigger = x->x_require = x->x_reset = x->x_wait = (1 << x->x_n) - 1;
+ else if(mode == gensym("left"))
+ {
+ x->x_trigger = 1;
+ x->x_reset = 0;
+ x->x_require = 0;
+ }
+ else if(mode == gensym("right"))
+ {
+ x->x_trigger = (1 << (x->x_n - 1));
+ x->x_reset = 0;
+ x->x_require = 0;
+ }
+
+ x->x_wait = x->x_require;
+}
+
+static void sync_float(t_sync *x, t_floatarg f)
+{
+ unsigned int bit = 1 << 0;
+
+ SETFLOAT(x->x_a, f);
+
+ x->x_wait &= ~bit;
+
+ if(!x->x_wait && (x->x_trigger & bit))
+ {
+ sync_output(x);
+ x->x_wait |= x->x_reset & x->x_require;
+ }
+}
+
+static t_class *sync_class;
+static t_class *proxy_class;
+
+static void *sync_new(t_symbol *s, int ac, t_atom *at)
+{
+ int n = 0;
+ int i;
+ t_sync *x = (t_sync *)pd_new(sync_class);
+ t_proxy *inlet[SYNC_MAX_SIZE];
+
+ /* void state - we fill with SEMI and treat this as 'void' */
+ for(i=0; i<SYNC_MAX_SIZE; i++)
+ SETSEMI(x->x_a + i);
+
+ if(ac == 1)
+ {
+ if(at->a_type == A_FLOAT)
+ {
+ n = atom_getfloat(at);
+
+ if(n < 2)
+ n = 2;
+ else if(n > SYNC_MAX_SIZE)
+ n = SYNC_MAX_SIZE;
+ }
+ else
+ {
+ post("sync: wrong argument");
+ return (0);
+ }
+ }
+ else if(ac > 1)
+ {
+ if(ac > SYNC_MAX_SIZE)
+ ac = SYNC_MAX_SIZE;
+
+ n = ac;
+
+ for(i=0; i<n; i++)
+ x->x_a[i] = at[i];
+ }
+
+ x->x_n = n;
+ x->x_trigger = x->x_require = x->x_reset = x->x_wait = (1 << n) - 1;
+
+ x->x_outlet[0] = outlet_new(&x->x_ob, gensym("list"));
+
+ for(i=1; i<n; i++)
+ {
+ inlet[i] = (t_proxy *)pd_new(proxy_class); /* create the proxy inlet */
+ inlet[i]->x = x; /* make t_sync *x visible to the proxy inlets */
+ inlet[i]->index = i; /* remember it's number */
+ /* it belongs to the object t_sync but the destination is t_proxy */
+ inlet_new(&x->x_ob, &inlet[i]->obj.ob_pd, 0,0);
+
+ x->x_outlet[i] = outlet_new(&x->x_ob, gensym("list"));
+ }
+
+ return (void *)x;
+}
+
+#ifndef MAXLIB
+void sync_setup(void)
+{
+ sync_class = class_new(gensym("sync"), (t_newmethod)sync_new,
+ 0, sizeof(t_sync), 0, A_GIMME, 0);
+#else
+void maxlib_sync_setup(void)
+{
+ sync_class = class_new(gensym("maxlib_sync"), (t_newmethod)sync_new,
+ 0, sizeof(t_sync), 0, A_GIMME, 0);
+#endif
+ /* a class for the proxy inlet: */
+ proxy_class = class_new(gensym("maxlib_sync_proxy"), NULL, NULL, sizeof(t_proxy),
+ CLASS_PD|CLASS_NOINLET, A_NULL);
+
+ class_addfloat(proxy_class, sync_float_input);
+ class_addanything(proxy_class, sync_input);
+
+ class_addfloat(sync_class, sync_float);
+ class_addmethod(sync_class, (t_method)sync_set_trigger, gensym("trigger"), A_GIMME, 0);
+ class_addmethod(sync_class, (t_method)sync_set_require, gensym("require"), A_GIMME, 0);
+ class_addmethod(sync_class, (t_method)sync_set_mode, gensym("mode"), A_SYMBOL, 0);
+#ifndef MAXLIB
+ class_sethelpsymbol(sync_class, gensym("help-sync.pd"));
+ post(version);
+#else
+ class_addcreator((t_newmethod)sync_new, gensym("sync"), A_GIMME, 0);
+ class_sethelpsymbol(sync_class, gensym("maxlib/help-sync.pd"));
+#endif
+}
+
diff --git a/src/temperature.c b/src/temperature.c
index 28a9352..509db76 100644
--- a/src/temperature.c
+++ b/src/temperature.c
@@ -90,12 +90,10 @@ static void *temperature_new(t_floatarg f)
}
x->x_index = 0;
clock_delay(x->x_clock, x->x_time);
-#ifndef MAXLIB
- post(version);
-#endif
return (void *)x;
}
+#ifndef MAXLIB
void temperature_setup(void)
{
temperature_class = class_new(gensym("temperature"), (t_newmethod)temperature_new,
@@ -104,5 +102,19 @@ void temperature_setup(void)
class_addfloat(temperature_class, temperature_float);
class_addmethod(temperature_class, (t_method)temperature_time, gensym("time"), A_FLOAT, 0);
class_addanything(temperature_class, temperature_anything);
+ class_sethelpsymbol(temperature_class, gensym("help-temperature.pd"));
+ post(version);
}
-
+#else
+void maxlib_temperature_setup(void)
+{
+ temperature_class = class_new(gensym("maxlib_temperature"), (t_newmethod)temperature_new,
+ (t_method)temperature_free, sizeof(t_temperature), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)temperature_new, gensym("temperature"), A_DEFFLOAT, 0);
+ class_addmethod(temperature_class, (t_method)temperature_reset, gensym("reset"), 0);
+ class_addfloat(temperature_class, temperature_float);
+ class_addmethod(temperature_class, (t_method)temperature_time, gensym("time"), A_FLOAT, 0);
+ class_addanything(temperature_class, temperature_anything);
+ class_sethelpsymbol(temperature_class, gensym("maxlib/help-temperature.pd"));
+}
+#endif \ No newline at end of file
diff --git a/src/tilt.c b/src/tilt.c
index 048022e..ca67914 100644
--- a/src/tilt.c
+++ b/src/tilt.c
@@ -154,13 +154,11 @@ static void *tilt_new(t_floatarg f, t_floatarg f2)
x->x_hi_limit = x->x_low_limit = x->x_trip_point = 0;
clock_delay(x->x_clock, x->x_wait); /* wait 4 sec and start calculation */
-#ifndef MAXLIB
- post(version);
-#endif
post("tilt: set interval to %g msec", x->x_wait);
return (void *)x;
}
+#ifndef MAXLIB
void tilt_setup(void)
{
tilt_class = class_new(gensym("tilt"), (t_newmethod)tilt_new,
@@ -171,5 +169,21 @@ void tilt_setup(void)
class_addmethod(tilt_class, (t_method)tilt_hi_limit, gensym("hi"), A_FLOAT, 0);
class_addmethod(tilt_class, (t_method)tilt_low_limit, gensym("low"), A_FLOAT, 0);
class_addmethod(tilt_class, (t_method)tilt_trip_point, gensym("trip"), A_FLOAT, 0);
+ class_sethelpsymbol(tilt_class, gensym("help-tilt.pd"));
+ post(version);
}
-
+#else
+void maxlib_tilt_setup(void)
+{
+ tilt_class = class_new(gensym("maxlib_tilt"), (t_newmethod)tilt_new,
+ (t_method)tilt_free, sizeof(t_tilt), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)tilt_new, gensym("tilt"), A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addfloat(tilt_class, tilt_float);
+ class_addmethod(tilt_class, (t_method)tilt_intv, gensym("intv"), A_FLOAT, 0);
+ class_addmethod(tilt_class, (t_method)tilt_tilt, gensym("tilt"), A_FLOAT, 0);
+ class_addmethod(tilt_class, (t_method)tilt_hi_limit, gensym("hi"), A_FLOAT, 0);
+ class_addmethod(tilt_class, (t_method)tilt_low_limit, gensym("low"), A_FLOAT, 0);
+ class_addmethod(tilt_class, (t_method)tilt_trip_point, gensym("trip"), A_FLOAT, 0);
+ class_sethelpsymbol(tilt_class, gensym("maxlib/help-tilt.pd"));
+}
+#endif \ No newline at end of file
diff --git a/src/timebang.c b/src/timebang.c
index e1f9b9c..3a679b1 100644
--- a/src/timebang.c
+++ b/src/timebang.c
@@ -29,7 +29,7 @@
#define MAX_TIMES 256 /* maximum number of times to process */
-static char *version = "timebang v0.1, written by Olaf Matthes <olaf.matthes@gmx.de>";
+static char *version = "timebang v0.2, written by Olaf Matthes <olaf.matthes@gmx.de>";
typedef struct timebang
{
@@ -76,6 +76,27 @@ static void timebang_tick(t_timebang *x)
static void timebang_set(t_timebang *x, t_symbol *s, int ac, t_atom *av)
{
+ int i;
+
+ if(ac == x->x_notimes * 3)
+ {
+ for(i = 0; i < ac; i += 3)
+ {
+ if (av[i].a_type == A_FLOAT) x->x_hour[x->x_notimes] = av[i].a_w.w_float;
+ else { post ("timebang: first argument must be (int) hours"); return; }
+ if (av[i+1].a_type == A_FLOAT) x->x_min[x->x_notimes] = av[i+1].a_w.w_float;
+ else { post ("timebang: second argument must be (int) minutes"); return; }
+ if (av[i+2].a_type == A_FLOAT) x->x_sec[x->x_notimes] = av[i+2].a_w.w_float;
+ else { post ("timebang: third argument must be (int) seconds"); return; }
+ x->x_over[i] = 0;
+ }
+ post("timebang: read in %d times of day:", x->x_notimes);
+ for(i = 0; i < x->x_notimes; i++)
+ {
+ post(" %02d:%02d:%02d", x->x_hour[i], x->x_min[i], x->x_sec[i]);
+ }
+ }
+ else post("timebang: wrong number of parameter");
}
static void timebang_bang(t_timebang *x)
@@ -94,9 +115,6 @@ static void *timebang_new(t_symbol *s, int ac, t_atom *av)
x->x_clock = clock_new(x, (t_method)timebang_tick);
-#ifndef MAXLIB
- post(version);
-#endif
if(ac > MAX_TIMES * 3)
{
post("timebang: too many creation arguments");
@@ -132,14 +150,25 @@ static void timebang_free(t_timebang *x)
clock_free(x->x_clock);
}
+#ifndef MAXLIB
void timebang_setup(void)
{
timebang_class = class_new(gensym("timebang"), (t_newmethod)timebang_new,
(t_method)timebang_free, sizeof(t_timebang), 0, A_GIMME, 0);
+#else
+void maxlib_timebang_setup(void)
+{
+ timebang_class = class_new(gensym("maxlib_timebang"), (t_newmethod)timebang_new,
+ (t_method)timebang_free, sizeof(t_timebang), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)timebang_new, gensym("timebang"), A_GIMME, 0);
+#endif
class_addmethod(timebang_class, (t_method)timebang_set, gensym("set"), A_GIMME, 0);
class_addbang(timebang_class, (t_method)timebang_bang);
#ifndef MAXLIB
+ class_sethelpsymbol(timebang_class, gensym("help-timebang.pd"));
+ post(version);
#else
+ class_sethelpsymbol(timebang_class, gensym("maxlib/help-timebang.pd"));
#endif
}
diff --git a/src/triang.c b/src/triang.c
index 9ecbf65..832bced 100644
--- a/src/triang.c
+++ b/src/triang.c
@@ -58,12 +58,23 @@ static void rand_triang_bang(t_rand_triang *x)
outlet_float(x->x_obj.ob_outlet, 0.5*(u1+u2));
}
+#ifndef MAXLIB
void triang_setup(void)
{
rand_triang_class = class_new(gensym("triang"), (t_newmethod)rand_triang_new, 0,
sizeof(t_rand_triang), 0, A_DEFFLOAT, 0);
+#else
+void maxlib_triang_setup(void)
+{
+ rand_triang_class = class_new(gensym("maxlib_triang"), (t_newmethod)rand_triang_new, 0,
+ sizeof(t_rand_triang), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)rand_triang_new, gensym("triang"), A_DEFFLOAT, 0);
+#endif
class_addbang(rand_triang_class, rand_triang_bang);
#ifndef MAXLIB
+ class_sethelpsymbol(rand_triang_class, gensym("help-triang.pd"));
post(version);
+#else
+ class_sethelpsymbol(rand_triang_class, gensym("maxlib/help-triang.pd"));
#endif
-}
+} \ No newline at end of file
diff --git a/src/unroute.c b/src/unroute.c
index 9a68a61..e6131e4 100644
--- a/src/unroute.c
+++ b/src/unroute.c
@@ -142,19 +142,22 @@ static void *unroute_new(t_symbol *s, int argc, t_atom *argv)
}
x->x_outlet = outlet_new(&x->x_obj, gensym("float"));
-#ifndef MAXLIB
- post(version);
-#endif
return (void *)x;
}
+#ifndef MAXLIB
void unroute_setup(void)
{
unroute_class = class_new(gensym("unroute"), (t_newmethod)unroute_new,
0, sizeof(t_unroute), 0, A_GIMME, 0);
-
+#else
+void maxlib_unroute_setup(void)
+{
+ unroute_class = class_new(gensym("maxlib_unroute"), (t_newmethod)unroute_new,
+ 0, sizeof(t_unroute), 0, A_GIMME, 0);
+#endif
/* a class for the proxy inlet: */
- proxy_class = class_new(gensym("proxy"), NULL, NULL, sizeof(t_proxy),
+ proxy_class = class_new(gensym("maxlib_unroute_proxy"), NULL, NULL, sizeof(t_proxy),
CLASS_PD|CLASS_NOINLET, A_NULL);
class_addanything(proxy_class, unroute_input);
@@ -163,6 +166,10 @@ void unroute_setup(void)
class_addlist(unroute_class, unroute_list);
class_addanything(unroute_class, unroute_any);
#ifndef MAXLIB
+ class_sethelpsymbol(unroute_class, gensym("help-unroute.pd"));
+ post(version);
#else
+ class_addcreator((t_newmethod)unroute_new, gensym("unroute"), A_GIMME, 0);
+ class_sethelpsymbol(unroute_class, gensym("maxlib/help-unroute.pd"));
#endif
-}
+} \ No newline at end of file
diff --git a/src/urn.c b/src/urn.c
index 4a09387..a657d42 100644
--- a/src/urn.c
+++ b/src/urn.c
@@ -127,16 +127,26 @@ notify:
outlet_bang(x->x_notify);
}
+#ifndef MAXLIB
void urn_setup(void)
{
urn_class = class_new(gensym("urn"), (t_newmethod)urn_new, 0,
sizeof(t_urn), 0, A_DEFFLOAT, 0);
+#else
+void maxlib_urn_setup(void)
+{
+ urn_class = class_new(gensym("maxlib_urn"), (t_newmethod)urn_new, 0,
+ sizeof(t_urn), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)urn_new, gensym("urn"), A_DEFFLOAT, 0);
+#endif
class_addbang(urn_class, urn_bang);
class_addmethod(urn_class, (t_method)urn_f, gensym("f"), A_FLOAT, 0);
class_addmethod(urn_class, (t_method)urn_clear, gensym("clear"), 0);
class_addmethod(urn_class, (t_method)urn_seed, gensym("seed"), A_FLOAT, 0);
#ifndef MAXLIB
+ class_sethelpsymbol(urn_class, gensym("help-urn.pd"));
post(version);
#else
+ class_sethelpsymbol(urn_class, gensym("maxlib/help-urn.pd"));
#endif
-}
+} \ No newline at end of file
diff --git a/src/velocity.c b/src/velocity.c
index a01aae5..7a003d0 100644
--- a/src/velocity.c
+++ b/src/velocity.c
@@ -83,19 +83,30 @@ static void *velocity_new(t_floatarg f)
{
t_velocity *x = (t_velocity *)pd_new(velocity_class);
x->x_out = outlet_new(&x->x_ob, gensym("float"));
-#ifndef MAXLIB
- post(version);
-#endif
x->x_lasttime = clock_getlogicaltime();
return (void *)x;
}
+#ifndef MAXLIB
void velocity_setup(void)
{
velocity_class = class_new(gensym("velocity"), (t_newmethod)velocity_new,
(t_method)velocity_free, sizeof(t_velocity), 0, A_DEFFLOAT, 0);
+#else
+void maxlib_velocity_setup(void)
+{
+ velocity_class = class_new(gensym("maxlib_velocity"), (t_newmethod)velocity_new,
+ (t_method)velocity_free, sizeof(t_velocity), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)velocity_new, gensym("velocity"), A_DEFFLOAT, 0);
+#endif
class_addfloat(velocity_class, velocity_float);
class_addbang(velocity_class, velocity_bang);
+#ifndef MAXLIB
+ class_sethelpsymbol(velocity_class, gensym("help-velocity.pd"));
+ post(version);
+#else
+ class_sethelpsymbol(velocity_class, gensym("maxlib/help-velocity.pd"));
+#endif
}
diff --git a/src/weibull.c b/src/weibull.c
index 8df527e..1dbf4aa 100644
--- a/src/weibull.c
+++ b/src/weibull.c
@@ -73,12 +73,23 @@ static void rand_weibull_bang(t_rand_weibull *x)
outlet_float(x->x_obj.ob_outlet, x->x_s*pow(log(a), tinv));
}
+#ifndef MAXLIB
void weibull_setup(void)
{
rand_weibull_class = class_new(gensym("weibull"), (t_newmethod)rand_weibull_new, 0,
sizeof(t_rand_weibull), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
- class_addbang(rand_weibull_class, rand_weibull_bang);
+#else
+void maxlib_weibull_setup(void)
+{
+ rand_weibull_class = class_new(gensym("maxlib_weibull"), (t_newmethod)rand_weibull_new, 0,
+ sizeof(t_rand_weibull), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)rand_weibull_new, gensym("weibull"), A_DEFFLOAT, A_DEFFLOAT, 0);
+#endif
+ class_addbang(rand_weibull_class, rand_weibull_bang);
#ifndef MAXLIB
+ class_sethelpsymbol(rand_weibull_class, gensym("help-weibull.pd"));
post(version);
+#else
+ class_sethelpsymbol(rand_weibull_class, gensym("maxlib/help-weibull.pd"));
#endif
}
diff --git a/src/wrap.c b/src/wrap.c
index cf94e6c..310772b 100644
--- a/src/wrap.c
+++ b/src/wrap.c
@@ -114,18 +114,29 @@ static void *wrap_new(t_floatarg fmin, t_floatarg fmax)
x->x_min = fmin;
wrap_b(x, fmax);
-#ifndef MAXLIB
- post(version);
-#endif
return (void *)x;
}
+#ifndef MAXLIB
void wrap_setup(void)
{
wrap_class = class_new(gensym("wrap"), (t_newmethod)wrap_new,
0, sizeof(t_wrap), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
+#else
+void maxlib_wrap_setup(void)
+{
+ wrap_class = class_new(gensym("maxlib_wrap"), (t_newmethod)wrap_new,
+ 0, sizeof(t_wrap), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)wrap_new, gensym("wrap"), A_DEFFLOAT, A_DEFFLOAT, 0);
+#endif
class_addfloat(wrap_class, wrap_float);
class_addmethod(wrap_class, (t_method)wrap_a, gensym("a"), A_FLOAT, 0);
class_addmethod(wrap_class, (t_method)wrap_b, gensym("b"), A_FLOAT, 0);
+#ifndef MAXLIB
+ class_sethelpsymbol(wrap_class, gensym("help-wrap.pd"));
+ post(version);
+#else
+ class_sethelpsymbol(wrap_class, gensym("maxlib/help-wrap.pd"));
+#endif
}