Signals and samples
Sampling and the sample rate, gain, delay and addition, the unit impulse and the response to it, the feedback echo, and the sine wave as a test signal.
7 minutes read
1327 words
Contents11
A sound is a pressure that rises and falls in time. A computer cannot hold a curve, only numbers, so it keeps the pressure at regular instants and nothing in between. That list of numbers is a digital signal, and everything an audio program does is arithmetic on the list.
Assumed knowledge
Arithmetic. The sine and cosine of an angle, which the section on sine waves needs and angles and polar form builds up from a right triangle.
Ground covered
What sampling is and what the sample rate means. How one sample is named. Gain, delay and addition, which are the three operations every audio process is built from. The unit impulse, and why the response to it describes a whole class of rules. Delay with feedback, which is the smallest echo. A sine wave as a test signal, and how its angle advances from one sample to the next. Blocks.
A reader who can write down the output of for an input that is 1 once and 0 ever after can skip the page.
Sampling
A microphone turns pressure into a voltage that varies continuously in time. Call that voltage . Sampling reads it at the instants and keeps only the readings.
The number is the sample rate, the count of readings per second. Compact discs use . Audio software uses or a multiple of it. At one sample lasts microseconds, and a second of sound is numbers for each channel.
A wave has to be read at least twice per cycle to be told apart from a slower one. The highest frequency a sampled signal can carry is therefore half the sample rate. At that limit is hertz, above the top of human hearing.1
Naming samples
The square brackets in mark a sequence. Here is the whole signal, is an integer, and is one number of the list. A negative refers to time before the recording started, and every such sample is taken to be zero.
Stereo sound is two sequences, and , one for each ear.
Three operations
Almost everything done to an audio signal is built from three rules. Gain multiplies every sample by the same number.
At the sound is half as large, and at it is gone. Delay shifts the signal later by a whole number of samples.
What was at sample is now at sample . A delay of samples lasts seconds, so samples at is milliseconds. Addition mixes two signals sample by sample.
A rule built only from these three, with and fixed, is linear and time-invariant. Linear means that doubling the input doubles the output, and that the output for a sum of two inputs is the sum of the two outputs. Time-invariant means that delaying the input only delays the output. Multiplying two signals together breaks linearity, and so does letting depend on how loud the signal is. Letting change over time breaks time invariance. Both are done in practice, and both are handled by treating the rule as linear over short stretches.
The unit impulse
The simplest signal of all is a single 1 at sample zero.
Any signal is a sum of scaled, delayed impulses, one per sample.
Equation (6) holds for every signal, because the term at contributes at sample and nothing at any other sample.
The impulse response
Feed a linear, time-invariant rule the impulse and record what comes out. That output, written , is the rule’s impulse response.
Now feed the same rule an arbitrary signal . By equation (6) that signal is a sum of scaled, delayed impulses. By linearity the output is the same sum of scaled, delayed copies of .
The impulse response therefore describes the rule completely. The sum in equation (7) is called convolution.2 A room is such a rule to a good approximation. Its impulse response is the sound of one clap in it. The sound of an orchestra in that hall is the convolution of the orchestra with that clap. A reverb effect is a device whose impulse response resembles a room’s.
Delay with feedback
Put a delay and a gain in a loop, so that the output is fed back to the input.
The impulse comes out at once, then again samples later multiplied by , then again after multiplied by .
This is an echo that repeats every samples and fades by the factor each time. It fades only when . At it repeats for ever, and at it grows without limit. Decibels and exponential decay says how long the fade takes. A reverb is a handful of these loops, cross-connected so that their echoes overlap into something too dense to hear as repeats.
Sine waves
The other basic test signal is the sine wave.
Here is the frequency in hertz, which is cycles per second, and is the starting angle, called the phase. Between one sample and the next the angle inside the sine grows by a fixed amount.
A full turn of is spread over the samples that one cycle occupies. A program that needs a sine wave keeps the current angle and adds once per sample. It subtracts whenever the angle passes it, and takes the sine. The angle is a point going round the unit circle at turns per second.
Sine waves matter because a linear, time-invariant rule cannot change the shape of one. Feed it a sine of frequency and out comes a sine of the same frequency, at a different size and shifted in time. The ratio of output size to input size, read as a function of , is the rule’s magnitude response. One-pole filters, shelves and all-passes shows how to read that ratio off the rule itself.
Blocks
A host program does not hand an effect one sample at a time. It hands over a block of some hundreds or thousands of samples, waits for the block back, and hands over the next. A rule written per sample, like every equation on this page, is unaffected. The effect keeps its memory across the boundary, meaning the delayed samples and the running sums. A block is therefore a loop over samples and nothing more.
Further reading
Sampling, its conditions and its failures.3
Why half the sample rate is the limit.1
The class of rules this page describes, and the sum that describes them.4 2
-
Nyquist-Shannon sampling theorem. Wikipedia. Retrieved 5 September 2026. https://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem (opens in a new tab) ↩︎ ↩︎
-
Convolution. Wikipedia. Retrieved 5 September 2026. https://en.wikipedia.org/wiki/Convolution (opens in a new tab) ↩︎ ↩︎
-
Sampling (signal processing). Wikipedia. Retrieved 5 September 2026. https://en.wikipedia.org/wiki/Sampling_(signal_processing) (opens in a new tab) ↩︎
-
Linear time-invariant system. Wikipedia. Retrieved 5 September 2026. https://en.wikipedia.org/wiki/Linear_time-invariant_system (opens in a new tab) ↩︎