Adafruit Pygamer MP3 Audio/ WAV audio not working as intende

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
NachoPi
 
Posts: 13
Joined: Tue Aug 03, 2021 2:15 am

Adafruit Pygamer MP3 Audio/ WAV audio not working as intende

Post by NachoPi »

Hello there,

I recently purchased a PyGamer Starter Kit directly from Adafruit. I ran Hello world on it, as well as a few pieces of tutorial code (such as the Stage library tutorial). I then decided that I wanted to try to play some short mp3's on the PyGamer.

So after finding the CircuitPython Essentials guide and scrolling down to "CircuitPython MP3 Audio", I input the test code, copied the files (begins.mp3 and xfiles.mp3) and ran the code. I input the code using the recommended Mu editor running on a raspberry pi 400, as that is what I prefer to use when programming CircuitPython devices. The resulting audio was heavily distorted AND came only out of the left ear cup. I tried this with headphones, a 3.5mm AUX speaker, and the Pygamer's default speaker. The audio was full of loud crackling and buzzing. I also tried the Audio out WAV player from the same guide, and got the same results. After re-flashing CircuitPython and the PyGamer's bootloader, and modifying the pieces of code to use my own mp3s (I chose mp3's that were under 2mb and at 44.1kHz) I decided to ask for help on the forums.

Any suggestions of what I could do next? Or should I try to refund the item?

User avatar
tannewt
 
Posts: 3304
Joined: Thu Oct 06, 2016 8:48 pm

Re: Adafruit Pygamer MP3 Audio/ WAV audio not working as int

Post by tannewt »

What version of CircuitPython are you using? Audio is tricky to code and I think it may have regressed in some of the 7 alphas. Dan has been looking into some issues so it should be getting better.

Lower sample rates should be more reliable to playback.

User avatar
NachoPi
 
Posts: 13
Joined: Tue Aug 03, 2021 2:15 am

Re: Adafruit Pygamer MP3 Audio/ WAV audio not working as int

Post by NachoPi »

Thank you for the response! I am using CircuitPython 6.3.0. I do not currently own any MP3's of a lower sample rate. I know Audacity is one way to lower the sample rates of MP3's, but are there other ways as well? I would rather not use Audacity because of their new privacy policy.

User avatar
NachoPi
 
Posts: 13
Joined: Tue Aug 03, 2021 2:15 am

Re: Adafruit Pygamer MP3 Audio/ WAV audio not working as int

Post by NachoPi »

I noticed one more piece of strange behavior while copying files to the Pygamer. When I would copy an MP3 to it, the Pygamer would reboot multiple times. This happened with both my Raspberry 400 and my Ubuntu computer.

User avatar
NachoPi
 
Posts: 13
Joined: Tue Aug 03, 2021 2:15 am

Re: Adafruit Pygamer MP3 Audio/ WAV audio not working as int

Post by NachoPi »

After some experimenting I came up with an idea. This line in the code:

Code: Select all

audio = AudioOut(board.A0)
, represents the audio output. After changing A0 to A1, I was able to get audio to play out of the right ear cup instead of the left one. I assume this is because the Pygamer has a stereo headphone jack. Does anyone know how to get the Pygamer to use BOTH pins A0 and A1?

User avatar
tannewt
 
Posts: 3304
Joined: Thu Oct 06, 2016 8:48 pm

Re: Adafruit Pygamer MP3 Audio/ WAV audio not working as int

Post by tannewt »

AudioOut can take in a second pin to output to for stereo.

https://circuitpython.readthedocs.io/en ... o.AudioOut

User avatar
NachoPi
 
Posts: 13
Joined: Tue Aug 03, 2021 2:15 am

Re: Adafruit Pygamer MP3 Audio/ WAV audio not working as int

Post by NachoPi »

Thank you for the response, I will try that now!

User avatar
NachoPi
 
Posts: 13
Joined: Tue Aug 03, 2021 2:15 am

Re: Adafruit Pygamer MP3 Audio/ WAV audio not working as int

Post by NachoPi »

Yes! The audio now plays out of both the left and right channels. The crackling and distortion is still present, though. Any suggestions?

User avatar
tannewt
 
Posts: 3304
Joined: Thu Oct 06, 2016 8:48 pm

Re: Adafruit Pygamer MP3 Audio/ WAV audio not working as int

Post by tannewt »

Try the absolute newest versions of CircuitPython. Dan has been fixing audio issues over the last few weeks.

User avatar
NachoPi
 
Posts: 13
Joined: Tue Aug 03, 2021 2:15 am

Re: Adafruit Pygamer MP3 Audio/ WAV audio not working as int

Post by NachoPi »

Thanks for the response! I tried CircuitPython 7.0.0-alpha 6, but still had the same audio issues. Is this the newest CircuitPython version?

User avatar
tannewt
 
Posts: 3304
Joined: Thu Oct 06, 2016 8:48 pm

Re: Adafruit Pygamer MP3 Audio/ WAV audio not working as int

Post by tannewt »

On the downloads page for a board there is "Absolute Newest" clicking the link there will take you to an S3 bucket. Click your language and then download the file at the top. These are builds that are done after every commit to the `main` branch in the CircuitPython repo.

User avatar
NachoPi
 
Posts: 13
Joined: Tue Aug 03, 2021 2:15 am

Re: Adafruit Pygamer MP3 Audio/ WAV audio not working as int

Post by NachoPi »

All right, I will try that.

User avatar
NachoPi
 
Posts: 13
Joined: Tue Aug 03, 2021 2:15 am

Re: Adafruit Pygamer MP3 Audio/ WAV audio not working as int

Post by NachoPi »

I have tried the top two releases, and the audio still crackles. I am beginning to think this is some sort of hardware failure.

User avatar
tannewt
 
Posts: 3304
Joined: Thu Oct 06, 2016 8:48 pm

Re: Adafruit Pygamer MP3 Audio/ WAV audio not working as int

Post by tannewt »

Audio is really tricky. What sample rate are you trying? The lower, the easier it is for the cpu to keep up.

User avatar
NachoPi
 
Posts: 13
Joined: Tue Aug 03, 2021 2:15 am

Re: Adafruit Pygamer MP3 Audio/ WAV audio not working as int

Post by NachoPi »

the MP3's I am using are 44.1 kHz. Do you know of an easy way to lower the sample rate of them?

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”