Sunday, August 21, 2022

Raspberry Pi 4 Eyesy Clone Guide

Raspberry Pi 4 "Eyesy" Clone 

Using a Raspberry Pi 4, MIDI, and an AudioInjector


Opening Note
This is pretty much the same thing you can find over on this Blokas thread, however this is modified to work with a much cheaper AudioInjector hat for the Pi. It does not have "The Button" like the PiSound has, but I might make an addendum on how to setup a button through the GPIO of the Pi. The setup cost me around $100, which includes the Pi, 45W USB-C Dell Power supply (a little overkill but what I had on hand that could put out 5V at 3A), 32gig MicroSD card, and microHDMI adapter.



The Guide
This is a step-by-step guide that worked for me, I now have a EYESY running smoothly on my Pi and is controllable by MIDI and OSC and I hope this will help you make one for your own for relatively cheap!

EYESY from Critter and Guitari is a self-contained video synthesizer based on a Raspberry Pi. It generates animated graphics (made with Python)

Original Critter and Guitari Eyesy



More Info on the original > EYESY




Difficulty: Intermediate

Optimized for Headless Use: Yes (with future modification)

Recommended Raspberry Pi Models: I have a Raspberry PI 4b 4GB, I wouldn't recommend anything under RaspberryPi 3

Required Hardware:
Required Software:

An important note: in order to run EYESY on a RaspberryPi 4 8Gb with AudioInjector, I mixed several information and tutorials together (I took most of this tutorial/guide from Blokas user jqrsound, and information gathered from the email group on AudioInjector.net)

Some passages may be redundant and when I encountered a problem I found a solution on various boards or websites. A little Google'ing can go a long way in trying to understand why something is happening, or isn't happening.

For this guide I did copy/paste the mentioned tutorial plus I added some personal notes. Some mistakes where probably made, so please report them to me, but please consider that after a lot of trial and error at the end is all working 

Note: according to Okyeron EYESY expects a pi/pi user/group, therefore I installed Raspbian Buster instead of Patchbox or Bullseye. I used a Windows 10 PC to set this up.

This is edited expecting you to know a bit on how to setup and work your way around a Raspberry Pi and a Linux/Debian environment already. Sorry if it doesn't cover minor details!


The process is 2 or 3 hours long, so grab a drink and here we go!


Step 01: Prepare the SD card with the base system image.
    Download Raspberry Pi OS Lite and flash it onto your SD card with Balena Etcher.
Open up the image for Raspbian Lite, choose the SD card and click flash.


Step 02: Setup Config
    Power on the Pi connected to a display and keyboard. First boot will have you log into the standard Pi root user. Log in, then type:

sudo raspi-config

This step uses the standard RaspberryPi configuration program to configure the Pi, it uses the arrow keys and the tab key to navigate.

Change/update the following:
System Option
    S3 Change User Password – Set a new password (please do this!)
    S1 Wireless Lan - Enter your SSID and passphrase here
    S5 Boot/Autologin – Desktop
Localisation Options
    L2 Change Timezone – pick your timezone
    L4 Change Wi-fi Country – pick your country
Interfacing Options
    P2 SSH - Yes
    P3 VNC – Yes
Performance
    P2 GPU Memory – 16
Display
    D1 Resolution – 1920x1080
Then [tab] key to Finish, hit return, then select Yes to reboot.
After the reboot, log in to pi with your new password you typed into the S3 step


Step 03: Log in to your Raspbian Lite remotely
    When you are logged in, get your IP address.
Type:

ifconfig

 

Note the IP for your WiFi connection.

    At this point, you can go back to a computer that you are reading this from (so you can copy and paste commands) and open PuTTy (or whatever ssh software you want to do SSH from). If you followed the steps above, your Pi should now be connected to the same network as your computer. type your IP address in and select SSH and connect. Accept the key request and log in with the username "pi" and the password you made in the config.




Step 04: Update and Install Basics
    Run these 2 commands.  This will ensure you have the latest version of all the installed packages.
sudo apt-get update
sudo apt-get dist-upgrade

 

    Depending on how old the image you downloaded is, this could be quick or take some time.
Now install the minimal things needed to be able to run a graphical desktop.
Run these two commands.
sudo apt-get install --no-install-recommends \
screen vim \
git make \
xserver-xorg xinit \
realvnc-vnc-server

sudo apt-get install raspberrypi-ui-mods

 


Step 05: Important packages and dependencies
    Run this command to install git and perl which are important packages you will need later on.

sudo apt update && sudo apt install git perl



Step 06: Disable the on-board audio output
    I did this because EYESY is looking for your sound card to be the “default” device, so I guessed it’d be easier to disable the others 
To disable the on board Jack output on the Pi open up the boot config file

sudo nano /boot/config.txt 

Find the line that says dtparam=audio=on and comment it out so that it looks like this:

#dtparam=audio=on

Then add this line to the end for the AudioInjector:

dtoverlay=audioinjector-wm8731-audio

Reboot, then check to see the audio input after you log in by typing this

aplay -l

You should see something like this:
**** List of PLAYBACK Hardware Devices ****
card 0: audioinjectorpi [audioinjector-pi-soundcard], device 0: AudioInjector audio wm8731-hifi-0 [AudioInjector audio wm8731-hifi-0]

  Subdevices: 1/1
  Subdevice #0: subdevice #0

If the card is the only one shown, then it is working so far! 



Step 07: Tuning the system
    The following commands are based on the canonical instructions for tuning your Linux system for audio work.
 Warning: These will alter config files on your system, use at your own risk and only on a fresh Raspbian installation.

Mads Kjeldgaard gathered these in a handy gist, so you can execute them just by copy-pasting his long command:

