Why does a recording still sound like a voice, violin or thunderstorm after a microphone has turned the changing air pressure into a long list of numbers? The answer is not “because computers are clever.” It is because mathematics tells engineers what must be measured, how often to measure it, how much precision is useful and what can go wrong. Digital audio sampling is a beautiful example of the importance of mathematics in everyday life: every voice note, video call, game soundtrack and streaming song depends on functions, frequency, inequalities, rounding, probability and careful error control.
This article builds the idea from the waveform up. We will distinguish sample rate from bit depth, derive the Nyquist limit, calculate an alias, examine quantisation and filters, and show how students can investigate the ideas safely. The goal is not to declare one “best” format. It is to understand the trade-offs well enough to ask better questions about audio quality, storage, latency and evidence.
A quick map of the mathematics
- A waveform represents air-pressure change as amplitude against time.
- Sampling records the waveform at regularly spaced times; the sample rate counts those measurements per second.
- Frequency counts cycles per second in hertz, while phase locates a cycle in time.
- The Nyquist condition says a band-limited signal must be sampled above twice its highest frequency for ideal reconstruction.
- Aliasing occurs when different continuous frequencies produce the same sampled sequence.
- Quantisation rounds amplitudes to available levels; bit depth controls how many codes are available.
- Filtering limits unwanted frequencies before or during a rate change.
- Fourier analysis describes a complicated sound as a combination of frequency components.
These ideas connect directly to sound, decibels and hearing exposure, musical tuning and frequency ratios and Fourier ideas in MRI image reconstruction. The application changes; the habit of relating a representation to the thing represented does not.
Sound begins as a continuous change
Imagine holding one point in the air near a loudspeaker. The pressure there rises and falls as the cone moves. A microphone converts that physical variation into an electrical signal. In a simplified model, we write the signal as x(t), where t is time and x is instantaneous amplitude. Time is continuous in the model: between 1.000 seconds and 1.001 seconds lie infinitely many possible instants.
A pure tone can be modelled as x(t) = A sin(2πft + φ). Here A is amplitude, f is frequency in hertz, and φ is phase. If f = 440 Hz, the waveform completes 440 cycles each second. Its period is T = 1/f = 1/440 seconds, about 2.27 milliseconds. Real sounds are more complex, but this sinusoid gives us a ruler for reasoning.
Three quantities students often mix up
Amplitude relates to signal size, not pitch by itself. Frequency relates to repetition rate, not loudness by itself. Phase describes position within a cycle and becomes important when waves combine. Two equal sinusoids in phase reinforce; the same sinusoids half a cycle apart cancel in the ideal model. Those facts explain why microphone placement, stereo mixing and noise cancellation all need more than a single “volume” number.
A waveform graph is also not a photograph of a vibrating object. It is a coordinate representation. Its horizontal scale might be seconds or samples; its vertical scale might be volts, pascals or normalised digital units. Reading the axes before interpreting the shape is part of mathematical literacy.
Did You Know? Silence is still data
In a digital recording, a silent interval may contain thousands of samples whose ideal value is zero. Practical microphones and electronics add some noise, so measured values usually wiggle slightly. “No intended sound” and “all numerical samples equal zero” are different statements. This is a useful lesson about measurement: physical observations nearly always include uncertainty and background effects.
Sampling turns time into an indexed sequence
Suppose we take a measurement every Δt seconds. The sample rate is fs = 1/Δt samples per second. At 48,000 samples per second, Δt = 1/48,000 seconds, approximately 20.83 microseconds. Instead of the continuous x(t), a computer stores x[n] = x(n/fs), where n is an integer index: 0, 1, 2, 3 and so on.
That compact notation carries a major change. The index does not say what happened at every instant; it records selected instants on a regular grid. Reconstruction is possible only under conditions. Mathematics identifies those conditions instead of relying on the vague idea that “more samples always means perfect sound.”
A one-second storage calculation
Consider uncompressed stereo audio at 48,000 samples per second and 24 bits per sample per channel. The raw bit rate is:
48,000 × 24 × 2 = 2,304,000 bits per second.
Dividing by eight gives 288,000 bytes per second before file headers or other packaging. One minute is about 17.28 MB using decimal megabytes. The calculation reveals three independent multipliers: sample rate, bit depth and channel count. Doubling any one doubles the raw data rate. That is why an audio-format claim is incomplete if it mentions only one number.
| Quantity | What it counts | Example | It does not directly mean |
|---|---|---|---|
| Sample rate | Measurements per second | 48 kHz | Bits per measurement |
| Bit depth | Available binary code width | 24 bit | Highest representable frequency |
| Channels | Simultaneous signal streams | Stereo = 2 | File compression ratio |
| Duration | Recording time | 60 s | Signal quality |
The W3C Web Audio API specification defines sample rate in sample-frames per second and exposes audio buffers, processing graphs and frequency analysis. It is a current technical specification, not a promise that every hardware path behaves identically.
The Nyquist limit is about distinguishability
Let a sinusoid have frequency f. At sampling times n/fs, its values are sin(2πfn/fs + φ). Now add one whole sample-rate multiple to the frequency: f + kfs, where k is an integer. The sampled angle gains 2πkn. Because n and k are integers, 2πkn is a whole number of turns. The samples are unchanged. Distinct continuous waves can therefore generate the same discrete sequence.
For a sinusoid below fs/2, its samples can be assigned a unique baseband frequency when the original signal is appropriately band-limited. The boundary fs/2 is called the Nyquist frequency. The familiar rule “sample at least twice the highest frequency” is a shorthand. In ideal sampling theory, strict recovery needs the signal to contain no energy at or above half the rate and the rate to exceed twice the highest component. Real filters need a transition band, so engineers leave margin.
Why two points per cycle is a boundary, not a drawing recipe
A common diagram says two samples define a wave. They do not. Two arbitrary points cannot determine amplitude, frequency and phase without additional assumptions. At exactly two samples per cycle, an unfortunate phase could place every sample at a zero crossing, producing a sequence of zeros. The theorem concerns a band-limited signal and all its samples, plus an ideal reconstruction process. It does not say that connecting pairs of dots with straight lines reveals the original curve.
If fs = 48 kHz, the Nyquist frequency is 24 kHz. That does not mean a practical system passes every component up to 24 kHz unchanged and blocks everything immediately above. An analogue anti-alias filter has a gradual transition. Designers choose a passband, transition region and stopband attenuation that fit the application.
Worked example: choose a minimum ideal rate
Suppose a measurement signal is known to contain frequencies only from 0 to 7.5 kHz. Ideal theory requires fs > 15 kHz. A choice of exactly 15 kHz sits on the boundary and is not robust. A practical designer might select a standard rate above it and design the input filter so that components which could fold into the wanted band are sufficiently reduced. “Above 15 kHz” is the mathematical constraint; the final engineering rate also depends on filters, hardware, latency, cost and standards.
Aliasing: when fast motion wears a slower mask
Aliasing is not simply “low quality.” It is ambiguity created by sampling. When a tone is above half the sample rate, its samples may match a lower-frequency tone. The folded frequency can often be found by choosing an integer k so that |f − kfs| lies between 0 and fs/2.
Worked example: a 1 kHz tone sampled at 1.5 kHz
Let f = 1000 Hz and fs = 1500 Hz. Half the sample rate is 750 Hz, so the tone exceeds the Nyquist frequency. Subtract one sample rate:
| 1000 − 1500 | = 500 Hz. |
|---|
At the sample instants, the 1 kHz sinusoid can be indistinguishable from a 500 Hz sinusoid, with phase or sign handled appropriately. The samples have not merely become rough; they support the wrong frequency interpretation.
Write the sample angles. The 1000 Hz tone advances 2π(1000/1500) = 4π/3 radians per sample. A negative 500 Hz tone advances −2π(500/1500) = −2π/3. Those increments differ by 2π, so sine values repeat in the same way. This algebra explains the visual “folding” seen in frequency diagrams.
Aliasing in more than audio
Wagon wheels can appear to rotate slowly backward in film because the camera samples position in frames. Striped fabrics can create moiré patterns in photographs because an image sensor samples space. A spreadsheet that records temperature once daily can miss faster fluctuations. The common mechanism is loss of distinguishability after discrete observation.
The lesson transfers to data science: a dataset is shaped by when, where and how measurements were taken. A neat chart cannot restore variation that the collection schedule never distinguished.
Did You Know? Changing speed can reveal an alias
If the sample rate changes while the original frequency stays fixed, the apparent alias usually changes. That behaviour helps diagnose sampling artefacts. A real lower-frequency component remains tied to the source; an alias is tied to the interaction between source and sampling grid. Scientists often vary a measurement condition precisely because changing the grid can expose hidden ambiguity.
Anti-alias filtering protects the boundary
Before an analogue signal is sampled, an anti-alias filter reduces frequencies that the chosen rate cannot represent safely. A low-pass filter ideally passes the wanted band and rejects higher frequencies. Real filters do neither instantly. Their response has ripple, a transition width and finite attenuation.
Suppose the wanted band ends at 20 kHz and sampling occurs at 48 kHz. The Nyquist frequency is 24 kHz, leaving a 4 kHz transition region between the nominal wanted edge and the folding boundary. A filter specification might state acceptable variation below 20 kHz and required attenuation by 24 kHz. Those numbers can be tested. “High quality filter” cannot.
Why a digital filter cannot undo analogue aliasing already recorded
Once a 30 kHz component sampled at 48 kHz has folded to 18 kHz, the stored sequence looks like an 18 kHz component. A later digital low-pass filter cannot generally know whether those samples came from a legitimate 18 kHz source or an aliased 30 kHz source. Prevention must happen before or as the rate changes.
When reducing an existing digital rate, the same logic applies in discrete form. Before downsampling, a digital low-pass filter removes components above the new Nyquist frequency. Then the system keeps fewer samples. Simply discarding every other sample without filtering can fold previously valid high-frequency content into the new baseband.
Filters introduce trade-offs
A sharper frequency transition generally requires more computation or a longer impulse response. Some filters alter phase; some preserve linear phase but add delay and pre-ringing around transients. In real-time communication, latency matters. In offline mastering, more processing delay may be acceptable. Mathematics does not select one universal winner; it makes consequences explicit.
Reconstruction is more than joining dots
If a continuous signal is ideally band-limited below fs/2, theory reconstructs it using shifted sinc functions. Each sample contributes a smooth curve that equals one at its own sample time and zero at all other sample times. Adding these weighted curves recovers the continuous function.
This is surprising because a sample sequence seems to contain gaps. Band limitation supplies the missing constraint: not every imaginable curve is allowed between samples. The permitted curves are linked across time. That is why the theorem is powerful and why removing its assumptions makes it false.
Why straight-line interpolation changes the spectrum
Connecting adjacent samples with straight segments produces a piecewise-linear curve. It can be useful for display or simple resampling, but it is not ideal band-limited reconstruction. Nearest-neighbour holding creates steps. Cubic interpolation creates smoother joins. Each method has a frequency response and error profile. “Looks smooth on screen” is not enough to establish accuracy, especially when a waveform display shows far fewer pixels than samples.
A digital-to-analogue converter produces electrical output from codes, and an output reconstruction filter smooths unwanted spectral images. The real chain includes clocks, converters, amplifiers and loudspeakers. Sampling theory guides the chain; it does not erase physical limitations.
Bit depth measures amplitude resolution
Sampling discretises time. Quantisation discretises amplitude. If a converter uses B bits for each sample, it can label up to 2^B codes. Eight bits give 256 codes; sixteen bits give 65,536; twenty-four bits give 16,777,216. How those codes map to voltages depends on the representation and full-scale range.
For a simple uniform quantiser spanning total range R, the step size is approximately Δ = R/2^B. Rounding an input to the nearest level produces an error roughly between −Δ/2 and +Δ/2, except at overload. Adding one bit halves the step size and roughly quadruples the mean-squared error performance for an ideal well-behaved signal.
Worked example: four-bit rounding
Suppose a toy unipolar converter covers 0 to 1 with 16 equally spaced code intervals, so Δ = 1/16 = 0.0625. An input 0.70 is closest to 0.6875 if levels are multiples of Δ in this simplified model. The error is −0.0125. An input beyond the permitted range cannot be represented by more rounding; it clips at an endpoint.
The example is deliberately simple. Production converters may use signed codes, offset binary, two's complement, noise shaping or calibration. The essential mathematics is that finite labels partition a continuous range into regions.
Quantisation noise is a model, not magic dust
Under suitable conditions, quantisation error can be modelled as noise approximately uncorrelated with the signal. For a full-scale sine in an ideal uniform B-bit converter, a frequently quoted signal-to-quantisation-noise ratio is about 6.02B + 1.76 dB. It is an idealised result, not a guarantee for every waveform or device. Quiet periodic signals can make the error correlated and audible as distortion.
Dither deliberately adds small noise before quantisation to decorrelate the error. It trades a little noise floor for more benign, statistically predictable behaviour. This is a delightful example of probability improving fidelity: adding randomness can reduce structured distortion.
Clipping, headroom and normalisation
Digital full scale is a boundary. If an input exceeds the representable range, values are clipped or otherwise overloaded. A sine with its peaks flattened is no longer a sine; the abrupt shape contains additional harmonics. Increasing bit depth does not rescue a signal clipped earlier in the chain.
Headroom leaves distance between expected peaks and the maximum. Recording too quietly may underuse available resolution; recording too hot risks irreversible overload. Modern practice balances noise, dynamic range and unpredictable peaks. The best setting depends on the source, equipment and later processing.
Normalisation multiplies samples so a chosen peak or loudness target is reached. It does not reconstruct clipped peaks, remove background noise or create missing frequency information. If every sample is multiplied by two, both wanted signal and embedded noise double in amplitude. A mathematical operation can be precisely executed while failing to solve the real problem.
Decibels need a reference
For an amplitude ratio A2/A1, the level change is 20 log10(A2/A1) dB. Halving amplitude gives about −6.02 dB. For a power ratio, the factor is 10 log10(P2/P1). Digital level often uses dBFS, referenced to full scale; acoustic sound-pressure level uses a different reference. Numbers ending in “dB” are not automatically comparable without their quantity and reference.
Fourier thinking explains spectra
A time waveform tells us when values change. A spectrum tells us how energy or amplitude is distributed across frequency. The discrete Fourier transform takes N samples and represents them with N complex frequency coefficients. Each coefficient carries magnitude and phase.
If N samples are taken at fs samples per second, the frequency-bin spacing is fs/N. At 48 kHz with N = 48,000, the spacing is 1 Hz and the analysed window lasts one second. Using only 4,800 samples gives 10 Hz spacing over 0.1 seconds. Longer windows improve nominal frequency spacing but reduce time localisation. This time-frequency trade-off matters for speech, music and transient sounds.
Spectral leakage is not a new frequency in the source
The transform treats a finite analysed block as if it repeats. If the block cuts a sinusoid at mismatched phases, the repeated edges jump, spreading energy across bins. A window function tapers the edges to reduce certain leakage, but broadens spectral peaks. Different windows trade main-lobe width against side-lobe level.
A student seeing a wide peak should therefore ask: is the source changing, is the window short, is the tone between bins, or is there actual bandwidth? Interpretation needs the measurement method.
From spectra to compression
Audio codecs exploit hearing, redundancy and transform structure, but compression is a different axis from sampling. Lossless compression can reproduce the same samples exactly; lossy compression changes them to save more space. A 48 kHz file can be highly compressed or uncompressed. To explore the information side, continue to data compression, entropy and Huffman coding and compare it with JPEG cosine transforms and quantisation.
Clock accuracy, jitter and synchronisation
Sampling assumes known times. A real converter uses a clock whose intervals are very close to, but not perfectly equal to, the ideal grid. Slow error in clock rate changes duration and pitch relative to another clock. Rapid timing variation is called jitter and can convert into amplitude error, especially for high-frequency, steeply changing signals.
For a sinusoid x(t) = A sin(2πft), a small timing error ε changes the sample by approximately x'(t)ε = 2πfA cos(2πft)ε. The derivative shows why the same timing error matters more as frequency or amplitude rises. It also shows that “jitter in nanoseconds” alone is incomplete; its spectrum and the signal matter.
When two devices run on independent clocks, their sample counts gradually drift. Professional systems may share a clock or perform sample-rate conversion. Video calls buffer packets and adjust playback to balance continuity against delay. Mathematics connects oscillator tolerance, buffer size, network variation and user experience.
Latency is a sum, not one mysterious delay
Interactive audio travels through stages: analogue filtering, conversion, input buffering, processing, network transport if any, output buffering, conversion and acoustic travel. Total latency is approximately the sum of stage delays. A buffer of 480 samples at 48 kHz represents 10 milliseconds. Two such buffers already contribute about 20 milliseconds before other stages.
Smaller buffers reduce delay but provide less time to finish computation and absorb scheduling variation. If processing misses a deadline, the listener hears a dropout or glitch. Larger buffers are more robust but feel sluggish to a musician. Optimisation therefore uses distributions and worst cases, not only average CPU time.
Worked comparison
System A uses 128-sample input and output buffers at 48 kHz. Their nominal combined duration is 256/48,000 ≈ 5.33 ms. System B uses two 1024-sample buffers, contributing about 42.67 ms. Neither number is the complete round-trip latency, but the calculation explains a material difference. A benchmark should state what points were measured.
Common misconceptions worth correcting
“A higher sample rate always sounds better”
A higher rate raises the Nyquist frequency and can ease some filter designs, but it also increases data and processing. Whether a listener benefits depends on the signal, converters, filters, playback chain, level matching and test design. A number alone does not establish audible improvement.
“The waveform becomes a staircase”
Stored samples are discrete numbers, but a reconstruction system does not have to connect them with stairs. The staircase is one display or zero-order-hold model. Band-limited reconstruction is smooth. Confusing a plotting convention with the physical output leads to false conclusions.
“More bits capture higher pitch”
Bit depth primarily increases amplitude code resolution and potential dynamic range. Sample rate controls the frequency boundary. Changing one cannot substitute for the other.
“Nyquist says two samples are enough”
It says more than two samples per cycle under band-limited assumptions can support reconstruction from the whole sequence. It does not let two isolated measurements reveal an arbitrary waveform.
“An MP3 at 320 kb/s is sampled at 320 kHz”
Bit rate counts stored or transmitted bits per second after coding. Sample rate counts sample frames per second before or after decoding. They have different units and meanings.
A safe student investigation
You can investigate aliasing without loud sounds or specialist hardware by using a spreadsheet or a short programming environment. Generate numerical samples; do not play high-frequency test tones at high volume.
Investigation 1: two tones, one sequence
- Choose fs = 12 samples per arbitrary second.
- Compute sin(2π × 2n/12) for n = 0 to 23.
- Compute sin(2π × 10n/12) for the same n.
- Compare the columns and explain the sign or phase relationship.
- Plot points against sample index, then plot hypothetical continuous curves separately.
Because 10 = 12 − 2, the higher tone folds around the sample-rate grid. The activity makes aliasing visible without suggesting that a chart proves what the original analogue signal was.
Investigation 2: quantisation error
- Generate a sine from −1 to 1.
- Round it to a toy set of 16 levels.
- Subtract the rounded value from the original.
- Plot the error and calculate its mean and root-mean-square value.
- Repeat with 256 levels and compare.
If you add dither, label its distribution and amplitude. Do not claim the result proves all converters behave that way; it demonstrates one mathematical model.
Investigation 3: window length
Create a signal containing 50 Hz and 55 Hz components in a simulation. Compare spectra from short and long time windows. Record frequency-bin spacing fs/N. Observe that longer duration separates nearby steady tones more clearly while locating changes less precisely.
How students can build transferable skill
Start with units. Write Hz as cycles per second, sample rate as samples per second, duration in seconds and bit rate in bits per second. Unit cancellation catches many errors. A result labelled “48,000 bits” when the calculation produced bits per second signals a conceptual mistake.
Draw both domains. Sketch amplitude against time and magnitude against frequency. Mark fs/2 on the spectrum. When downsampling, draw the old and new limits before calculating. Visual structure often reveals an aliasing risk before algebra does.
Use boundary tests. Ask what happens at zero frequency, at fs/2, just above fs/2 and after adding fs. Check whether a formula respects symmetry. Substitute a simple sine before trusting a method on music.
Separate ideal theorem, implementation and perception. The sampling theorem is mathematical. A converter and filter are engineered approximations. An audibility claim is an empirical question requiring controlled listening. Strong explanations state which layer supports each conclusion.
Keep a calculation log. Record formula, values, units, result and interpretation. If software performs a transform, record the window, N, sample rate and scaling. Reproducibility is a habit students can carry into physics, computing, engineering and statistics.
Guidance for parents and educators
Ask a learner to explain a voice note as a chain: air pressure, microphone voltage, anti-alias filter, sampling, quantisation, storage, decoding, reconstruction and loudspeaker. They do not need circuit-level detail. The value lies in connecting mathematical choices to consequences.
Use household technology as an invitation, not proof. A music app, phone recorder or video editor may display rates and waveforms, but its interface can hide resampling and compression. Encourage students to distinguish what the software reports from what they infer.
Reward qualified language. “Above the Nyquist limit this component can alias unless filtered” is better than “high frequencies disappear.” “Under an ideal uniform-quantisation model” is better than presenting an approximation as a universal law.
For curriculum planning, link ratios and rates to lower-secondary mathematics, trigonometric functions to Additional Mathematics, vectors and complex numbers to later study, and probability to noise. Singapore students can explore pathways without assuming one subject guarantees a career. Mathematics supports audio engineering, communications, software, acoustics and research when combined with domain knowledge, experimentation and communication.
For broader progression, the eduKate Sengkang Mathematics Hub organises learning themes, while the Bukit Timah mathematics pathways guide helps families consider routes without treating them as a single ladder.
Frequently asked questions
What is the difference between sample rate and frequency?
Signal frequency describes how quickly a component repeats. Sample rate describes how often the measuring system records values. Both may use hertz-like “per second” units, but they refer to different processes.
Is 44.1 kHz twice 20 kHz?
It is slightly more than twice 20 kHz, leaving a transition region between a nominal audio band and the 22.05 kHz Nyquist frequency. The history and implementation of a format include more than that single arithmetic observation.
Does a 48 kHz sample rate mean 48,000 values for stereo?
It means 48,000 sample frames per second. A stereo frame contains one sample for each of two channels, so there are 96,000 channel-sample values per second.
Can software remove aliasing after recording?
It may reduce an audible artefact in a particular case, but aliasing merges information: an aliased component can be indistinguishable from a legitimate lower one. Prevention with appropriate filtering and sampling is more reliable.
Does 24-bit audio always contain 24 useful bits?
No. Electronic noise, converter performance, microphone self-noise and recording level limit effective resolution. The storage field width is not the same as measured signal-to-noise performance.
Why do spectrograms use colours?
A spectrogram divides a signal into time windows, computes spectra and maps magnitude to colour. Window length, overlap, scale and colour map all affect appearance. It is a measurement visualisation, not a literal picture of sound.
What mathematics should a beginner learn first?
Ratios, rates, scientific notation, graphs, sine functions and logarithms provide a strong start. Then explore complex numbers, Fourier transforms, probability and digital filters as the questions become deeper.
Is audio mathematics only for engineers?
No. Musicians use timing and frequency relationships; programmers manage buffers and transforms; researchers analyse signals; informed listeners evaluate claims. The same reasoning helps whenever continuous change becomes discrete data.
A final perspective
Digital audio works because representation is disciplined. A sample is not the sound; it is a measurement made at a known time. A bit depth is not quality; it is a capacity for codes. A spectrum is not a second recording; it is another mathematical view. The Nyquist condition is not marketing; it is a boundary on distinguishability under stated assumptions.
That is why mathematics matters. It tells us what information a system can preserve, what ambiguity it creates, how resources scale and where evidence must replace intuition. Once students see those habits in a voice note, they can recognise them in images, sensors, medical scans, communications and scientific data.
