Inspired from whale-av i started to build a .tcl mouse plug-in.
I need to put the .tcl file into my "extra" folder, somehow it doesnt work with the declare object. Right now i get the mouse coordinates of a defined canvas, it would be nice to switch between different canvases and not to get any coordinates if i click outside of the canvas. I know that there are already some libraries that can handle mouse tracking, i just wanted to find out whats possible and learn a little bit about .tcl. Heres the test patch and the plugin: mouse_coordinates_plugin_test_4.zip
-
Experimental Mouse Plugin
-
thanks david, now it works nice without externals, still you need the experimental mouse plugin in your extras folder: experimental_mouse_plugin_7h.zip
jumps in mouse data exist also with dsp 0. its when i get mousecoordinates, but also if i move numbers in a number box or a slider with the mouse, it depends on the speed of the mouse.
in contrast if i move data structures with the mouse i get every value. its not a serious problem, but i was wondering. -
i tried to implement the plugin into the struct sequencer, now its possible to draw in the grid (like with an mouse external): structsequencer_mouse_plugin.zip
-
i removed list-rev for finding pointers in a list in the struct sequencer, now the drawing is much faster. theres a 16, 32 and 64 step version. in the 64 step version you can almost paint something and play the "painting". @whale-av in the 64 step version you see the jumps of the mouse visualised in the pattern, in the other versions the mouse tracking is accurate enough: structsequencer_mouse_plugin.zip
-
i build a function that generates melodies. choose nth, and manipulate nth1 and nth2. it works without the mouse plugin but then it gives error messages. perhaps i will also build it into the sequencer version without the mouse plugin. for testing i connected the sequencer to the nice polywavesynth from http://www.pkstonemusic.com (which requires cyclone, and mr peach for osc): structsequencer_mouse_plugin64step_nth_polysynth.zip
-
@jona @whale-av I've been starting to mess with tcl plugins to see if I could replace [toxy/tot] object.
toxy
totThe tot's third outlet optionally captures a stream of Pd gui messages dealing with user control over a destination canvas.
i.e. motion, mouseup/down, keys, etc... of specific chosen windows (title passed by message or argument).How could one translate the window ID in jona's plugin to the window title?
-
@kyro I don't think the window title can be returned.
Pd obviously knows the canvas by its os filename as you can send a message directly to it through [;pd-mypatch.pd(
But the new [pdcontrol] object doesn't offer the patch name, only the paths to it.
Tcl refers to the window index returned by the os when the window is opened..... $focussed_window in this case.
The hcs library has tools for retrieving the index as does the iem_guts library.
You can set a supplementary name for your patches with [namecanvas] so that other canvases can send messages to them without knowing the window title.In experimental-mouse-plugin the $focussed_window is sent before the mouse info.
You can get the window ID for the window the mouse is actually over..... focussed or not....... with %W and then filter for it like this.......
this.zip
You will need the hcs library for [window_name]
You could test for $focussed_window(join ".c") == %W within the plugin and only send the mouse info when that is true..... but it would still send to all [mouse_receive] objects.Interestingly, if you attach a print within only_me.pd and look at the incoming messages, you will see that %W does return the literal name for the console (pdwindow) and other tcl (owned by wish) windows..... but not patches (owned by Pd).
David. -
Thanks a lot, @whale-av, I think I know what to try! If I want to listen to [pd mysubpatch], I just have to get its id with [window_name pd-mysubpatch] and filter out the messages from other windows.
$focussed_window(join ".c") == %W
Where can I learn more about this wizardry? I wasn't able to get key info from the plugin, I don't understand how to use commands from the tcl doc...
-
Nevermind, <KeyPress> steals keys for itself and turns pd unusable.
Thanks for that %W trick, I now have the mouse features I was looking for. -
@kyro P.S. "$focussed_window(join ".c") == %W" was my pseudo code for add .c to the focussed window name.
There are some people on the forum that can play nicely with tcl.
I have just learnt by experimentation and trying to understand what is already in the pd/tcl folder..... a sort of guesswork with clues really.
David.