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.
You might also like...
Cvdl-hw2 - Find Contour, Camera Calibration, Augmented Reality and Stereo Disparity Map

opevcvdl-hw2 This project uses openCV and Qt to achieve the requirements. Version Python 3.7 opencv-contrib-python 3.4.2.17 Matplotlib 3.1.1 pyqt5 5.1

Python project that aims to discover CDP neighbors and map their Layer-2 topology within a shareable medium like Visio or Draw.io.

Python project that aims to discover CDP neighbors and map their Layer-2 topology within a shareable medium like Visio or Draw.io.

 tidevice can be used to communicate with iPhone device
tidevice can be used to communicate with iPhone device

h 该工具能够用于与iOS设备进行通信, 提供以下功能 截图 获取手机信息 ipa包的安装和卸载 根据bundleID 启动和停止应用 列出安装应用信息 模拟Xcode运行XCTest,常用的如启动WebDriverAgent测试

Simple utlity for sniffing decrypted HTTP/HTTPS traffic on a jailbroken iOS device into an HAR format.
Simple utlity for sniffing decrypted HTTP/HTTPS traffic on a jailbroken iOS device into an HAR format.

Description iOS devices contain a hidden feature for sniffing decrypted HTTP/HTTPS traffic from all processes using the CFNetwork framework into an HA

AndroidEnv is a Python library that exposes an Android device as a Reinforcement Learning (RL) environment.
AndroidEnv is a Python library that exposes an Android device as a Reinforcement Learning (RL) environment.

AndroidEnv is a Python library that exposes an Android device as a Reinforcement Learning (RL) environment.

An AI-powered device to stop people from stealing my packages.

Package Theft Prevention Device An AI-powered device to stop people from stealing my packages. Installation To install on a raspberry pi, clone the re

Script for resizing MTD partitions on a QNAP device in order to be available to upgrade from buster to bullseye
Script for resizing MTD partitions on a QNAP device in order to be available to upgrade from buster to bullseye

QNAP partitions resize for kirkwood devices. As explained by Marin Michlmayr, Debian bullseye support on kirkwood QNAP devices was dropped due to [mai

CDM Device Checker for python

CDM Device Checker for python

Easy installer for running Amazon AVS Device SDK on Raspberry Pi

avs-device-sdk-pi Scripts to enable Alexa voice activation using Picovoice Porcupine If you like the work, find it useful and if you would like to get

Comments
  • voicemeeter

    voicemeeter

    hi, sorry i'm pretty new to github, i'm sure this isn't the right place to put this but i don't know where else... it's more suggestion and potential offer of contribution than issue...

    do you know voicemeeter? it's an absurdly powerful virtual audio mixer, with built-in 'macro-button' system and VBAN- a comprehensive multi-stream audio over ip solution

    these solutions are all donationware. they are being used fairly widely in professional and semi-professional environments.

    macrobuttons can be defined in ui or xml, and perform a very long list of actions within and outside of the voicemeeter program - launch programs, send keypresses, do so conditionally on state of the mixer, eg i make a midi controller light flash if input on a given channel is over 6db, or switch output between different audio systems, including (via VBAN) other computers on the network, and my phone. it can send audio outside of local network too.

    voicemeeter also has an api which allows for wide-ranging control of the setup.

    i'm thinking there may be ways to combine vm and pymidicontroller, and in doing so create a bridge between vm and homeassistant, which would be very very powerful for creating and controlling multi-zone audio systems, with multiple inputs, including audio-over-ip, taking audio from different applications and proicessing independently (eg reverb on that channel, eq on this one, 5.1 on this channel, stereo on that one, etc) all eminently controllable through automations and manual inputs from midi controllers, homeassistant android, or literally any other input...

    i'm a novice coder, but i'm hacking away at a few personal projects and might be able to contribute here, but i'd need a little help determining approaches and strategies, and if i can't use python i'm probably out...

    opened by Paul-Sees-Solutions 0
Owner
Tane Barriball
Tane Barriball
Blender Add-on That Provides Quick Access to Render Controls

Blender Render Buttons Blender Add-on That Provides Quick Access to Render Controls A Blender 3.0 compatablity update of Blender2.8x-RenderButton v0.0

Don Schnitzius 3 Oct 18, 2022
This application demonstrates IoTVAS device discovery and security assessment API integration with the Rapid7 InsightVM.

Introduction This repository hosts a sample application that demonstrates integrating Firmalyzer's IoTVAS API with the Rapid7 InsightVM platform. This

Firmalyzer BV 4 Nov 9, 2022
Simple Python-based web application to allow UGM students to fill their QR presence list without having another device in hand.

Praesentia Praesentia is a simple Python-based web application to allow UGM students to fill their QR presence list without having another device in h

loncat 20 Sep 29, 2022
My HA controller for veg and flower rooms

HAGrowRoom My HA controller for veg and flower rooms I will do my best to keep this updated as I change, add and improve. System heavily uses custom t

null 4 May 25, 2022
Python PID Controller and Process Simulator (FOPDT) with GUI.

PythonPID_Simulator Python PID Controller and Process Simulator (FOPDT) with GUI. Run the File. Then select Model Values and Tune PID.. Hit Refresh to

null 19 Oct 14, 2022
An app that mirrors your phone to your compute and maps controller input to the screen

What is 'Dragalia Control'? An app that mirrors your phone to your compute and maps controller input to the screen. Inputs are mapped specifically for

null 1 May 3, 2022
Dockernized ZeroTierOne controller with zero-ui web interface.

docker-zerotier-controller Dockernized ZeroTierOne controller with zero-ui web interface. 中文讨论 Customize ZeroTierOne's controller planets Modify patch

sbilly 209 Jan 4, 2023
Controller state monitor plugin for EVA ICS

eva-plugin-cmon Controller status monitor plugin for EVA ICS Monitors connected controllers status in SFA and pushes measurements into an external Inf

Altertech 1 Nov 6, 2021
A turtlebot auto controller allows robot to autonomously explore environment.

A turtlebot auto controller allows robot to autonomously explore environment.

Yuliang Zhong 1 Nov 10, 2021
Plugin to manage site, circuit and device diagrams and documents in Netbox

Netbox Documents Plugin A plugin designed to faciliate the storage of site, circuit and device specific documents within NetBox Note: Netbox v3.2+ is

Jason Yates 38 Dec 24, 2022