How could i make a widget to react only on a special udp osc input port?

I am really impressed about the performance and the abilities in O S C!
Thank you @jean-emmanuel really great work!

I have a Mixer, which consists of 3 main busses, each is addressed by:
/busInput, /busPlayback, /busOutput

The Problem is, that it uses the same address sheme for all controls (faders, meters, tracknames, knobs, buttons, etc) depending on the previous selected bus:
ex:
/busInput
/1/volume1 (for IN-fader1)
/1/volume2 (for IN-fader2)
etc...

/busPlayback
/1/volume1 (for PB-fader1)
/1/volume2 (for PB-fader2)
etc...

/busOutput
/1/volume1 (for Out-fader1)
/1/volume2 (for Out-fader2)
etc..

But... The mixer has the possibility to assign up to 4 seperate Controllers:
Each controller can be addressed by its own sending udp port - and its own listening udp port (on the Mixer side)

So, my goal is to control all 3 busses independant, but in one json (or O S C Session).
I have created 3 Panels, each ihas a seperate target port -> Outgoing commands work.
But to be able to spread the incoming commands, (meters, tracknames, etc) i have to assign 3 seperate listenening ports - one for each bus(or panel).

Hope i described my problem clearly, for you :slight_smile:

Or is there already a solution, to achieve this, i did not found here?

Thanky for suggestions and hints.

Thank you :slight_smile:

Currently there's no built-in solution for this, you'll need to write a custom module in order to differentiate these widgets with identical addresses, something like that:

// Custom module: select this file in the server's "custom-module" option

module.exports = {

    oscInFilter: (data)=>{

        // Add an address prefix to incoming messages depending on the origin port
        // Widgets will need to have their addresses prefixed accordingly to make this work

        if (data.port === BUS_INPUT_PORT) data.address = '/busInput' + data.address
        if (data.port === BUS_OUTPUT_PORT) data.address = '/busOutput' + data.address
        
        return data
    },

    oscOutFilter: (data)=>{

        // Remove address prefixes from outgoing messages

        if (data.address.includes('/busInput/')) data.address = data.address.slice(9)
        if (data.address.includes('/busOutput/')) data.address = data.address.slice(10)

        return data
    }

}

It may become possible without a custom module at some point, but for now it's the only solution I can think of.

Thank you. I did not expect to get an answer so quickly...

Yes, i already thought of the custom module, but i had no clue how to get started with this.
I think, i got what you mean...

I adressed busInput and busOutput on Mixer to the same port on O S C, debug looks like this:

(DEBUG, OSC) In: { address: '/1/level1L', args: 0.12726223468780518 } From: 192.168.1.1:51586
(DEBUG, OSC) In: { address: '/1/level1R', args: 0.14018331468105316 } From: 192.168.1.1:51586
(DEBUG, OSC) In: { address: '/1/level1L', args: 0.7014337182044983 } From: 192.168.1.1:59203
(DEBUG, OSC) In: { address: '/1/level1R', args: 0.6953405141830444 } From: 192.168.1.1:59203

so, the oscInFilter would look like this, f. ex?

...
if (data.port === 51586) data.address = '/busInput' + data.address
if (data.port === 59203) data.address = '/busOutput' + data.address
...

(i mean, i should replace the blue strings from your code with the concrete incoming port numbers, right?)

if yes - then my next task is to figure out which port belongs to which bus, because it seems that they are random generated each time the mixer reconnects to O S C (after restart, session reset, etc). But i have some ideas how to get it...

You got me right ! However, if by any chance the mixer sends a message that you could use to know which bus it's talking to, you could use it to save the port number associated with the message and reuse it later:

// unknown ports (yet)
// declared as variables we'll use below
var BUS_INPUT_PORT,
    BUS_OUTPUT_PORT

module.exports = {

    oscInFilter: (data)=>{

        // store mixer port
        if (data.address === '/hey/i/am/talking/to/busInput') {
            BUS_INPUT_PORT = data.port
        }
    

        // add an address prefix to incoming messages depending on the origin port

        if (data.port === BUS_INPUT_PORT) data.address = '/busInput' + data.address
        if (data.port === BUS_OUTPUT_PORT) data.address = '/busOutput' + data.address
        
        return data
    },

    oscInFilter: (data)=>{

        // remove prefix from outgoing messages

        if (data.address.includes('/busInput/')) data.address = data.address.slice(9)
        if (data.address.includes('/busOutput/')) data.address = data.address.slice(10)

        return data
    }

}
1 Like

Yes, you got a similar idea. Thanks again!

I added a button to trigger for ex the /1/busOutput command (later, i will move it to onCreate in the Scripting Area of the accoding panal or sth similar)

when i fire up the button it sets the busOutput (port 9300 belongs to the busOutput controller):

(DEBUG, OSC) Out: { address: '/1/busOutput', args: [ { type: 'f', value: 1 } ] } To: 192.168.0.1:9300

i get imediatly the answer with all the positions and params of the busOutput faders, knobs, etc...

...
(DEBUG, OSC) In:  { address: '/1/solo/1/24', args: 0 } From: 192.168.0.1:50409 
....
(DEBUG, OSC) In:  { address: '/1/busInput', args: 0 } From: 192.168.0.1:50409 
(DEBUG, OSC) In:  { address: '/1/busPlayback', args: 0 } From: 192.168.0.1:50409 
(DEBUG, OSC) In:  { address: '/1/busOutput', args: 1 } From: 192.168.0.1:50409 
....

so the line with "address: '/1/busOutput', args: 1 " indicates, that it is mapped now to busOutput and the incoming port is 50409 for it.

so i have to handle this in the js module. But it seems not to work.


if (data.address === '/1/busOutput' && data.args[1].value === 1) {
            BUS_OUTPUT_PORT = data.port
            console.log(data)
        }

console never logs the full data. How would it be best practice to also handle the args value in the js?

Thanks in advance, again.

Arrays are zero indexed in javascript, the first item in data.args is data.args[0], not data.args[1]

if (data.address === '/1/busOutput' && data.args[0].value === 1) {
    BUS_OUTPUT_PORT = data.port
    console.log(`BusOutput port set to ${data.port}`)
}
1 Like

Works perfectly now... Thank you!

Edit:
I am really impressed, about the performance. And the job you have done!
Respect to you!
TouchOSC, Lemur, etc... not comparable...

It's running on my small pi smoothly now
:grinning: