I found a solution, thanks to all for your ideas!
I took the road proposed by @lacuna about file parsing.
Here is the patch, Instant Mapping:
the keyboard shortcut to call Instant-Mapping is Ctl+1 then F2
(weird shortcut, but I couldn't find a way to create an empty object at mouse-position via dynamic patching, so... Ctl+1)
tested on Pd 53.1 windows.
the idea was to find a solution Vanilla only, no external.
I don't know any way to do dynamic patching in the active canvas.
It looks like you always have to choose a canvasname or a filename to send the instructions.
So it breaks a bit the purpose to have a one-shortcut-solution... You have first to give a canvasname "main" to your patch.
it works for auto-replacing $1, but not for $0, you have to replace them manually (I'm not sure it's possible to query the $0 from outside)
about the mouse position when using the shortcut: try to target the top-left of the object, because this is where is the origin point of each object
I'm afraid it's not totally reliable (I wouldn't use it in live performance, I had some crashs), but it works for my use case.
I'm still interested in a cleaner way to achieve that in Vanilla.
@ddw_music Thank you, this approach works well, I'll use this if I don't find a way to make it automatic.
But I'd like to continue investigating with something that could work without having to prepare each numbox.
The idea of parsing .pd files by @lacuna is interesting.
I'm investigating in that direction.
The problems with this approach:
- how to query the file name of the abstraction that contains the numbox?
- how to find the right line in the .pd file? using the XY coords of the numbox and the position of the mouse cursor?
I try to find a solution full Vanilla / no external.
I should explain what I'd like to achieve:
I'll have hundreds of numboxes like this one, in different abstractions, and I'd like to be able to pick some of them and to control them from outside (from another abstraction or from another software)
A bit like "Instant mapping" in Ableton Live. You activate this mode, you click any parameter and now you can control it.
For now, the workflow is as follows:
- Picking a numbox I want to automate from outside
- Opening the abstraction (Right click on the abstraction / Open)
- Opening the properties (Right click on the numbox / Properties)
- Copying the Receive Symbol content
- Coming back to the main patch
- Creating a Send object connected to a numbox
- Pasting the content of Send Symbol in the send object [s $0-sendnum-r]
- Finding the ID of the abstraction (going back inside the abstraction, creating a [bang] -- [f $0] -- [print] in the abstraction)
- Replacing $0 in the Send object by the ID of the abstraction [s 1003-sendnum-r]
Now I can control this numbox from the new send object, or from another software...
But this is a rather long process, not really usable in a live situation.
An alternative would be to do it the way recommended by @ddw_music, printing [symbol $0-sendnum-r] every time the parameter is changed. This involves preparing all the abstractions/parameters to make it work that way.
But I'd like to find a way that would work with any unprepared gatom.
That's how I came up with the idea of intercepting internal PD messages.
I'd like to print the "sent symbol" of a numbox, rather than the value itself
Printing something like this when I change the value of the numbox:
As everything in PD is a message, I guess that the message 1003-sendnum-s 53 ; is sent somewhere when I click on this numbox, but is there a way to intercept it?
So far I tried with:
[receive pd] | [print]
And I can see something happening when I click this numbox, but the only thing printed is ping, not the full message unfortunately.
The idea of sending the message with commas and to attach a message box to Netreceive works perfectly!
About the semicolon at the beginning of a message, I don't thing it's a local shortcut for [s pd]
In this example, only the left one is working.
It looks like the first semicolon means "send argument 2 to argument 1 for each line".
The helpfile for Netsend shows how to send a simple message to a Netreceive object in another instance of PureData.
But how to send a "global message" and execute it automatically?
For global message I mean the messages starting with a semicolon,
; pd dsp 1
; $0-param1 0; $0-param2 62;
I tried this, but no success:
I'd like to execute the instruction on the destination instance only, and not on the source instance.
Is there a fast way to replace a wire in PD Vanilla?
For example when you connect a new object on an already used Inlet, it would automatically delete the already used wire.
Ideally it would be something like Alt-Click when creating a wire on an already used Inlet.
I'm aware of the intelligent patching videos, that shows a lot of hidden shortcuts:
But there is nothing about wire replacement, while it's maybe the patching behavior I use the most.
Did I miss something, or it's not available in Vanilla?