Home

Awesome

Pysha

Pysha is a Python 3 app to use Push2 as a standalone MIDI controller. It has manily been designed to work as a controller for Squarp's Pyramid, but it can also be used as a generic controller. To run Pysha, you just need to install Python requirements and run app.py on a computer connected to Push2 and with a MIDI interface to output messages.

pip install -r requirements.txt
python app.py

Pysha can run on a Raspberry Pi (see instructions below) so you can use Push2 as a standalone controller without your laptop around. Pysha is based on push2-python. push2-python requires pyusb which is based in libusb. You'll most probably need to manually install libusb for your operative system if pip install -r requirements.txt does not do it for you. Moreover, to draw on Push2's screen, Pysha uses pycairo Python package. You'll most probably also need to install cairo if pip install -r requirements.txt does not do it for you (see this page for info on that). The name "Pysha" is some sort of blend of the names of the technologies/devices that are used.

NOTE: Development for Pysha as a controller for Squarp's Pyramid has been abandoned and has evolved into Shepherd, a full "Raspberry Pi + Push 2" based MIDI sequencer which does not depend on any external piece of hardware.

Features

I designed Pysha (and I continue to update it) to serve my own specific setup needs, but hopefully it can be useful (or adapted!) to work on other setups as well. In my setup, I run Pysha on a Rapsberry Pi and connected to Push2. Push2 is used as my main source of MIDI input, and the generated MIDI is routed to a Squarp Pyramid sequencer. From there, Pyramid connects to all the other machines in the setup. Also, I have a MIDI keyboard connected to Pysha so that the notes generated from the keyboard are merges with the notes generated from Push. Below is a diagram of my setup with Pysha. These are the features that Pysha has currently implemented:

<img src="docs/diagram.jpeg" style="width:100%"/>

Here are a couple of photos of Pysha working:

<img src="docs/pysha_melodic_mode.jpeg" style="width:100%"/>

Melodic mode

<img src="docs/pysha_rhythmic_mode.jpeg" style="width:100%"/>

Rhythmic mode

<img src="docs/pysha_instrument_selection_midi_cc.jpeg" style="width:100%"/>

MIDI CC controls with instrument definition file

<img src="docs/pysha_velocity_curves.jpeg" style="width:100%"/>

Interactive adjustment of aftertouch range/velocity curve

User manual

Well, this is not a proper user manual, but here are some notes about how to use Pysha:

Instructions to get Pysha running on a RaspberryPi

These are instructions to have the script running on a Rapsberry Pi and load at startup. I'm using this with a Raspberry Pi 2 and Raspbian 2020-02-13. It works a bit slow but it works. I also tested on a Raspberry Pi 4 and it is much faster and reliable.

These instructions assume you have ssh connection with the Rpasberry Pi. Here are the instructions for enabling ssh on the Pi. Here are instructions for setting up wifi networks. Also, here are instructions for changing the hostname of the Pi so for example you can access it like ssh pi@pysha.

  1. Install system dependencies
sudo apt-get update && sudo apt-get install -y libusb-1.0-0-dev libcairo2-dev python3 python3-pip git libasound2-dev libatlas-base-dev
  1. Clone the app repository
git clone https://github.com/ffont/pysha.git
  1. Install Python dependencies
cd pysha
pip3 install -r requirements.txt
  1. Configure permissions for using libusb without sudo (untested with these specific commands, but should work)

Create a file in /etc/udev/rules.d/50-push2.rules...

sudo nano /etc/udev/rules.d/50-push2.rules

...with these contents:

add file contents: SUBSYSTEM=="usb", ATTR{idVendor}=="2982", ATTR{idProduct}=="1967", GROUP="audio"

Then run:

sudo udevadm control --reload-rules
sudo udevadm trigger

5. Configure Python script to run at startup:

Create file in /lib/systemd/system/pysha.service...

sudo nano /lib/systemd/system/pysha.service

...with these contents:

[Unit]
Description=Pysha
After=network-online.target

[Service]
WorkingDirectory=/home/pi/pysha
ExecStart=/usr/bin/python3 /home/pi/pysha/app.py                                                
StandardOutput=syslog
User=pi
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

Set permissions to file:

sudo chmod 644 /lib/systemd/system/pysha.service

Enable the service (and do the linger thing which really I'm not sure if it is necessary nor what it does)

loginctl enable-linger pi
sudo systemctl enable pysha.service

After that, the app should at startup. You can start/stop/restart and check logs running:

sudo systemctl start|stop|restart pysha
sudo journalctl -fu pysha