I’ve been thinking about proposing this idea for scripting for a long time. Now that we have global ports available, I think it could be implemented well and without any danger.
The basic idea is to have an action to be able to send midi messages through different output ports in the scripted buttons and dials.
That is, the idea is that the scripted buttons and dials are not limited to being able to send midi messages only through the port selected in the drop-down menu.
I’ll give an example. The following code would send the same midi message to two different global output ports:
[(press) {outputport:GP1} {cc:1,1,1} {outputport:GP2} {cc:1,1,1}]
If this is implemented, it could be approached in two ways:
1- Temporary change: The command {outputport:GP1} does not change the output port in the port drop-down menu, it is a change limited to the line of code where the command appears
2- Permanent change: The command {outputport:GP1} changes the output port in the port drop-down menu
I will develop both options a little.
1- Temporary change
Let’s imagine that we have a scripted dial that has the GP1 output port configured in the port drop-down menu with the following code:
[(press) {outputport:GP5} {cc:1,1,127}]
All rotation actions will always be sent through port GP1. Every time the dial is pressed, a midi message will be sent through the GP5 port. If we added a second line of (press), it would mean that the first time the dial is pressed a midi message would be sent through the GP5 and the second time it would be sent through the GP1:
[(press) {outputport:GP5} {cc:1,1,127}] → sent through the GP5
[(press) {cc:1,1,127}] → sent through the GP1
2- Permanent change
Let’s use the same example as before: we have a scripted dial that has the output port GP1 configured in the port dropdown menu with the following code:
[(press) {outputport:GP5} {cc:1,1,127}]
Before the dial is pressed, all rotation actions will be sent through the GP1 port. However, when the dial is pressed, a midi message will be sent out the GP5 output port, and all rotation actions will be sent out the GP5 port from now on. In the drop-down menu of ports, the GP1 port will be replaced by the GP5 port.
In this permanent change mode, we could also easily make the change temporary, with the conditions we want. For example, the following code would send the same midi message to GP5 and immediately set the output port back to GP1:
[(press) {outputport:GP5} {cc:1,1,127} {outputport:GP1}]
And where it gets interesting is that we can use variables that would give us many possibilities:
[(press) (@myGP:5) {outputport:GP5} {cc:1,1,127} {outputport:GP1}]
[(press) (@myGP:2) {outputport:GP2} {cc:1,1,127} {outputport:GP1}]
[(press) (@myGP:1) {cc:1,1,127}]
I don’t know which is better in terms of performance, programming, risks, etc. but I think that the most powerful, practical and interesting for the user is the permanent change mode.
Regarding the port that is changed, I have thought that it is better to limit it to global ports to make everything simpler and more scalable. But maybe some users would like to have the freedom to write the port name directly. I don’t know if this is more difficult to implement or if it is worth it.
Now that I have explained the concept, I will explain why I find it useful to implement it.
Now that I have bought the SD+XL and have been making modifications (quite a lot because now I go from having 4-track banks to having 6-track banks) I have realized again that I have some quite complicated configurations that share midi messages and variables between many button/dial scripts and several background scripts.
All these complicated configurations would be very simple if I could send midi messages from the same script through different ports.
So, as I see it, the main benefit of this idea is to allow the user to make complex configurations in a simple way (and therefore easier to maintain and document)
Finally, in case you consider it worth implementing the {outputport:GP1} action in the permanent mode option, it would also be useful to implement an {inputport:GP1} action.
The {inputport} action would be limited only to the {init} events, without being able to set any other conditions (multievent disabled).
The following code would be accepted and executed:
[(init){inputport:GP1}]
But the following codes would give an error and would not be executed
init) (@l_var:1) {inputport:GP1}]
[(init) (@l_var:2) {inputport:GP2}]
[(init+) (@l_var:1) {inputport:GP1}]
[(init+) (@l_var:2) {inputport:GP2}]
[(init+) (cc:1,1,1) {inputport:GP1}]
[(cc:1,1,1) {inputport:GP1}]
[(press) {inputport:GP1}]
etc.
This implementation would be useful for configuring input and output ports from the script code, which would save time when making new scripted buttons or dials. You would only need to write this at the beginning of the script:
[(init) {inputport:GP1} {ouputport:GP2}]