Hi Alexandre
On Fri, 2015-05-15 at 14:18 -0300, Alexandre Torres Porres wrote:
Howdy, I have a patch attached to show how downsampling produces artifacts/distortion for a 440 sine wave. I don't hear "aliasing" and I think it couldn't be foldover at all because 440 is below the nyquist. Moreover, I hear harmonic higher pitches - so it seems like a harmonic distortion from the original sine wave that I can also still perceive. This kind of distortion happens when you have a reduced dynamic range.
You're on Pd-extended, right? Maybe I didn't look hard enough, but I wasn't able to find the interesting part about [inlet~] and [outlet~] in its documentation. You'll find it in vanilla, when you open the help for [outlet~], in [pd up/downsampling]. There are three different modes for up- and downsampling that you can specify as argument to [inlet~]/[outlet~]:
The default is 'hold'. In this mode, the holes are filled with the value of the previous sample. If you upsample by a factor of 8 (which is the same as when your signals comes out of a downsampled-by-factor-8 subpatch), you get 1 sample from the subpatch followed by 7 samples of the same value added by [outlet~]. You can imagine that a signal like this looks quite ragged. A slightly smoother method is 'lin'. It does linear interpolation between the samples coming from the subpatch. It still has clear artefacts, but they're not as strong as with the 'hold' method.
You can't compare the sound coming out of a downsampled subpatch to a sound played on a DAC set to a similar low samplerate. When playing a sound on a sound card advanced filtering is applied in order to get rid of aliasing effects. In your example patch, the actual samplerate conversion is causing the aliasing effects, since no "smart" filtering is used (the best you can get easily is linear interpolation). And yes, this causes artefacts that are _above_ the nyquist frequency of the lower samplerate.
Check the graph in the attached modified patch and compare hold, lin, pad.
Roman