【问题标题】:Send and receive response Rug.Osc发送和接收响应 Rug.Osc
【发布时间】:2019-01-31 01:46:23
【问题描述】:

我使用 Rub Osc。发送没问题,接收也没问题。

但我需要发送 OSC 命令并接收响应。给 Beringher x32。

例如,发送“/ch/01/mix/on”并得到 0 或 1。

    public double GetOSC(string IPOSC, int REMOTEPORTUSE, int LOCALPORTUSE, string ENVIOCOMANDO)
        {
    // Envio Comando 
            OscReceiver receiver;
            OscSender sender2;
        // Create the receiver
        using (receiver = new OscReceiver((int)LOCALPORTUSE))
        {              

            IPAddress address = IPAddress.Parse(IPOSC);



                using (sender2 = new OscSender(address, (int)LOCALPORTUSE, (int)REMOTEPORTUSE))
                {
                    // Connect the receiver
                    receiver.Connect();

                    //And Send
                    sender2.Connect();
                    sender2.Send(new OscMessage(ENVIOCOMANDO)); //"/ch/01/mix/on" 

                 // if we are in a state to recieve

                    if (receiver.State == OscSocketState.Connected )
                    {
                            // get the next message 
                            // this will block until one arrives or the socket is closed
                            OscPacket packet = receiver.Receive();

                            // Write the packet to the console

                            var output = Regex.Replace(packet.ToString().Split(',')[1], @"[^0-9.]", string.Empty);
                            double decim = double.Parse(output, System.Globalization.CultureInfo.InvariantCulture);

                        return decim;

                    }
                    else
                    {
                        return -1;

                    }

                }
        }

}

我全部启动一个线程。但是,如果 Threath 睡眠时间小于一秒.. 会破坏应用程序。 并出现:System.ObjectDisposedException。

对发送和接收 OSC 有什么想法吗?

【问题讨论】:

    标签: c# osc


    【解决方案1】:

    “easy”:您需要每 10 秒发送一次 /remote OSC 命令,X32 将向您的应用程序回显桌面上发生的所有变化(推子移动等)。有关完整信息和应用示例(有些简单,有些不简单),请参阅https://sites.google.com/site/patrickmaillot/x32 的文档。 -帕特里克

    【讨论】:

      猜你喜欢
      • 2014-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多