Michael Smith just posted up a great project where he uses PWM to play back sampled sound on the Arduino. His code is posted up at the Arduino Playground here.
Michael hijacked two timers, one for PWM generation and the other for the playback sample rate. His sample rate is 8KHz and the PWM runs at about 60KHz which is easy to filter. In fact, you don’t even need to filter it for most applications. I had no trouble loading up his project and playing the sound though my PC as described in a previous article here.
I plan to use Michael’s code my next article about Digital to Analog Converters (DACs) for audio. Michael uses the PWM function to act as a DAC for PCM audio and I can adapt his code to work with several types of DACs. The sound sample he uses is somewhat broad spectrum which makes it ideal for testing various DAC configurations and playback techniques. Great work Michael!