Downsampling

Downsampling is used as a technical means when converting between different sample rates, but is also commonly used as an effect for aesthetic purposes. Since the lower sampling rate may be unable to represent some of the higher harmonics of the input signal, we get a particular kind of distortion if the higher harmonics. This is called aliasing, and what happens is that the audio signal frequencies that fall above the Nyquist frequency get mirrored down from this limit. Say, if we sample at 30kHz sampling rate, the Nyquist frequency is at 15kHz. Now, if we have a sine tone with frequency 16kHz, it will be mirrored in the Nyquist frequency and what we will actually hear is a tone at 14kHz. Likewise, a tone at 17 kHz will be mirrored and we will hear a tone at 13 kHz. As a result, the part of the spectrum that falls above the Nyquist frequency will be turned upside down. High frequencies (e.g. the 17 kHz tone) being representad as signals with lower frequency (13 kHz) that the original lower frequencies (16 kHz, represented at 14 kHz).
When doing signal conversion between different sampling rates for technical reasons (as opposed to aesthetical reasons), it is possible to filter the signal so as to avoid this kind of distortion.

Reducing the sample rate

Here's we'll present an example of downsampling using a simple sample and hold method with no interpolation or other filtering. This method will generate distortion (zero order hold distortion) in most cases, and it is also the method most common downsampling method in effects processing plugins.

Signal flow

Downsampling via sample and hold

Audio signal graphs

A Sine wave
A downsampled sine wave

Sound examples


Audio sample at 44.1 kHz sampling rate

Audio sample, downsampled to 11.025 kHz sampling rate

Audio sample, downsampled to 5 kHz sampling rate

Audio sample, downsampled to 2.5 kHz sampling rate

Audio sample, downsampled to 1.25 kHz sampling rate

440 Hz Sine wave at 44.1 kHz sampling rate

440 Hz Sine wave, downsampled to 11.025 kHz sampling rate

440 Hz Sine wave, downsampled to 5 kHz sampling rate

440 Hz Sine wave, downsampled to 2.5 kHz sampling rate

440 Hz Sine wave, downsampled to 1.25 kHz sampling rate


Csound code

The following Csound code generates a sine wave (at the original audio sampling rate, let's say CD quality 44.1 kHz), then uses a custom sample clock pulse (also synthesized as an audio signal in Csound) to control the sample and hold process.

;***************************************************
; downsampling
;***************************************************
	instr	1

; basic parameters: amp and frequency for the oscillator
	iamp		= ampdbfs(p4)
	icps		= p5

; downsample to this sample rate
	iSampleRate	= p6				

; audio generator (sine oscillator)
	a1		oscil	1, icps, giSine		

; generate new sample clock 
	aSampleClock	mpulse	1, 1/iSampleRate	

; sample and hold (downsample)
	aDownsamp	samphold a1, aSampleClock	

; audio out
	out		aDownsamp*iamp		

	endin
;***************************************************