jshea2 / OSC-for-OBS

Control and listen to OBS via OSC
113 stars 8 forks source link

strange behavior of strings #2

Open HansElectrumpet opened 3 years ago

HansElectrumpet commented 3 years ago

Hi, I don't know if it should be here or is actually an obs websockets issue, but I used the following code (hacked some of yours) because I want to use the streamFX plugin through OSC. If it works I can give you my code if you want it when finished. I am not familiar much with javascript per se but thought I knew enough about programming languages to do this... Anyway. In the following piece of code, changing the x position works, but y and z don't. As I want to make the code versatile I'd like to use variables and not have to type out every single string. Do you have any idea why this wouldn't work? I get no error message. You see a few variations, but any variation gives the same result.

   //Triggers the Source Camera position (via Filter > 3D_Transform)
    else if ((msg[0].includes('macbookCamSkew')) && (msg[0].includes('Position'))){
        console.log(`OSC IN: ${msg[0]} ${msg[1]} ${msg[2]} ${msg[3]}`)
        var msgArray = msg[0].split("/")
        msgArray.shift()
        var x = msg[1]
        var y = msg[2]
        var z = msg[3]
    var filterType = 'Filter.Transform.'
    var actionX = filterType.concat(msgArray[3], '.X')
    var actionY = 'Filter.Transform.' + msgArray[3] + '.Y'
    var actionZ = filterType.concat(msgArray[3], '.Z')
        console.log(`filterprint: ${actionY}`)
        obs.send("SetSourceFilterSettings", {
           'sourceName': msgArray[0].split('_').join(' '),
           'filterName': msgArray[1].split('_').join(' '),
           'filterSettings': { 'Filter.Transform.Position.X' : x, actionY : y, actionZ : z }
        }).catch(() => {
            console.log("ERROR: Transform Command Syntax is Incorrect. Refer to Node OBSosc Github for Reference")
        })  
    }
jshea2 commented 3 years ago

Hey, sorry I'm unfamiliar with StreamFX, because I only have a Mac. I have looked into it and it looks pretty cool. I don't know what the properties or key should be, but it looks like if X works and it's

"Filter.Transform.Position.X" : x

then shouldn't Y be:

"Filter.Transform.Position.Y": y

Cause Right now it is:

"Filter.Transform.[msgArray[3]].Y" : y

If you wanted that variable to be "Position", after the msgArray.shift(), 'msgArray[0]' should then equal "Position" (as long as the OSC message is set up kinda like this: "[/macbookCamSkew/Position], [x], [y], [z]")

Another debugging thing you could try to see if Y or Z is a different key name. obs.send("GetSourceFilterSettings) after that you can .then() and console.log whatever is going on in the 'filterSettings' properties.

Sorry if this info isn't much help, but it's my best guess

WilliamAHuston commented 3 years ago

Wow! I am very interested in controlling StreamFX via OSC. Please keep me posted and provide other details if possible. Thanks!

h/t: @jshea2 for directing me here.