Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RP2040 mp3 playback is static #6133

Closed
tannewt opened this issue Mar 9, 2022 · 14 comments · Fixed by #6245
Closed

RP2040 mp3 playback is static #6133

tannewt opened this issue Mar 9, 2022 · 14 comments · Fixed by #6245
Labels
audio documentation rp2 Raspberry Pi RP2 Micros
Milestone

Comments

@tannewt
Copy link
Member

tannewt commented Mar 9, 2022

Reported on the forum and confirmed by Neradoc and cater on Discord:

https://forums.adafruit.com/viewtopic.php?f=60&t=189077&p=915505#p915505

@tannewt tannewt added bug audio rp2 Raspberry Pi RP2 Micros labels Mar 9, 2022
@tannewt tannewt added this to the 7.x.x milestone Mar 9, 2022
@prplz
Copy link

prplz commented Mar 16, 2022

I was able to reproduce this, but if I convert the mp3 to mono first, it goes away. Reducing the bitrate further didn't fix the issue.

@prplz
Copy link

prplz commented Mar 16, 2022

Lowering the sample rate of the mp3 down from 44100 to 16000 makes the issue go away. I think the noise is just stuttering because the processor isn't keeping up.

@Alizarosebud3
Copy link

Lowering the sample rate of the mp3 down from 44100 to 16000 makes the issue go away. I think the noise is just stuttering because the processor isn't keeping up.

How do you go about lowering the sample rate of the mp3?

@gamblor21
Copy link
Member

How do you go about lowering the sample rate of the mp3?

I use Audacity. Lots of tutorials online on how to lower the sample rate and always worked well for me.

@Alizarosebud3
Copy link

lowered to 16kHz and its producing the same static noise on mine.
@prplz are you still using the following code? or a different one?

`import board
import audiomp3
import audiopwmio

audio = audiopwmio.PWMAudioOut(board.GP0)

decoder = audiomp3.MP3Decoder(open("slow.mp3", "rb"))

print("Begin playing!")

audio.play(decoder)
while audio.playing:
pass

print("Done playing!")`

@prplz
Copy link

prplz commented Mar 17, 2022

Can you upload slow.mp3 so I can try it? Github won't let you drag mp3 files into the comment box, but you can get around it by zipping them first

@prplz
Copy link

prplz commented Mar 17, 2022

Here are the ones I'm using: mp3s.zip
mono.mp3 is 44100Hz with one channel and stereo.mp3 is 16000Hz with two channels

@Alizarosebud3
Copy link

yes
slow.zip

I will try your sounds when I get a chance. Again I am using the STEMMA speaker from adafruit

@prplz
Copy link

prplz commented Mar 17, 2022

Your mp3 files play fine for me. I'm just plugging the PWM pin straight into the line in on my computer (I know, probably not the best idea).

Could this maybe be an issue that the speaker has with PWM? I will see if anyone can do some more testing with other boards and PWM.

@Alizarosebud3
Copy link

hmm your stereo.mp3 works for me, but not my slow16kHz.mp3.

The stereo.mp3 plays very quietly and the sound goes away when I try changing the volume on the STEMMA speaker itself.

how do you connect it straight into the computer line is that pin 0 on the raspberry pi pico?

@prplz
Copy link

prplz commented Mar 17, 2022

@Neradoc reports that slow.mp3 plays ok if you adjust the volume pot on the speaker, can you try that?

@Alizarosebud3
Copy link

Got it! Thank you for assisting me !

@dhalbert
Copy link
Collaborator

Let's document in the shared-bindings docs that MP3 problems could be due to the bit rate being too high.

@ghstwhl
Copy link

ghstwhl commented Jan 13, 2023

While I know this issue was closed several months ago, I am having this exact same problem.

In my case, I am using a Feather RP2040 running CircuitPython 7.3.3, and using a Prop-Maker feather as my amplifier. I have downloaded the stereo.mp3 file that folks in this thread say works for them, and it has a lot of static for me. My code is pretty generic:

import audiomp3
import audiopwmio
import digitalio

audio = audiopwmio.PWMAudioOut(board.A0)

enable = digitalio.DigitalInOut(board.D10)
enable.direction = digitalio.Direction.OUTPUT
enable.value = True

decoder = audiomp3.MP3Decoder(open("stereo.mp3", "rb"))

audio.play(decoder)
while audio.playing:
    pass

print("Done playing!")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audio documentation rp2 Raspberry Pi RP2 Micros
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants