Skip to content

Latest commit

 

History

History
93 lines (67 loc) · 2.15 KB

README.md

File metadata and controls

93 lines (67 loc) · 2.15 KB

Launchpad

A library can enable to talk to your Launchpad Mini device in .NET & .NET Core. You can light buttons, listen pressed keys

Developed this library on Novation Launchpad Mini But you can contribute to extend library for another launchpads

Getting Started

  1. You have to install "PortMidi" library on your computer

Linux (Ubuntu)

$ apt-get install libportmidi0

Mac OS

$ brew install portmidi

Windows

choco install portmidi
  1. Install launchpad library on your project
$ dotnet add package launchpad

Example

Basic example usage of launchpad library

        static readonly LaunchpadManager LaunchpadManager = new LaunchpadManager();
        static readonly Dictionary<string, int> Histories = new Dictionary<string, int>();

        static void Main(string[] args)
        {
            if (!LaunchpadManager.FindDevice())
            {
                Console.WriteLine("Cannot find any Launchpad Device");
                return;
            }

            if (!LaunchpadManager.Open())
            {
                Console.WriteLine("Cannot open Launchpad device");
                return;
            }

            LaunchpadManager.Clear();

            LaunchpadManager.ListenStart(KeyPressed);
            Console.ReadKey();
            LaunchpadManager.ListenStop();
        }


        static void KeyPressed(LaunchpadEventArgs e)
        {
            string key = $"X:{e.Hit.X} Y:{e.Hit.Y}";

            if (!Histories.ContainsKey(key))
            {
                Histories.Add(key, 1);
            }

            Console.WriteLine($"Pressed: {key}");
            LaunchpadManager.Light(e.Hit, (LaunchpadColor) Histories[key]);
            if ((LaunchpadColor) Histories[key] == LaunchpadColor.Red)
            {
                Histories[key] = 0;
            }
            else
            {
                Histories[key]++;
            }
        }

Contributing

  • If you want to contribute to codes, create pull request
  • If you find any bugs or error, create an issue

License

This project is licensed under the MIT License