Beispiel #1
0
        public void processPacket(InputOutputItem item, object[] eventPacket)
        {
            if (item.deviceAction == DeviceAction.FaderSlider)
            {
                int value;
                int valuewdwdw;
                int buttonY = int.Parse(eventPacket[1].ToString());

                OSCHandler.Instance.SendMessageToClient("UnityOSC", "/Mx/fader/" + item.oscParams[0], (int)Math.Round(buttonY / (float)item.midiParams[2] * 255));
            }
        }
 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"); }
 }
 public void processPacket(InputOutputItem item, object[] eventPacket)
 {
     try
     {
         if (item.deviceAction == DeviceAction.FaderSlider)
         {
             int ledToLit = (int)Math.Round((float)eventPacket[0] / 255f * (item.midiParams[2] - item.midiParams[1])) + 1;
             for (int i = 0; i <= item.midiParams[2]; i++)
             {
                 if (i < ledToLit)
                 {
                     launchpad[item.midiParams[0], item.midiParams[1] + i].SetColor(ButtonColor.Grey);
                 }
                 else
                 {
                     launchpad[item.midiParams[0], item.midiParams[1] + i].SetColor(ButtonColor.Off);
                 }
             }
         }
         else if (item.deviceAction == DeviceAction.FaderCueGo)
         {
             if (eventPacket[0].ToString() == "0")
             {
                 launchpad[item.midiParams[0], item.midiParams[1]].SetColor(ButtonColor.Red);
             }
             else
             {
                 launchpad[item.midiParams[0], item.midiParams[1]].SetColor(ButtonColor.Green);
             }
         }
         else if (item.deviceAction == DeviceAction.FaderCueRelease)
         {
             Console.WriteLine("FaderCueRelease");
         }
         else if (item.deviceAction == DeviceAction.FaderCueRelease)
         {
             Console.WriteLine("FaderCueRelease");
         }
         else
         {
             Console.WriteLine("No Midi-Processor found for this packet.");
         }
     }
     catch { Console.WriteLine("Error on processing Packet for Midi."); }
 }