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~]:
 
 * hold
 * pad
 * lin

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 

#N canvas 520 424 555 294 10;
#X obj 59 166 output~;
#X text 173 70 Downsampling producing artifacts/distortion;
#N canvas 643 208 566 473 Downsampling 0;
#X obj 218 250 samplerate~;
#X obj 218 285 nbx 6 20 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 14
-241261 -1 -1 2756.25 256;
#X obj 218 215 trigger bang float;
#X msg 218 179 0.25;
#X msg 193 156 0.125;
#X obj 323 305 block~;
#X obj 94 197 osc~ 440;
#X msg 323 269 set 64 1 \$1;
#X text 182 132 Downsampling;
#X text 255 180 1/4;
#X text 235 157 1/8;
#X msg 154 108 0.0625;
#X obj 93 399 outlet~ hold;
#X text 183 394 <- compare: hold \, pad \, lin;
#X connect 0 0 1 0;
#X connect 2 0 0 0;
#X connect 2 1 7 0;
#X connect 3 0 2 0;
#X connect 4 0 2 0;
#X connect 6 0 12 0;
#X connect 7 0 5 0;
#X connect 11 0 2 0;
#X restore 59 46 pd Downsampling;
#N canvas 0 0 450 300 (subpatch) 0;
#X array graph 200 float 1;
#A 0 0.982479 0.982479 0.982479 0.982479 0.982479 0.982479 0.982479
0.982479 0.982479 0.982479 0.982479 0.982479 0.982479 0.982479 0.982479
0.982479 0.371267 0.371267 0.371267 0.371267 0.371267 0.371267 0.371267
0.371267 0.371267 0.371267 0.371267 0.371267 0.371267 0.371267 0.371267
0.371267 -0.583189 -0.583189 -0.583189 -0.583189 -0.583189 -0.583189
-0.583189 -0.583189 -0.583189 -0.583189 -0.583189 -0.583189 -0.583189
-0.583189 -0.583189 -0.583189 -0.998475 -0.998475 -0.998475 -0.998475
-0.998475 -0.998475 -0.998475 -0.998475 -0.998475 -0.998475 -0.998475
-0.998475 -0.998475 -0.998475 -0.998475 -0.998475 -0.490672 -0.490672
-0.490672 -0.490672 -0.490672 -0.490672 -0.490672 -0.490672 -0.490672
-0.490672 -0.490672 -0.490672 -0.490672 -0.490672 -0.490672 -0.490672
0.47077 0.47077 0.47077 0.47077 0.47077 0.47077 0.47077 0.47077 0.47077
0.47077 0.47077 0.47077 0.47077 0.47077 0.47077 0.47077 0.996974 0.996974
0.996974 0.996974 0.996974 0.996974 0.996974 0.996974 0.996974 0.996974
0.996974 0.996974 0.996974 0.996974 0.996974 0.996974 0.60149 0.60149
0.60149 0.60149 0.60149 0.60149 0.60149 0.60149 0.60149 0.60149 0.60149
0.60149 0.60149 0.60149 0.60149 0.60149 -0.350074 -0.350074 -0.350074
-0.350074 -0.350074 -0.350074 -0.350074 -0.350074 -0.350074 -0.350074
-0.350074 -0.350074 -0.350074 -0.350074 -0.350074 -0.350074 -0.978
-0.978 -0.978 -0.978 -0.978 -0.978 -0.978 -0.978 -0.978 -0.978 -0.978
-0.978 -0.978 -0.978 -0.978 -0.978 -0.701753 -0.701753 -0.701753 -0.701753
-0.701753 -0.701753 -0.701753 -0.701753 -0.701753 -0.701753 -0.701753
-0.701753 -0.701753 -0.701753 -0.701753 -0.701753 0.223258 0.223258
0.223258 0.223258 0.223258 0.223258 0.223258 0.223258 0.223258 0.223258
0.223258 0.223258 0.223258 0.223258 0.223258 0.223258 0.941878 0.941878
0.941878 0.941878 0.941878 0.941878 0.941878 0.941878;
#X coords 0 1 199 -1 200 140 1 0 0;
#X restore 276 145 graph;
#X obj 148 116 tabwrite~ graph;
#X obj 146 94 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 59 82 *~ 1;
#X connect 2 0 6 0;
#X connect 5 0 4 0;
#X connect 6 0 0 0;
#X connect 6 0 0 1;
#X connect 6 0 4 0;
_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

Reply via email to