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






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
You don't have to follow my build part for part, program for program. Feel free to branch off.
Power Supply for Raspberry Pi DigiAMP+
Waveshare 4.3inch Capacitive Touch Display for Raspberry Pi
Waveshare 128x32, General 0.91inch OLED display Module
Potentiometers (these look similar to the potentiometers I use)
Push Buttons (the most basic option linked to here)
Think About Purpose



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



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


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 0.91inch OLED Module
Flash the OS



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:
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:
For the DigiAMP+
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



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.
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

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

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

The music player will use the system I created to control media playback on OLEDs, MusicPi.
Install the dependencies with this terminal command:
Next, download the programs from Github:
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





In the MusicPi folder there is a JSON file labeled settings.json with these default settings:
It is intended to make customization of the MusicPi system easier.
- "mediaDir" specifies the location of the media folder you want the MusicPi system to handle
- The content of "picoPort" is supposed to reflect the device port your Pico is connected to
- "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







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:
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.
Run MusicPi on Boot

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

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.