Unity Community |

Does anyone have any ideas about how i can use/get MIDI or OSC control inside a unity game?
(aside from that MIDI plugin someone made that only works in Unity Pro)
As far as I know, you're out of luck for the time being. If MIDI/OSC gets implemented in an official release of ControllerMate, that will probably be your best bet.
http://www.orderedbytes.com/forum/vi...8cb03382b4857b
I'm currently using OSC in Unity. There is a (very basic) implementation of the OSC protocol in C# available at http://www.makingthings.com/ref/dotnet/html/ , which is what I use.
Jonas, any chance you could post some example code? That would be really helpful...
thanks
Download their SDK from http://downloads.sourceforge.net/mak...ngs/dotnet.zip
The source files you are interested in are Osc.cs and Packet.cs. These compile in unity (I think I had to do some very minor modifications to make them compile). Then you can just send and receive OSC messages, as documented in:
http://www.makingthings.com/ref/dotnet/html/
anyone wanna hazard a javascript port?
You are the cattle, I am the catalyst.
If you are using Maxon's C4D R11.x with Unity 3D try:
Python for C4D plugin:
http://www.py4d.com/2009/09/py4d-0-9-9980-rc/
in conjunction with
Python SimpleOSC:
http://www.ixi-software.net/content/...kyard_osc.html
For those who are wanting to use OSC with Unity, I am attaching an example project that shows a bare bones hello world for receiving messages.
It is based off the above mentioned MakingThings library but has been modified to compile in unity, and comes with a project showing how to set it up.
Hope it helps someone out there!
Hi, that's very cool! Could you please add a OSC Send JavaScript example as well? I am trying to get it work, but still fail...
EDIT: I was able to finally come up with the right syntax, so just add this function to the above code:
Code:
public function sendOSC(txt : String){ handler.Send(handler.StringToOscMessage(txt)); }
Thanks to obviousjim
Seems that there is a pretty good set of osc code wrapped into this TUIO example I came across
http://forum.unity3d.com/viewtopic.php?p=82916 (see downloadable file)
That should get you set up with an OSC Sender.
Mhhhh i have a problem to build the osc example. if i press play in unity it works, but after building nothing happens. I use the old 2.5 Indie version, is this a problem? or should i implements something in the builded file? I'm workin on a mac...
Thank you very much for this example. I implemented a C# starter script instead of the javascript one. And run into two funny problemsOriginally Posted by obviousjim
For those who are wanting to use OSC with Unity, I am attaching an example project that shows a bare bones hello world for receiving messages.
It is based off the above mentioned MakingThings library but has been modified to compile in unity, and comes with a project showing how to set it up.
Hope it helps someone out there!
1. The udp listener thread is not stopping and continues to run even when the game is stopped
2. The udp port is not freed when restarting the game (play-stop-play).
This will give also strange timeouts when pressing play a second time - having to wait for some seconds until the game really starts.
To workaround these problems, I found the following solution (I can also post the C# script here if anyone is interested):
1. The starter script needs to implement an object destructor that calls the function oscHandler.Cancel()
2. The udp listener thread in Osc.cs should be a foreground thread (set ReadThread.IsBackground=false in Osc.init). This will ensure that the thread can be terminated normally (when pressing stop) and the socket can be freed.
This way, OSC works perfectly in Unity. To test with the example code above, I can also recommend the (osc.M monitor or OSCMonitor - on Windows platforms).
Cheers, Kai
PS. I just realized one more thing: the c# callback function to be used with oscHandler.SetAddressHandler() should be declared static. Otherwise the solution above will not work at all because the destructor is never called. I guess the GC cannot resolve the cyclic reference.
All this would not be a problem, if there would be a stop method for the GameObject (that is called when the game is stopped in the editor) - then we could clean up properly. Is there maybe such a method?
Interested! Please post.Originally Posted by kjauslin
To workaround these problems, I found the following solution (I can also post the C# script here if anyone is interested):
Ok, here is the working example (the code from above, but full c# and bugfixes for init/closing udp socket). It runs now very nicely. The correct way is to implement the "OnDisable" method and close the udp socket there.Originally Posted by dpentecost
Interested! Please post.
It still gives a warning, that the listener socket is already in use, but you can ignore it and messages arrive nevertheless. I have tested with a C++ program using OSCpack (send and receive OSC messages).
A nice addition to better work with OSCpack would be some OSC 1.1 features (e.g. boolean types)... anyone?
Regards, Kai
Thanks Kai!
Thanks to obviousjim and Kai - I got both receive and send tests working with TouchOSC on the iPhone and OSCulator on the Mac.
Hello, im with a little problem when I run that example this happens
Code:
UDPPacketIO:SendPacket(Byte[], Int32) (at Assets\Plugins\UDPPacketIO.cs:108) Osc:Send(OscMessage) (at Assets\Plugins\Osc.cs:248)
And this:
Code:
System.Net.Sockets.SocketException: Address already in use at System.Net.Sockets.Socket.Bind (System.Net.EndPoint local_end) [0x00000] at System.Net.Sockets.UdpClient.InitSocket (System.Net.EndPoint localEP) [0x00000] at System.Net.Sockets.UdpClient..ctor (System.Net.IPEndPoint localEP) [0x00000] at UDPPacketIO.Open () [0x0001c] in C:\Documents and Settings\user\Desktop\osc_example_662\osc_example\Assets\Plugins\UDPPacketIO.cs:54 UDPPacketIO:SendPacket(Byte[], Int32) (at Assets\Plugins\UDPPacketIO.cs:108) Osc:Send(OscMessage) (at Assets\Plugins\Osc.cs:248)
And I really sure what that port is open without other application running.
I tried with other port and get same error. I sending with oscP5 (for Processing) and this app get unity3D messages.
Someone knows what how I can fix it?
PS: I try run in MAC and the same error appear.
Thanks.
I got a pm from another beginner asking how I had gotten this to work. So I have put together a project that combines the previous two (both send and receive), added a screenshot and a readme. It still just confirms send and receive in the console - no manipulation of objects in Unity yet.
EDIT: Check my post a few posts down from this one, for a downloadable demo that does manipulate Unity objects.
Hope it helps someone else. All the pieces were there but if you are not a coder (I am not) it can be a bit confusing.
The readme includes links to TouchOSC, OSCulator, and oscP5.
Good luck!
PS psydack - My guess is that you will have to play with your IP and port settings to get it right. Check what ports Processing is using.
Thanks, I'm really like but I'm got confused now! I'm get your way, step by step and nothing.Originally Posted by dpentecost
I got a pm from another beginner asking how I had gotten this to work. So I have put together a project that combines the previous two (both send and receive), added a screenshot and a readme. It still just confirms send and receive in the console - no manipulation of objects in Unity yet.
Hope it helps someone else. All the pieces were there but if you are not a coder (I am not) it can be a bit confusing.
The readme includes links to TouchOSC, OSCulator, and oscP5.
Good luck!
PS psydack - My guess is that you will have to play with your IP and port settings to get it right. Check what ports Processing is using.
Im really don't know what happens. I'm now using one PC with Processing (192.168.1.110) and other Mac using Unity (192.168.1.103). I already test with inverting the programs (PC with Unity and Mac with Processing) and both tests Processing work normally.
I'd put a print screen with I'm using Mac with Unity don't working. I'm tried others ports and I'm tried with runs every at same local: Mac with Processing and Unity3D and PC with Unity3D and Processing.
The other Script wich only send(with the error when try to open but send) I'm realized some tests with Processing and it works. But this don't received only send.
Sorry for something and thanks for all!
Hi,Originally Posted by psydack
Thanks, I'm really like but I'm got confused now! I'm get your way, step by step and nothing.
Im really don't know what happens. I'm now using one PC with Processing (192.168.1.110) and other Mac using Unity (192.168.1.103). I already test with inverting the programs (PC with Unity and Mac with Processing) and both tests Processing work normally.
I'd put a print screen with I'm using Mac with Unity don't working. I'm tried others ports and I'm tried with runs every at same local: Mac with Processing and Unity3D and PC with Unity3D and Processing.
The other Script wich only send(with the error when try to open but send) I'm realized some tests with Processing and it works. But this don't received only send.
Sorry for something and thanks for all!
from your screenshots I can see that you are sending in processing to path '/test' (new OscMessage("/test")). But the c# address handlers you use have the paths "/1/toggle1" and "/2/toggle2". This has to match. So setting this to e.g. "/1/toggle1" in processing should make it work.
Regards, Kai