OpenSoundControl (OSC) in Rev?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Nicke
Posts: 36
Joined: Thu Nov 28, 2013 11:19 am
Location: Helsinki, Finland

Re: OpenSoundControl (OSC) in Rev?

Post by Nicke » Sun Feb 08, 2015 7:21 pm

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!

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2695
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: OpenSoundControl (OSC) in Rev?

Post by mwieder » Sun Feb 08, 2015 8:56 pm

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

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
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).

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
...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.

Nicke
Posts: 36
Joined: Thu Nov 28, 2013 11:19 am
Location: Helsinki, Finland

Re: OpenSoundControl (OSC) in Rev?

Post by Nicke » Mon Feb 09, 2015 9:13 am

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!

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2695
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: OpenSoundControl (OSC) in Rev?

Post by mwieder » Mon Feb 09, 2015 8:29 pm

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.

Da_Elf
Posts: 308
Joined: Sun Apr 27, 2014 2:45 am

Re: OpenSoundControl (OSC) in Rev?

Post by Da_Elf » Mon Feb 16, 2015 1:58 pm

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

DusX
Posts: 4
Joined: Wed Mar 27, 2013 6:55 pm

Re: OpenSoundControl (OSC) in Rev?

Post by DusX » Fri Mar 30, 2018 1:48 am

Any chance OSC will become an included communication protocol in LC?
If been watching this for years, and supported the Kickstarter with this hope.

sphere
Posts: 687
Joined: Sat Sep 27, 2014 10:32 am
Location: the Netherlands

Re: OpenSoundControl (OSC) in Rev?

Post by sphere » Mon Apr 02, 2018 9:46 am

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.
Please, stop quoting things my brother did not say. Thank you. Hans Zweistein.

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”