Search Unity

[Released] extOSC - Open Sound Control

Discussion in 'Assets and Asset Store' started by dr_ext, Oct 13, 2016.

  1. harryhow

    harryhow

    Joined:
    Jun 22, 2015
    Posts:
    3
    Hi,

    Is it possible to send IP to broadcast IP to sort of simulate broadcast behavior? Please let know. Thanks!

    For example, the broadcast IP is queried from ifconfig command.

    Code (CSharp):
    1. en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    2.     ether 8c:85:90:9d:10:d1
    3.     inet6 fe80::148f:4bae:44c1:340d%en0 prefixlen 64 secured scopeid 0x6
    4.     inet 10.255.234.42 netmask 0xffffff00 broadcast 10.255.234.255
    5.     nd6 options=201<PERFORMNUD,DAD>
    6.     media: autoselect
    7.     status: active
     
  2. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Hello,
    If I understand you correctly, then you can use OSCPacket.Ip property:
    Code (CSharp):
    1. public void ReceiveCallback(OSCMessage message)
    2. {
    3.     Debug.Log(message.Ip);
    4. }
     
  3. harryhow

    harryhow

    Joined:
    Jun 22, 2015
    Posts:
    3

    Hi,

    Thanks, I haven't had chance to try your suggestion, will try. For more details about what I want to do is I want to send out OSC message from one PC to many PCs. So I try to setup my OSC host IP to my network's broadcast IP (in my case 10.255.234.255). Under this scenario, it seems not working with your plugin from my first try.
     
  4. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Oh, then that's not what I advised you. I'm not sure about the possibility of such on extOSC.
     
  5. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    extOSC - Open Sound Control Ver. 1.8.2 is Avaible:
    - Replaced OSCUtilities.StructToByte(object) to StructToByte<T>(T).
    - Replaced OSCUtilities.ByteToStruct(Type, byte[]) to ByteToStruct<T>(byte[]).
    - Fixed UWP support in OSCUtilities. Again.

    Asset Store: https://www.assetstore.unity3d.com/#!/content/72005 - FREE
     
    Last edited: Jul 13, 2018
  6. hyperreelist

    hyperreelist

    Joined:
    Mar 6, 2018
    Posts:
    1
    Hi,
    I am new to both Unity Dev and extOSC.

    I have copied the examples in the Fast Track video. However when changing the address to an external modulating source. I am not able to replicate the GameObject.SetActive switch/button example with an external float, it only switches the object on or off once, unlike the video where the button can hide show the object continuously. The console show the continue stream of data and I have changed the incoming Float to a Bol with the OSC mapping settings.

    What am I missing?
     
  7. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Hello,

    1) Check, did you set Map Bundle in OSCReceiver.
    2) OSC Component should not be on the hidding object. Since when you turn it off it will stop receiving messages.
     
  8. MikeChr

    MikeChr

    Joined:
    Feb 2, 2018
    Posts:
    43
    Hi. I'm new to Unity dev. I have an OSC receiver using MonoBehavior and it only processes incoming messages when the "running" i.e. Play. I realize this is not extOSC's fault, but is there an example or simply a pointer to how to build an editor component that will continue to process received messages regardless of the play mode? Thanks,
     
  9. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Hello,

    extOSC works in editor only for OSC Console and OSC Debug, and only when GameObject with OSCReceiver is selected in hierarchy.

    Only like this you can make “Editor Component”: Create behaviour with ExecuteInEditMode attribute, and in Awake os Start method you must bind osc address.
     
    Last edited: Mar 13, 2018
  10. MikeChr

    MikeChr

    Joined:
    Feb 2, 2018
    Posts:
    43
    Thanks for the response. Can you provide any insight into why the object maintaining the Receiver must have focus for the receiver to process incoming messages?
     
  11. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    This is my personal software restriction, in order to separate the OSC from use in the editor.
    You can see how the OSCReceiver work is done in the editor here - extOSC/Scripts/Editor/Editors/OSCReceiverEditor.cs

    I also wrote a small extension for extOSC. Allowing to use the OSC specifically for the editor only:

    > https://github.com/Iam1337/extEditorOSC

    For receiving message you must create Editor script like this:
    Code (CSharp):
    1. public class OSCEditorComponentExample : OSCEditorReceiverComponent // Must be inherited from this class
    2. {
    3.     #region Public Methods
    4.  
    5.     public override void InitBinds(OSCEditorReceiver receiver)
    6.     {
    7.         // Binding address
    8.         receiver.Bind("/editor/example", MessageReceive);
    9.     }
    10.  
    11.     #endregion
    12.  
    13.     #region Private Methods
    14.  
    15.     private void MessageReceive(OSCMessage message)
    16.     {
    17.         Debug.LogFormat("Received message: {0}", message);
    18.     }
    19.  
    20.     #endregion
    21. }
    For transmitting message:
    Code (CSharp):
    1. var message = new OSCMessage("/editor/example");
    2. message.AddValue(OSCValue.String("Editor message!"));
    3.  
    4. OSCEditorManager.Transmitter.Send(message);
     
    Last edited: Mar 14, 2018
  12. Ozone_ABN

    Ozone_ABN

    Joined:
    Jan 11, 2014
    Posts:
    12
    Hello,

    I'm writing on a Connection between Oculus touch controllers and the Hololens. I use extOSC to transmit the position and orientation of the touch controllers. This works quite well, only on the Hololens I get the following exception after a short time:

    NullReferenceException: Object reference not set to an instance of an object.
    at extOSC.Core.Network.OSCTransmitterWindowsStoreBackend.<SendAsync>d__9.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_0(Object state)
    at UnityEngine.UnitySynchronizationContext.WorkRequest.Invoke()
    at UnityEngine.UnitySynchronizationContext.Exec()
    at UnityEngine.UnitySynchronizationContext.ExecuteTasks()
    at UnityEngine.UnitySynchronizationContext.$Invoke1(Int64 instance, Int64* args)
    at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)

    After that, the Hololens no longer receives OSC data.

    Any idea what might be the cause?

    I'm using Unity 2017.3.1f1 (64-bit) and extOSC v1.8.2
     
  13. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Hello,

    I think I found a problem, I'll try to fix it within 24 hours, and post fix here and AssetStore.
     
  14. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Okay, try to change line 72 in OSCTransmitterWindowsStoreBackend.cs file:
    Code (CSharp):
    1. private async void SendAsync(byte[] data)
    to:
    Code (CSharp):
    1. private async Task SendAsync(byte[] data)
    And add line:
    Code (CSharp):
    1. using System.Threading.Tasks;
    after line 6:
    Code (CSharp):
    1. using System;
    2. using System.Threading.Tasks; // Added line
     
  15. Ozone_ABN

    Ozone_ABN

    Joined:
    Jan 11, 2014
    Posts:
    12
    Thank you for your quick answer. That fixes the nullpointer exception but it seems that I still have other problems in my project that make sure that I don't receive anything after a while. This does not seem to be a problem for extOSC.
     
  16. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Interesting. I can not reproduce the problem with receive messages. Similar programs/assets work exactly the same?
     
  17. Pointcloud

    Pointcloud

    Joined:
    Nov 24, 2014
    Posts:
    37
    Hi,
    For some reason the local host does not reflect the correct IP address for my machine and I can't change the local port value.

    OSC Receiver claims my local host is: 172.17.82.113
    When I look up my IP address it is: 10.1.10.22

    What can I do to properly target my IP address?

    Thanks.
     
  18. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Hello,
    Now such function in extOSC is not present, it is planned in next version extOSC - 1.9.
     
    Last edited: Apr 5, 2018
  19. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    By default, now the OSCReceiver receives data from all local host addresses.

    IP in OSCReceiver Editor is currently used for display first finded local host which you can refer to OSCReceiver.
     
  20. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Hello! I want to introduce you extEditorOSC - OSC extension for Unity Editor based on extOSC.

    This asset allows you to use all features of extOSC directly into the Unity Editor. To create your own OSC Editor Component, you only need to create a subclass from «OSCEditorReceiverComponent» or the «OSCEditorTransmitterComponent», and implement all the functions what you need.

    GitHub: https://github.com/Iam1337/extEditorOSC

    Examples:

    OSCEditorReceiverComponentExample.cs
    Code (CSharp):
    1. [OSCEditorComponent("Examples", "Example Receiver Component")]
    2. public class OSCEditorReceiverComponentExample : OSCEditorReceiverComponent
    3. {
    4.     #region Protected Methods
    5.  
    6.     protected override void PopulateBinds(List<IOSCBind> binds)
    7.     {
    8.         binds.Add(new OSCBind("/editor/example", MessageReceive));
    9.     }
    10.  
    11.     #endregion
    12.  
    13.     #region Private Methods
    14.  
    15.     private void MessageReceive(OSCMessage message)
    16.     {
    17.         Debug.LogFormat("Received message: {0}", message);
    18.     }
    19.  
    20.     #endregion
    21. }
    OSCEditorTransmitterComponentExample.cs
    Code (CSharp):
    1. [OSCEditorComponent("Examples", "Example Transmitter Component")]
    2. public class OSCEditorTransmitterComponentExample : OSCEditorTransmitterComponent
    3. {
    4.     #region Protected Methods
    5.  
    6.     protected override void Update()
    7.     {
    8.         var message = new OSCMessage("/editor/example");
    9.         message.AddValue(OSCValue.String("Editor message!"));
    10.  
    11.         Send(message);
    12.     }
    13.  
    14.     #endregion
    15. }
    Screenshots:

    OSCEditorManager


    OSCEditorComponents


    GitHub: https://github.com/Iam1337/extEditorOSC
     
  21. robertofux83

    robertofux83

    Joined:
    Sep 3, 2015
    Posts:
    1
    Hi, I want to use with hololens too, is work for you?
     
  22. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Yes, the current version supports UWP.
     
  23. SeaMink

    SeaMink

    Joined:
    Jun 3, 2013
    Posts:
    3
    Hi!

    I have a question about the possibility of binding the Receiver UDP port to the same port as the UDP port as the Transmitter sends from. Here is a bit of info from the OSC Remote Protocol documentation about the device communication flow:

    "The X32 is using a communication protocol that is compatible to standard OSC with some MUSIC Group specific extensions (e.g. parameter enquiry, subscriptions). OSC packets are received on UDP port 10023 and replies are sent back to the requester's IP/port."

    In testing, I've seen that the Transmitter uses a random high numbered port to send the initial message, but my receiver is expecting to receive a message back on port 7001, per the config. Is there any way to map the Transmitter port to always use the same local port that I'm setting to receive on, e.g. 7001, or dynamically change the Receiver port to match the same random port that is being used?

    Thanks for your time!

    SeaMink
     
  24. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Hello, I did not really understand your problem. But you can dynamically change the ports for Transmitter and Receiver, by changing LocalPort and RemotePort fields.
     
  25. SeaMink

    SeaMink

    Joined:
    Jun 3, 2013
    Posts:
    3
    Thanks for the reply, I'll try to clarify...

    I have my OSC Transmitter IP address to set to my mixer IP and the Remote Port set to 10023 as required by the mixer. The IP address of my OSC Receiver is my local computer IP and the Local Port is set to 7001.

    If I send a message to the mixer and watch the traffic with a packet sniffer, I see that the outgoing UDP message originates from the IP address of my computer from a random port, 5394 in the test that I ran, and the message is received at the mixer on port 10023. The mixer then sends a return message to my IP, but sends that message back to port 5394 instead of 7001, because the mixer always sends its messages back to the port on which the message was received. But, my local port is bound to 7001, so I never receive the return message.

    I guess I was hoping by setting the Local Port to be a fixed value that it would be able to send messages from that port so that the mixer would know to send its response back to that port and we would be ready to receive the response.

    Hope that clears it up a bit. Thanks!

    Craig
     
  26. mba-nhyde

    mba-nhyde

    Joined:
    Jul 24, 2014
    Posts:
    3
    Hello ExT_rus!

    Following up with what SeaMink said above, the problem appears to be that we require two way communication (send and receive) from a single UDP client.

    The X32 sends responses to the source port or the original message. We need both the Transmitter and Receiver to use the same localPort. We have had success at using a single instance of a System.Net.Sockets.UdpClient to send and receive when the client is instantiated with a local port and that same client is used to receive info with BeginReceive/EndReceive but we would like to use your enhanced tools, if possible. :)

    Perhaps some working code would help? (Note that the snippet below uses an alternate implementation of OSCPacket (jorgegarcia's UnityOSC))

    Code (CSharp):
    1.  
    2.     public OSCBytesReceivedEvent m_BytesRecievedEvent;
    3.  
    4.     [Tooltip("IP Address of the x32")]
    5.     public string recipientIpAddress = "192.168.1.10";
    6.  
    7.     [Tooltip("OSC port number on the x32")]
    8.     public int recipientPort = 10023;
    9.  
    10.     /// <summary>
    11.     /// Port to listen for UDP traffic on this device
    12.     /// Will be used as the source port for all messages sent from this class.
    13.     /// </summary>
    14.     [Tooltip("Port to listen for UDP traffic on")]
    15.     public int localPort = 5394;
    16.  
    17.     private UdpClient _udpClient;
    18.     private IPEndPoint _target;
    19.  
    20.     void OnUdpData(IAsyncResult result) {
    21.       UdpClient _udpClient = result.AsyncState as UdpClient;
    22.       IPEndPoint source = new IPEndPoint(0, 0);
    23.       // get the actual message and fill out the source:
    24.       byte[] message = _udpClient.EndReceive(result, ref source);
    25.  
    26.       if(message != null && message.Length > 0)
    27.       {
    28.         if (m_BytesRecievedEvent != null)
    29.           m_BytesRecievedEvent.Invoke(source, message);
    30.       }
    31.       _udpClient.BeginReceive(new AsyncCallback(OnUdpData), _udpClient);
    32.     }
    33.  
    34.     public void InitUdp() {
    35.       _udpClient = new UdpClient(localPort);
    36.       _udpClient.BeginReceive(new AsyncCallback(OnUdpData), _udpClient);
    37.       _target = new IPEndPoint(
    38.         IPAddress.Parse(recipientIpAddress),
    39.         recipientPort
    40.       );
    41.     }
    42.  
    43.     public void Send(OSCPacket packet)
    44.     {
    45.       byte[] data = packet.BinaryData;
    46.       _udpClient.Send(data, data.Length, _target);
    47.     }
    48.  
    Also, I've attached a screenshot from Wireshark of the above code in action. I hope this helps.

    Nathan
     

    Attached Files:

    dr_ext likes this.
  27. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Ah, okay. Currently extOSC use two different instance of UDPClient/DatagramSocket classes. Now it is impossible to use the same local port to send and receive messages.

    I’ll make this in the future updates.
     
  28. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Hello, I make a new version with support for what you asked for (not support UWP currently). If you want to test it, you can write to my support mail: ext@iron-wall.org And I’ll send it to you.

    The release version will appear in two weeks.

     
  29. SeaMink

    SeaMink

    Joined:
    Jun 3, 2013
    Posts:
    3
    Thanks for the quick turnaround! I'll send you an email right now.

    SeaMink
     
    dr_ext likes this.
  30. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    extOSC - Open Sound Control Ver. 1.9 is Avaible:
    - Added port info in received messages for in OSC Console.
    - Added local port support in OSCTransmitter.
    - Added LocalPortMode property in OSCTransmitter (Random, Custom, FromReceiver).
    - Added LocalReceiver property in OSCTransmitter.
    - Added LocalPort property in OSCTransmitter.


    Asset Store: https://www.assetstore.unity3d.com/#!/content/72005 - FREE
     
    Last edited: Jul 13, 2018
  31. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    extOSC - Tooltips #1

    In extOSC you can generate message C# code inOSC Debug and OSC Console by one click.

    OSC Debug


    OSC Console


    Final result in clipboard:
     
    MrMatthias likes this.
  32. MrMatthias

    MrMatthias

    Joined:
    Sep 18, 2012
    Posts:
    191
    Can you explain what it is used for? Is it for creating Transmitters/Receivers in Editor mode and managing these? Is it superseded by the "work in Editor" option?
     
  33. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    This is a highly specialized component that allows you to work with the OSC only within the Unity Editor.

    For example: using third-party devices working through the OSC to extend the functionality of the Unity Editor. (Currently there are no components for implementing, but are planned in the future)

    It is not a replacement for "Work In Editor". Unlike the OSCTransmitter, the OSCEditorTransmitter runs only with the Unity Editor and not present on Game Scene.
     
    MrMatthias likes this.
  34. CodeIsTheAnswer

    CodeIsTheAnswer

    Joined:
    Jul 16, 2013
    Posts:
    4
    I want to use your component to receive messages from 3 or 4 cellphones while the game is in Play mode. Does your component support this or will it only work while in in Editor?
    Also, if the users are located remotely and the transmission occurs over the internet, how much of delay typically occurs assuming everyone has a fast connection?
    I read a few earlier posts that say we can inherit from one of the classes in order to make this work in play mode.
    Is that correct?
    Do you have any online examples of how to use it within a game?
    Thanks,
    Mark
     
  35. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Hi,

    Transmit and receive OSC messages in play mode is a main function extOSC.
    - extOSC for Game Build, Editor Play mode.
    - extEditorOSC for any mode of Unity Editor.

    Unfortunately, testing outside the local network was not carried out.

    I’m sorry, I did not understand the question. In earlier posts was asked about the possibility of using extOSC in the Unity Editor only. For such tasks I did extEditorOSC. ()

    Nope, OSC is not intended for realtime online games. It is intended primarily for the art installations and demonstration applications. (On Unity)
     
  36. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    173
    @ExT_rus using extOSC for sync mutil pc video (One for master,and others for slave),it possible(using timecode)?I am new for osc so if possible can you show how to do it? thanks very much.
     
  37. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Hi! Yes, you can synchronize video using timecode. But i recomend use OSC for send message with start or stop commads. If desynchronization in a few milliseconds is not important to you.
     
  38. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    173
    hello,thanks ! I am new in osc.can you tell me using timecode detail? I want to video frame to video frame sync .
     
  39. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Currently I can not help. But you can send to my mail (ext@iron-wall.org) the name of asset, what you using for video, and I will try to help you.
     
  40. Cloudless-Rain

    Cloudless-Rain

    Joined:
    Jun 24, 2015
    Posts:
    12
    Hi.

    Sorry about what's probably a pretty simple question. I've been using OSC with other software for years but am pretty new to Unity and C#.

    I'm trying to use extOSC to trigger an object pool to spawn objects and tell it where along one axis to place them. So when a 10 comes through the pool releases an object in one place, when a 15 comes through it places one somewhere else. The pooling system works, and I see my OSC data coming in but I don't know how to assign the data to where I need it.

    My original plan was to store incoming OSC floats in a variable but it seems this isn't so easy for someone at my beginner level. So my second plans was to send the OSC data to the intensity of a light, assign the intensity a variable and then use this variable for the job. But alas, now it triggers the spawning every frame instead of spawning only when new OSC comes through.

    This can't be hard! But I don't know what I'm doing.
     
  41. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Hello, can you send your source code on my mail (ext@iron-wall.org)? I will try to help you.
     
  42. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    extOSC - Open Sound Control Ver. 1.10 is Available:
    - Added MapBundle to OSCReceiverComponents.
    - Added MapBundle to OSCTransmitterComponents.
    - Added OSCReceiverReflection.GetMembers() method.
    - Fixed OSCReflectionProperty.PropertyType property.
    - Removed OSCReceiverReflection.AddMember(Component, string) (is obsolete).
    - Removed OSCReceiverReflection.RemoveMember(Component, string) (is obsolete).

    Asset Store: https://www.assetstore.unity3d.com/#!/content/72005 - FREE
     
    Last edited: Jul 13, 2018
  43. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    VirtualPierogi and eric_delappe like this.
  44. VirtualPierogi

    VirtualPierogi

    Joined:
    Sep 3, 2012
    Posts:
    54
    Im sorry, but I cant set it up to work in Unity 2018.2, seems like none of the current available osc plugins connect to remote apps, I tried to receive sensors from osc hook app, and while touchdesigner with the same ip setup and port displays data correctly, and processing app with receiver does the same, this isnt the case with extOSC.
    otherwise this is the most roubust osc plugin ive ever seen on github.
     
  45. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
  46. Xin

    Xin

    Joined:
    Aug 30, 2012
    Posts:
    11
    Hi Ext_Rus

    Is it at all possible to have extOSC running on two different unity projects on one local PC ? So I can test out the setup on the same PC instead of having to have two PCs. I have tried few different things but so far no luck. The second instance of unity running OSC will complain about ports already being used.
     
  47. Xin

    Xin

    Joined:
    Aug 30, 2012
    Posts:
    11
    I think it's the same issue that's been discussed here. Any news about this ?
     
  48. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Hi, just change in OSCTransmitter "Local Port Mode" to "Random".

     
  49. sweetclimusic

    sweetclimusic

    Joined:
    Nov 11, 2016
    Posts:
    12
    Hi, does this asset allow incoming messages from Abelton Link apps? I'd like to get messages from Alberton link app into my unity app.
     
  50. dr_ext

    dr_ext

    Joined:
    Apr 8, 2014
    Posts:
    100
    Hi, this asset implements the fully OSC-protocol. If you receive messages from Ableton on OSC, then this asset will allow it.
     
    Last edited: Oct 31, 2018