How to create 20hz-20khz a sine wave
It really depends on your needs. Do you really want to build a solution? ...or are you more interested in using a solution to test audio?

If you want really low noise and distortion (&lt; 0.001%) you might be more prone to use/build an analog generator, if you can accept some moderate distortion (>0.01%) then likely digital generation is more likely viable. 

You can get a free signal generator for a PC, MAC or Linux that outputs on the audio channels that is more than adequate for most audio sanity checks. Distortion here is low because the applications are (usually) using 16-24 bit digital signal generation. The quality however is ultimately set by the output audio amplifier used so don't expect better than 0.1-0.2% distortion unless using high quality plug in audio boards .....here you could be using everything from a basic sound card through to professional generators like this: http://www.ni.com/datasheet/pdf/en/ds-337

One particularly good PC signal generation application is here: http://www.dr-jordan-design.de/Download/SignalGenerator.pdf

This generator will sweep your full range in one setting.

There are literally dozens of other freeware applications as simple signal generators: http://download.cnet.com/s/audio-signal-generator

If you fancy digging into source code you could try looking at Jaaa: https://apps.ubuntu.com/cat/applications/saucy/jaaa/  ...this works on a range of ALSA compatible sound cards.