Re:Digital Audio 101: Playing Audio from a Microcontroller
by colanderman on Friday April 16, 2021 @10:25AM
(#26834276)
Note also that one of the main benefits of a dedicated DAC is that many implement digital oversampling: they use a high-quality digital antialiasing filter to upsample the audio to the 100 kHz-1 MHz range, so that a simpler (= cheaper) analog antialiasing filter can be used on the output.
You can also use a scheme a little bit like PWM called PCM where the GPIO pin can be switched on and off at a frequency much higher than audio (typically 2Mhz or higher) and the duty cycle is varied at the sample rate. This can be implemented on an Arduino using code like https://github.com/damellis/PCM/blob/master/PCM.c