initial commit

This commit is contained in:
Adrian Baumgart 2024-04-01 00:05:23 +02:00
commit b047c3b21c
No known key found for this signature in database
4 changed files with 97 additions and 0 deletions

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 Adrian Baumgart
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

47
README.md Normal file
View File

@ -0,0 +1,47 @@
# Midictrl-Companion
Read signals from a MIDI device and redirect them to Bitfocus Companion.
## Requirements
- `alsa-utils` must be installed
- Running instance of [Bitfocus Companion](https://bitfocus.io/companion)
## Setup
First, clone this repository:
```sh
$ git clone https://git.abmgrt.dev/rainloreley/midictrl-companion.git
$ cd midictrl-companion
```
Connect the MIDI device and run
```sh
$ aseqdump -l
Port Client name Port name
0:0 System Timer
0:1 System Announce
14:0 Midi Through Midi Through Port-0
24:0 Arduino Micro Arduino Micro MIDI 1
...
```
to get the device name of the MIDI device.
Edit the `midictl.sh` file and change the following variables:
- `MIDI_CLIENT`: The client name you just got from the command before
- `BANK`: The id of the bank in Bitfocus Companion you want to control
Now make the file executable and copy it to `/usr/local/bin`:
```sh
$ chmod +x midictrl.sh
$ mv midictrl.sh /usr/local/bin
# If using systemd:
$ mv midictrl.service /etcx/systemd/system
$ systemctl daemon-reload
$ systemctl enable midictrl.service --now
```
Currently you have to restart the service/script if you connect the MIDI device after the computer is started.
## License
This code is licensed under the MIT license

9
midictrl.service Normal file
View File

@ -0,0 +1,9 @@
[Unit]
Description=MIDI to Bitwarden Companion Translator
[Service]
Type=simple
ExecStart=/usr/local/bin/midictrl.sh
[Install]
WantedBy=multi-user.target

20
midictrl.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
# Read the MIDI inputs of a MIDI device and redirect them to Bitfocus Companion.
#
# 2024 Adrian Baumgart, MIT License
# https://git.abmgrt.dev/rainloreley/midictrl-companion
#
# Code based on https://linux.reuf.nl/projects/midi.htm
MIDI_CLIENT="Arduino Micro"
BANK=1
aseqdump -p "$MIDI_CLIENT" |
{
read
read
while IFS=" ," read src ev1 ev2 ch label1 ctrl_no label2 ctrl_value rest
do
curl -s "http://127.0.0.1:8000/press/bank/$BANK/$ctrl_no" > /dev/null
done
}