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
Wunderland desktop wallpaper and Microsoft Teams background.

Wunderland Professional Impress your colleagues, friends and family with this edition of the "Wunderland" wallpaper. With the nostalgic feel of the or

3 Dec 14, 2022
Python bindings for Basler's VisualApplets TCL script generation

About visualapplets.py The Basler AG company provides a TCL scripting engine to automatize the creation of VisualApplets designs (a former Silicon Sof

Jürgen Hock 2 Dec 07, 2022
Q-Tracker is originally a High School Project created by Admins of Cirus Lab.

Q-Tracker is originally a High School Project created by Admins of Cirus Lab. It's completly coded in python along with mysql.(Tkinter For GUI)

Adithya Krishnan 2 Nov 14, 2022
The purpose of this code base is to add a specified signal-to-noise ratio noise from MUSAN dataset to a pure speech signal and to generate far-field speech data using room impulse response data from BUT [email protected] Reverb Database.

Add_noise_and_rir_to_speech The purpose of this code base is to add a specified signal-to-noise ratio noise from MUSAN dataset to a pure speech signal

Yunqi Chen 7 Oct 30, 2022
The program converts Swiss notes into American notes

Informatik-Programmieren Einleitung: Das Programm rechnet Schweizer Noten in das Amerikanische Noten um. Der Benutzer kann seine Note eingeben und der

2 Dec 16, 2021
dotfiles - Cristian Valero Abundio

In this repository you can find various configurations to configure your Linux operating system, preferably ArchLinux and its derivatives.

Cristian Valero Abundio 1 Jan 09, 2022
A few of my adventures with Devito.

Devito-playbox A few of my adventures with Devito. This repository contains a few notebooks and scripts that will lead me in the road of learning this

Átila Saraiva Quintela Soares 1 Feb 08, 2022
A fancy and practical functional tools

Funcy A collection of fancy functional tools focused on practicality. Inspired by clojure, underscore and my own abstractions. Keep reading to get an

Alexander Schepanovski 2.9k Dec 29, 2022
A male and female dog names python package

A male and female dog names python package

Fayas Noushad 3 Dec 12, 2021
Hoopoe - Get notified of important stuff, right away.

Hoopoe - Get notified of important stuff, right away. Report a Bug · Request a Feature . Ask a Question Table of Contents About Getting Started Prereq

Vahid Al 8 Nov 12, 2022
Simple and easy to use python API for the COVID registration booking system of the math department @ unipd (torre archimede)

Simple and easy to use python API for the COVID registration booking system of the math department @ unipd (torre archimede). This API creates an interface with the official browser, with more useful

Guglielmo Camporese 4 Dec 24, 2021
Fisherman is a free open source fishing bot written in python.

Fisherman is a free open source fishing bot written in python.

Pure | Cody 33 Jan 29, 2022
A basic DIY-project made using Python and MySQL

Banking-Using-Python-MySQL This is a basic DIY-project made using Python and MySQL. Pre-Requisite needed:-- MySQL command Line:- creating a database

ABHISHEK 0 Jul 03, 2022
Analyze FnO trends by using NSE Bhav copy

BhavFnO Analyze FnO trends by using NSE Bhav copy Download entire BhavFnO folder and unzip it In that folder open command window

33 Jan 04, 2023
Repository specifically for tcss503-22-wi Students

TCSS503: Algorithms and Problem Solving for Software Developers Course Description Introduces advanced data structures and key algorithmic techniques

Kevin E. Anderson 3 Nov 08, 2022
Blender addon that enables exporting of xmodels from blender. Great for custom asset creation for cod games

Birdman's XModel Tools For Blender Greetings everyone in the custom cod community. This blender addon should finally enable exporting of custom assets

wast 2 Jul 02, 2022
Xbps-install wrapper written in Python that doesn't care about case sensitiveness and package versions

xbi Xbps-install wrapper written in Python that doesn't care about case sensitiveness and package versions. Description This Python script can be easi

Emanuele Sabato 5 Apr 11, 2022
Automated rop chain generation

This is the accompanying code to the blog post talking about automated rop chain generation. Build the test file with: make Install the dependencies:

Christopher Roberts 14 Nov 22, 2022
Function Plotter✨

Function-Plotter Build With : Python PyQt5 unittest matplotlib Getting Started This is an list of needed instructions to set up your project locally,

Ahmed Lotfy 3 Jan 06, 2022
Script to work around some quirks of the blender obj importer

ObjFix 1.0 (WIP) Script to work around some quirks of the blender obj importer Installation Download this repo In Blender, press "Edit" on the top-bar

Red_3D 4 Nov 20, 2021