Custom Program for Pirate Audio DAC Speaker

Hello! Long time observer of this community, first time poster.
I’ve been working on a project for my band. The thought was to create a custom “iPod” for the release of our album. I am using a Raspberry Pi Zero 2 WH and the Pirate Audio DAC Speaker.

Some info on the functionality of this entire project:
three menu options, “Music” “Photos” “Lyrics”
main menu, music, and lyrics all have custom .gif backgrounds that are playing.
Photos has a custom loading screen, and then a photo slideshow of some artwork.
Lyrics is just a menu selection for our songs, that opens a .txt file.
A button = up
B button = down
X button = return to main menu
Y button = select

I have confirmed that the ALSA configuration is spot on, as I have created numerous test scripts that play all of our .wav songs perfectly fine.
I integrated this test player into the program, and I do not get audio even though console logs that all my songs are playing, and I am able to pause/play them.

Another weird thing I noticed is when I completely unplug the device, and plug it back in, ssh into it, then run “python3 test.py” THATS ONLY TIME I GET AUDIO. after i hit “ctrl c” to cleanly exit the test, and then proceed to run it again, no audio!
Unfortunately, if i try running “python3 main.py” then the program itselfs work great, just no audio lol.

It seems to be a very niche issue I am encountering, and I have literally been stuck on this for over FIVE MONTHS now. Our release is coming up in two weeks…I really need some assistance on this.

If you’d like to reach out to me personally about this project and helping I would be eternally grateful. I am so desperate to get this to work, I am willing to pay out of sheer frustration and time constraints lol. (being serious)

If you would like access to the program code, please reach out to me individually.

Console Logs / Images:




It may help to note that with the custom program I am developing for this hardware, for some reason months ago I had an extremely difficult time using any form of RaspberryPi OS. So I ended using DietPi. I don’t believe that would cause any sort of issue for the audio

This is very strange, since this is similar to another problem that others have reported. Here: Pirate audio no more working - #16 by bablokb
I describe the installation of one of my projects which is very similar to yours. My project does not play wav-files, but internet streams from radio-stations, but the rest is very similar (i.e. buttons for navigation, images for station-logos).

Honestly, I have no idea why this “just works” for me and fails for others. The only thing I am really doing related to the Pirate Audio (fifth step) is to tweak config.txt and then it works.

In your setup, it might be the problem that you are not just using ALSA, but also “higher level” sound-processing - I spotted “jack” for example. And you also seem to have an usb-soundcard with the same driver active (“usbstream”??).

Now this is a simple device, and my suggestion is to remove everything that is not ALSA.

Hmm I did not notice that usb device there. I’m wondering if that may be my RJ45 to micro usb adapter.

You’ve also sparked an idea for me to verify audio codec’s I’m using with Pirate Audio. I’m wondering if .wav file is set to be mono audio. Going to also test with .mp3 and other file types.

Wondering if the .wav is too much for the little program lol.

Hopefully this will bring me closer to an answer!

The device is powerful enough to play wav. Even the first generation Zero was. So this is not the problem. But in may well be that you have to pass the -c n (n is the number of channels) to aplay. BTW: aplay won’t play mp3, I am using mpg123 for this task.

Unrelated: in your image I can see a (green) case. Is this 3D-printed? Is the model available?

I am able to hear audio when i do a fresh clean boot of the device, and then play my test audio script. I am able to close this script, and then play it again, and hear audio.

After I run my program, “main.py” I get absolutely no audio, and it seems that audio itself is completely broken after running this script… Extremely confused by this lol.

In other words, I bought a bunch of these cases for this project and I will say they are absolutely wonderful! Very sturdy, fit together nice, and i enjoy the colors!
Premium Raspberry Pi Zero Case | The Pi Hut

So maybe it is time that you publish your “main.py” somewhere. If after booting everything is fine, this is a strong hint that the device is setup correctly, but the script messes up something. Maybe something as simple as setting the volume to zero.

Coming back to say I found a solution. for some reason the .wav files were not working very well within my main script… ended up switching to mpg123 and converting files to .mp3 and implementing it into the script.

not sure what happened but all is well now! just my own stupidity (:

1 Like