Beta

Sync to cloud

Uses your current signed-in YoolVi account. A Learn profile is not required.

Upload a snapshot of this browser’s saved lesson work across all subjects, including notes, experiments, journal and review history. Existing guest work is included only when you confirm below. This does not upload account credentials or award XP.

Sync uploads to your private account; it does not automatically merge or replace this device’s work. On another device, download the cloud copy and use My Learning’s backup import. The previous cloud snapshot is retained when a new one replaces it.

Export or import this device’s work

No background uploads. Edits made after a snapshot need another sync. On shared devices, work is bound to the first account observed by cloud sync; another account must use a separate browser profile. Keep your own downloaded backup too.

Learning preferences

Make learning more comfortable. Changes apply immediately.

Enlarges page content, including diagrams and their labels. You can also use your browser’s zoom.

Choose the colours that are easiest for you to distinguish. Applies to lesson diagrams and lab plots. Labels, shapes, hatching and line patterns also distinguish meanings. Source photographs and raw image brightness stay unchanged; mask-only views are available for image overlays.

ExampleComparisonSample link

Saved in this browser on this device. Preferences are separate from progress backups.

Back to Signals and sequences

Shared AI lesson · Signals and sequences

Understand sound sampling

Sound samplingFixed teaching example — not your saved experiment.
  1. Starting information

    Air pressure measured at regular times

  2. Relationship or operation

    Group samples into short analysis windows

  3. Consequence

    A changing description of frequency content

Sampling records a signal at discrete times. Window size trades timing detail against frequency detail; features are not the original sound.

The idea in everyday terms

A digital sound signal is a sequence of samples. Sample rate tells you how often values are recorded; frequency tells you how quickly a wave repeats. These are different quantities. Too few samples can make different waves look identical.

What to watch in the experiment

Inspect the sampled wave and frequency view together. Compare windows that preserve short-time changes with windows that distinguish nearby frequencies more clearly. A frequency-bin value describes the chosen window and calculation, not the entire sound forever.

What this does not establish

The lab generates teaching waves rather than microphone recordings. Sampling can lose information that later analysis cannot recover, and a clean spectrum is not evidence of speech or real-world sound recognition.

Full worked explanation, calculations and control definitions

Use this reference for the detailed mechanism and control meanings. Derivations explicitly marked optional are enrichment.

A waveform is a sequence of measurements

Sound varies over time. A digital signal records a value at each sample time. Sample rate, measured in samples per second, tells you how close those measurements are. Frequency, measured in hertz (Hz), counts cycles per second; it is not the number of stored values.

The lab generates dimensionless amplitude-0.5 cosine waves, not microphone pressure measurements. At 8,000 samples per second, samples are 1/8,000 second apart: 0.125 ms. A 1,000 Hz tone completes one cycle in 1 ms, so this setting stores eight samples per cycle. The generated duration is always 128 ms: 1,024 samples at 8 kHz or 2,048 at 16 kHz.

A chirp changes frequency over time. Our chirp increases or decreases linearly between the selected endpoints. To generate it correctly, we accumulate the changing frequency into phase. Simply multiplying the instantaneous frequency by time would produce the wrong sweep rate.

Sampling can make different waves indistinguishable

At 8,000 samples per second, 6,000 Hz and 2,000 Hz cosines with this phase produce the same stored values. The high frequency has aliased to a lower one. A frequency analyzer cannot tell which continuous source produced identical samples.

The Nyquist frequency is half the sample rate: 4,000 Hz at 8 kHz. For an appropriately band-limited signal, sampling faster than twice its highest frequency avoids this ambiguity. Actual acquisition also needs a suitable anti-alias filter before sampling. Our deliberately unfiltered generator lets you observe the failure; it is not an audio-capture pipeline.

Changing to 16 kHz raises Nyquist to 8,000 Hz, allowing these 2,000 and 6,000 Hz examples to differ. Increasing only the analysis-window length cannot recover a distinction already lost during sampling. Listening to the sampled preview cannot recover it either.

Ask which frequencies are present in a short interval

A window selects a short run of samples. A rectangular window keeps them unchanged. A Hann window smoothly reduces their contribution near the edges. The discrete Fourier transform, or DFT, compares the windowed samples with cosine and sine patterns at a set of frequencies called bins.

fk=kfsN,Δf=fsNf_k=k\frac{f_s}{N},\qquad \Delta f=\frac{f_s}{N}

Here fₛ is sample rate in samples/second, N is window length in samples, k is the bin number beginning at zero, fₖ is that bin’s frequency in Hz, and Δf is spacing between bins. Our real-valued signal uses bins from zero through Nyquist. At 8 kHz with N = 128, bins are 62.5 Hz apart. The 1,000 Hz tone lands exactly at bin 16.

Practice: double the window to 256 samples at the same rate. Bin spacing becomes 8,000/256 = 31.25 Hz, while the window covers 32 ms, twice as long as the 128-sample window. Finer bin spacing is not unlimited frequency resolution: the window shape and signal also matter.

Multiply, add, and normalize

For each bin, multiply windowed samples by the matching cosine pattern and sum them to form the real part. Multiply by the negative sine pattern and sum to form the imaginary part. Those two numbers keep phase information that a magnitude-only picture discards. Their combined magnitude is the square root of real² + imaginary².

The lab divides this magnitude by the sum of the window weights. Interior bins are doubled to account for the omitted negative-frequency partner. The zero-frequency (DC) and Nyquist bins are not doubled. This produces the displayed one-sided amplitude spectrum; it is not a power-density or loudness measurement.

For the default bin-centered tone, amplitude is approximately 0.5 at 1,000 Hz. An off-bin tone such as 650 Hz spreads across neighboring bins: spectral leakage. The Hann taper reduces distant leakage for this example but broadens its central peak. It does not discover a uniquely correct source frequency in every case. The strongest bin is an estimate on this frequency grid.

Optional calculation convention

The periodic Hann weights are w[n] = 0.5 − 0.5 cos(2πn/N), for sample index n from 0 to N−1. The first weight is zero; the final weight is near zero, not exactly zero. Each DFT frame uses these N weights, no extra zero padding and no subtraction of a fitted mean. These details matter when reproducing the numerical values in another library.

Slide the window to build a spectrogram

A spectrogram places frequency measurements beside one another over time. This lab moves each window by half its length, so adjacent frames overlap. They are correlated measurements, not independent new observations. Each plotted column is positioned at the center of its frame; its display band is one hop wide. No frames are invented beyond the recorded boundaries.

Compare early and late frames of a 500-to-3,000 Hz chirp. The strongest bin should move upward, subject to the window width and bin spacing. Longer windows include more cycles but also mix changes across a longer interval. Shorter windows localize change better while providing coarser frequency detail. State both quantities when choosing a representation.

The plots use fixed amplitude ranges rather than stretching each frame to appear equally strong. Every selected frame has a numerical spectrum, and the spectrogram has a numerical peak timeline. Optional playback uses reduced gain and short edge fades; those playback-only changes do not alter the analyzed samples.

For a guided report, explain an alias pair and a window tradeoff. For implementation, reproduce selected complex bins, amplitude scaling and frame times. For a decision brief, specify the signal frequencies and timing detail a system must capture, then justify a sampling and analysis choice. Generated tones are useful controlled cases, not evidence of performance on speech, music or real recordings.