Audio aliasing experiment / 音频混叠实验 / 音声のエイリアシング実験
2026-10-10

Tested on macOS 27.0.1 arm64, Python 3.12.14;
NumPy 2.3.5, SciPy 1.18.1, Matplotlib 3.11.2.
The pinned SciPy version requires Python 3.12 or newer.

In the extracted folder, with Python 3.12 installed:
  python3.12 -m venv .venv
  .venv/bin/python -m pip install -r audio-aliasing-requirements.txt
  .venv/bin/python audio-aliasing-lab.py audio-aliasing-output

The script synthesizes two seconds of 900 Hz + 3900 Hz at 48 kHz,
each with peak amplitude 0.4, using float64 arrays. It compares
taking every eighth sample with scipy.signal.resample_poly(up=1,
down=8, window=('kaiser', 5.0), padtype='constant'). Both outputs
have 12,000 samples at 6 kHz and remain two seconds long.

Measurements use the central 1.8 seconds, before WAV quantization.
The sine tones occupy exact FFT bins in that interval. A one-sided
rFFT amplitude spectrum is scaled by 2/N, except DC and the even-N
Nyquist bin, which are not doubled. Trimming excludes end transients
from the amplitude table; it does not validate endpoint or streaming
behavior in another application.

Outputs: original.wav, stride.wav, filtered.wav, spectrum.png,
results.json. WAVs are mono PCM16 with no independent normalization;
the script rereads their headers and samples to check serialization.
Spectral measurements refer to float arrays, not the quantized WAVs.
The script does not play sound or test microphones, DACs, speakers,
perceived sound quality, real speech, recognizers or streaming systems.

Boundary checks compare the 3900 Hz strided samples with a negative
2100 Hz sine, and compare phases 0 and pi/2 at exactly 3000 Hz.
These finite pure-tone cases do not define a universal quality score
or a general recommended audio sample rate.

Sources:
  https://www.analog.com/en/resources/technical-articles/basics-of-bandlimited-sampling-and-aliasing.html
  https://www.analog.com/en/resources/technical-articles/guide-to-antialiasing-filter-basics.html
  https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.resample_poly.html
  https://numpy.org/doc/2.3/reference/generated/numpy.fft.rfft.html
  https://numpy.org/doc/2.3/reference/routines.fft.html
