Page 1 of 3

OpenSoundControl (OSC) in Rev?

Posted: Wed Jul 28, 2010 8:16 pm
by bschiett
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

Re: OpenSoundControl (OSC) in Rev?

Posted: Wed Jul 28, 2010 11:10 pm
by Mark
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

Re: OpenSoundControl (OSC) in Rev?

Posted: Wed Mar 27, 2013 7:00 pm
by DusX
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?

Re: OpenSoundControl (OSC) in Rev?

Posted: Fri Mar 29, 2013 8:45 pm
by mwieder
I did an OSC library some years ago. I'll see if I can dig it up for you.

Re: OpenSoundControl (OSC) in Rev?

Posted: Fri Mar 29, 2013 9:46 pm
by DusX
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.

Re: OpenSoundControl (OSC) in Rev?

Posted: Fri Apr 05, 2013 12:39 am
by mwieder
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.

Re: OpenSoundControl (OSC) in Rev?

Posted: Fri Apr 05, 2013 1:59 am
by DusX
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 ;)

Re: OpenSoundControl (OSC) in Rev?

Posted: Fri Apr 05, 2013 6:46 am
by mwieder
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.

Re: OpenSoundControl (OSC) in Rev?

Posted: Fri Jan 02, 2015 1:42 am
by Da_Elf
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"

Re: OpenSoundControl (OSC) in Rev?

Posted: Wed Jan 07, 2015 4:48 am
by mwieder
Yeah, either a socket or a serial port. I provided for both approaches in the library.

Re: OpenSoundControl (OSC) in Rev?

Posted: Thu Jan 08, 2015 9:25 pm
by Da_Elf
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

Re: OpenSoundControl (OSC) in Rev?

Posted: Sat Jan 10, 2015 3:29 am
by mwieder
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

Re: OpenSoundControl (OSC) in Rev?

Posted: Sat Jan 10, 2015 3:47 am
by Da_Elf
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

Re: OpenSoundControl (OSC) in Rev?

Posted: Sat Jan 10, 2015 5:26 am
by mwieder
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.

Re: OpenSoundControl (OSC) in Rev?

Posted: Sat Jan 10, 2015 11:56 am
by Da_Elf
cool. Thanks. for a 6 year old code its still pretty useful