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: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

bschiett
Posts: 1
Joined: Wed Jul 28, 2010 8:14 pm

OpenSoundControl (OSC) in Rev?

Post by bschiett » Wed Jul 28, 2010 8:16 pm

Hi,

Is there a way to create a server application in revolution that will handle network packets that come in on a certain port?

For example, if one wants to create an application that responds to OSC messages?

http://opensoundcontrol.org/

see also http://www.audiomulch.com/~rossb/code/oscpack/

Thanks,
B

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: OpenSoundControl (OSC) in Rev?

Post by Mark » Wed Jul 28, 2010 11:10 pm

Hello B,

I don't know anything about OBC, but RunRev can communicate through sockets. Just read the manual. You can also search the dictionary for "socket".

Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

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

Re: OpenSoundControl (OSC) in Rev?

Post by DusX » Wed Mar 27, 2013 7:00 pm

I would also like to know if there is a library or something for easy OSC (open sound control ) messaging in LiveCode.
If not does anyone have experience doing this via the socket support?

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

Re: OpenSoundControl (OSC) in Rev?

Post by mwieder » Fri Mar 29, 2013 8:45 pm

I did an OSC library some years ago. I'll see if I can dig it up for you.

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

Re: OpenSoundControl (OSC) in Rev?

Post by DusX » Fri Mar 29, 2013 9:46 pm

That would be awesome.. OSC is the primary reason I want to work in LiveCode..
I really want to use live code to create custom UI's for my OSC enabled visual performance packages.

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

Re: OpenSoundControl (OSC) in Rev?

Post by mwieder » Fri Apr 05, 2013 12:39 am

Whew-

Took a while to dig this up, and it's dated 2008, so the code may not be pretty, but maybe it'll give you something to start with.
This is a substack for a controller I wrote for a general-purpose I/O board that's no longer being made.
Some of it will be very specific to the MakeBoard: toggling the I/O controls, reading the DACs, etc, but the basic OSC drivers should work fine.
Strip out what you don't need and add what you do.
It works (or at least worked in 2008) on Windows and OSX. No linux support because I never built the usb handlers (linux versions of ioreg, etc).
Good luck.
Attachments
libOSC.zip
LiveCode library to use OSC
(28.57 KiB) Downloaded 515 times

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

Re: OpenSoundControl (OSC) in Rev?

Post by DusX » Fri Apr 05, 2013 1:59 am

This is great.. thank-you!
I think it might take me sometime before I have the know how to use this, but now I am motivated ;)

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

Re: OpenSoundControl (OSC) in Rev?

Post by mwieder » Fri Apr 05, 2013 6:46 am

Cool. Lemme know if you have problems. Looking it over, there's a lot I could have stripped out that's specific to the MakeBoard, but the basic protocols should work and you can build out from there.

Have fun.

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

Re: OpenSoundControl (OSC) in Rev?

Post by Da_Elf » Fri Jan 02, 2015 1:42 am

Just curious how livecode would send OSC commands. I'm looking to bridge livecode and casparCG client using OSC commands which casparCG client can receive. Id assume i need to open socket to the localhost:port number then would i just write to that socket? apparently the command thats supposed to be sent to casparCG is "/control/layername/play 1"

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

Re: OpenSoundControl (OSC) in Rev?

Post by mwieder » Wed Jan 07, 2015 4:48 am

Yeah, either a socket or a serial port. I provided for both approaches in the library.

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

Re: OpenSoundControl (OSC) in Rev?

Post by Da_Elf » Thu Jan 08, 2015 9:25 pm

the library looks really good. im trying to communicate with another software. currently im using PD to send the osc messages but would like to bypass that and go direct from livecode. this is my setup in PD. Still trying to figure out exactly how i use the library to reproduce this.
error3.JPG
im guessing its not as easy as this

Code: Select all

on mouseUp
   OSC.Open
   OSC.Send "/control/mark1/play 1"
   OSC.Close
end mouseUp

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

Re: OpenSoundControl (OSC) in Rev?

Post by mwieder » Sat Jan 10, 2015 3:29 am

That'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:

Code: 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
and then in a button script you'll want something like

Code: Select all

on mouseUp
  OSC.Send "/control/mark1/play 1"
end mouseUp

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

Re: OpenSoundControl (OSC) in Rev?

Post by Da_Elf » Sat Jan 10, 2015 3:47 am

wow, it works. perfect :)
if the only commands im going to be using are those listed there with the message sent changed would i need all of those items in the library our could i start going through it and slimming it down. Im unsure if having all of those lines of code there would slow down the program

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

Re: OpenSoundControl (OSC) in Rev?

Post by mwieder » Sat Jan 10, 2015 5:26 am

Yay!

You could trim things down if you choose, but the script gets compiled down to a pretty compact intermediate code by the engine when it's loaded, so that long names and comments and unused code, etc, don't slow things down.

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

Re: OpenSoundControl (OSC) in Rev?

Post by Da_Elf » Sat Jan 10, 2015 11:56 am

cool. Thanks. for a 6 year old code its still pretty useful

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”