Rapsberry Pi OS

If you're using the Raspberry Pi 400 Desktop - Full Computer Kit you'll already have an SD card with Rapsberry Pi OS on it. If you are using the Pi 400 Computer Only, you'll need to get an SD card and install Rapsberry Pi OS on it

With the SD card inserted, plug an HDMI monitor into your Pi 400 using HDMI port 0, plug in a mouse, and then power it up.

I've labeled the HDMI ports in this photo -- sometimes there are issues with playing audio over HDMI when adjusting to certain resolutions and it can be helpful to start off using HDMI port 0.

If this is your first time using the Pi, get started with this excellent book, The Official Raspberry Pi Beginner's Guide, which is available as a free .pdf.

Once your Pi is set up and running proceed with the directions below.

Audio Out

Since the Pi 400 lacks an audio output jack (all audio must be sent over HDMI), we'll plug in a USB sound "card" in order to get audio out to powered speakers, a mixer, or other gear.

Plug this into any USB port on the Pi, then run a 3.5mm TRS cable to the output jack.

Software Setup

Now, make sure you have Python 3 setup, as Python 2 is no longer used or supported.

 pip3, is the software package installer you'll use. Upgrade it to the latest version with this command from a terminal:

sudo pip3 install --upgrade setuptools

If above doesn't work try

sudo apt-get install python3-pip

Once that has finished you'll be returned to the prompt.

Make sure you're using Python 3!

The default Python on your computer may not be Python 3. Python 2 is officially discontinued and all our libraries are Python 3 only.

We'll be using python3 and pip3 in our commands, use those versions of Python and pip to make sure you're using 3 and not 2.

Python Installation of PCF8591 Library

 Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready!

Once that's done, from your command line run the following command:

sudo pip3 install adafruit-circuitpython-pcf8591

If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!

Sonic-Pi

You can use the knobs and ADC on your Pi any way you like, but for the purposes of this guide, you should try it out with Sonic-Pi, the live coding music software.

Head to this link and then follow the terminal installation instructions. They look something like this (the version may update after this guide was written, so follow the instructions on that linked page):

sudo apt update
sudo apt install ./sonic-pi_3.3.1_1_armhf.deb

Python OSC

In order for the knobs to send messages to Sonic-Pi (or other synth software) you'll use OSC (Open Sound Control) which is a modern alternative to MIDI for inter-instrument communications.

One great feature of OSC is its ability to send and receive messages among different programs on the same computer via UDP.

Install the python-osc library by running the following commands from the terminal:

pip3 install python-osc

Sending and Receiving OSC

Here's a terrific example of sending OSC messages from a Python script and listening/receiving those messages in Sonic-Pi. I've excerpted sections of it here:

Download: file
live_loop :foo do
  use_real_time
  a, b, c = sync "/osc*/trigger/prophet"
  synth :prophet, note: a, cutoff: b, sustain: c
end

In this example we described an OSC path "/osc*/trigger/prophet" which we're syncing on. This can be any valid OSC path (all letters and numbers are supported and the / is used like in a URL to break up the path to multiple words). The /osc prefix is added by Sonic Pi to all incoming OSC messages, so we need to send an OSC message with the path /trigger/prophet for our sync to stop blocking and the prophet synth to be triggered.

Sending from Python

We can send OSC to Sonic Pi from any programming language that has an OSC library. For example, if we're sending OSC from Python we might do something like this:

Download: file
from pythonosc import osc_message_builder
from pythonosc import udp_client

sender = udp_client.SimpleUDPClient('127.0.0.1', 4560)
sender.send_message('/trigger/prophet', [70, 100, 8])

Later you'll create a Python script that reads the knob inputs, and then converts the values and sends OSC messages to be read by Sonic-Pi.

PiTFT Install

Follow these steps to install the PiTFT in FBCP mode. This mode mirrors the HDMI output onto the PiTFT, and can be used stand-alone, no HDMI monitor required!

This guide was first published on Apr 02, 2021. It was last updated on Apr 02, 2021.

This page (Raspberry Pi 400 Setup) was last updated on Apr 10, 2021.

Text editor powered by tinymce.