# Custom Program for Pirate Audio DAC Speaker

**URL:** <https://forums.pimoroni.com/t/custom-program-for-pirate-audio-dac-speaker/26637>\
**Category:** Support\
**Created:** [November 26, 2024, 6:54pm UTC](https://forums.pimoroni.com/t/custom-program-for-pirate-audio-dac-speaker/26637 "2024-11-26T18:54:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![imgonnakms42069](https://avatars.discourse-cdn.com/v4/letter/i/dec6dc/32.png) [@imgonnakms42069](https://forums.pimoroni.com/u/imgonnakms42069)\
**Post date:** [November 26, 2024, 6:54pm UTC](https://forums.pimoroni.com/t/custom-program-for-pirate-audio-dac-speaker/26637/1 "2024-11-26T18:54:17Z")

</div>

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:

 ![log 1](https://us1.discourse-cdn.com/flex016/uploads/pimoroni/original/2X/7/7055c49ebd0230dd08ec620e275f6259ea960e4e.png)  
 ![log 2](https://us1.discourse-cdn.com/flex016/uploads/pimoroni/original/2X/3/32257ef757d1e673fc287a2cb32528200cabd278.png)  
 ![main menu](https://us1.discourse-cdn.com/flex016/uploads/pimoroni/original/2X/0/0dad31ae5682b4dfd015c1ba5795567e580f656a.jpeg)  
 ![musicplayer](https://us1.discourse-cdn.com/flex016/uploads/pimoroni/original/2X/e/e973e1a33b9d73f17b5806e4fab2140037294279.jpeg)

---

<div class="post-metadata">

**Author:** ![imgonnakms42069](https://avatars.discourse-cdn.com/v4/letter/i/dec6dc/32.png) [@imgonnakms42069](https://forums.pimoroni.com/u/imgonnakms42069)\
**Post date:** [November 26, 2024, 6:56pm UTC](https://forums.pimoroni.com/t/custom-program-for-pirate-audio-dac-speaker/26637/2 "2024-11-26T18:56:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bablokb](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@bablokb](https://forums.pimoroni.com/u/bablokb)\
**Post date:** [November 26, 2024, 8:13pm UTC](https://forums.pimoroni.com/t/custom-program-for-pirate-audio-dac-speaker/26637/3 "2024-11-26T20:13:25Z")

</div>

This is very strange, since this is similar to another problem that others have reported. Here: [Pirate audio no more working - #16 by bablokb](https://forums.pimoroni.com/t/pirate-audio-no-more-working/26520/16)  
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.

---

<div class="post-metadata">

**Author:** ![imgonnakms42069](https://avatars.discourse-cdn.com/v4/letter/i/dec6dc/32.png) [@imgonnakms42069](https://forums.pimoroni.com/u/imgonnakms42069)\
**Post date:** [November 26, 2024, 10:11pm UTC](https://forums.pimoroni.com/t/custom-program-for-pirate-audio-dac-speaker/26637/4 "2024-11-26T22:11:14Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![bablokb](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@bablokb](https://forums.pimoroni.com/u/bablokb)\
**Post date:** [November 27, 2024, 6:57am UTC](https://forums.pimoroni.com/t/custom-program-for-pirate-audio-dac-speaker/26637/5 "2024-11-27T06:57:33Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![imgonnakms42069](https://avatars.discourse-cdn.com/v4/letter/i/dec6dc/32.png) [@imgonnakms42069](https://forums.pimoroni.com/u/imgonnakms42069)\
**Post date:** [November 27, 2024, 3:03pm UTC](https://forums.pimoroni.com/t/custom-program-for-pirate-audio-dac-speaker/26637/6 "2024-11-27T15:03:51Z")

</div>

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](https://thepihut.com/products/premium-raspberry-pi-zero-case)

---

<div class="post-metadata">

**Author:** ![bablokb](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@bablokb](https://forums.pimoroni.com/u/bablokb)\
**Post date:** [November 27, 2024, 3:42pm UTC](https://forums.pimoroni.com/t/custom-program-for-pirate-audio-dac-speaker/26637/7 "2024-11-27T15:42:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![imgonnakms42069](https://avatars.discourse-cdn.com/v4/letter/i/dec6dc/32.png) [@imgonnakms42069](https://forums.pimoroni.com/u/imgonnakms42069)\
**Post date:** [November 28, 2024, 4:10am UTC](https://forums.pimoroni.com/t/custom-program-for-pirate-audio-dac-speaker/26637/8 "2024-11-28T04:10:22Z")

</div>

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 (:
