From 267170167d52cab9e97f879d9127a1cf04f6bb58 Mon Sep 17 00:00:00 2001 From: Martin Peach Date: Tue, 15 Mar 2011 20:53:57 +0000 Subject: This is a version of Claude Heiland-Allen's lua for Pd. The objects are named pdlua and pdluax instead of lua and luax. So far it seems to work on linux. svn path=/trunk/externals/pdlua/; revision=15030 --- examples/lexpr-help.pd | 152 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 examples/lexpr-help.pd (limited to 'examples/lexpr-help.pd') diff --git a/examples/lexpr-help.pd b/examples/lexpr-help.pd new file mode 100644 index 0000000..3f2978a --- /dev/null +++ b/examples/lexpr-help.pd @@ -0,0 +1,152 @@ +#N canvas 0 22 936 656 10; +#X floatatom 110 102 5 0 0 0 - - -; +#X floatatom 110 56 5 0 0 0 - - -; +#X floatatom 202 56 5 0 0 0 - - -; +#X floatatom 294 57 5 0 0 0 - - -; +#X obj 72 53 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 +-1; +#X floatatom 26 232 5 0 0 0 - - -; +#X floatatom 205 236 5 0 0 0 - - -; +#X floatatom 385 235 5 0 0 0 - - -; +#X floatatom 26 278 5 0 0 0 - - -; +#X obj 26 255 lexpr phi rho gamma -> 100*cos(phi) + gamma*sin(rho) +; +#X msg 115 205 lexpr foo bar baz -> foo * bar / baz; +#X msg 115 181 lexpr x y z -> x+y+z; +#X text 12 11 First come variable names \, then -> surrounded by spaces +\, then an expression (in Lua syntax).; +#X obj 110 77 lexpr a b c -> min(a \, b \, c); +#X text 14 122 Messages can change the expression (provided inlet count +stays the same). This resets the state of all variables. Note: weird +tricks are needed for commas in messages :(; +#X obj 86 441 lexpr a b c -> a + b + c; +#X msg 190 412 hot \$1; +#X obj 190 392 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +1; +#X msg 270 412 hot \$1; +#X obj 270 392 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +1; +#X msg 110 412 hot \$1; +#X obj 110 392 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +1; +#X floatatom 86 367 5 0 0 0 - - -; +#X floatatom 167 367 5 0 0 0 - - -; +#X floatatom 249 367 5 0 0 0 - - -; +#X obj 68 387 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 +-1; +#X floatatom 86 469 5 0 0 0 - - -; +#X text 13 305 Eaxh inlet supports a "hot " method \, that makes +the inlet hot or not. By default only the first inlet is hot. Sending +a bang to the first inlet always performs the calculation \, no matter +if that inlet is set to be cold.; +#X text 22 491 Multiple outlets are supported \, with multiple expressions +separated by commas.; +#X obj 82 546 lexpr a b -> a + b \, a - b; +#X floatatom 82 528 5 0 0 0 - - -; +#X floatatom 252 528 5 0 0 0 - - -; +#X floatatom 82 568 5 0 0 0 - - -; +#X floatatom 252 568 5 0 0 0 - - -; +#N canvas 2 22 450 300 \$0-weird-tricks-to-get-commas-in-messages 0 +; +#X obj 58 231 lexpr a b -> max(a \, b) \, min(a \, b); +#X floatatom 32 194 5 0 0 0 - - -; +#X floatatom 33 273 5 0 0 0 - - -; +#X floatatom 284 198 5 0 0 0 - - -; +#X floatatom 284 275 5 0 0 0 - - -; +#X obj 123 148 makefilename %c; +#X msg 123 128 44; +#X obj 123 68 makefilename %c; +#X msg 123 48 44; +#X msg 123 88 lexpr a b -> min(a \$1 b) \$1 max(a \$1 b); +#X msg 123 168 lexpr a b -> max(a \$1 b) \$1 min(a \$1 b); +#X text 28 18 This is really ugly \, but it seems to work...; +#X connect 0 0 2 0; +#X connect 0 1 4 0; +#X connect 1 0 0 0; +#X connect 3 0 0 1; +#X connect 5 0 10 0; +#X connect 6 0 5 0; +#X connect 7 0 9 0; +#X connect 8 0 7 0; +#X connect 9 0 0 0; +#X connect 10 0 0 0; +#X restore 27 606 pd \$0-weird-tricks-to-get-commas-in-messages; +#X text 502 5 New in pdlua-0.5: interaction with Pd [value] objects. +; +#X obj 608 70 value \$0-foo; +#X floatatom 608 45 5 0 0 0 - - -; +#X obj 528 97 lexpr x y -> val("\$0-foo") * x / y; +#X floatatom 528 72 5 0 0 0 - - -; +#X floatatom 763 72 5 0 0 0 - - -; +#X floatatom 528 129 5 0 0 0 - - -; +#X text 504 161 Trying to access a [value] that doesn't exist returns +0:; +#X obj 539 224 lexpr z -> z + val("\$0-bar"); +#X floatatom 539 202 5 0 0 0 - - -; +#X floatatom 539 253 5 0 0 0 - - -; +#X obj 508 384 lexpr scale name -> scale * val(name); +#X obj 782 319 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X obj 672 343 symbol \$0-foo; +#X obj 672 319 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X obj 782 343 symbol \$0-baz; +#X floatatom 792 377 5 0 0 0 - - -; +#X obj 792 399 value \$0-baz; +#X floatatom 508 354 5 0 0 0 - - -; +#X floatatom 508 415 5 0 0 0 - - -; +#X text 505 292 New in lexpr for pdlua-0.5: inputs can be symbols. +; +#X obj 511 531 lexpr left right -> "" .. left .. right; +#X symbolatom 511 497 10 0 0 0 - - -; +#X symbolatom 781 497 10 0 0 0 - - -; +#X symbolatom 511 570 0 0 0 0 - - -; +#X text 501 471; +#X text 494 446 New in lexpr for pdlua-0.5: outputs can be symbols +too. The inital "" is to make sure that we have a string.; +#X floatatom 737 496 5 0 0 0 - - -; +#X floatatom 594 497 5 0 0 0 - - -; +#X connect 1 0 13 0; +#X connect 2 0 13 1; +#X connect 3 0 13 2; +#X connect 4 0 13 0; +#X connect 5 0 9 0; +#X connect 6 0 9 1; +#X connect 7 0 9 2; +#X connect 9 0 8 0; +#X connect 10 0 9 0; +#X connect 11 0 9 0; +#X connect 13 0 0 0; +#X connect 15 0 26 0; +#X connect 16 0 15 1; +#X connect 17 0 16 0; +#X connect 18 0 15 2; +#X connect 19 0 18 0; +#X connect 20 0 15 0; +#X connect 21 0 20 0; +#X connect 22 0 15 0; +#X connect 23 0 15 1; +#X connect 24 0 15 2; +#X connect 25 0 15 0; +#X connect 29 0 32 0; +#X connect 29 1 33 0; +#X connect 30 0 29 0; +#X connect 31 0 29 1; +#X connect 37 0 36 0; +#X connect 38 0 41 0; +#X connect 39 0 38 0; +#X connect 40 0 38 1; +#X connect 43 0 45 0; +#X connect 44 0 43 0; +#X connect 46 0 54 0; +#X connect 47 0 50 0; +#X connect 48 0 46 1; +#X connect 49 0 48 0; +#X connect 50 0 46 1; +#X connect 51 0 52 0; +#X connect 53 0 46 0; +#X connect 56 0 59 0; +#X connect 57 0 56 0; +#X connect 58 0 56 1; +#X connect 62 0 56 1; +#X connect 63 0 56 0; -- cgit v1.2.1