The Pico has no DAC. So you can't play audio - or can you?

Here's a test of how GlyphBlaster will play audio. It's pretty much identical to the way PWM audio is played on the PC - bit-banging the speaker on and off rapidly.

This is the music from Area 5150's credits scene, by cTrix.

#glyphblaster

Turns out there's an even more efficient way to simulate a DAC - set a PWM pin to a high multiple of your sample rate, then use your sample data to modulate the PWM duty cycle. This method was demonstrated by antirez.

cTrix's music isn't really done justice by the shitty PC speaker, so check out a higher quality version here:

https://www.youtube.com/watch?v=olbCqhdVPnA&t=1714s

Demovibes vol. 15 : Tracks, Odds & Miracles (mixtapes from the Demoscene)

YouTube
Here's a test meow

The GlyphBlaster will mix its audio with the motherboard's own transparently, using these passthrough headers.

There's a protection diode in case you hook anything up backwards.

@gloriouscow That's an accepted way to make a DAC. Put a low pass filter with the right parameters between the PWM and the speaker and you get a perfect reproduction of the original sample, Nyquist limit and resolution permitting. Just like with a PCM DAC.
@gloriouscow oh... I think I see what you mean... it's a simulation in the sense that the PC speaker hardware isn't intended to be used as a DAC. (But I would argue that it IS a DAC when set up in this way, albeit a crappy one πŸ™‚).

@whimsy I called it a simulation of a DAC because real DAC hardware would just take your samples without fuss and do it for you.

is it electrically equivalent? maybe, but it looks like an odd duck from a software perspective.

@gloriouscow I never thought of the process of reading from a buffer as being part of the DAC but that might be an oddity on my part and I'm splitting hairs at this point πŸ™‚
@whimsy i have no real electronics background so half the shit i say when i talk about this stuff probably sounds stupid

@whimsy nobody would call the abomination you create by driving samples into the reload register of the 8253 to drive a PC speaker with PWM a DAC.

yet that's not too far removed from what we're doing here

@gloriouscow I don't suppose they would, no, but it is electrically equivalent to a really bad PWM DAC with no filter (at least per my understanding).
@gloriouscow Fun fact: this is also how the audio jack on a raspberry pi works (at least on the earlier ones I’m familiar with). It also has no DAC!
@gloriouscow
PWM pin(s) direct to speaker?
I like the NJM2113D amplifier. DIP8, bridged drive so no big capacitors needed. But the DIP part is now NRND. I guess I need to buy a bunch.
:-(
@gloriouscow
Maybe I should buy a few hundred before they're gone. Or maybe I should design a small class-D amplifier board that can run on +3V to +15V and drive a mono 8 ohm speaker. I looked at TI class D audio amp chips a few years back, and none seemed exactly right for what I wanted. Maybe it's time to look again.
@brouhaha the pc speaker is an open collector driver so no amp for me :(