[PD] Using mouse speed for input?

Krzysztof Czaja czaja at chopin.edu.pl
Tue Jan 8 09:37:36 CET 2002


hi,

strangely enough, this may be achieved with a simple abstraction,
and a minor hack in pd.tk.

The attached MouseState.pd abstraction follows a MouseState interface
(Max class).  First outlet (mouse button) requires making a few
additional changes to pd.tk, 2nd/3rd outlets (x/y position) work in
a polling mode only, while 4th/5th outlets (dx/dy) work in a waiting
mode only.

To get into it, insert the following line in pdtk_canvas_motion
procedure in pd.tk (0.35test-4: before line 976):

  pd #mouse motion $x $y \;

and run ``pd MouseState-test.pd''.  Starting Pd without the test
patch will also do, if you do not mind watching ``no such object''
complaints -- the modified pd.tk requires that a #mouse target exists
during an entire Pd session (I have not found any usable target
available already in Pd to borrow from).

If transformed into an external, MouseState would not cause such
trouble, because it would dynamically modify Tcl definitions and/or
bindings.  If transformed into an internal, it would behave even
better.  This is one of the cases, when it is harder to make
a prototype, than a real thing.

Btw. I have been catching mouse motion in an external (sic) made as
an attempt to emulate Max's assistance feature in Pd.  The external
itself is working (clumsily), but no way I will soon find the time
needed to compile the docs.  Expecting major changes to be done to
Pd internals, I think the spy project must wait anyway...

Krzysztof

Kjetil Falkenberg Hansen wrote:
...
> I am looking for a way of translating mouse (or touchpad etc) speed to
> amplitude: the faster the mouse speed, the louder the sound. (The mouse button
> can be pressed in.)
-------------- next part --------------
#N canvas 37 46 584 390 12;
#X obj 20 71 route mouseup motion;
#X obj 107 111 unpack;
#X obj 20 162 outlet;
#X obj 107 162 outlet;
#X obj 192 162 outlet;
#X msg 20 111 0;
#X obj 268 225 int;
#X obj 319 225 int;
#X obj 347 111 t b b b b;
#X obj 372 225 int;
#X obj 423 225 int;
#X obj 373 268 -;
#X obj 268 268 -;
#X obj 347 29 inlet;
#X obj 268 306 outlet;
#X obj 373 306 outlet;
#X obj 20 29 r #mouse;
#X connect 0 0 5 0;
#X connect 0 1 1 0;
#X connect 1 0 3 0;
#X connect 1 0 6 1;
#X connect 1 1 4 0;
#X connect 1 1 7 1;
#X connect 5 0 2 0;
#X connect 6 0 12 0;
#X connect 6 0 9 1;
#X connect 7 0 10 1;
#X connect 7 0 11 0;
#X connect 8 0 6 0;
#X connect 8 1 9 0;
#X connect 8 2 7 0;
#X connect 8 3 10 0;
#X connect 9 0 12 1;
#X connect 10 0 11 1;
#X connect 11 0 15 0;
#X connect 12 0 14 0;
#X connect 13 0 8 0;
#X connect 16 0 0 0;
-------------- next part --------------
#N canvas 208 185 444 308 12;
#X msg 27 25 bang;
#X msg 94 25 stop;
#X obj 27 67 metro 50;
#X obj 27 109 MouseState;
#X floatatom 48 238 5 0 0;
#X floatatom 69 207 5 0 0;
#X floatatom 90 175 5 0 0;
#X floatatom 112 144 5 0 0;
#X connect 0 0 2 0;
#X connect 1 0 2 0;
#X connect 2 0 3 0;
#X connect 3 1 4 0;
#X connect 3 2 5 0;
#X connect 3 3 6 0;
#X connect 3 4 7 0;


More information about the Pd-list mailing list