# Measurement & validation Python tools to exercise and characterize the finished amplifiers through a PC sound card. | Script | Purpose | |--------|---------| | [`generate_test_signals.py`](generate_test_signals.py) | Build 1 kHz sine, pink noise, and 20 Hz–20 kHz log sweep WAVs | | [`measure_thd.py`](measure_thd.py) | FFT THD / THD+N from a 1 kHz recording (or live capture) | | [`plot_frequency_response.py`](plot_frequency_response.py) | Sweep deconvolution → FR plot + CSV | ## Setup ```bash cd measurement python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt # Optional for live I/O: system PortAudio (e.g. apt install libportaudio2) ``` ## Safety **Never** feed speaker-level voltages straight into a sound-card line input. Use a resistive attenuator / divider (see comments in `measure_thd.py`). Incorrect hookup can destroy the PC interface and is a shock hazard on high-power rails. ## Typical session ```bash python generate_test_signals.py --outdir wav_out --duration 10 # Play wav_out/sine_1kHz.wav through crossover → amp → attenuator → record python measure_thd.py --wav capture_1k.wav --f0 1000 # Play sine_sweep_20_20k.wav, record, then: python plot_frequency_response.py \ --recorded capture_sweep.wav \ --reference wav_out/sine_sweep_20_20k.wav \ --out fr_mid.png ```