To my ears, sawtooth and square waves are more similar to each other than either one is to a triangle wave. However, when I compare their magnitude spectra against each other using normalized cross-correlation, the square and triangle waves are the most similar to each other, followed by the sawtooth and triangle waves. Does anyone know what the source of this apparent mismatch is?
- Even and odd harmonics, falling off at 1/n
- Odd harmonics only, falling off at 1/n
- Odd harmonics only, falling off at 1/n2
So while triangle and square have the same set of frequencies present, the spectral envelope of sawtooth and square is more similar, with much stronger high frequency harmonics. Triangle waves are simpler/closer to a sine wave.
(Also, if you're generating them digitally, it's uncommon for them to be bandlimited, which produces worse aliasing artifacts with the square and sawtooth than with the triangle. This would be most audible with frequency sweeps or high fundamental frequencies.)
The human ear does not "sense" the time-domain representation of the signal, but, in a rough approximation, the magnitude of its frequency-domain representation (spectrum).
In particular, several variants of the same stationary signal with different phase shifts will sound exactly the same. From that, it is clear to see that normalized cross-correlation is a poor metric for comparing audio signals; since a sine-wave and the same sine-wave with a 90° phase shift will have a low cross-correlation, while they are indistinguishable. A better place to start to compare waveforms would be to compute the cross-correlation of the magnitude spectra.