If you have a "digital" audio source, say from Bluetooth or optical and a class D output amp, presumably one could calculate the PWM duty cycle direct from the digital signal
At least NXP microcontrollers like i.MX RT1062 support MQS or Medium Quality Sound using a dedicated subsystem. Basically, the MQS subsystem controls any two PWM pins, connected to a power amplifier, to drive stereo speakers or headphones, given 2-channel 16-bit LSB data stream at 44 kHz or 48 kHz sample rate. For up to 10 kHz, the signal to noise ratio is about 20 dB, or roughly equivalent to 8-bit audio, like on old Amigas and Sound Blasters. It's not Hi-Fi, but surprisingly okay. It is even supported for
Teensy 4.0 and 4.1 by the Teensy Audio library.
Considering it is basically a DMA-capable fire-and-forget subsystem in the chip hardware, I'd be surprised if it was particularly rare.
I seem to recall that in the 1988-1991 time frame, there were some demos (and maybe even games) that used the PC beeper –– which is a PWM only audio device –– for PCM audio effects (screams, even rough music). Ah, yes; see e.g.
https://youtu.be/pzNbGa05dfg for examples.
(In a couple of different threads here, I've mentioned PDM – pulse density modulation – and how, by sacrificing a bit of the output Vpp, say instead of 0..Vpp to Vpp/16..Vpp×15/16, you can move all the quantization noise quite high in the spectrum, so that a simple low-pass filter will yield surprisingly good results. It's dead simple to do, too: all you need is an adder and a register. On each clock cycle, you add the current sample value to the register. If the addition overflows/carries, set the output high, and otherwise low. You can modify the current sample value at any point in time, but technically, to get 2
n-bit output, you should emit the same sample for 2
n clock cycles. If you do vary the sample, the output is the inverse of a delta-sigma ADC; a "delta-sigma DAC?" It was common in embedded audio DACs with binary sample input streams at some point, not sure if still common.)