LEET Linux

Linux based sound synthesis for LEET modules (or any other USB MIDI keyboard).

This project is suited for anyone that wants to build a powerful synthesizer engine. The project is built around the compact and affordable Raspberry Pi Zero (with WiFi) and has a miniature OLED display and six buttons. LEET Linux forms a complete synthesizer together with a USB HUB, a USB soundcard and other LEET devices (see video below).

All LEET devices use 3DPCB – a method where the circuit-board is replaced with a single 3D printed part that keeps all components in place while it also encompasses the case and structure of the product. Integrated wire channels makes it easy and fool prof to assemble and there is no need to pay and wait for a PCB delivery ;)

Demonstration of high-quality sound generation with LEET Linux running FluidSynth with Yamaha Disklavier Pro Grand Piano soundfont.

LEET Linux is part of the LEET synth project. Before continuing with the details below, it’s a good idea to read the main post first (if you haven’t already):

Part list:

  • 1x 3D printed core (3DPCB), uses 20g PLA filament.
  • 1x Raspberry Pi Zero W
  • 1x 128×64 0.96” SPI OLED display (I used the 6 pin version without CS, blue display)
  • 6x 6x6mm 4pin through hole tact switches – preferably with low activation force (50g / 0.5N)
  • 1x USB hub with micro USB cable, or a micro USB OTG adapter
  • 0.3mm copper wires (can be found in RK mains wire or similar)

Equipment:

  • 3D printer (FFF/FDM with PLA filament)
  • Solder station with a narrow tip
  • Basic tools: needle- and cutting pliers, knife, hot-glue

Build it

Print the core using a fff/fdm 3D printer. I used the following settings:

  • 3D printer: Prusa i3 MK3S with 0.4mm nozzle
  • Material: PLA
  • Nozzle temperature: 210deg C
  • Layer height: 0.2mm
  • Infill: 20%
  • Support: None

    The printing time is ~2.5 hours with default speed.

I have not made a step by step building instruction, but if you have built another LEET device, it should be sufficient to look at the illustration below.

Sound Engines

There are lots of different sound engines in Linux. So far, I have tried two different programs (FluidSynth and SamplerBox).

I hope that with the help of other LEET users the installation can be improved (providing ISO images) and more supported engines can be added. It would be nice to have ZynAddSubFX, sunvox and maybe an adaptation of zynthian in the future.

FluidSynth

I have successfully used FluidSynth (without a custom OLED interface). In the video above I used the Yamaha Disklavier Pro Grand Piano soundfont to demonstrate the quality of the sound. LEET sequencer is sending MIDI data to LEET Linux that is rendering the sound using an external USB soundcard and forwarding the MIDI events to the LEET keyboards (using aconnect command). By using pyFluidSynth, an interface can be developed in python that uses the OLED and the buttons to select soundfonts, map instruments and midi channels (3×2 buttons).

Installation of fluidsynth is quite straight forward. Follow the raspberry pi initialization below and type:

sudo apt-get install fluidsynth

Here is the bash script I used to start fluidSynth and map a LEET Keyboard to fluid MIDI:

(sleep 5; aconnect 16:0 128:0)&fluidsynth -a alsa -o audio.alsa.device='hw:1' -C0 -R0 -r48000 ./YDP-Grand.sf2

As you can see, I use plain alsa for sound generation (avoiding jack or pulseaudio that can cause additional delay.)

It is sometimes helpful to test audio to rule out other error sources:

First use this command to find the id of the attached soundcard

cat /proc/asound/modules
speaker-test -c2 -twav -Dhw:1,0  (where 1 is the id I got from the first command)

If you encounter problems, visit the forum to see if someone has found a solution to your problem, if not this is a great place to ask for assistance.

SamplerBox

I have also worked with SamplerBox and adjusted the script to use the OLED and keys to select sampleset. However, I have only got a few samples set to work properly, and haven’t figured out if the others are not working due to memory restrictions, configuration error or something else…

