welcome to "build your own midi/piano/music/song identifier from scratch". Within the following steps we will guide you through installing the necessary software on your raspberry and building the casing - all files included.
If you’ve grown up in the 70s and 80s, you may even recognize parts of the design. We drew our inspiration mainly from the Apple II. The slight upward angle at the bottom front, as well as the slightly upward angled keyboard are iconic (have a look at the pictures for a comparison).
Alright, let’s get going!
Step 1: Required Components
Below you can find the list of parts we used. Have other loudspeakers or a different keyboard lying around? By all means, go ahead and use them instead! The specific parts are not that important as long as you have all of them. ;)
- Raspberry Pi 3 Model B (other raspberries will also likely work)
- Capacitive touch display 7" (Waveshare for Raspberry Pi RPI Raspberry Pi 3.5 inch Touch Screen TFT LCD (A) 320 * 480/Raspberry Pi Model B/Raspberry Pi Model B)
- Loudspeakers (Basetech Mini USB PC Speaker)
- Midi USB keyboard (AKAI LPK25 | 25-Key Ultra-Portable USB MIDI Keyboard Controller for Laptops)
- Wood for laser cutting (approx 3mm thick)
Step 2: Software Dependencies
Prior to installing the actual software for the midiIdentifier, there is a number of dependencies that need to be installed first. Most of them can be installed with the tool "apt-get" which is preinstalled on every Raspbian OS distribution. The specific commands necessary for installing the respective dependencies can be found below, including a brief description of the dependency's functionality. The dependencies are as follows:
1. A clean Raspbian OS image
2. Fluidsynth (required for audio output and audio generation of piano notes):
sudo apt-get install fluidsynth
Download the Fluidsynth sound font from the following URL:
Setup Fluidsynth Autostart:
Add the following line:
@reboot /usr/bin/screen -dm /usr/bin/fluidsynth -a alsa -m alsa_seq -i -s -o "shell.port=9988" -g 2 /FluidR3_GM.sf2
3. Install Py-Audio (required for various sound input and output functionalities):
sudo apt-get install python3-pyaudio
4. Telnet (required to connect to the Fluidsynth server which is responsible for audio output):
sudo apt-get install telnet
5. Screen (required to run the application as a background task):
sudo apt-get install screen
6. Git (required to download the midiIdentifier software / clone the code repository)
sudo apt-get install git
Step 3: Display Setup
Raspbian OS requires some initial configuration changes in order to function correctly with the touch screen. This requires a variety of changes to the boot configuration file. Please note that accidental changes to the file may keep the Raspberry Pi from booting properly.
1. Open the boot configuration file with a text editor of your choice (i.e. nano). Root privileges (sudo) are required to make changes to the file. Command to open and edit the file:
sudo nano /boot/config.txt
Add the following lines (if already present, please remove the existing ones)
max_usb_current=1 hdmi_group=2 hdmi_mode=87 hdmi_cvt 1024 600 60 6 0 0 0 hdmi_drive=1
Please pay attention not to include any spaces before and after “=” symbols.
Save and close the file. If you are using nano, do the following:
Press CTRL + X
Type "Y" and press Enter
2. Connect the display to the HDMI and to a random USB port of the Raspberry Pi.
3. Turn on the backlight (the switch is located on the backside of the display)
4. Reboot the Raspberry Pi.
Step 4: The MidiIdentifier Software
In the following, we assume that the application will be run under the user named "pi". If this is not the case, the directory paths need to be adapted accordingly (i.e. /home/pi becomes /home/[your user]).
1. Clone the midiIdentifier repository from Github with the following command:
git clone https://github.com/Andreas-Scholz/midiIdentifier.git
2. Add the repository to the Pythonpath.
Open the file ~/.bashrc (i.e. with nano, see the previous step).
Add the following line:
Save the file, then reload it with the following command:
That is: dot space tilde slash dot bashrc. Reboot the Raspberry Pi.
3. Setup autostart of the application.
Create a file called "start_gui.sh" in the home directory and add the following lines:
#!/bin/bash sleep 3 cd /home/pi/workspace/midiIdentifier/src/guiMI python3 /home/pi/workspace/midiIdentifier/src/guiMI/gui.py sleep 30
Open the file ~/.config/lxsession/LXDE-pi/autostart and add the following line:
@lxterminal -e /home/pi/start_gui.sh
4. In order for the midiIdentifier to work, a set of midi files needs to be copied manually into the midi directory. To avoid copyright infringements, these files are not included in our git repository. They can, however, be downloaded from various online sources as can be found with a simple Google search. Once you downloaded the files, they need to be copied into the following directory:
After this, the midi files need to be parsed with the following command:
5. Reboot the Raspberry Pi.
6. Congratulations, you made it! By now the midiIdentifier should be up and running!
Step 5: Building the Case
This part is actually pretty straight forward - if you have access to a laser cutter. The final casing has dimensions of approx. 450mm x 100mm x 300mm (W/H/D), so you will need a laser cutter that can cut at least 450mm x 250mm (that is the largest single piece). Alternatively you can split some of the parts into subparts which will enable you to build the case with a smaller laser cutter. Also, if you use a smaller keyboard you can probably get away with a smaller build in general. We used 3mm thick plywood. You might have to experiment with the speed and power settings of your laser cutter to get good results.
All the files you need to cut the box for the screen and the overall case can be found at the bottom of this step.
Optional: In case you want to modify our build or if you are just interested in the process of designing the files for the laser cutter, read on:
After drawing a basic sketch on paper to get a feel for the dimensions, we used Adobe Illustrator to design the files for the laser cutter (you can get a 1 week test version from their website). We didn't draw the individual notches however, as there is a wonderful free online tool to help you with that, Joinery. We exported our AI files as SVG and imported them in joinery, where we connected the different edges with each other. Joinery lets you define profiles for different angles to reuse later on and also allows saving of a project. Hence, we’ve included our joinery profiles and projects below. These are especially useful if you want to make minor changes to our design, as they can be changed easier than the adobe illustrator files when it comes to tolerances for cutting and the like.
Step 6: Putting It All Together
- Once you installed the software on the Raspberry Pi (and tested that it works correctly) and cut all the plywood you can start combining software and hardware. There is no easy way of doing this and it definitely will involve some pushing, pulling, rasping, measuring, cutting, glueing and wiggling.
- First, you should put the complete casing together, except for the back plate. Also, don’t attach the screen box yet, this will be the last step. If you want to use glue for additional support, go ahead.
- Insert the piano from the back into the casing, make sure it is plugged in, as it will be difficult to plug it in later. Hold it up against the wood and measure the height of the pieces you’ll need to cut to hold it in place. Cut these pieces (2 or 3) and attach them to the piano and the base of the box, keeping the piano in the place it should be in and making sure that pressing the keys won’t move it.
- Attach the plates the loudspeakers will later be placed on with hinges to the main case. You can use hot glue or two component glue for that. Place some wooden support below so that they’ll stay horizontal even if the boxes are placed on them later on.
- Attach the complete screen box (screen inside, cables protruding through the hole at the bottom of the box) via hinges to the main case.
- Add a wooden block inside the case to hold up the screen box in a horizontal position when folded back into the main case (see pictures). This support block will also be used to attach a small beam to, to keep the screen in different upright angles.
- Attach the loudspeakers to their plates (we used simple two sided tape). For transportation, the screen as well as the boxes can be folded back into the case!
- Finally, connect all the cables to the raspberry.
And that’s it, you are done! We hoped you enjoyed our tutorial and would love to hear from you if you decided to build a midiIdentifier yourself!