OSC commands using C#

1,569 views
Skip to first unread message

var...@gmail.com

unread,
Feb 4, 2014, 4:50:57 PM2/4/14
to vpt-...@googlegroups.com
Hey everyone,

I’m trying to send OSC commands via UDP protocol from a program written in C# using VisualStudio Windows App Form. The send code when a button is pressed is:

string IP = “127.0.0.1″;
int port = 6666;
byte[] packetData = System.Text.ASCIIEncoding.ASCII.GetBytes(“/presetnext”);
IPEndPoint ep = new IPEndPoint(IPAddress.Parse(IP), port);
Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
client.SendTo(packetData, ep);

However VPT isn’t detecting any OSC commands when OSC IN is being monitored. Any ideas to make this work? Any reply is greatly appreciated!


hc

unread,
Feb 6, 2014, 4:17:02 AM2/6/14
to vpt-...@googlegroups.com
I don´t know C so hard for me to know if your code is right. You could test it with another app that receives osc.

As another test option, you could open the patch below from VPT (or from Max runtime), don´t use 6666 as port though as only one udp object at a time can listen to a particular port:

http://nervousvision.com/vpt/xtension/listen_port6665_b.maxpat.zip

Otherwise, maybe it´s smarter to test with a osc message that you can easily see the result of, like /1layer/fade .5

hc
Message has been deleted
Message has been deleted

var...@gmail.com

unread,
Feb 6, 2014, 6:46:21 PM2/6/14
to vpt-...@googlegroups.com
Hi HC,

thanks a million for the reply. I downloaded a program called SocketSniff to monitor the localhost ports and confirmed that my program is definitely sending a command (/1layer/fade 0.5) to the local host. So great idea with the third party program.

However VPT is still not receiving. I think the problem may be with the addressing of the computer that VPT is running on. Is the address "127.0.0.1" necessarily universal for every localhost - or can this change for different PC's? The help page tells me theres an 'ip check' button which I can click to confirm the localhost address - however I can't see this button on my version of VPT (the spot where the button is meant to be is just blank). Is there a way to retrieve the 'ip check' button?

Any reply is appreciated. Chris.


hc

unread,
Feb 10, 2014, 4:22:07 AM2/10/14
to vpt-...@googlegroups.com
Hi again,
strange that you don´t get it to work. I have tested it with openframeworks, processing, pd, max and TouchOSC ++ without any problems. I guess you could try to use the ip assigned to your computer instead of the localhost option (but localhost should work though). The ip check button is gone (because of java dependency) so the documentation hasn´t been updated properly.

I am curious if you get the videotrigger or soundtrigger apps to work, since they use OSC ove localhost to communicate with VPT.

hc

var...@gmail.com

unread,
Feb 12, 2014, 12:54:14 AM2/12/14
to vpt-...@googlegroups.com
Hi again,

looking at the Max Runtime window, it looks as though I'm getting an error message related to the udpreceive object whenever I try to send a command:

"OSC Bad Messgae name string: DataAfterAlignedString: Unreasonably long string dropping entire message." I've searched online but couldn't find a solution - except perhaps the command may not be in the correct OSC format. The command I'm using is a string, "/1layer/fade .5 " (with a space after the 5 to make it 16 bytes).

Therefore VPT is successfully receiving the message but not processing it since it may be in the wrong format. Any thoughts on this error message?

Thanks again!

Chris.

hc

unread,
Feb 13, 2014, 4:14:50 AM2/13/14
to vpt-...@googlegroups.com
it seems to me that your udp message might not be terminated properly. "DataAfterAlignedString" I assume meen the data following the / messages. Do you have a return at the end of your message? If not it will probably just keep adding incoming OSC messages until the buffer is full.

var...@gmail.com

unread,
Feb 13, 2014, 5:00:48 PM2/13/14
to vpt-...@googlegroups.com
Hi Hc,

thanks for answering. It all works great now!

Turns out the message wasn't correctly formatted as OSC. I found a library which had inbuilt classes for formatting OSC messages really simply. If anybody has the same problem with C# they should download the Ventuz.OSC library (attached).

Thanks for all your help! Great program.

Chris.
Ventuz.OSC.zip

hc

unread,
Feb 16, 2014, 10:39:40 AM2/16/14
to vpt-...@googlegroups.com
glad you got it to work!


On Tuesday, February 4, 2014 10:50:57 PM UTC+1, var...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages