Пример #1
0
        private void processOSCMessage(OSCMessage message)
        {
            Console.WriteLine(string.Format("message received: {0} {1}", message.Address, ListToString(message.Data)));

            DeviceAction deviceAction = DeviceAction.None;
            int          data         = -1;

            if (message.Address.Contains("Text"))
            {
                return;
            }
            try
            {
                string[] address = message.Address.Split('/');
                string   action  = address[2];
                data = int.Parse(address[3]);
                if (action == "fader" && address.Length == 4)
                {
                    deviceAction = DeviceAction.FaderSlider;
                }
                else
                {
                    return;
                }
            }
            catch { Console.WriteLine("Error on OSC Packet processing. Unknow packet?"); }

            Programm.onDeviceEvent(Device.Launchpad, deviceAction, new int[] { data }, message.Data.ToArray());
        }
 void packetRecievedEvent(object sender, ButtonPressEventArgs eventArgs)
 {
     try
     {
         int[]           coords = new int[] { eventArgs.X, eventArgs.Y };
         InputOutputItem item   = Programm.Items.Where(x => x.midiParams[0] == coords[0] && x.midiParams[1] <= coords[1] && x.midiParams[2] >= coords[1]).FirstOrDefault();
         if (item != null)
         {
             Programm.onDeviceEvent(Device.Onix, item.deviceAction, item.midiParams, new object[] { eventArgs.X, eventArgs.Y });
         }
     }
     catch { Console.WriteLine("Error on Midi Packet reading"); }
 }