Ruari: it's very hard to estimate the quality of any oscillator only by looking at the waveform. At least, look at the spectrum, which is more important here.
You do not want to generate a signal whose waveform looks close to the reference signal : you want to generate a signal whose frequency content is close to the reference signal frequency content. Because this is the only thing your ears will pay attention to.
And guess what : in a digital world, the closest waveform generally sounds like shit.
Waveforms which contain discontinuities (square wave) or sharp edges (triangle wave) have a spectrum which extends to infinity. But frequencies higher than half the sampling rate can't be represented in a digital signal.
Unfortunately, those frequencies don't magically disappear, instead, they get reflected into the range of frequencies your sampling rate can represent.
Which means you now have a signal full of alien frequencies, some of them going down as your pitch increases ; in one word, your oscillator aliases.
You have to filter all of these non-audible high frequencies, which means smoothing the sharp edges of your signal.
Take a look at the picture below.
In red, the reference square wave. In an analog world, this would probably be what you would aim for.
In blue, the filtered square wave. See what happens on the edges? This is not a bug in the synthesis algorithm, this is something you actually want! Because this is what allows you to stay close to a square wave, but without having edges in your signal.
[Blocked Image: https://farm4.staticflickr.com/3389/4625477547_d974f432a2.jpg]