HackerBox 0110: Synth

by HackerBoxes in Circuits > Raspberry Pi

1334 Views, 4 Favorites, 0 Comments

HackerBox 0110: Synth

HB0110 Whole Box.png

Welcome to HackerBox 0110. Experiment with the Raspberry Pi Pico 2 featuring the new RP2350 microcontroller. Explore MIDI (Musical Instrument Digital Interface) technology. Configure the Pico 2 development board for use with CircuitPython and the Mu Editor. Assemble the Raspberry Pi Synthy Kit using the Pico 2, a circular TFT display, an I2S digital audio module, and two rotary encoders for input. Program the Raspberry Pi Synthy hardware as a Bouncy-Ball Synth and then reprogram the hardware as a Drone Synth. Configure the PICOboot RP2040 development board for use with CircuitPython. Assemble the PICOboot onto a custom full-color PCB to create a 26 input USB-MIDI control surface. Leverage that MIDI controller as an input device to a Digital Audio Workstation or a computer-based synthesizer. Explore some of the interesting mathematics behind music and sound synthesis.

There is a wealth of information for current and prospective members in the HackerBoxes FAQ. Almost all of the non-technical support emails that we receive are already answered there, so we'd really appreciate it if you can take a few minutes to read the FAQ.

Supplies

This Instructable contains information for getting started with HackerBox 0110. The full box contents are listed on the product page for HackerBox 0110 where the box is also available for purchase while supplies last. If you would like to automatically receive a HackerBox like this right in your mailbox each month, you can subscribe at HackerBoxes.com and join the party. Subscription members save at least $15 every month and automatically receive each new HackerBox shipped immediately off the production line.

A soldering iron, solder, and basic assembly tools are generally needed to work on the monthly HackerBox. A computer for running software tools is also required. Have a look at the HackerBox Workshops for tools and supplies along with a wide array of introductory activities and experiments.

The most import thing you will need is a sense of adventure, hacker spirit, patience, and curiosity. Building and experimenting with electronics, while very rewarding, can be tricky, challenging, and even frustrating at times. The goal is progress, not perfection. When you persist and enjoy the adventure, a great deal of satisfaction can be derived from this hobby. Take each step slowly, mind the details, and don't be afraid to ask for help.

WEAR SAFETY GLASSES WHEN SOLDERING, WHEN TRIMMING WIRE LEADS, OR WHEN CUTTING, DRILLING, ETC.

CircuitPython and the Mu Editor

mu.png

We're going to be using CircuitPython, which is Adafruit's open-source derivative of the MicroPython programming language. If CircuitPython is new for you, check out Welcome to Circuit Python!

Follow the Adafruit instructions on Installing the Mu Editor. Mu is a simple code editor that works with CircuitPython hardware. There are versions for Windows, MacOS, Linux, and Raspberry Pi. Having a built in serial console, Mu provides immediate feedback from our hardware's serial output. Mu is Adafruit's recommended editor and they very wisely advise us to "please use it."

Raspberry Pi Pico 2

Raspberry Pi Pico 2: a RISC-V bet!

The original Raspberry Pi Pico is pretty amazing, but now there's something even meatier...

Featuring the same form factor and pinout, the Raspberry Pi Pico 2 looks just like the Raspberry Pi Pico.

However, it is based on a new RP2350 microcontroller instead of the original RP2040.

Improvements from the original Raspberry Pi Pico:

  1. Double the Flash memory, from 2MB to 4MB
  2. Faster 150MHz ARM processor cores, upgraded from M0+ to M33
  3. Addition of Hazard 3 RISC-V cores (operates ARM or RISC-V, not both)
  4. Hardware single-precision floating point and DSP instructions
  5. Additional security features (hacking challenge)
  6. One extra PIO, from two to three
  7. Improved power efficiency

Prior to Soldering the Pico 2

Connect the Pico 2 to your computer using a microUSB cable

The LED on the Pico 2 will illuminate at this time

Your computer should now have a new "drive" called RP2350

We're going to configure the pico 2 for use with CircuitPython

Head over here and download the UF2 file for the latest stable release

Copy the UF2 file onto the RP2350 drive

The drive will disconnect and reconnect as CIRCUITPY

Also, the green LED will blink (very slowly)

Assemble the Raspberry Pi Synthy Kit

rp-synthy.png

Do This First (VERY IMPORTANT)

Configure Four Jumpers on Digital Audio Module. The PCM5102A (specifications and datasheet from Texas Instruments) Digital Audio Module will be configured to receive Inter-Integrated Circuit Sound (I2S) data streams from the Raspberry Pi Pico 2.

The four jumpers on the back side of the PCM5102A module must be set using four blobs of solder as shown here.

Jumper #3 is set HIGH (solder blob between 3 and H)

Jumpers 1, 2, and 4 are set LOW (solder blob between the respective number and L)

For now, set the PCM5102A module aside

Mount the Raspberry Pi Pico 2

Position the Exclusive RP-Synthy PCB with the text "rp-synthy" showing

This is the rear of the PCB

Orient the Pico 2 as shown with the USB connector at the edge of the PCB

In this application, do not use header pins for the Pico 2

Instead, attach the Pico 2 by soldering its castellated edges to pads on the PCB

If you are new to soldering castellated modules, review this SparkFun tutorial

Place the Circular 240x240 TFT Color Display Module

Insert the included header pins into the display module

The black plastic insulator and longer pins go on the rear of the display module

Solder the header pins from the front (glass side) of the display module

Gently slide the black plastic insulator off from the header and discard

Place the display module onto the front of the PCB (opposite side from the Pico 2)

Hold the display parallel to, but very gently pressed against, the PCB

Solder the header pins from the rear of the PCB (where the Pico 2 is)

Mount the PCM5102A Digital Audio Module

Double check the four configuration jumpers as discussed above

Snap one pin from the provided header strip

Populate this single pin into the "L" position on the audio module

The plastic insulator for this "L pin" should be on the back side of the module

The other eight pins along the longer edge of the module are not populated

Snap six pins from the provided header strip

Position the six pins along the short edge of the module and solder into place

Leave the black plastic insulators in place on the audio module

Place the audio module onto the rp-synthy PCB as shown

The audio module rests gently atop the display board, just off the glass

Solder the seven pins of the audio module from the rear of the PCB

Place the two EC11 Rotary Encoders

Solder the encoders onto the same side as the display module, as shown

Prevent the Aluminum Knob Caps from Bottoming Out

On each encoder, locate a tiny tab extending UPWARD next to the shaft

Do not confuse this tab with the two downward facing PCB mounting tabs

Snip off that one tab that is extending upward next to the shaft

Cut two pieces of paper approximately 5x30 mm each

Wad each piece into a tiny ball and jam one into each of the caps

Place a cap onto each shaft

Peel and Stick Four Rubber Bumpers Under the PCB

Bouncy Ball Synth

Demonstrate Pico2 RP2350 w/ algorithmic music generation in CircuitPython

Our Raspberry Pi Synthy hardware was inspired by the synthy-balls project from Tod Kurt [todbot].

Tod's project has been featured on Adafruit Show and Tell, where he explains that the increased capabilities of the Pico 2 afford the ability to generate stereo, CD-quality audio at the same time as rendering the color display. This is particularly thanks to the addition of hardware floating point support in the RP2350 microcontroller chip.

Display Library

The circular 240x240 TFT display module has a GC9A01 driver chip...

Grab the file gc9a01.py from this repo

Navigate to the lib folder on the CIRCUITPY drive

Paste the gc9a01.py file into that lib folder

CircuitPython Code

Grab the HB0110-synthy-balls.py file attached here

Using the Mu Editor...

Open code.py from the CIRCUITPY drive

As told here, this file runs automatically whenever it is saved to the Pico 2

Paste the code from the HB0110-synthy-balls.py file into code.py

Save the file to make it start running on the Pico 2

Open the Serial window in Mu to watch what is happening

Press the right encoder to launch a new ball

Press the left encoder to "pop" the oldest ball

Hook up some earphones or amplified speakers to 3.5mm jack

Drone Synthesizer

Two-knob drone synth w/ echo effect in CircuitPython synthio

The Raspberry Pi Synthy hardware is quite versatile and may be programmed for a number of different purposes. Quite a different sound synthesis example from the previous one is a drone synthesizer...

Try out the rp_synthy_drone.py file attached here.

This project began as todbot's two_pot_drone_synth.py as shown in the video above, which was then modified to work on our Raspberry Pi Synthy hardware. These mods include outputting I2S audio (instead of PWM audio) and taking inputs from the two rotary encoders (instead of from analog potentiometers and buttons).

Downloads

PICOboot RP2040 Development Board

RP2040.png

If you're a regular around these parts, you'll remember this awesome RP2040 dev board from the Newstalgia HackerBox. It was originally designed to serve as an IPL modchip for the Nintendo GameCube leveraging the same RP2040 chip found on the Raspberry Pi Pico. We're going to use it here to make a "touchy" control surface.

Prior to Soldering the PICOboot RP2040 Dev Board

Connect it to your computer using a USB-C cable

The Green LED should light up

We're going to configure the PicoBoot RP2040 for use with CircuitPython

Head over here and download the UF2 file for the latest stable release

(Note that the Pico and the Pico 2 have different UF2 files)

On the dev board, hold the bootsel button and hit the reset button

Your computer should now have a new "drive" called RPI-SP2

Copy the UF2 file to that new drive

The drive will disconnect and reconnect as CIRCUITPY

Also, the green LED will blink (very slowly)

Raspberry Pi Touchy Kit - Assembly

touchy.png

The HackerBox RP-Touchy Kit is inspired by yet another todbot project picoslidertoy.

Place Twenty-Six SMD Resistors

Position the Exclusive Full-Color RP-Touchy PCB with the white side facing up

The 1 MegaOhm resistors are a larger "1206" size, which is easy to solder by hand

Mount the PICOboot RP2040 Dev Board

Orient the PICOboot as shown with the USB connector at the edge of the PCB

Solder the PICOboot castellated edges to the pads on the PCB

Peel and Stick Four Rubber Bumpers Under the PCB

The box has extra sets of these bumpers incase some peel off during shipping

Otherwise, they can be used for other PCB projects

Serial Test Code

Grab the file touchslider.py attached here

Copy the touchslider.py file into the root of the CIRCUITPY drive

Grab the file rp_touchy_serial_test.py attached here

Using the Mu Editor...

Open code.py from the CIRCUITPY drive

Paste the code from the rp_touchy_serial_test.py file into code.py

Save the file to get it running

Open the Serial window in Mu to monitor the "touchy" control surface inputs

USB MIDI Controller

Helm Synth Review & Presets Demo (Free VST Plugin by Matt Tytel) + Download Link

The "touchy" control surface that you've implemented with the Raspberry Pi Touchy kit could be used as a USB macropad or a MIDI controller.

MIDI (Musical Instrument Digital Interface) is a technical standard that describes a communication protocol, digital interface, and electrical connectors that connect a wide variety of electronic musical instruments, computers, and related audio devices for playing, editing, and recording music. (Wikipedia)

If you're a musician, you are probably familiar with the traditional round DIN-5 MIDI jacks that look like the keyboard jacks from a the original IBM PC/XT/AT (prior to being shrunk to mini-DIN jacks for the IBM PS/2 line). In this application, we'll be using USB-MIDI which sends the same MIDI signals, over USB instead of the DIN-5 connected MIDI cable.

At this point, you may want to check out this Ultimate Guide to Using MIDI in Music Production noting specifically the sections titled Types of MIDI Messages and What is a MIDI controller?

MIDI Helper Library

You'll need Adafruit's MIDI library for CircuitPython found here

Copy the adafruit_midi folder into the lib folder on your Pico's CIRCUITPY drive

MIDI Controller Example

Grab the file HB0110_mini_slidertoy.py attached here

Using the Mu Editor...

Open code.py from the CIRCUITPY drive

Paste the code from the HB0110_mini_slidertoy.py file into code.py

Save the file to get it running

Note that touchslider.py (previously copied into the root of CIRCUITPY) is still needed

OK, so what is it doing?

Take a look at the controller code that we just loaded. The "while True:" loop near the end of the file is the portion of code that loops forever (since "True" is always true).

Digging into that loop, we can see that whenever one of the eight touch pads is engaged, a note is sent onto the MIDI channel.

Similarly, whenever one of the "sliders" (the four linear faders and two rotary controls) is engaged, a MIDI CC (continuous control) signal is sent onto the MIDI channel.

Scrolling up near the top of the code, look under "# midi cc and note definitions" to see the values for the notes and ccs that are being generated in the forever loop. Feel free to hack away at these values.

Show me something I can use.

So now we have a USB port squirting out MIDI notes and CCs. This is a MIDI controller. It can be used as input to a Digital Audio Workstation (DAW) platform such as Garage Band, Waveform Free, or Cakewalk - or as control input for the open source Helm Synthesizer or anything else that speaks USB-MIDI. Let's rock!

Shout-Out to Tod Kurt

cubemodes

As you've probably noticed along the way, Tod Kurt [todbot] has made a number of elegant advancements in embedded synth tech/art. Tod is an extremely talented engineer as well as a very creative maker, artist, and musician. On a personal trivia note, Tod and Joe (your HackerBox founder) were young students together at Caltech so many years ago. It probably comes as no surprise that they were both frequently found in the microprocessor lab doing what we now call embedded systems work. Also not surprisingly, you can usually find them both back in Pasadena every November at the Hackaday Supercon.

Tod's work can be enjoyed at a number of cyber spots...

todbot blog

GitHub

THINGM

todbod synth toys < Tindie store

Todbot's CircuitPython Tricks

Mathematics Behind Music and Sound Synthesis

The Math Behind Music and Sound Synthesis

Whether or not you're interested in mathematics, this video from YouTuber Gonkee is worth a watch.

HACK THE PLANET

outro.png

We hope you are enjoying this month's HackerBox adventures into electronics, computer technology, and hacker culture. We aim to curate a challenging and rewarding experience of learning through experimentation and exploration. Thank you for joining us on this journey.

Reach out and share your success in the comments below. Email support@hackerboxes.com anytime with questions or whenever you need some help.

Hungry for more? Surf over to HackerBoxes.com and join us as a monthly HackerBox subscription member. You'll get a cool box of hackable gear delivered right to your mailbox every month and you'll enjoy a generous member discount.

Please consider sharing this free Instructable with others who may be interested in learning about these subjects. Word of mouth advertising is the greatest compliment that we can receive. We sincerely appreciate your support.