Simple DIY Electronic Music Projects<p>I’ve finally gotten myself a Raspberry Pi 400 computer. I’ve wanted one for a while to use as a MIDI player for my Lo-Fi Orchestra. The idea is that eventually I might be able to run it without a large display, but instead use something like the Adafruit Cyberdeck and a PiTFT display (or similar) to give a nice, portable solution.</p> <p><em><strong>Warning!</strong> I strongly recommend using old or second hand equipment for your experiments. I am not responsible for any damage to expensive instruments!</em></p><p>These are the key Arduino tutorials for the main concepts used in this project:</p><ul><li><a href="https://www.raspberrypi.com/documentation/computers/getting-started.html" rel="nofollow noopener" target="_blank">Raspberry Pi Getting Started</a></li><li><a href="https://projects.raspberrypi.org/en/projects/raspberry-pi-using/0" rel="nofollow noopener" target="_blank">Using your Raspberry Pi</a></li><li><a href="https://learn.adafruit.com/cyberdeck-bonnet-and-hat/overview" rel="nofollow noopener" target="_blank">Cyberdeck Bonnet and HAT for Raspberry Pi 400</a></li><li><a href="https://learn.adafruit.com/adafruit-2-8-pitft-capacitive-touch/overview" rel="nofollow noopener" target="_blank">Adafruit 2.8″ PiTFT – Capacitive Touch</a></li></ul><p>If you are new to microcontrollers and single board computers, see the <a href="https://diyelectromusic.wordpress.com/getting-started/" rel="nofollow noopener" target="_blank">Getting Started</a> pages.</p><p><strong>Parts list</strong></p><ul><li>Raspberry Pi 400 and power.</li><li>Adafruit Cyberdeck for Raspberry Pi 400.</li><li>Adafruit 2.8″ PiTFT Plus capacitive touch LCD display (for use with a Pi 2/B+ onwards, not the original PiTFT which was just for the Pi 1).</li><li>Mouse, HDMI display, etc to set up the Raspberry Pi 400.</li></ul><p><strong>Raspberry Pi 400 Setup</strong></p><p>I bought a kit so I had an SD card all ready to go with Raspberry Pi OS, so I booted that up and went through the “first run” configuration to get the basic computer up and running.</p><p>I used the command line raspi-config utility to set the hostname to something other than the default “raspberrypi”.</p><p>Then I used the add/remove software to install some interesting looking apps. There are a lot of sound and music apps including a range of soft-synths, digital audio workstations, sonic programming environments, sound and MIDI utilities, and a lot more.</p><p>For my initial purposes I wanted a command-line MIDI player, so I installed pmidi.</p><p>Then I used the <a href="https://projects.raspberrypi.org/en/projects/raspberry-pi-using/9" rel="nofollow noopener" target="_blank">Raspberry Pi configuration</a> tool to set instruct the system to boot into the command line.</p><p>Then on reboot it will not start the desktop environment. If at any point the desktop environment is required, then simply using the command ‘startx’ will start it.</p><pre>pi@raspberrypi:~ $ startx</pre><p><strong>Setting up the Cyberdeck PiTFT</strong></p><p>I followed the instructions in the Adafruit learning guide for the 2.8″ PiTFT, which can be found here: <a href="https://learn.adafruit.com/adafruit-2-8-pitft-capacitive-touch/easy-install-2" rel="nofollow noopener" target="_blank">https://learn.adafruit.com/adafruit-2-8-pitft-capacitive-touch/easy-install-2</a></p><p>I ignored the talk of a virtual environment, and went ahead and run the suggested commands, although I cloned the Adafruit repository into a newly created tmp directory:</p><pre>cd ~<br><br>sudo apt-get update<br>sudo apt-get install -y git python3-pip<br><br>pip3 install --upgrade adafruit-python-shell click<br>mkdir tmp<br>cd tmp<br><br>git clone https://github.com/adafruit/Raspberry-Pi-Installer-Scripts.git<br><br>cd Raspberry-Pi-Installer-Scripts</pre><p>Then I ran the automatic installer for my 2.8″ PiTFT:</p><pre>sudo -E env PATH=$PATH python3 adafruit-pitft.py --display=28c --rotation=270 --install-type=console</pre><p>Some notes:</p><ul><li>The suggested command uses a rotation of 90 degrees, but when I first booted everything up the display was upside down on the Cyberdeck. I had to re-run with the value rotation=270.</li><li>On first running, I was informed I was running a 64-bit kernel but a 32-bit userspace, so was asked to reboot to enable a 32-bit kernel. For what I’m planning on using this for, a 32-bit kernel should be fine so I let it reboot and run the command again.</li><li>It takes a few minutes on boot for the display to become active. If a HDMI monitor is still connected then the progress of the startup can be seen there and you can see the point where the display flickers and it switches over to the PiTFT.</li><li>Note: This just enables a text console on the PiTFT. There are separate commands to be used to enable the graphical framebuffer which will allow the desktop environment to run on the PiTFT. Full details are available in the Adafruit learning guide.</li><li>I’m also not doing anything with the touchscreen at the moment.</li></ul><p>One nice thing about having the PiTFT in console mode is that using the ‘startx’ command will start up the desktop on any attached HDMI monitor. This gives a “best of both worlds” option, at least for me.</p><p><strong>PiTFT GPIO Usage</strong></p><p>The PiTFT display and touch screen use both the I2C and SPI buses, plus two additional GPIO pins. The four buttons are connected to a GPIO pin each.</p><p>According to the <a href="https://www.adafruit.com/product/2423" rel="nofollow noopener" target="_blank">product page</a> and <a href="https://learn.adafruit.com/assets/25554" rel="nofollow noopener" target="_blank">schematic</a>, the following are used.</p>GPIO 2I2C SDAGPIO 3I2C SCLGPIO 8CE0GPIO 9MISOGPIO 10MOSIGPIO 11SCLKGPIO 24Additional Display/Touch usageGPIO 25Additional Display/Touch usageGPIO 17ButtonGPIO 22ButtonGPIO 23ButtonGPIO 27Button<p>The most interesting point for me here being that both RX/TX are free, so could be used for MIDI, and GPIO 18,19,20,21 are free so an I2S audio device could be added too.</p><p><strong>Additional RPi Configuration</strong></p><p>I’ve also enabled SSH access and the serial port using the RPi configuration tool. I’ve disabled the serial console however. As mentioned above, eventually I’d like to be able to use the serial port for a MIDI interface.</p><p><strong>Getting Files to the Pi</strong></p><p>I’ve created a directory on the Pi that can be shared out. To do this requires the Samba client so using the add/remove software I’ve installed the following:</p><ul><li>samba-2.4.13.13+… SMB/CIFS file, print and login server for Unix.</li><li>samba-common-2.4.13.13+… Common files used by both the Samba server and client.</li><li>samba-common-bin-2.4.13.13+… Samba common files used by both the Samba server and the client.</li></ul><p>The standard install includes many CIFS utilities for mounting Windows shares already.</p><p>To configure an area for dropping files, I’ve created a directory in my home area and shared it out using samba.</p><pre><code>pi@raspberrypi:~ $ mkdir midi</code></pre><p>To configure samba, edit (via sudo) the /etc/samba/smb.conf file:</p><pre><code># Add the following at the end<br>[Midi]<br>path=/home/(user)/midi<br>browseable=no<br>writeable=yes<br>read only=no<br>create mask=0777<br>directory mask=0777<br>public=no<br>guest ok=no<br>write list=(user)</code></pre><p>Samba also needs to be told about the user too:</p><pre><code>pi@raspberrypi:~ $ sudo smbpasswd -a (user)</code></pre><p>Note: I’ve disabled the sharing of the home directories by default by commenting out the [homes] line and all following commands in that section.</p><p>At this point, browsing to the share \\raspberrypi will not show any visible shares (as browseable and public are set to “no”), but browsing to \\raspberrypi\midi should connect to the directory on the Pi 400.</p><p>Now I can drop over MIDI files and they will be available on the Pi.</p><p><strong>Playing MIDI files</strong></p><p>The first thing is to find the “port number” of the MIDI interface being used.</p><p>I’ve plugged in my Roland UM-ONE and use the command “pmidi -l” to list the playable output ports as shown below.</p><p>Then pmidi can be given that port number and a MIDI file to plau and it will just get on with it.</p><pre><code>pi@raspberrypi:~/midi $ pmidi -l<br> Port Client name Port name<br> 14:0 Midi Through Midi Through Port-0<br> 20:0 UM-ONE UM-ONE MIDI 1<br><br>pi@raspberrypi:~/midi $ pmidi -p 20:0 LoFi\ Orchestra\ -\ Carol\ of\ the\ Bells.mid</code></pre><p>Here is the output of dmesg showing the UM-ONE detected displayed on the cyberdeck.</p><p><strong>Closing Thoughts</strong></p><p>This is a great start with many of the building blocks in place. There are some issues though – sometimes it seems to “forget” to use the cyberdeck and I have to re-run the install script with a monitor attached. I don’t know what is causing that so naturally that isn’t any good for a proper solution.</p><p>But as can be seen in the video at the start of this post, in general, this seems to work!</p><p>Next steps:</p><ul><li>Fix the issue naturally!</li><li>It would be nice to find a way to automatically select any plugged in MIDI interface when it comes to playing a file.</li><li>It would be nice to have some kind of application running to list files and play them.</li><li>I’d like to have a RPI400 MIDI interface that I can use directly too. Perhaps some variant of my <a href="https://diyelectromusic.wordpress.com/2023/12/12/raspberry-pi-zero-midi-pcb/" rel="nofollow noopener" target="_blank">Raspberry Pi Zero MIDI PCB</a>.</li></ul><p>So still plenty to do!</p><p>Kevin</p><p><a href="https://diyelectromusic.wordpress.com/2023/12/12/raspberry-pi-400-cyberdeck-midi-player/" rel="nofollow noopener" target="_blank">https://diyelectromusic.wordpress.com/2023/12/12/raspberry-pi-400-cyberdeck-midi-player/</a></p><p><a rel="nofollow noopener" class="hashtag u-tag u-category" href="https://diyelectromusic.wordpress.com/tag/midi/" target="_blank">#midi</a> <a rel="nofollow noopener" class="hashtag u-tag u-category" href="https://diyelectromusic.wordpress.com/tag/raspberry-pi-400/" target="_blank">#raspberryPi400</a></p>