[PD] Fwd: basic logic (AND OR) and control in PD

Roman Haefeli reduzierer at yahoo.de
Mon Jan 22 14:44:29 CET 2007


On Mon, 2007-01-22 at 12:01 +0000, matthew venn wrote:

> So I want a bunch of buttons that do *multiple actions, depending on
> the current state of the sampler*. So for example I gave:
> 
> * in stop mode, if I press the button we go to record/play mode
> * in record/play mode, the button closes the loop and stops playback.
> 
> I will need a few different states, such as
> 
> * playing
> * overdubbing
> * stopped
> * recording
> 
> that will be tied to 1 of a few different parallel samplers (probably
> around 4).

hi matthew again

i attached a small patch, that shows how i would implement the most
simple 'state alternator'. if you want to make state switching dependent
on other states, it might be helpfull to have a look at the helppatch of
[&& ], [|| ], [== ] and such. with these objects, it should be possible
to implement the logic you want to achieve. 

some random tips, that are important, when doing logic-stuff:

* many objects with two inlets only send a 'result' to the outlet, when
they're triggered by the left ('hot') inlet, whereas, if they get a
message at their right ('cold') inlet, only their internal state is
changed, but nothing is sent to the outlet. (Section 2.3.3 of the
pd-html-manual is more detailed and might be interesting for you)

* you should care about execution order. for example, when one outlet is
connected to two inlets, the order of execution is *not* defined, or in
other words: you don't know, which inlet gets the message first.
therefore usually a [trigger]-object is inserted in between in order to
avoid 'undefinedness' (have a look at the help of [trigger]).

* read the section about the 'depth-first'-principle in pd (section
2.3.2).  

i hope, that was not too 'teacherish' ;-)

roman
-------------- next part --------------
#N canvas 746 329 458 378 10;
#X obj 51 21 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X text 73 20 <-- switch states;
#X obj 51 85 ==;
#X obj 93 85 f;
#X obj 51 179 select 0 1;
#X text 64 58 ----------------------------------------;
#X text 64 145 ----------------------------------------;
#X text 82 41 (when hit \, it sends a a 'bang';
#X text 94 109 sends alternating '0' and '1';
#X text 144 174 if input matches \, send 'bang to;
#X text 143 191 the appropriate output.;
#X text 99 216 -----------------------------------;
#X msg 51 261 stop;
#X msg 93 261 play/record;
#X obj 51 307 print;
#X connect 0 0 2 0;
#X connect 2 0 3 0;
#X connect 2 0 4 0;
#X connect 3 0 2 1;
#X connect 4 0 12 0;
#X connect 4 1 13 0;
#X connect 12 0 14 0;
#X connect 13 0 14 0;


More information about the Pd-list mailing list