Exemple #1
0
    public static void FlushLED(bool skipUI)
    {
        for (int x = 1; x <= 8; x++)
        {
            for (int y = 1; y <= 8; y++)
            {
                LaunchpadHandler.PadSendNote(x, y, 0, Color.gray, skipUI);
            }
        }

        for (int i = 1; i <= 33; i++)
        {
            LaunchpadHandler.mcSendNote(i, 0, Color.gray, skipUI);
        }
    }
Exemple #2
0
    public static void Launchpad_MessageReceived(object sender, MidiInMessageEventArgs e)
    {
        if (e.MidiEvent == null && e.MidiEvent.CommandCode == MidiCommandCode.AutoSensing)
        {
            return;
        }

        if (e.MidiEvent.CommandCode == MidiCommandCode.NoteOn)
        {
            NoteEvent NoteCasted = (NoteEvent)e.MidiEvent;
            int       NoteNum    = NoteCasted.NoteNumber;
            int       x          = 1;
            int       y          = 1;

            if (LaunchpadHandler.midiinput_kind == 0)   //Launchpad S / Mini
            {
                x = (int)Math.Truncate(NoteNum / 16f) + 1;
                y = (NoteNum % 16) + 1;
            }
            else if (LaunchpadHandler.midiinput_kind == 1)   //Launchpad MK2
            {
                x = 9 - (int)Math.Truncate(NoteNum / 10f);
                y = NoteNum % 10;
            }
            else if (LaunchpadHandler.midiinput_kind == 2)   //Launchpad Pro
            {
                x = 9 - (int)Math.Truncate(NoteNum / 10f);
                y = NoteNum % 10;
            }
            else if (LaunchpadHandler.midiinput_kind == 3)   //MIDI FIGHTER 64
            {
                System.Drawing.Point key = LaunchpadHandler.MIDIFighter64_GetKey(NoteNum);
                x = key.X;
                y = key.Y;
            }
            else if (LaunchpadHandler.midiinput_kind == 4)   //Launchpad X / Mini MK3
            {
                x = 9 - (int)Math.Truncate(NoteNum / 10f);
                y = NoteNum % 10;
            }

            if (NoteCasted.Velocity > 0)
            {
                if (x >= 1 && x <= 8 && y >= 1 && y <= 8)
                {
                    PadInfoRequestQueue.Enqueue(new PadInfoStructure(UniPack_SelectedChain, x, y, 1));
                }
                else   //Control Change
                {
                    if (LaunchpadHandler.midiinput_kind == 0)
                    {
                        y = LaunchpadHandler.LaunchPadS_MC_GetKey(NoteNum);
                    }
                    else if (LaunchpadHandler.midiinput_kind == 1)
                    {
                        y = LaunchpadHandler.LaunchPadMK2_MC_GetKey(NoteNum);
                    }
                    else if (LaunchpadHandler.midiinput_kind == 2)
                    {
                        y = LaunchpadHandler.LaunchPadPro_MC_GetKey(NoteNum);
                    }
                    else if (LaunchpadHandler.midiinput_kind == 4)
                    {
                        y = LaunchpadHandler.LaunchPadX_MC_GetKey(NoteNum);
                    }
                    PadInfoRequestQueue.Enqueue(new PadInfoStructure(UniPack_SelectedChain, -1, y, 1));
                }
            }
            else if (NoteCasted.Velocity == 0)
            {
                if (y >= 1 && y <= 8)
                {
                    PadInfoRequestQueue.Enqueue(new PadInfoStructure(UniPack_SelectedChain, x, y, 0));
                }
                else
                {
                    PadInfoRequestQueue.Enqueue(new PadInfoStructure(UniPack_SelectedChain, -1, x + 8, 0)); //CLICKED CHAIN
                }
            }
        }
        else if (e.MidiEvent.CommandCode == MidiCommandCode.NoteOff)   //Only For MIDI FIGHTER 64
        {
            NoteEvent NoteCasted = (NoteEvent)e.MidiEvent;
            int       NoteNum    = NoteCasted.NoteNumber;
            int       x          = 1;
            int       y          = 1;

            if (LaunchpadHandler.midiinput_kind == 3)
            {
                System.Drawing.Point key = LaunchpadHandler.MIDIFighter64_GetKey(NoteNum);
                x = key.X;
                y = key.Y;

                if (y >= 1 && y <= 8)
                {
                    PadInfoRequestQueue.Enqueue(new PadInfoStructure(UniPack_SelectedChain, x, y, 0));
                }
                else
                {
                    PadInfoRequestQueue.Enqueue(new PadInfoStructure(UniPack_SelectedChain, -1, x + 8, 0));
                }
            }
            else if (LaunchpadHandler.UP_PLAYER_CustomFirmware == true)   //Present NoteOff when you are using Launchpad Pro Custom Firmware instead NoteOn Velocity 0.
            {
                if (LaunchpadHandler.midiinput_kind == 0)
                {
                    x = (int)Math.Truncate(NoteNum / 10f) + 1;
                    y = (NoteNum % 16) + 1;
                }
                else if (LaunchpadHandler.midiinput_kind == 1)
                {
                    x = 9 - (int)Math.Truncate(NoteNum / 10f);
                    y = NoteNum % 10;
                }
                else if (LaunchpadHandler.midiinput_kind == 2)
                {
                    x = 9 - (int)Math.Truncate(NoteNum / 10f);
                    y = NoteNum % 10;
                }
                else if (LaunchpadHandler.midiinput_kind == 4)
                {
                    x = 9 - (int)Math.Truncate(NoteNum / 10f);
                    y = NoteNum % 10;
                }

                if (x >= 1 && x <= 8 && y >= 1 && y <= 8)
                {
                    PadInfoRequestQueue.Enqueue(new PadInfoStructure(UniPack_SelectedChain, x, y, 0));
                }
                else
                {
                    if (LaunchpadHandler.midiinput_kind == 0)
                    {
                        y = LaunchpadHandler.LaunchPadS_MC_GetKey(NoteNum);
                    }
                    else if (LaunchpadHandler.midiinput_kind == 1)
                    {
                        y = LaunchpadHandler.LaunchPadMK2_MC_GetKey(NoteNum);
                    }
                    else if (LaunchpadHandler.midiinput_kind == 2)
                    {
                        y = LaunchpadHandler.LaunchPadPro_MC_GetKey(NoteNum);
                    }
                    else if (LaunchpadHandler.midiinput_kind == 4)
                    {
                        y = LaunchpadHandler.LaunchPadX_MC_GetKey(NoteNum);
                    }

                    PadInfoRequestQueue.Enqueue(new PadInfoStructure(UniPack_SelectedChain, -1, y, 0));
                }
            }
        }
        else if (e.MidiEvent.CommandCode == MidiCommandCode.ControlChange)
        {
            ControlChangeEvent NoteCasted = (ControlChangeEvent)e.MidiEvent;
            int mcKey = 0;

            if (LaunchpadHandler.midiinput_kind == 0)
            {
                mcKey = LaunchpadHandler.LaunchPadS_MC_GetKey(int.Parse(NoteCasted.Controller.ToString()));
            }
            else if (LaunchpadHandler.midiinput_kind == 1)
            {
                mcKey = LaunchpadHandler.LaunchPadMK2_MC_GetKey(int.Parse(NoteCasted.Controller.ToString()));
            }
            else if (LaunchpadHandler.midiinput_kind == 2)
            {
                mcKey = LaunchpadHandler.LaunchPadPro_MC_GetKey(int.Parse(NoteCasted.Controller.ToString()));
            }
            else if (LaunchpadHandler.midiinput_kind == 4)
            {
                mcKey = LaunchpadHandler.LaunchPadX_MC_GetKey(int.Parse(NoteCasted.Controller.ToString()));
            }

            if (NoteCasted.ControllerValue > 0) //mc Button Clicked
            {
                PadInfoRequestQueue.Enqueue(new PadInfoStructure(UniPack_SelectedChain, -1, mcKey, 1));
            }
            else //mc Button UnClicked
            {
                PadInfoRequestQueue.Enqueue(new PadInfoStructure(UniPack_SelectedChain, -1, mcKey, 0));
            }
        }
    }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        List <LEDStructure> LEDThreadQueue_RL   = new List <LEDStructure>();
        List <LEDStructure> LEDMCThreadQueue_RL = new List <LEDStructure>();

        //LED Thread Worker
        for (int i = 0; i < LEDThreadQueue.Count; i++)
        {
            LEDStructure item = LEDThreadQueue[i];
            if (Mathf.RoundToInt(Time.time * 1000) >= item.delay)
            {
                switch (item.feat)
                {
                case 0:     //On
                    LaunchpadHandler.PadSendNote(item.x, item.y, item.velocity, item.color, false);
                    break;

                case 1:     //Off
                    LaunchpadHandler.PadSendNote(item.x, item.y, item.velocity, Color.gray, false);
                    break;

                case 3:     //LED Wormhole
                    break;
                }

                LEDThreadQueue_RL.Add(item);
            }
        }

        for (int i = 0; i < LEDThreadQueue_RL.Count; i++)
        {
            LEDThreadQueue.Remove(LEDThreadQueue_RL[i]);
        }
        LEDThreadQueue_RL.Clear();



        //MC LED Thread Worker
        for (int i = 0; i < LEDMCThreadQueue.Count; i++)
        {
            LEDStructure item = LEDMCThreadQueue[i];
            if (Mathf.RoundToInt(Time.time * 1000) >= item.delay)
            {
                switch (item.feat)
                {
                case 0:     //On
                    LaunchpadHandler.mcSendNote(item.y, item.velocity, item.color, false);
                    break;

                case 1:     //Off
                    LaunchpadHandler.mcSendNote(item.y, 0, Color.gray, false);
                    break;
                }

                LEDMCThreadQueue_RL.Add(item);
            }
        }

        for (int i = 0; i < LEDMCThreadQueue_RL.Count; i++)
        {
            LEDMCThreadQueue.Remove(LEDMCThreadQueue_RL[i]);
        }
        LEDMCThreadQueue_RL.Clear();

        if (LaunchpadHandler.midiinput_avail == true && PadInfoRequestQueue.Count > 0)   //LAUNCHPAD HANDLER (MAIN THREAD)
        {
            PadInfoStructure item = PadInfoRequestQueue.Dequeue();
            Pad_VTouch(item.chain, item.x, item.y, item.touchMode);
        }
    }
 public void MidiDevices_Connect()
 {
     LaunchpadHandler.ConnectTheDevice(input_index, output_index, input_kind, output_kind);
 }
 public void MidiDevices_Load()
 {
     LaunchpadHandler.LoadDevices(prefab);
 }
 void Start()
 {
     LaunchpadHandler.LoadDevices(prefab); //same as Load Function
 }