- Extended readme
This commit is contained in:
parent
9e01adbce5
commit
3ff162e780
@ -86,9 +86,9 @@ def relay_midi_host_to_out(host_name, devices_out):
|
|||||||
print(reset)
|
print(reset)
|
||||||
while not reset:
|
while not reset:
|
||||||
# Process all pending messages
|
# Process all pending messages
|
||||||
#print("Entering loop", input_port.iter_pending() )
|
|
||||||
for message in input_port.iter_pending():
|
for message in input_port.iter_pending():
|
||||||
read_message = str(message)
|
read_message = str(message)
|
||||||
|
#print(read_message)
|
||||||
|
|
||||||
if 'start' in read_message or 'stop' in read_message:
|
if 'start' in read_message or 'stop' in read_message:
|
||||||
for dev in output_ports:
|
for dev in output_ports:
|
||||||
@ -105,6 +105,7 @@ def relay_midi_host_to_out(host_name, devices_out):
|
|||||||
|
|
||||||
# Check if the last 3 messages are all 'stop'
|
# Check if the last 3 messages are all 'stop'
|
||||||
if recent_messages[-3:] == ['stop time=0', 'stop time=0', 'stop time=0']:
|
if recent_messages[-3:] == ['stop time=0', 'stop time=0', 'stop time=0']:
|
||||||
|
print("Exiting", recent_messages)
|
||||||
recent_messages.clear()
|
recent_messages.clear()
|
||||||
|
|
||||||
reset = True
|
reset = True
|
||||||
@ -133,10 +134,10 @@ def main_run():
|
|||||||
# Retrieve the list of available input devices
|
# Retrieve the list of available input devices
|
||||||
devices_in = mido.get_input_names()
|
devices_in = mido.get_input_names()
|
||||||
devices_out = mido.get_output_names()
|
devices_out = mido.get_output_names()
|
||||||
print("Available MIDI input devices:", devices_in)
|
|
||||||
|
|
||||||
devices_in = remove_through_ports(devices_in)
|
devices_in = remove_through_ports(devices_in)
|
||||||
devices_out = remove_through_ports(devices_out)
|
devices_out = remove_through_ports(devices_out)
|
||||||
|
print("Available MIDI input devices:", devices_in)
|
||||||
|
|
||||||
# Listen for devices that send start and return the host name
|
# Listen for devices that send start and return the host name
|
||||||
midi_host_in = determine_host(devices_in)
|
midi_host_in = determine_host(devices_in)
|
||||||
|
62
readme.md
62
readme.md
@ -9,11 +9,34 @@ The output is filtered so the host doesn´t receive sync signals from the member
|
|||||||
*Notes,CCs and other messages are not handled currently.*
|
*Notes,CCs and other messages are not handled currently.*
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
- SSH into PI
|
||||||
|
|
||||||
|
### Get repository
|
||||||
- pull from repository with `git clone https://git.raise-uav.com/Hermes/AutoSyncHost.git`
|
- pull from repository with `git clone https://git.raise-uav.com/Hermes/AutoSyncHost.git`
|
||||||
|
- Alternatively download directly from page via download zip and extract into a folder.
|
||||||
|
|
||||||
|
### Preparation
|
||||||
|
Install Python and pip if they are not already installed. You can use the following commands to install them:
|
||||||
|
- `sudo apt-get update`
|
||||||
|
- `sudo apt-get install python3 python3-pip`
|
||||||
|
|
||||||
|
### Create Environment
|
||||||
|
Navigate to the directory where you cloned the repository. For example:
|
||||||
|
- One directory below the AutoSyncHost directorys like `/home/pi`
|
||||||
|
- `python3 -m venv AutoSyncHost`
|
||||||
|
- `source AutoSyncHost/bin/activate`
|
||||||
|
|
||||||
|
### Install Packages
|
||||||
- `pip install mido`
|
- `pip install mido`
|
||||||
- `pip install python-rtmidi`
|
- `pip install python-rtmidi`
|
||||||
- `python ashost.py` in folder
|
- 'sudo apt-get install libjack-jackd2-dev' (Might be necessary if error occurs)
|
||||||
- App is running and waiting for a device playing
|
|
||||||
|
### Start Program
|
||||||
|
- `cd AutoSyncHost`
|
||||||
|
- `python ashost.py`
|
||||||
|
|
||||||
|
App is running and waiting for a device playing. You need to restart the script if new devices have been connected.
|
||||||
|
If oyu got the systemd service running you need to restart the PI.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
- First MIDI device that sends a midi "start" command becomes the host everybody listens to.
|
- First MIDI device that sends a midi "start" command becomes the host everybody listens to.
|
||||||
@ -23,5 +46,40 @@ The output is filtered so the host doesn´t receive sync signals from the member
|
|||||||
### Notes
|
### Notes
|
||||||
It is especially interesting for devices that don´t have a physical MIDI port like the OP-Z or OP-1.
|
It is especially interesting for devices that don´t have a physical MIDI port like the OP-Z or OP-1.
|
||||||
|
|
||||||
|
### Make it a service
|
||||||
|
This will start the script automatically after the pi has started and will restart it.
|
||||||
|
|
||||||
|
Create a ashost.service file in /etc/systemd/system
|
||||||
|
- `sudo nano /etc/systemd/system/ashost.service`
|
||||||
|
|
||||||
|
```
|
||||||
|
[Unit]
|
||||||
|
Description=AutoSyncHost service
|
||||||
|
Wants=network-online.target
|
||||||
|
After=network.target network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
Restart=always
|
||||||
|
ExecStart=/bin/bash /home/maxi/Desktop/start.sh
|
||||||
|
RestartSec=5
|
||||||
|
TimeoutSec=60
|
||||||
|
RuntimeMaxSec=infinity
|
||||||
|
PIDFile=/tmp/mydaemon.pid
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
```
|
||||||
|
|
||||||
|
- Save and exit with CTRL -O, Enter, CTRL X
|
||||||
|
- `sudo systemctl daemon-reload`
|
||||||
|
- `sudo systemctl enable ashost.service`
|
||||||
|
- `sudo systemctl start ashost.service`
|
||||||
|
- `sudo systemctl status ashost.service`
|
||||||
|
|
||||||
|
The status command should show a running service*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user