git clone https://gist.github.com/madskjeldgaard/c5731e95bc5be9b3e2789b14b1149b6e && mv c5731e95bc5be9b3e2789b14b1149b6e raspiaudiotune && cd raspiaudiotune && chmod +x raspiaudiotune.sh && ./raspiaudiotune.sh && cd ~ && rm -rf raspiaudiotune

To make these changes take effect, the Pi must be rebooted once more.

sudo reboot

 


Step 08: Install and setup Jack
    Jack is used to patch audio throughout your audio system on Linux.
Let’s install and setup Jack:

sudo apt-get install jackd2

Jack has a configuration file in ~/.jackdrc that we will set up on installation, but you can edit this anytime to tune the system’s settings using a text editor by running "
nano ~/.jackdrc"


The config file consists of a jackdcommand which will be run when we boot the audio server in there.

Create config file in home folder called .jackdrc:

echo /usr/bin/jackd -P75 -dalsa -dhw:0 -r48000 -p512 -n2 > ~/.jackdrc

Explanations of the flags used here:
-P75 - the real-time priority of the audio
-dhw:0 is AudioInjector device number.
-r48000 is AudioInjector sample rate.
-p512 is the block size. This can be tuned to achieve lower latency. Must be power of two.
-n2 - Jack’s buffer periods.



Step 09: Watchdog (optional)
If you are using your Pi for a live gig or an installation, setting up a watchdog can be a good idea. If your Pi gets overexcited or crashes, the watchdog will reboot the system (which as a consequence will trigger whatever startup script you have installed, if any).

sudo apt install watchdog

Open up the config file for the watchdog: /etc/watchdog.conf
Uncomment the following:
max-load-1 = 24
min-memory = 1
watchdog-device = /dev/watchdog

Then add the following:


watchdog-timeout=15

The watchdog can be run and activated automatically using systemd. This is done using the following commands:

sudo systemctl enable watchdog 
sudo systemctl start watchdog

To test if the watchdog is doing it’s job, you can stress the system by creating a so-called fork bomb which will make the system crash by recursively calling a function until the Pi chokes up.
On the Pi (not your main computer!), execute the following fork bomb:

forkbomb(){ forkbomb | forkbomb & }; forkbomb

Wait a bit and then see your Pi crash. After choking up, it should automatically reboot itself. If it does this, your watchdog is doing it’s job.




Step 10: Backup

    It’s a good idea to back up your sd card at this point.
I followed this instructions: Backing up and Restoring your Raspberry Pi's SD Card




Step 11: Graphic Login
    You can work with your Pi entirely from the ssh connection. But having a graphical desktop on the Pi often makes setting up patches, and debugging them much much easier.

On your computer, install RealVNC Viewer:

Run it and connect to your Pi.

You’ll need to enter login information twice, once so RealVNC connect to the Pi and then once to the Pi screen that comes up.




Step 12: Install VideoSynth Eyesy (by Okyeron)
    Open a terminal on the VNC connection and type the following:

git clone https://github.com/okyeron/EYESY_OS_for_RasPi.git Eyesy 
cd Eyesy ./deploy.sh 


This will install Pure Data and over 700 MB of packages.




Step 13: Install amidiauto to control MIDI.
    This will really help troubleshoot programming your MIDI controllers to control the Eyesy

Run in the Terminal via VNC:

sudo apt-get update && sudo apt-get install amidiauto

Copy the following lines in /etc/amidiauto.conf (if you can’t find the file, create it):

[allow]
* <-> *

Now open Pure Data under the audio settings and under Media select Alsa MIDI. 


    Before you run EYESY and play with the MIDI the first time, an IMPORTANT NOTE on the MIDI CC setupCC34 doesn’t work correctly, instead of modifying the input gain of EYESY, it actually mute your audio input (Midi 0 to127 result in a gain stage of 0.00% to 0.29%). To restore the original setup you need to reinstall the entire Eyesy folder on the Pi!

Shutdown your Pi, connect a display to the HDMI out and boot up your Pi.
Power the device back on and run the following

sudo ./Eyesy/run.sh

    Audio and MIDI should work as expected, to test them follow the Control via Midi section from Okyeron Github page: GitHub - okyeron/EYESY_OS_for_RasPi
There you will find the CC numbers to control the parameters for the Eyesy software via MIDI.

    Side Note: The TouchOSC software mentioned on that page is another way to control your Eyesy via WiFi. It does cost some money, but the layout and intuitiveness is amazing.



Step 14: Setup your pi to auto start Eyesy, add a button to turn on and off, etc.
  -  To make Eyesy start upon boot, open a terminal or ssh in and type

sudo nano /etc/profile

    At the end of the file, type this

sudo ./Eyesy/run.sh
 
Save and close the file.

    (power switch coming soon)



Step 15: Clean and clone (optional)
To removes packages which are not longer needed from the system, run:

sudo apt autoremove && sudo apt clean

Download Piclone (SD Card Copier) 

sudo apt update sudo apt install piclone

The SD Card Copier application, which can be found on the Accessories menu of the Raspberry Pi Desktop, will copy Raspberry Pi OS from one card to another. To use it, you will need a USB SD card writer.

To back up your existing Raspberry Pi OS installation, put a blank SD card in your USB card writer and plug it into your Pi, and then launch SD Card Copier.




That’s it, at this point you have a running EYESY on your headless Pi, have fun! 


Afterword: I have set my "Eyesy" to work with an old M-Audio Triggerfinger by changing the knobs and sliders to the correct CC channels. MIDI transported over USB connection, and Triggerfinger powered by RasPi. Video below...






Here you can read the original tutorials:

No comments:

Post a Comment

Don't be a dingus

StreamElements Overlay Chat - Top Down display!

 Okay, this seems silly to make a post like this, but I wish I had found a page that told me this before wasting a few hours trying to figur...