I hope that with the help of other LEET users the supported engines can be improved and expanded. It would be nice to add ZynAddSubFX, sunvox and maybe even adapt zynthian in the future. It would also be nice to provide ISO images for easy installations. Until then this project requires manual configuration and installation of different programs so Linux experience is preferred. But even a novice user should be able to follow the installation procedure of SamplerBox, however – expect to spend time googling for installation and configuration errors…

It was a bit tricky to use Samplerbox with the OLED display since samplerbox is using python2 while the luma library is using python3.

Here is a list of the installation steps I did:

Initialize the raspberry pi

  • Download “Raspberry Pi Imager” from https://www.raspberrypi.org/software/
  • Run and install “Raspberry Pi OS Lite” on empty micro SD card
  • Connect QWERTY keyboard, a MIDI keyboard and usb soundcard to a USB hub, connect the hub to the pi (use a micro USB OTG adapter). Insert micro SD card, Connect a HDMI display and power up the Pi.
  • Logon as default user: pi and password: raspberry
  • type:
sudo raspi-config

and change the following configurations:

  • system options/Wireless LAN (input wifi credentials to the same network as your PC)
    • system options/change password (you don’t want your raspi to become an attack vector to your network)
    • system options/Boot Autologin (select console autologin)
    • interface options/ssh (enable)
    • interface options/spi (enable)
  • unplug the HDMI cable and rebot when exit: (SamplerBox USB audio won’t work if HDMI is connected).
  • it is a good idea to configure your router and give the raspberry pi a static IP.
  • open a terminal and ssh pi@192.168.xxx.xxx (use the static IP). This enables you to cut and paste the long commands below, making installation easier.

Install SamplerBox

The following commands are copied from the merge request regarding Python3 installation of SamplerBox:

Install the required dependencies (Python-related packages and audio libraries):

  sudo apt-get update ; sudo apt-get -y install git python3-dev python3-pip python3-numpy cython3 python3-smbus portaudio19-dev libportaudio2 libffi-dev
  sudo pip3 install rtmidi-python pyaudio cffi sounddevice

Download SamplerBox and build it with:

  git clone https://github.com/josephernest/SamplerBox.git
  cd SamplerBox ; sudo python3 setup.py build_ext --inplace

Install libraries for the OLED display:

  sudo -H pip3 install --upgrade luma.oled
  sudo apt-get install libopenjp2-7
  sudo apt install libtiff5

Add LEET files

use SFTP to copy logo_128x64.png, Linux128x64, pixelmix.ttf, oledTest.py and samplerbox.py to /home/pi/SamplerBox/

Edit sound configuration

  sudo nano /usr/share/alsa/alsa.conf

change defaults.ctl.card 0 to defaults.ctl.card 1

change  defaults.pcm.card 1 to defaults.pcm.card 1

sudo /etc/init.d/alsa-utils stop ; sudo /etc/init.d/alsa-utils restart ; sudo /etc/init.d/alsa-utils start

Test Samplerbox

python3 samplerbox.py

Autostart SamplerBox:

If everything works, you can make SamplerBox autostart by changing this script:

sudo nano /home/pi/.bashrc

add this at the end:

  python3 /home/pi/SamplerBox/samplerbox.py

Download project files

All files required for this project are available at this GitHub repository:
https://github.com/vonkonow/LEET-Synthesizer/tree/main/Linux

License

This project is open source under MIT License
(Attribution is optional, but appreciated /Johan von Konow ;)

3 Replies to “LEET Linux”

    1. Not sure i understand the question – The LEET Linux is connected to a USB-hub and a USB sound-card. The audio comes from the sound-card in my setup.
      (pi zero doesn’t have an audio jack, but can also use hdmi or pwm with a filter)

  1. If you are trying this since raspberry pi os has been upgraded to bullseye I recommend using the Raspberry Pi OS Lite (Legacy) option which is built on buster. If you use legacy everything can be installed pretty much copy paste from Johan’s guide. If you use the latest you will be compiling python3.8 from source along with all the other packages which is a very lengthy process.

Leave a Reply

%d bloggers like this: