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
ELF file deserializer and serializer library

elfo ELF file deserializer and serializer library. import elfo elf = elfo.ELF.from_path('main') elf ELF( header=ELFHeader( e_ident=e

Filipe Laíns 3 Aug 23, 2021
Scraping comments from the political section of popular Nigerian blog (Nairaland), and saving in a CSV file.

Scraping_Nairaland This project scraped comments from the political section of popular Nigerian blog www.nairaland.com using the Python BeautifulSoup

Ansel Orhero 1 Nov 14, 2021
Draw random mazes in python

a-maze Draw random mazes in python This program generates and draws a rectangular maze, with an entrance on one side and one on the opposite side. The

Andrea Pasquali 1 Nov 21, 2021
A python based app to improve your presentation workflow

Presentation Remote A remote made for making presentations easier by enabling all the members to have access to change the slide and control the flow

Parnav 1 Oct 28, 2021
My attempt at this years Advent of Code!

Advent-of-code-2021 My attempt at this years Advent of Code! day 1: ** day 2: ** day 3: ** day 4: ** day 5: ** day 6: ** day 7: ** day 8: * day 9: day

1 Jul 06, 2022
Generating rent availability info from Effort rent

Rent-info Generating rent availability info from Effort rent Pre-Installation Latest version of python Pip module json, os, requests, datetime, time i

Laixuan 1 Oct 20, 2021
MiniJVM is simple java virtual machine written by python language, it can load class file from file system and run it.

MiniJVM MiniJVM是一款使用python编写的简易JVM,能够从本地加载class文件并且执行绝大多数指令。 支持的功能 1.从本地磁盘加载class并解析 2.支持绝大多数指令集的执行 3.支持虚拟机内存分区以及对象的创建 4.支持方法的调用和参数传递 5.支持静态代码块的初始化 不支

keguoyu 60 Apr 01, 2022
Created a Python Keylogger script.

Python Script Simple Keylogger Script WHAT IS IT? Created a Python Keylogger script. HOW IT WORKS Once the script has been executed, it will automatic

AC 0 Dec 12, 2021
Just RESTing

petnica-api-workshop Just RESTing Setup Using pipenv You can setup this project with pipenv if you want isolated libraries. After you've installed pip

Aleksa Tešić 1 Oct 23, 2021
A fishing bot script written in Python!

A fishing bot script written in Python!

Anel Drocic 3 Nov 03, 2021
A scuffed remake of Kahoot... Made by Y9 and Y10 SHSB

A scuffed remake of Kahoot... Made by Y9 and Y10 SHSB

Tobiloba Kujore 3 Oct 28, 2022
Python calculator made with tkinter package

Python-Calculator Python calculator made with tkinter package. works both on Visual Studio Code Or Any Other Ide Or You Just Copy paste The Same Thing

Pro_Gamer_711 1 Nov 11, 2021
The Great Autoencoder Bake Off

The Great Autoencoder Bake Off The companion repository to a post on my blog. It contains all you need to reproduce the results. Features Currently fe

Tilman Krokotsch 61 Jan 06, 2023
A python script to search for k-uniform Euclidean tilings.

k-uniform-solver A python script to search for k-uniform Euclidean tilings. This project's aim is to replicate and extend the list of k-uniform Euclid

3 Dec 06, 2022
A program that makes all 47 textures of Optifine CTM only using 2 textures

A program that makes all 47 textures of Optifine CTM only using 2 textures

1 Jan 22, 2022
Completed task 1 and task 2 at LetsGrowMore as a data science intern.

LetsGrowMore-Internship Completed task 1 and task 2 at LetsGrowMore as a data science intern. Task 1- Task 2- Creating a Decision Tree classifier and

Sanjyot Panure 1 Jan 16, 2022
A python script for practicing Toki Pona.

toki.py A python script for practicing Toki Pona. Modified from a hirigana script by ~vilmibm. Example of the script running: $ ./toki.py This script

Dustin 2 Dec 09, 2021
Certipy is a Python tool to enumerate and abuse misconfigurations in Active Directory Certificate Services (AD CS).

Certipy Certipy is a Python tool to enumerate and abuse misconfigurations in Active Directory Certificate Services (AD CS). Based on the C# variant Ce

ollypwn 1.3k Jan 01, 2023
Expression interpreter written in Python

Calc Interpreter An interpreter modeled after a calculator implemented in Python 3. The program currently only supports basic mathematical expressions

1 Oct 17, 2021
A Python script made for the Python Discord Pixels event.

Python Discord Pixels A Python script made for the Python Discord Pixels event. Usage Create an image.png RGBA image with your pattern. Transparent pi

Stanisław Jelnicki 4 Mar 23, 2022