OpenSoundControl (OSC) in Rev?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: OpenSoundControl (OSC) in Rev?
mweider: I tried to build my own OSC lib (did not get it to fully work, I see the messages but didn't get the formatting working) before I found yours. I'm also trying to use it with CasparCG and following your advice above I have now connected but I can not figure out how to listen to all messages the client (CasparCG) sends.
I assume I should somehow use the OSC.ReadData function but I haven't figured out how to use it. Do I need to make changes to your lib or can I access this data as it is?
Thanks in advance!
I assume I should somehow use the OSC.ReadData function but I haven't figured out how to use it. Do I need to make changes to your lib or can I access this data as it is?
Thanks in advance!
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: OpenSoundControl (OSC) in Rev?
Well, I don't know anything about the CasparCG server itself, so you'll have to rely on someone else if you need more detailed information about that, but the procedure for my board is to send a message and then wait for the response.
For instance to get the value of analog input 3 I would say
But my guess is that the responses from the CasparCG server will differ from the ones returned from my board, so you may want to either add or change the switch statement in OSC.ReadData or just override it in your code (if you use the libOSC code as a backscript then your handlers of the same name will have precendence).
...and bear in mind that I wrote the library in 2006 for a specifi project, and probably would do some things differently today.
I may update the library some day when time permits.
For instance to get the value of analog input 3 I would say
Code: Select all
UpdateAnalogData 3
Code: Select all
local sReadData
-- override the default handler for the listener
ON Analogin.Listener pParams
put pParams into sReadData
END Analogin.Listener
---------------------------------------------------------------------------
-- UpdateAnalogData
--
-- Get the channel A/D value and display it
---------------------------------------------------------------------------
command UpdateAnalogData pChannel
local tData
OSC.Send "/analogin/" & pChannel & "/value"
OSC.ReadData -- read the incoming data and leave it in sReadData
-- convert hex to decimal
put OSC.HexToDecimal(sReadData) into tData
return tData
end UpdateAnalogData
Code: Select all
insert script of stack 'libOSC" into back
on OSC.ReadData
-- your code here would get executed *instead* of the library OSC.ReadData handler
end OSC.ReadData
I may update the library some day when time permits.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: OpenSoundControl (OSC) in Rev?
CasparCG sends realtime data and events as soon as you are connected like this:
http://casparcg.com/wiki/CasparCG_OSC_Protocol
So it seems that the best way to do it is to override your OSC.ReadData. Thanks!
http://casparcg.com/wiki/CasparCG_OSC_Protocol
So it seems that the best way to do it is to override your OSC.ReadData. Thanks!
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: OpenSoundControl (OSC) in Rev?
OK. Post back here if you have problems or an overloaded function if you get it working - I think it will help others working with CasparCG as well.
What I really should do is separate the switch statement that deals with the message payload into its own function so that just that part can be overloaded instead of having to parse the header in the overload function. Someday when I get the time.
What I really should do is separate the switch statement that deals with the message payload into its own function so that just that part can be overloaded instead of having to parse the header in the overload function. Someday when I get the time.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: OpenSoundControl (OSC) in Rev?
Hi guys. thanks for the help. hopefully i can tackle this some time this week. Ive been so overwhelmed with other stuff i havent had a chance to play with OSC in a while
Re: OpenSoundControl (OSC) in Rev?
Any chance OSC will become an included communication protocol in LC?
If been watching this for years, and supported the Kickstarter with this hope.
If been watching this for years, and supported the Kickstarter with this hope.
Re: OpenSoundControl (OSC) in Rev?
I created a bug request as feature request for TUIO, it's an opensource Touch protocol for all desktops mac, win, linux etc. check here http://quality.livecode.com/show_bug.cgi?id=20655
It is based on OSC, you can check here https://www.tuio.org/
on that website are API etc for almost all languages except Livecode. We can wait for LC to implement it or try to do it ourselfs with help from others with LCB.
I just tried a bit LCB a few weeks ago and have to try more, but not enough time yet.
Also probably a bit to dificult for me to use the C++ or JAVA API's and use LCB to get the grip of it, but it would be openeing another world of possibilities using that touch protocol.
But since TUIO is based on OSC, if one would work i guess the other with some minor changes will too.
It is based on OSC, you can check here https://www.tuio.org/
on that website are API etc for almost all languages except Livecode. We can wait for LC to implement it or try to do it ourselfs with help from others with LCB.
I just tried a bit LCB a few weeks ago and have to try more, but not enough time yet.
Also probably a bit to dificult for me to use the C++ or JAVA API's and use LCB to get the grip of it, but it would be openeing another world of possibilities using that touch protocol.
But since TUIO is based on OSC, if one would work i guess the other with some minor changes will too.
Re: OpenSoundControl (OSC) in Rev?
Hi @mwieder ... Sorry i still no luck to follow your instructionmwieder wrote: ↑Sat Jan 10, 2015 3:29 amThat's pretty close. Here's what I do (after adding the "libOSC" stack as a substack and making any appropriate changes to the constants that define the environment)
In the card script:and then in a button script you'll want something likeCode: Select all
on openStack insert the script of stack "libOSC" into back -- now the handlers in the stack script are available to all scripts OSC.SetUDPMode true OSC.Open end openStack on closeStack OSC.Close remove the script of stack "libOSC" from back end closeStack
Code: Select all
on mouseUp OSC.Send "/control/mark1/play 1" end mouseUp
what i'm tring to do is
controlling Resolume via OSC by livecode apps
here what i have done
In Resolume
- set OSC Input to active, in port 7000
In Livecode:
- Create a Stack (Draco OSC)
- Copy your libOSC script into (Draco OSC) Stack
- Change ipAddress and port
Code: Select all
-- NOTE: change these for your system as appropriate
constant kOSCUSBPort = "COM3:"
constant kOSCIPAddress= "127.0.0.1"
constant kOSCUDPPort = "7000"
- Create button script
on mouseUp
OSC.Send "/track4/connect 1"
end mouseUp
do i miss something?
This is my Livecode file
https://drive.google.com/file/d/16kPndH ... sp=sharing
Comment and help would be appreciate
Thanks
Gilar | from INDONESIA
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: OpenSoundControl (OSC) in Rev?
Well, it's been a dozen years now since I wrote this library and a good five years since I've looked at the code, I'll see what I can do...
first of all, it's not necessary (and maybe a bad idea) to copy the OSC library into the main stack script. You've already got it in a substack and you're putting it into play with the openStack handler, so that should be sufficient.
Next, I'm assuming you changed the network address in the library (kOSCIPAddress) to the actual ip address of the resolume device. If not then you're only sending messages to yourself, and that won't do anything useful. Are you able to ping the address of the resolume successfully?
OSC.SetUDPMode true will work in your case, but the officially supported way to call that is OSC.SetUDPMode 1 (and yes, I realize that some years ago I posted "true"). The handler for that command really should be rewritten to handle "true" and "false" as well. Someday.
Are you sure you want to be in UDP mode? I can't tell from the resolume manual. You might try OSC.SetUDPMode 0 instead.
Are you getting an error dialog after the OSC.Send command?
What platform are you on? It looks to me like I wrote the original library for OSX to be a usb connection only because I wrote this for a specific hardware board.
first of all, it's not necessary (and maybe a bad idea) to copy the OSC library into the main stack script. You've already got it in a substack and you're putting it into play with the openStack handler, so that should be sufficient.
Next, I'm assuming you changed the network address in the library (kOSCIPAddress) to the actual ip address of the resolume device. If not then you're only sending messages to yourself, and that won't do anything useful. Are you able to ping the address of the resolume successfully?
OSC.SetUDPMode true will work in your case, but the officially supported way to call that is OSC.SetUDPMode 1 (and yes, I realize that some years ago I posted "true"). The handler for that command really should be rewritten to handle "true" and "false" as well. Someday.
Are you sure you want to be in UDP mode? I can't tell from the resolume manual. You might try OSC.SetUDPMode 0 instead.
Are you getting an error dialog after the OSC.Send command?
What platform are you on? It looks to me like I wrote the original library for OSX to be a usb connection only because I wrote this for a specific hardware board.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: OpenSoundControl (OSC) in Rev?
Thank you so much for coming back again on this thread ....
I use resolume on local host so i change the IP into localhost sometimes i change into 127.0.0.1Next, I'm assuming you changed the network address in the library (kOSCIPAddress) to the actual ip address of the resolume device. If not then you're only sending messages to yourself, and that won't do anything useful. Are you able to ping the address of the resolume successfully?
Is it really need to play with another Machine?
Because i tested with CasparCG Client which has OSC command it is ok to control resolume in local machine.
I read about OSC with TCP or UDP and most of it use UDP, but Actually I'm not sure about it.Are you sure you want to be in UDP mode? I can't tell from the resolume manual. You might try OSC.SetUDPMode 0 instead.
for the first try, i just want it work.
I'm using Windodws 10Are you getting an error dialog after the OSC.Send command?
What platform are you on? It looks to me like I wrote the original library for OSX to be a usb connection only because I wrote this for a specific hardware board.
No. I got no Error
Then I check if i close resolume
i got this Errror Error::7000,Error10038 on socket
I'm trying to trace my message (OSC.Send "/track3/connect 1") and put it into field "testMessage_fld"
Code: Select all
on OSC.Send pMessage
local tParsedMessage
local tCatMessage
local tKeys
local tHex
if blnIsConnected then
put OSC.format(pMessage) into tParsedMessage
put the keys of tParsedMessage into tKeys
repeat for each line tKey in tKeys
put tParsedMessage[tKey] after tCatMessage
end repeat
put tCatMessage into field "testMessage_fld" of card "games_crd"
if blnIsUDP then
write tCatMessage to socket (kOSCIPAddress & ":" & kOSCUDPPort)
else
if the platform contains "Win" then
write numtochar(kOSCEnd) & tCatMessage & numtochar(kOSCEnd) to driver sUSBOutput
else
write numtochar(kOSCEnd) & tCatMessage & numtochar(kOSCEnd) & cr to driver sUSBOutput
end if
end if
if the result is not empty then
answer "Send::" && the result
end if
end if
end OSC.Send
Code: Select all
,i/track3/connect
Gilar | from INDONESIA
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: OpenSoundControl (OSC) in Rev?
No, it should be /track3/connect,iThis is the result
CODE: SELECT ALL
,i/track3/connect
is this ok?
And then the value you're sending (in this case a 1) will be binary-encoded, so you won't see the actual value in your field without decoding it back again.
But since you're seeing the other values out of order, try inserting a sort command in the OSC.Send handler:
Code: Select all
if blnIsConnected then
put OSC.format(pMessage) into tParsedMessage
put the keys of tParsedMessage into tKeys
sort tKeys ascending numeric # this will return the keys in the proper order
repeat for each line tKey in tKeys
put tParsedMessage[tKey] after tCatMessage
end repeat
The resolume device looks like a great piece of equipment, but I don't have one here so I'm just having to guess about code that's a dozen years old.
Here's a link to what the OSC packet format should look like:
http://opensoundcontrol.org/spec-1_0
i.e., address string comma type tag binary-encoded data
all padded out to 4-byte boundaries
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: OpenSoundControl (OSC) in Rev?
Ok. now it like what suppoused to be. /track3/connect,i
Now it's working .... thank you very muchand see if that gets things working.
Ok. I need to learn it ...The resolume device looks like a great piece of equipment, but I don't have one here so I'm just having to guess about code that's a dozen years old.
Here's a link to what the OSC packet format should look like:
http://opensoundcontrol.org/spec-1_0
i.e., address string comma type tag binary-encoded data
all padded out to 4-byte boundaries
Sorry more question ...
can we receve message from resolume after we do OSC.Send "/track3/connect 1" ?
it means if resolume received this command.
i try this /layer1/video/opacity/values (Float 0.0 - 1.0) ---> OSC.Send "/layer1/video/opacity/values 0.5"
but it's not working, it seem would be different too for string, bolean, and double.
- /layer1/video/opacity/values 0.5 ----- > /layer1/video/opacity/values,f ---- > the opacisty change to 0
- /layer1/video/opacity/values 1.0 ----- > /layer1/video/opacity/values,i ---- > nothing change in opacity
Thanks
Gilar | from INDONESIA
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: OpenSoundControl (OSC) in Rev?
Gilar- haven't forgotten about you here. I downloaded Resolume Avenue over the weekend and have been having too much fun playing with it.
...and in looking things over, I realize that the OSC library I wrote was very much oriented towards the board I was working with, and could easily be stripped down to the OSC routines themselves, isolating the makeboard controller functions to a separate script. That makes working with resolume a bit easier, especially because I wrote the routines to read back from an OSC source *very* specific to my board.
And like you, I can send messages to resolume but can't yet read them back.
...and in looking things over, I realize that the OSC library I wrote was very much oriented towards the board I was working with, and could easily be stripped down to the OSC routines themselves, isolating the makeboard controller functions to a separate script. That makes working with resolume a bit easier, especially because I wrote the routines to read back from an OSC source *very* specific to my board.
And like you, I can send messages to resolume but can't yet read them back.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: OpenSoundControl (OSC) in Rev?
Hi ... finally you installed Resolume ...
so it would be more exploring.
Do you think OSC could replace video file or image on a clip, like in CasparCG or vMix?
I mean ... is it possible to change the url path of the clip then play it?
Gilar | from INDONESIA
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: OpenSoundControl (OSC) in Rev?
Gilar-
Give this a try... I reworked the library to keep just the pertinent routines in the stack itself and then created a sample resolume card (click the "resolume" button to go there) that hardcodes record on/off buttons, has a text field for experimenting with sending other commands, and logs the messages coming back from resolume into a scrolling text field.
Watch what you wish for though... there are a *lot* of messages coming back, especially when you're looping. You may want to filter for just the messages you're interested in.
Trying to see what resolume supports in the way of OSC messages seems to be a bit hit or miss. I haven't found detailed documentation on those. And I'm not at all sure there's support for uploading clips via OSC.
Give this a try... I reworked the library to keep just the pertinent routines in the stack itself and then created a sample resolume card (click the "resolume" button to go there) that hardcodes record on/off buttons, has a text field for experimenting with sending other commands, and logs the messages coming back from resolume into a scrolling text field.
Watch what you wish for though... there are a *lot* of messages coming back, especially when you're looping. You may want to filter for just the messages you're interested in.
Trying to see what resolume supports in the way of OSC messages seems to be a bit hit or miss. I haven't found detailed documentation on those. And I'm not at all sure there's support for uploading clips via OSC.
- Attachments
-
- libOSC.livecode.zip
- (34.79 KiB) Downloaded 190 times
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev