Custom Raspberry Pi Music Player Powered by Raspberry Pi, Fueled by Imagination

by 1ComputerL in Circuits > Raspberry Pi

412 Views, 5 Favorites, 0 Comments

Custom Raspberry Pi Music Player Powered by Raspberry Pi, Fueled by Imagination

IMG_4658.jpg
icon.JPG
MusicPi Demonstration Video
IMG_4619.jpg
IMG_4598.jpg
IMG_4616.jpg

What if you wanted to build a music player—something portable, housed in an old CD player? You gut a dead boombox, keep only the speakers, and rebuild everything else from scratch. With a Raspberry Pi, an audio DAC, some wrecking tools, and a whole lot of programming, maybe you can actually make it work. But how?

That’s what this Instructable is about: how to build your own MusicPi.

Powered by a Raspberry Pi 4 and Pico, MusicPi is a Linux- and Python-based system—an open-source alternative to mainstream media platforms, designed for simplicity and usability.

Here’s how I approached the project, step by step. Don't forget to check out the MusicPi Github.

Supplies

Think About Purpose

IMG_4565.jpg
IMG_4620.jpg
IMG_4596.jpg

As shown in the picture of my notes above, I had great expectations for my music player, but didn't end up making it into everything I planned. Try to keep things simple at first, and remember that you can always add extra features later.

The main features to consider are the operating system, brain, DAC (Digital-to-Analog Converter), speakers, display, and input. In this guide you will be using a Raspberry Pi computer as the brain and Raspberry Pi OS. The OLED display is highly recommended so that users can navigate the menus and see what songs are playing. Buttons are absolutely essential, unless you decide to include some sort of touchscreen. Actually, a touchscreen could be the only input and display you need, but if that's the path you head down, be ready for a lot of GUI programming. This guide is based around the OLED display idea.

Obtain a Suitable Enclosure

enclosure.jpg
PICT00005.JPG
PICT00004.JPG

The next most important step is obtaining a shell for your music player. You can gut and re-purpose an old boom box, which can probably be found for free or online for a low price.

The enclosure must have places for the speakers, OLED display, power cord, potentiometers, and buttons to stick through. It needs to provide suitable protection from the elements and have places for the internal components to be glued to. Do what you can to create room for the components in the enclosure.

Research Parts

IMG_4580.jpg
IMG_4578.jpg

You can search for your own parts online or use the parts I listed above.

Don't throw together a bunch of parts and expect them to work. Do some research to find a compatible DAC and speakers. Then, buy an Raspberry Pi compatible OLED display that will fit in the shell. Find the best prices, and, if you can, order from the same place to avoid separate shipping fees.d

Find Documentation

You should be able to find links to documentation on the product pages of the components. Get a general idea of how to connect the various parts to your controlling units. Documentation and helpful informative links for the parts I used are linked to below:

Waveshare 4.3inch DSI LCD

Waveshare 0.91inch OLED Module

Pi-DigiAMP+ at Raspberry Pi Pinout

Iqaudio Product Guide

Pi-DigiAMP+ in Raspberry Pi Documentation

Flash the OS

20250804_12h05m48s_grim.png
20250804_12h05m04s_grim.png
20250804_12h05m30s_grim.png

Flash an SD card with the latest version of Raspberry Pi OS. The best way to do this is with Raspberry Pi Imager. Once the card is ready, pop it into the Raspberry Pi computer, and then plug in a monitor, keyboard, mouse, and power supply. I suggest setting up Raspberry Pi Remote Connect, which will enable you to connect to and program the Pi from a separate computer. After that is set up, disconnect the monitor, keyboard and mouse, and remote connect from a different computer.

Configure the OS

There should be some specific instructions for you to follow if you are using a touchscreen or audio DAC. Look at the documentation and make sure you get all the configuration done for your parts now.

Here are the operating system configuration instructions for the parts I used. You will need to add some lines to the end of the /boot/firmware/config.txt file as the documentation for the Waveshare 4.3inch DSI LCD and the DigiAMP+ instructs. To begin, enter this command:

sudo nano /boot/firmware/config.txt

Scroll to the bottom of the text file and paste the following lines (don't touch ANYTHING else):

For the 4.3inch DSI LCD touchscreen:

dtoverlay=vc4-kms-v3d
#DSI1 Use
dtoverlay=vc4-kms-dsi-7inch
#DSI0 Use
#dtoverlay=vc4-kms-dsi-7inch,dsi0

For the DigiAMP+

# Make the DigiAMP+'s soundcard default
dtoverlay=iqaudio-dacplus,unmute_amp

After you've done that, press Control+X on your keyboard, confirm that you want to save the file with Y, and then hit the return button to close it.

Pico Setup

IMG_4591.jpg
IMG_4564.jpg
cdSensorThing.jpg

Go ahead and get out the Pico. In this step you will be connecting it to all the components. Begin by placing the Pico on the breadboard. Connect the wires leading from the buttons and potentiometers to the Pico as outlined below in the diagram and above in the graphing paper image and below.

+----------+------+----------+---------------------------------+
| Function | GPIO | Enabled | Description |
+-----------------+----------+---------+-----------------------+
| Backward | GP0 | Yes | Button to GND, input pull-down |
| Play | GP1 | Yes | Button to GND, input pull-down |
| Forward | GP2 | Yes | Button to GND, input pull-down |
| Mode | GP3 | Yes | Button to GND, input pull-down |
| Display | GP4 | Yes | Button to GND, input pull-down |
| Stop | GP5 | Yes | Button to GND, input pull-down |
| Power | GP6 | Yes | Button to GND, input pull-down |
| CD | GP7 | Yes | Button to GND, input pull-down |
| Vol Pot | GP26 | Yes | Analog input, other lead to GND |
| Tone Pot | GP27 | Yes | Analog input, other lead to GND |
+----------+------+----------+---------------------------------+

In the Pico connections blueprint above, you'll see that there is a button labeled 'CD'. This button serves as a sensor in my cyber deck style CD port and the Pi toggles the touchscreen on and off based on the button's state. You can choose to not include this button if you wish and selectively remove the code for it from main.py and background.py.

Test the Components

edited_oled_test_1.jpeg

Now, work on experimenting with the parts. Hook up the Pi to a keyboard, mouse, and monitor and test each of the components individually. Download the driver libraries that you will need to control them and then use the examples to determine if everything is connected correctly. In the picture below, I connected the DAC and OLED touchscreen to the Pi and started testing the capabilities.

Assembly

IMG_4571.jpg

Put it all together as the different documentations instruct for the various parts. If you think something might go wrong between two pieces, write code to test them both simultaneously. Put the whole setup in the enclosure. Try to refrain from gluing things down permanently unless you are confident they will continue to work as expected throughout the programming phase. Leave the whole thing open for now just in case you need to switch things up later.

Install the MusicPi System

icon.png

The music player will use the system I created to control media playback on OLEDs, MusicPi.

Install the dependencies with this terminal command:

sudo apt-get install python3-pip python3-pil python3-numpy mpv socat python3-mutagen python3-evdev python3

Next, download the programs from Github:

git clone https://github.com/1computerl/musicpi

You should now see a folder labeled 'MusicPi' in your home directory.

Edit the Programs to Work With Alternate Hardware

You can skip this step if you are using the same parts I did. If not, there will be a bit of difficulty ahead configuring the programs to work with different hardware. I will cover some tips for setting up alternate OLEDs and input options.

To use a different OLED display, install the driver software needed to make the OLED work with Python. You should find instructions for how to accomplish this in the OLED's documentation. Paste the drivers folder into the MusicPi folder. Now, you need to tinker with OLED.py to get it to make calls to the new OLED library. The best and most efficient way to do this is with AI. Navigate to chatgpt.com, and paste the OLED driver and example program into the chatbar, followed by an explanation of what the two programs are. After the AI gives its response, paste OLED.py (from the MusicPi system) in, followed by a request like "Configure this program to work with the provided OLED driver".

For those wishing to replace the Pico, buttons and potentiometers with different methods of input, I suggest using some kind of program that sends key presses just as the Pico does in the normal scheme. Edit handle_volume.py to take input from your program in some way, and then specify the input device the program will act as in MusicPi's settings.json file. Again, I recommend using AI to ease the process of transition.

Settings.JSON

20250804_19h34m31s_grim.png
findportexample.png
20250804_19h32m21s_grim.png
20250804_19h32m33s_grim.png
20250804_19h32m35s_grim.png

In the MusicPi folder there is a JSON file labeled settings.json with these default settings:

{
"mediaDir":"/home/me/Music",
"picoPort":"/dev/ttyACM0",
"eventDevice":"/dev/input/event4"
}

It is intended to make customization of the MusicPi system easier.

  1. "mediaDir" specifies the location of the media folder you want the MusicPi system to handle
  2. The content of "picoPort" is supposed to reflect the device port your Pico is connected to
  3. "eventDevice" points to the input 'event' source that your Pico acts as

The screenshots above demonstrate how to find what these values are in your setup.

MusicPi Media Folder

20250804_10h34m03s_grim.png
20250804_10h34m17s_grim.png
20250804_10h38m45s_grim.png
20250804_10h38m58s_grim.png
20250804_10h39m14s_grim.png
20250804_10h42m01s_grim.png
20250804_10h44m27s_grim.png

The media folder that MusicPi references should look sort of like the pictures above. It is best to have everything organized nicely and ordered with the naming convention "01. Folder or Media Name", "02. Folder or Media Name".

Use .m3u files with mpv to create playlists and play media from the internet. As shown in the screenshots above, all you have to do is create a text file with the .m3u extension, and paste links and file paths inside! Make sure that the file paths are relative, so that they will work wherever you move the media folder.

Here are a few helpful links explaining relative file paths and M3U files:

Relative File Paths

M3U Files

MusicPi Controls

As shown in Step 7's diagram, there are 7 different buttons and two potentiometers that act as the input. I'll outline below what each button and potentiometer does. The buttons all affect music_system.py, excepting Power and CD, which trigger background.py.

+----------+------------------------------------------------------------------------+
| Function | What will it do? |
+----------+------------------------------------------------------------------------+
| Backward | navigate to the previous menu item or playing item
| Play | enter the current menu item or play/pause the current playing item
| Forward | navigate to the next menu item or playing item
| Mode | navigate to the root menu item
| Display | poweroff the computer (sudo poweroff)
| Stop | navigate to the parent menu or stop the current playing item
| Power | toggle the music_system.py on and off
| CD | toggle DSI-1 screen on and off
| Vol Pot | adjust the computer's volume from mute to 100 (0-100)
| Tone Pot | nothing
+----------+------------------------------------------------------------------------+

Run MusicPi on Boot

example.png

Now you have to tell Raspberry Pi OS to run MusicPi system on boot. You can do this quite easily with Botspot's AutoStar. Here are the instructions on how to install this helpful tool: https://github.com/Botspot/autostar. Open AutoStar and press the New button. Edit the Filename and Display name as needed. In the 'Command to run' box, enter '/bin/python ' followed by the path of the background.py program in your MusicPi folder. I included a picture of my autostart configuration above.

Example Usage

MusicPi Demonstration Video

In this step I include a video of my completed MusicPi in action. It shows almost all the basic functions that can be performed in regular usage of the system. You can take a look at it above.

Conclusion

Hopefully your project went well and resulted in a working music playing system! If not, please leave a comment so that I can improve the instructable for others.