is there a way to be able to use dynamically the port number?
What I need is one single place where to set the port (either in a json config file or in the OSC config) that I can use to set the port to each widget declared in the UI statically and the ones created from the custom modules.
Is there a way to access the default port from the target attribute of the UI? (if I leave it blank it does not work)
And from the source code?
I assume by port you mean midi port as created with the server's midi option. You could retrieve the server's midi option in the custom module a do what you want with the port names:
var midiports = settings.read('midi') // read server's midi option
.filter(x => x.includes(':')) // keep only port declarations
.map(x => x.split(':')[0]) // keep only port names
Would that help ?
Is there a way to access the default port from the target attribute of the UI? (if I leave it blank it does not work)
I'm not sure to understand, but when the target is left blank, widgets will only send message if a default target is set using the server's "send" option. Since the "send" option affects all widgets, the ignoreDefault property can be used to ignore the default target(s).
And from the source code?
No sure to understand either, I mean you could change everything from the source code
Thanks for the answer but I was referring to the port number
I assume there is also a way to access this?
What I want is that:
one can set for example 5100 and this will be automatically set for all the OSC actions that are declared in the UI, plus the ones generated via the code is ok I know how to do it
so in the UI instead of declaring the target like this, let him use the one set in the config
You could create a variable widget to hold that number, define the widget's target as "localhost:@{variable_id}" and feed the variable from the custom module when the session is loaded:
var port = 5000 // or maybe var port = require('config.js').port
app.on('sessionOpened', ()=>{
receive('/variable_address', port)
})