Open Sound Control
"Open Sound Control (Osc) is an open, transport-independent, message-based protocol developed for communication among computers, sound synthesizers, and other multimedia devices." (from http://opensoundcontrol.org/spec-1_0)
There are a number of Osc implementations, including another in C#, but I decided to roll my own and make it freely available. This implementation sits atop the .NET 4.5 Framework and uses TCP or UDP as the transport protocol. It includes support for Osc Messages and Bundles, and supports the following payload data types: Int32, Int64, Float, Double, String, Blob (byte array), Osc TimeTag, ASCII character, boolean, Nil, Infinitum, and RGBA color.
The OscServer class is at the heart of the system, and includes support for unicast, broadcast, and multicast. As OSC packets, bundles, and messages are received corresponding events are fired. Additionally, the system will (optionally) filter Osc address patterns that the user registers.
The package includes simple client and server examples in both C# and Visual Basic.NET.
4/27/2013 Update
I’ve begun hosting this project on bitbucket.org. I’m leaving this page here for the time being, but please refer to the Bitbucket repository for code updates and issue tracking.
Archive
Release Notes (version 2.0)
- Updated to .NET 4.0 Framework and Visual Studio 2010.
- Overhauled TCP transport and corrected message framing.
- Added support for Osc TimeTag, ASCII character, boolean, Nil, Infinitum, and RGBA color.
- Events now properly raised for nested Osc bundles and messages.
- Much improved documentation.
- Simplified and separated out functionality in the Bespoke.Common library.
- Changed the default expected byte order (endianness) back to Big endian (as per the OSC specification).
- Improved demo applications.
- General refactoring.
Release Notes (version 1.7.0)
- Fixed TcpServer spinning in its listener thread.
- Changed the default expected byte order (endianness) from Big to Little endian.
- Added OscPacket.LittleEndianByteOrder property to allow users to change the expected byte order.
- Fixed asynchronous, inline data handling within TcpServer. Default data handling behavior for TCP messages is now asynchronous (previously synchronous).
- Added explicit project configurations for x64 platforms and have included pre-compiled x64 binaries (along with x86 binaries).
Release Notes (version 1.6.0.0)
- Added UDP port reuse (multi-cast only). This allows for multiple simultaneous OscServer instances (or other services) bound to the same port.
- Added OscServer.ConsumeParseExceptions (enabled by default) which suppresses parsing exceptions caused by malformed OSC packets. Disable this option to allow such exceptions to bubble up through the OscServer.
Previous Revisions
[...] Open Sound Control [...]
I’ve been looking for an open source OSC library for .net that works well. You made my day!
Thanks Ben. I appreciate the positive feedback.
Paul
This is working great!
Only thing was I found that the UDP listener thread was polling for available bytes and using 100% CPU in UdpServer.Start.
I commented that out as below so it block in Receive until packets arrive. Any reason this shouldn’t work?
while (mAcceptingConnections)
{
// This was eating CPU, so block until we get data
// if (udpClient.Available > 0)
// {
IPEndPoint remoteEndPoint = null;
byte[] data = udpClient.Receive(ref remoteEndPoint);
if (data != null && data.Length > 0)
{
OnDataReceived(new UdpDataReceivedEventArgs(remoteEndPoint, data));
}
// }
}
Hi Rich,
You’re right, doing a spin like that was a poor decision — and guaranteed to peg the CPU. The problem with not checking the udpClient.Available property and simply blocking on the Receive call, is that you can’t interrupt the call — even with a Thread.Abort or Thread.Interrupt. This means, that calling Stop on the UdpServer, which toggles the volatile bool mAcceptingConnections, won’t do anything until the Receive call finishes. If the UdpServer is continuously receiving data, you’ll never notice this. But if not, the Receive call will never finish and the Stop won’t actually stop.
So a better route is a paired BeginReceive/EndReceive call for asynchronous communication without a while loop. I’ve written this and will upload a new release shortly.
Paul
[...] Open Sound Control [...]
Rich,
I’ve uploaded a new release which addresses the performance issue. Thanks for the heads up.
Paul
Hey Paul,
I’ve encountered an unhandled error exception in the UdpServer object used in the client on line 276:
byte[] data = udpClient.EndReceive(asyncResult, ref ipEndPoint);
An unhandled exception of type ‘System.Net.Sockets.SocketException’ occurred in System.dll
Additional information: The I/O operation has been aborted because of either a thread exit or an application request
I corrected it by blocking lines 276 to 280 and catching the socket exception, while leaving the receive function call in the original try catch.
Is there any reason why this shouldn’t work for continual use?
Chris
Hi Chris,
I haven’t encountered that error in any of my testing. The EndReceive() call is paired with the BeginReceive() calls that originate in the Start() method and are continued after each EndReceive() completes. I assume what you mean by “blocking out lines 276-280″ is that you’re commenting out those calls — and within that the OnDataReceived() call is pretty critical. Also, if you’ve changed BeginReceive() to Receive(), you’re changing the behavior from asynchronous communication to a blocking call.
In short, I’m not entirely clear on why you’re seeing the error and what your fix entails. If you’d like to send me your changes, I’d be happy to take a look. My email address is pvarchol [at] bespokesoftware.org.
One last thought… are you interrupting the UdpServer thread using a Thread.Kill() anywhere? And is this exception happening in the included demo client/server?
Paul
Chris,
I’ve found the problem. With the 1.1 release of the library I changed to asynchronous communication using BeginReceive()/EndReceive(). However, I didn’t change the OscServer.Start() method — which called the underlying UdpServer.Start() in a separate thread. This was necessary in version 1.0 because the UdpServer didn’t use asynchronous communication and I didn’t want to block on the Start() call.
When I went to asynchronous communication, I left the Start call in its own thread, but this thread now exists very rapidly. I found a 1-line blurb about this at: http://msdn.microsoft.com/en-us/library/dxkwh6zw.aspx which states that
“All I/O initiated by a given thread is canceled when that thread exits. A pending asynchronous operation can fail if the thread exits before the operation completes.”
Interestingly, I didn’t see this on my development machine — but when I tested this on a slightly faster computer the SocketException with error code 995 cropped up. This is the nature of thread exceptions and concurrent code — sometimes the bugs are intermittent. Anyhow, I’ve fixed the problem simply by making OscServer.Star()t call UdpServer.Start() in the OscServer thread. I’ve released version 1.2 of the library which includes this change.
Paul
Paul,
Thank you for the quick response and solution! Much appreciated. I’ll continue playing with it today
Chris
[...] Open Sound Control [...]
how do you reference an appended value to an oscmessage from OscMessageReceivedEventArgs
Message.append(“Hello”);
You reference all appended values through the Data property — an array of objects. For example: mMessage.Data[index].
Hi,
thank you very much for providing this library.
Is there any other example application (demo) available? Or a more detailled description of the included demo?
Who can help me to understand what happens here in the demo (server)? :
sMessage.Append(memoryStream.ToArray());
Why the server creates the OSC message?
Sorry for my stupid questions, but I would like to understand this application.
Thanks
Best regards Frank
Hi Frank,
The OSC message is created before the statement you’re referencing. Specifically, the message is created on line 24 of Program.cs with the following:
sMessage = new OscMessage(new IPEndPoint(IPAddress.Loopback, Port), AliveMethod, sOscClient);
That statement constructs a new OscMessage instance with the source endpoint of the local computer (IPAddress.Loopback and a port number), an OSC address (AliveMethod == “/osctest/alive”), and an OscClient instance if the transport type is TCP/IP (default is UDP).
With UDP, the OscMessage is transmitted with sOscMessage.Send(Destination). Using TCP it’s simply sOscMessage.Send().
The statement you asked about:
sMessage.Append(memoryStream.ToArray());
Appends a piece of data to the message. In this demo, that piece of data is a JPEG image that gets loaded into a MemoryStream object. The MemoryStream class has a ToArray() method that converts its contents to a byte array. The Bespoke OSC Library supports byte arrays, integers (32- and 64-bit) , floats, doubles, and strings. Thus, the OscMessage.Append() method is a generic method that accepts all of these data types.
Hope this helps.
Paul
Hi! Thanks for this perfect and clean implementation.. though I’m wondering how I can create a UDP client which listens on port 3333?
I’ve been looking at the samples but found it a bit confusing that the ‘client’ examples creates a OscServer object and that the ‘server’ example creates a OscClient object.. ?
Did I miss something?
Thanks
Roxlu
Hi Roxlu,
I know, the terms “client” and “server” are a bit confusing. This terminology comes from the OSC specification (http://opensoundcontrol.org/spec-1_0). It states: “The unit of transmission of OSC is an OSC Packet. Any application that sends OSC Packets is an OSC Client; any application that receives OSC Packets is an OSC Server.”
So, if you’re trying to create an application that listens for OSC packets, you’ll create a Bespoke.Common.Osc.OscServer object. In my OscDemo project (included with the distribution) I name the two sub-projects Client and Server with the more traditional meaning of the terms. In this demo, the “Client” project listens for OSC packets and the “Server” project sends them.
Creating an OscServer object for UDP, bound to the loopback address (127.0.0.1) and port 3333 is as simple as:
OscServer oscServer = new OscServer(TransportType.Udp, IPAddress.Loopback, 3333);
Then you’ll attach a handler to the oscServer.MessageReceived event and start the server with oscServer.Start();
Hope this helps.
Paul
Hello!
I’m having some trouble getting this library working in VB.NET.
I’ve done my best to convert the client demo from c# to vb.net
however theres just one line that’s troubling me.
sOscServer.MessageReceived = new OscMessageReceivedHandler(sOscServer_MessageReceived);
Im assuming this add’s the handler for when a message is recieved. I Wondered if you could help me? or provide a basic VB.NET client (Listen on a port and output any data)
any help is appriciated. Thanks a lot, Rob.
Hi Rob,
Yes, the code in question attaches a handler to the MessageReceived event. In VB.NET this is accomplished by declaring the OscServer object “WithEvents” and creating a function with the suffix: “Handles OscServerVariableName.MessageReceived”.
I went a step further and ported the C# samples to VB.NET and uploaded them with revision 1.4. If you have any questions just shout.
Paul
[...] Open Sound Control [...]
Paul, Thanks a lot.
In my code I mistaked WithEvents for AddHandler.
The source code you provided is working flawlessly, can’t thank you enough for your help.
Rob.
Hi Paul!
I#m using your lib to build a tool to remote control Resolume Avenue via OSC. My Problem is that after I initialised the application and the oSC-sender like this:
Dim adress As IPAddress = IPAddress.Parse(“127.0.0.1″)
Dim port As Integer = 7000
Dim udp As TransportType = TransportType.Udp
Dim oscMessage As OscMessage
Dim oscClient As New OscClient
oscClient.Connect(adress, port)
oscMessage = New OscMessage(New Net.IPEndPoint(adress, port), “/composition/disconnectall 1″, oscClient)
But everytime I call these codelines i get an Error which says :”System.Net.Sockets.SocketException wurde nicht behandelt.
ErrorCode=10061
Message=”No connection could be made because the target machine actively refused it 127.0.0.1:7000″
NativeErrorCode=10061
Source=”System”
StackTrace:
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
……..”
I have no clue how to fix this.
When the app tries to connect to 127.0.0.1:7000 my firewall asks to pass the programm an i let it pass.
I would like to hear from you!
mfg deadlock
Hi deadlock,
It’s likely that you aren’t intending to use TCP as the transport protocol; but wish to use UDP instead. However, the OscClient class is specifically for TCP communication. Have a look at the Visual Basic sample included with the distribution for the usage differences between TCP and UDP. UDP is a connection-less protocol and requires no explicit connection (which is what you’re invoking with the call to oscClient.Connect()). Instead, you only need to use the OscMessage class and its Send() method.
Paul
Hi again Paul!
Thanks for your helping hand. Your tip showed me the right way to do it. I will post my source code for everyone:
””””””””””””””’
Dim adress As IPAddress = _ IPAddress.Parse(“127.0.0.1″)
Dim port As Integer = 7123
Dim destination As IPEndPoint = _ Net.IPEndPoint(adress.Loopback, port)
Dim oscMessage As OscMessage
oscMessage = New OscMessage(destination, “/layer2/clip0/connect 1″, oscClient)
oscMessage.Send(destination)
”””””””””””””””””’
oscClient is globaly declared without further settings.
Now i modified your sample code so it is recieving the message at port 7123.
But, unfortunately , Resolume Avenue is not reacting to it. I hope its just problem tracing and solving.
( If you have some time you can look yourself into the application. The demo is freely available at http://www.resolume.com/download/)
But thanks for all!
deadlock
Hi again!
I’ve finally found out, that I forgot to give the adress a value via oscMessage.Append(value).
Now everything works fine!
Thanks again for all the help. Pretty handy Site and library!
Glad to hear you’ve found a solution and that the software’s been useful for you.
Paul
[...] scriptable and flexible audio toolbox. The combined product is named Max for Live. There are existing C# libraries that allow Max, and hence Max for Live, to be controlled over a TCP [...]
Hi, I wanna use liveosc to create a c# control program for ableton live.
1.Im a little confused if i should edit any .py-files for this to work, or just copy the folder into live.
2. When creating a OscServer-object in the example, an “AliveMessage” is somehow attached. What is this for?
Lets just say i wanna monitor som given live listener in my c# program. Whats the code for this?
Hi Thomas,
I’m afraid I can’t speak to any settings within Ableton Live — you’ll need to determine if you need to edit any python files.
To your second question, the AliveMessage is merely an example. Understand that Open Sound Control is a specification for communicating messages — it doesn’t define them. My library implements this specification and makes it easy (hopefully) to send messages via OSC. You’ll need to determine what OSC messages Ableton Live is sending that you need to listen for. You can adapt the OscServer sample and replace the AliveMessage with those messages specific to Ableton Live.
Paul
Thanks for your answer!
Im still having a hard time understanding…
Should I create one OscServer-object per message want to listen to?
Hi Thomas,
Nope, you only need 1 OscServer object — this is the class that sets up the communication via OSC. For every message you wish to receive, you call OscServer.RegisterMethod(“OscMessageAddress”). Where “OscMessageAddress” is the OSC structured address of your message.
If you have any further questions, let’s take this conversation to the Forums (http://www.bespokesoftware.org/wordpress/?page_id=141). That’s a much better area for such topics.
Paul
Hello,
The library works great, thanks! Is is possible to send UDP messages on the same pc port everytime?
Thanks,
-ren
Hello ren,
If I understand your question correctly, you’re asking if it’s possible to use the same outgoing port with each UDP datagram. If this is your question, I’m unaware of a mechanism to do this. Certainly you can send TO the same destination port with each datagram, but I don’t believe you can request which local port you bind to when sending outbound UDP packets. Quite the opposite when using TCP.
Paul
Paul,
Yes, that is what I am asking, to send out on the same pc port everytime. I think you can specify the local port in the UDPClient constructor, ref ->http://msdn.microsoft.com/en-us/library/system.net.sockets.udpclient.udpclient.aspx. I suspect that the OscPacket class could be modified to allow this.
Thanks,
-ren
I stand corrected, that constructor does indeed allow you to bind a UDP connection to a specific local port. I just experimented with this a bit, and found it to be problematic. The constructor behaves as advertised, but the reality of binding to the same port is troublesome when placed within OscPacket’s ctor. Not saying I can’t make this change, but it’s not a simple one-liner in the OscPacket ctor. Better might be to build a UdpClient within an overloaded OscPacket.Send() method that takes a source and a destination. You just eat the cost of the UdpClient instantiation with each Send.
Paul
Here’s the method I suggested. Not the last word in this, but for a 10-minute investigation, this is what I’ve got.
public void Send(IPEndPoint source, IPEndPoint destination)
{
byte[] data = ToByteArray();
UdpClient udpClient = new UdpClient(source);
udpClient.Send(data, data.Length, destination);
udpClient.Close();
}
Paul,
Thanks, works great!
-ren
Paul,
Got a new one for you. I able to udp send fine. Now I am want to receive osc msg. I send msg via click of button, like so:
Dim smessage As New OscMessage(New IPEndPoint(IPAddress.Loopback, port), “/pwm/6″, x)
smessage.Send(Local, Destination)
But I am having problems receiving msgs destined for Local(my pc). I tried setting up via click of button(Server sent to Local params):
sOscServer = New OscServer(TransportType, ServerAddress, ServerPort)
sOscServer.RegisterMethod(“/pwm/6″)
sOscServer.Start()
Sub sOscServer_MessageReceived(ByVal sender As Object, ByVal e As OscMessageReceivedEventArgs) Handles sOscServer.MessageReceived
Debug.WriteLine(String.Format(“Message Received [{0}]: {1}”, e.Message.SourceEndPoint.Address, e.Message.Address))
End Sub
All params OK, device sending to pc, but no debug msgs. Do you know how I can receive msgs?
Thanks,
-ren
Hi ren,
If you don’t mind, let’s take this conversation to the forums: http://www.bespokesoftware.org/wordpress/?page_id=141/open-sound-control-library/udp-send-problem/#p29
Paul
[...] functionality is provided by the Bespoke OSC Library by Paul [...]
in german you say “Obergeil!!”
something like thumbs up!
I am very pleased with the bespoke library! Thank you very much.
Paul,
very nice library. I’m wondering if you could provide some insight to a problem I’m trying to solve. I am building a custom gaming interface with buttons, trackballs, joysticks, and touch surfaces. The entire installation is comprised of six user stations. I would like to unify all hardware and software communication using OSC. The problem is that I can not open more than one OscServer (receiver) on the same port despite the fact that I’m binding to “ANY” and sending my messages as “BROADCAST”. UDP sockets on Windows allow port reuse and non-exclusive binding but must be explicitly opened using the SO_REUSEADDR attribute. What are your thoughts on modifying the Bespoke OSC library to do this? Will I break anything?
Thanks.
Hi Bryan,
I’ve posted a reply to the Forums section at http://www.bespokesoftware.org/wordpress/?page_id=141/open-sound-control-library/udp-port-reuse/#p60.
Paul
I am very new to OSC but I find this fascinating.
Recently I came across iOSC for Iphone (http://www.creativeapplications.net/iphone/iosc-iphone/ ) and is convinced this is the way to demo our .net application changing parameters from the iOSC device and seeing how our .net application adjust.
The problem is where to start. The iOSC just allows “server” and “port” configuration settings. How can I capture the incoming event using your framework?
Any help would be greatly appreciated
Rouxbox,
I’ve posted a reply to the Forums section at http://www.bespokesoftware.org/wordpress/?page_id=141/open-sound-control-library/iosc-iphone-osc-app-question/#p70.
Paul
[...] Open Sound Control [...]
Hello, I am currently trying to run OScontrol on my window x64 system but it doesn’t work.. after searching the internet I noticed that the Bespoke libraries are not x64 compatible. Is there any chance there will be support for this?
Actually, they are completely compatible with Windows x64 systems. Indeed, I’ve wrote the last two releases on a Windows 7 64-bit system. The pre-compiled binaries are simply compiled to be 32-bit.
These 32-bit binaries work like a champ on 64-bit Windows systems, without modification. If you’d like to make them 64-bit, you’re welcome to do this of course. The full source code is included, and you need only change the target environment for each of the projects.
But again, I’m unaware of any issues with the 32-bit binaries. If you have a specific error, I’d be happy to help you troubleshoot it. If so, please post your reply to the Forums section (http://www.bespokesoftware.org/wordpress/?page_id=141) as this is better than the comments section for threaded discussions.
Paul
Derek, I read a forum post about OSControl that I think describes the problem you’re having. I posted a reply to https://sourceforge.net/tracker/index.php?func=detail&aid=2984389&group_id=295990&atid=1249412?feedback=openid_error.
Please let me know if this addresses your issue.
Paul
Thanks for the quick response to the issue. I’ll take a look at changing the target environment of the library tonight. Not the most advanced programmer but I should be able to figure it out.. Thanks for all your work.. This is great stuff your doing!!
[...] Bespoke OSC Library (.NET) [...]
[...] Open Sound Control Library for.NET v1.6?BespokeSoftware??? .NET??(C#?VB)?OSC?????????????? http://www.bespokesoftware.org/wordpress/?page_id=69 [...]
Hello, I am trying to communicate my iphone (with TouchOSC application) to my pc (using your example VB.net client application). I changed the ServerAddress to iphone’s IP on the local network and also the ServerPort to the same one as iphone uses. However the client does not seem to get signals from the iphone. What may be the problem? Maybe I’ve forgot to add/change something in the code?
Thanks.
Hello Mazvydas,
I’ve posted a reply to your question on the Forums at http://www.bespokesoftware.org/wordpress/?page_id=141/open-sound-control-library/iphone-to-bespoke-osc-using-touchosc/.
Paul
[...] Open Sound Control [...]
The “Online Documentation” link http://www.bespokesoftware.org/OSC/1.7.0.0/doc results in a “403 Permission Denied” error.
Thanks for the heads up Andrea. It’s fixed.
Paul
Out of interest, what might be required to make this run on Linux?
Hello Luke,
I’ve posted a response to your question under the Forums section at http://www.bespokesoftware.org/wordpress/?page_id=141/open-sound-control-library/bespoke-osc-library-for-linux/.
Paul
[...] Open Sound Control [...]
Wow!
Haven’t tested it myself yet, but… great, thanks
Thanks for the library. Horrible c# examples though!
I have encountered a problem with the TCP version. In TcpServer.OnDataReceived, when mTotalBytesReceived > mMessageLength an assertion is invalidated. I’m not sure why you assume that mTotalBytesReceived always will be equal to or less than mMessageLength, since it might as well be more (which should be fully valid), in which case you should remove the message and then save the extra data for the next message?
Hello Robert,
I’ve responded to your question on the Forums at http://www.bespokesoftware.org/wordpress/?page_id=141/open-sound-control-library/tcp-mtotalbytesreceived-mmessagelength/#p116
Paul
Since I need to be logged in and cannot register account at that forum I will reply here.
I’m with you all the way but to “mTotalBytesReceived <= mMessageLength". Since TCP does not in anyway guarantee chunk length you can receive more data than mMessageLength (which is valid), e.g. recevied bytes could contain the end of the current message and the beginning of the next. As you are doing now you are discarding any extra data (beginning of the next message), when that should be prepended to the next received bytes.
Hello Robert,
I’ve made a post about why I’ve disabled Forum account creation — I’ve been inundated with forum spam. If you’d like an account I’d be happy to create one for you.
To your statement. If you don’t feel the implementation is correct, you’re welcome to change it.
Paul
Please create an account for me. I might play around with a bit the library.
Thanks for making the code available. It’s a shame it doesn’t compile.
I’m using Visual Studio Professional with .NET 3.5, trying to use the C# version http://www.bespokesoftware.org/OSC/OscFramework_1.7.zip
Error 1 The type or namespace name ‘Bespoke’ could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\Desktop\OscFramework_1\Source Code\Samples\OscDemo\CS\Client\Program.cs 5 7 Client
Error 2 The type or namespace name ‘OscBundleReceivedEventArgs’ could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\Desktop\OscFramework_1\Source Code\Samples\OscDemo\CS\Client\Program.cs 27 62 Client
Error 3 The type or namespace name ‘OscMessageReceivedEventArgs’ could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\Desktop\OscFramework_1\Source Code\Samples\OscDemo\CS\Client\Program.cs 32 57 Client
Error 4 The type or namespace name ‘OscServer’ could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\Desktop\OscFramework_1\Source Code\Samples\OscDemo\CS\Client\Program.cs 52 18 Client
Error 5 The type or namespace name ‘Bespoke’ could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\Desktop\OscFramework_1\Source Code\Samples\OscDemo\CS\Server\Program.cs 7 7 Server
Error 6 The type or namespace name ‘OscBundle’ could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\Desktop\OscFramework_1\Source Code\Samples\OscDemo\CS\Server\Program.cs 84 24 Server
Error 7 The type or namespace name ‘OscMessage’ could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\Desktop\OscFramework_1\Source Code\Samples\OscDemo\CS\Server\Program.cs 85 18 Server
Error 8 The type or namespace name ‘OscClient’ could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\Desktop\OscFramework_1\Source Code\Samples\OscDemo\CS\Server\Program.cs 86 24 Server
Plus a load of warnings. Sorry, but I’ll have to keep looking.
Peter
I take that back! The Mono version works fine. Thank you!
Hello Peter,
I’m glad you’ve got the Mono version working, but the Visual Studio version does work as well (same code, different environment). I suspect that your seeing an issue opening the project in Visual Studio 2010, though the projects are in VS 2008 format. VS 2010 doesn’t like that the OscDemo Client and Server projects target the .NET 2.0 Framework while the Bespoke.Common and Bespoke.Common.Osc projects target the .NET 3.5 Framework. VS 2008 is fine with it.
To fix this issue, simply change the targets of the Client and Server projects to .NET 3.5 and you’ll be good to go.
Paul
[...] C# wrapper, but it seemed to be rather complicated. Using Bespoke’s Open Sound Control (OSC) library, I started implementing my own C# TUIO server. It is still quite limited (only support external [...]
Hello,
I am using this code to send the osc message to the application running on the same computer.
public void sendMsg()
{
OscMessage msg = new OscMessage(_oscServer, _defaultPath);
msg.Append((Int32)1);
msg.Send(_oscServer);
}
However, I am getting this on the other application:
16777216
int)
I use the “other application” all the time, it doesn’t have any problem with OSC at all. Do you know what might be the problem? When I try the float value, I am always getting “0.00000″ as well.
Thanks in advance!
Hello hc,
I suspect that your “other application” might be sending/receiving data in the reverse byte order (endianess) from the Bespoke OSC Library. This is easy to modify, just set the static OscPacket.LittleEndianByteOrder property from true to false.
Paul
I thought it is only applicable in an OSC Server. Now I add the code and it works fine. Thank you so much! Your library saved me from extra mile!
[...] Open Sound Control [...]
What’s the difference between .net and mono versions?
Mono is still .NET, but supports POSIX operating systems (e.g. Unix/Linux). The non-Mono release uses Microsoft Visual Studio.
That’s the only difference, the codebase is identical.
Paul
Hi! Can you tell me how to change target IP and Port?
Regards!
Have a look at the demo app included with the library. It’s quite straight forward to transmit an OscPacket to a particular IPEndPoint, with minor differences between TCP and UDP transmission. With TCP you’ll “Connect” to the destination end point before calling “Send” and with UDP you’ll include the destination end point during “Send”.
Paul
You’re right, yesterday i wasn’t looking carefully. A bit new to C#, so I am still a bit dumb
Thank you for your answer!
Hello,
I would like to use it for a Windows Phone 8 app, do you think it’s possible?
thanks
Hello Bruce,
Yes, this should be possible but it’ll take some effort. As I understand it, Windows Phone 8 projects can’t reference non-Windows Phone 8 projects — so at a minimum you’d need to port the existing libraries to that platform. I can’t predict how much work that might be, but it’s nonzero.
In particular, the Bespoke.Common.Osc library will need be to be ported, and it relies on a number of classes/enumerations within Bespoke.Common. I doubt the Osc-specific classes will cause much grief, but the network-related code within Bespoke.Common could pose problems.
This is something I would ordinarily like to do, but I’m swamped at the moment and don’t see any free clock cycles in my schedule for the next couple of months.
Paul
Hello Paul,
I am currently creating a WP8 project and I have added your libraries. I got 65 errors, but I’m confident to fix it all! I’ll let you know and will share the source when it’s fixed.
Yes! it works fine, I managed to control Resolume with my windows phone 8.
Good deal. Glad you’ve found the library useful.
Paul
Hello Paul,
I am doing a kinect project and found your mono version library helpful for transmitting Messages. I used TCP Transport but the problem is that I cannot send the message too frequently. I did a test in Local Network. The result is that when message frame rate is greater than 20 Hz, a noticeable delay occurs. Am I writing some wrong codes as below?
while (true)
{
Thread.Sleep(1000/framerate);
OscMessage message = new OscMessage(sourceEndPoint, “/test/framerate”);
message.Append(DateTime.Now.ToString());
message.Client = mOscClient;
message.Send();
}
Really appreciate for your help!
Bob
Hi Paul!
I try to write a little vb.net application to remotely control a Behringer X32. Therefore I need to send messages from a certain port. But when I code something like that:
Dim ipX32 As IPAddress = IPAddress.Parse(“10.7.181.78″)
Dim ipepX32 As IPEndPoint = New IPEndPoint(ipX32, 10024)
Dim ipepXControl As IPEndPoint = New IPEndPoint(IPAddress.Parse(“10.7.180.67″), 10023)
Dim msg As New OscMessage(ipepX32, “/info V0.90 osc-server X32 1.13″)
msg.Append(0)
msg.Send(ipepXControl)
the message is’nt sent from port 10024 (as I expected) but from a random port number (as it Looks like)
Also when I try to set up a osc-server to listen on incoming messages I get the following error: “The index and the Count have to point to a position in the buffer. Parameter: bytes” (probably not translated correctly as I use a german version)
Can you help me out?
Thanks,
Andy from Austria
Hi Andy,
To your question about specifying an outgoing port. As it happens, I’ve had another report recently, on this same issue and have added some code to address it. However, I haven’t published an update. I’m moving the code base to bitbucket (a github-style source control system). I’m actively working on that and expect to have an update later today. I’ll post back when it’s complete.
I can’t speak to your second question. I have no error like that within the OSC library. Have you tried stepping through the code to find that error?
Paul
[...] Open Sound Control [...]
Ok Andy, I’ve relocated the source code to bitbucket at https://bitbucket.org/pvarcholik/bespoke.osc. This is the latest revision and includes a new property for setting the UdpClient on all OscPackets. This allows you to send messages from a particular port by setting, for example, OscPacket.UdpClient = new UdpClient(10024);
The updated demos (both C# and VB) include this call for the UdpTransmitter. Shout if you have any questions.
Paul