-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add PWM based audio playback #4167
Conversation
tested, works pretty well! |
Will stereo playback of samples work ok? |
Yes, it should work. The pins need to share a PWM slice under the hood. |
I saw #4143 but haven't yet worked out exactly what's going on there, is that related to this? Is there anything simple that documents "the slices" or is in the monster datasheet? A cytron maker board is on the way to me which uses GP18 and GP19 for stereo audio. |
This bug is fixed in main. (I'll close shortly.)
It's in the pin function section. It's simple though. The slice is pin number / 2 % 8 and the channel is pin number %2. In words, starting at zero the next two pins share a slice, then the next two do and so forth until pin 16 which starts the pattern again.
That should work. It will block PWM on pins GP2 and GP3 though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problems spotted, but I didn't do any testing. (@ladyada did but didn't formally review the PR)
It's a bummer that the audio sample converter APIs I added didn't work out to use here, but I see why it wasn't used.
What converter APIs? Please open a long term issue for us to unify buffer conversion. This DMA stuff is too tied to buffer conversion at the moment. |
there are a bunch of these, for converting bit count, signedness, and mono-to-stereo. Declared in shared-module/audiocore/init.h. |
I just ran this
On Cytron Maker Pi Pico which has LEDs on the pins. Even numbered ones light up, odd numbered ones stay off.
That doesn't help. Is this a bug? [Added later]: I can get odd ones to light up but not evens with this, it must be the first one in each pair to be instantiated works:
Same issue exists on |
I can't find libraries which hold
|
@kevinjwalters Please file new issues that refer to a PR. Discussion on a merged PR is hard to track. (For those following along, the library finding issue was due to this PR not being in beta.2. It was merged after and is available in "absolute newest" builds.) |
See
https://learn.adafruit.com/circuitpython-essentials/circuitpython-audio-out
to get started.
Fixes #4037