# Why does slowing down audio introduce aliasing?

I have an 8khz mono buffer of samples, and I am trying to manipulate the playback speed of it by modifying the number of samples in it. When slowing down (a speedScale value of 0.5 for example) then the values are repeated-- a buffer of samples: [0.1, 0.2, 0.3..] becomes [0.1, 0.1, 0.2, 0.2, 0.3, 0.3 ..]. When I do this, although the speed has slowed down correctly, I am noticing aliasing happening. I was under the impression that repeating samples like this would not require low pass filtering to avoid aliasing. Am I doing something wrong?

Here's the code for slowing-down/speeding-up:

function process(buffer, speedScale) {
size = ceil(buffer.size / speedScale);

counter = 0.0;
ratio = 1 * speedScale;
processed = [];

for (i = 0; i < size; i++) {
index = floor(counter);
processed[i] = buffer.samples[index];
counter += ratio;
}
return processed;
}

• because you are reconstructing you original audio using the zero-order hold (a.k.a. piecewise-constant) interpolation and then resampling. the ZOH reconstruction is far worse than the use of a windowed $\operatorname{sinc}(\cdot)$ function in that it leaves images that get reflected back into your baseband. – robert bristow-johnson Apr 6 '15 at 19:11

• the means of interpolation that the OP is using (zero-order hold) with the index = floor(counter); processed[i] = buffer.samples[index]; code, does not attenuate the images very much and those images fold back into the baseband as aliases. unless the input has only very low-frequency content, that will be a problem for any signal that does not originally have frequency components extending beyond Nyquist. – robert bristow-johnson Apr 6 '15 at 19:15