Easily map device and application controls to a midi controller

Overview

pymidicontroller

Introduction

Easily map device and application controls to a midi controller
Example video availble here: https://streamable.com/ie5jtt

This library is ideally not only easy to use but also easy to extend with additional targets. Currently included targets are:

  • Homeassistant (via REST API)
  • Windows Volume Mixer (via pycaw)

Note: This library is in need of refactoring as the way things were done was changed multiple times during the devlopment, therefore please be aware that there may be upcoming breaking changes.

Installation

Clone the repo and run pip install . from the cloned directory.

Usage

The following shows my currently in-use implementation of the library. It demonstrates both the volumemixer and homeassistant extensions as well as how you may decide to control multiple targets with the same controlclass. (i.e. same slider controlling multiple application audios, or multiple lights)

from pymidicontroller.classes.controller import Controller
from pymidicontroller.extensions import *
import mido

my_midi_controller = "WORLDE easy CTRL"  ##CHANGEME
homeassistant_uri = "https://my-home-assistant"  ##CHANGEME
homeassistant_token = "3fs0eXAsfOiJKV1QiL...."  ##CHANGEME

if __name__ == '__main__':
    dev = my_midi_controller
    names = mido.get_input_names()
    device_name = None
    if dev != None:
        for name in names:
            if name.startswith(dev):
                device_name = name

    device = Controller(device_name)

    homeassistant_client = homeassistant.Client(homeassistant_uri, homeassistant_token)

    #Create controllable objects
    bedroom_lights = homeassistant.Light(entity_id='light.bedroom_lights', client=homeassistant_client)
    circadian_lighting = homeassistant.Switch(entity_id='switch.circadian_lighting_circadian_lighting', client=homeassistant_client)
    power_switch_02 = homeassistant.Switch(entity_id='switch.iot_kem_02_plug', client=homeassistant_client)
    cycle_color_mode = arbitrary.Toggle(func=bedroom_lights.change_colour_mode)

    master_volume = volumemixer.Device()
    spoitfy_volume = volumemixer.Application(application='Spotify.exe')
    discord_volume = volumemixer.Application(application='Discord.exe')
    tarkov_volume = volumemixer.Application(application='EscapeFromTarkov.exe')
    r6_volume = volumemixer.Application(application='RainbowSix.exe')

    #Create controllers and map them to controllable objects
    #device.register_mapping(CHANNEL, CONTROL, TARGET, EXTRA_DATA)

    device.register_mapping(1, 21, bedroom_lights,'brightness_channel')
    device.register_mapping(1, 8, bedroom_lights,'red_channel')
    device.register_mapping(1, 9, bedroom_lights,'green_channel')
    device.register_mapping(1, 9, bedroom_lights,'hue_channel')
    device.register_mapping(1, 10, bedroom_lights,'blue_channel')
    device.register_mapping(1, 10, bedroom_lights,'saturation_channel')

    device.register_mapping(1, 29, power_switch_02)
    device.register_mapping(1, 30, cycle_color_mode)
    device.register_mapping(1, 31, circadian_lighting)

    device.register_mapping(1, 11, master_volume)
    device.register_mapping(1, 3, spoitfy_volume)
    device.register_mapping(1, 4, discord_volume)
    device.register_mapping(1, 5, tarkov_volume)
    device.register_mapping(1, 5, r6_volume)

    device.loop()

Future Plans

  • WRITE DOCUMENTATION
  • ADD ERROR HANDLING
  • Add Spotify functionality via spotipy
  • Add Discord functionality via discord.py
  • Add the ability to get the current state of each control on initialization. I believe this will require a midi controller with the sys_ex function to support this but I know pretty little about sys_ex messages.
  • Add functionality to change between channels or banks without relying on the controller to have a bank switch.
Owner
Tane Barriball
Tane Barriball
A not exist cat image generator python package

A not exist cat image generator python package

Fayas Noushad 2 Dec 03, 2021
The functions we created are included in a script. The necessary parts for pre-processing were taken. Analysis complete.

Feature-Engineering The functions we created are included in a script. The necessary parts for pre-processing were taken. Analysis complete. Business

Ayşe Nur Türkaslan 4 Oct 17, 2021
Hello, Welcome to this repo. don't forget to read guidelines in readme.md

Hacktoberfest_2021 If you looking for your first contribution, we are here to help. Just create a simple program using any language you like in our fo

