Which Switching Frequency?:
The higher the frequency the better but at the price of a higher computational load. Anything above the audio spectrum its ok, using 8 bit resolution a nice balanced point is using 31.3KHz.
If you want to understand all the posibilities and
Configuring Arduino UNO registers for PWM audio:
There are basically 3 registers that controls everything:
PWM_QTY: Sets to 1 for Single PWM, and 2 for Dual PWM.
PWM_FREQ: Sets the PWM frequency following the table below.
PWM_MODE Sets the Fast Mode (1) or the Phase Correct Mode (0)
note: Fast Mode can reach higher switching frequencies ( ) at the expense of higher harmonic distortion ( ). By default we use Phase Correct Mode although you can try the Fast one and find the sound differences.
The works done by OpenMusicLabs in the Arduino Uno PWM generation are great. I really appreciate all the outstanding analysis and examples. THANKS.