Wafa Rifqi Anafin 117 Dec 14, 2022
AKSWINPOSTINIT -- AKS Windows node post provisioning initialization

AKSWINPOSTINIT -- AKS Windows node post provisioning initialization Features This is a tool that provides one-time powershell script initilization for

Ping He 3 Nov 25, 2021
lets learn Python language with basic examples. highly recommended for beginners who just start coding.

Lets Learn Python 🐍 Learn python from basic programs. learn python from scratch. 1.Online python compiler: https://www.onlinegdb.com/online_python_co

Subhranshu Choudhury 1 Jan 18, 2022
Location of public benchmarking; primarily final results

CSL_public_benchmark This repo is intended to provide a periodically-updated, public view into genome sequencing benchmarks managed by HudsonAlpha's C

HudsonAlpha Institute for Biotechnology 15 Jun 13, 2022
A set of scripts for a two-step procedure to measure the value of access to destinations across several modes of travel within a geographic area.

A set of scripts for a two-step procedure to measure the value of access to destinations across several modes of travel within a geographic area.

Institute for Transportation and Development Policy 2 Oct 16, 2022
A simple projects to help your seo optimizing has been written with python

python-seo-projects it is a very simple projects to help your seo optimizing has been written with python broken link checker with python(it will give

Amirmohammad Razmy 3 Dec 25, 2021
A Python script to parse Fortinet products serial numbers, and detect the associated model and version.

ParseFortinetSerialNumber A Python script to parse Fortinet products serial numbers, and detect the associated model and version. Example $ ./ParseFor

Podalirius 10 Oct 28, 2022
This is the code of Python enthusiasts collection and written.

I am Python's enthusiast, like to collect Python's programs and code.

cnzb 35 Apr 18, 2022
Implements a polyglot REPL which supports multiple languages and shared meta-object protocol scope between REPLs.

MetaCall Polyglot REPL Description This repository implements a Polyglot REPL which shares the state of the meta-object protocol between the REPLs. Us

MetaCall 10 Dec 28, 2022
Python Project For Beginner

Basic-Vitrual-AI-Assistant Python Project For Beginner Hey There, I had manipulated Selenium WebDriver to make this assistant. I hope, It will be help

Maruf Billah 13 Dec 12, 2022
navigation_commander is a ROS package to command the robot to navigate autonomously to each table for food delivery inside a hotel.

navigation_commander navigation_commander is a ROS package to command the robot to navigate autonomously to each table for food delivery inside a hote

ALEENA LENTIN 9 Nov 08, 2021
Chess bot can play automatically as white or black on lichess.com, chess.com and any website using drag and drop to move pieces

Chessbot "Why create another chessbot ?" The explanation is simple : I did not find a free bot I liked online : all the bots I saw on internet are par

Dhimas Bagus Prayoga 2 Nov 11, 2021
Decipher using Markov Chain Monte Carlo

Decipher using Markov Chain Monte Carlo

Science étonnante 43 Dec 24, 2022
Scalene: a high-performance, high-precision CPU, GPU, and memory profiler for Python

Scalene: a high-performance CPU, GPU and memory profiler for Python by Emery Berger, Sam Stern, and Juan Altmayer Pizzorno. Scalene community Slack Ab

PLASMA @ UMass 7k Dec 30, 2022
万能通用对象池,可以池化任意自定义类型的对象。

pip install universal_object_pool 此包能够将一切任意类型的python对象池化,是万能池,适用范围远大于单一用途的mysql连接池 http连接池等。 框架使用对象池包,自带实现了4个对象池。可以直接开箱用这四个对象池,也可以作为例子学习对象池用法。

12 Dec 15, 2022
AdventOfCode 2021 solutions from the Devcord server

adventofcode-21 Ein Sammel-Repository für Advent of Code 2021-Lösungen der deutschen DevCord-Community. A repository collecting Advent of Code 2021 so

Devcord 12 Aug 26, 2022
A practice program to find the LCM i.e Lowest Common Multiplication of two numbers using python without library.

Finding-LCM-using-python-from-scratch Here, I write a practice program to find the LCM i.e Lowest Common Multiplication of two numbers using python wi

Sachin Vinayak Dabhade 4 Sep 24, 2021
Gerador de dafaces

🎴 DefaceGenerator Obs: esse script foi criado com a intenção de ajudar pessoas iniciantes no hacking que ainda não conseguem criar suas próprias defa

LordShinigami 3 Jan 09, 2022