Files
closed_loop_audio_test_suite/README.md

2.5 KiB

Closed Loop Audio Test Suite

Simple Python-based testing system for PCB audio hardware validation.

Features

  • Automated Testing: Latency, THD, and SNR measurements across multiple frequencies
  • Metadata Tracking: PCB version, revision, software version, timestamps, notes
  • YAML Output: Human-readable structured results
  • Simple Workflow: Run tests, view results, compare versions

Quick Start

1. Install Dependencies

pip install -r requirements.txt

2. Run a Test

python run_test.py \
  --pcb-version "v2.1" \
  --pcb-revision "A" \
  --software-version "a3f2b1c" \
  --notes "Replaced capacitor C5"

3. View Results

# View specific test
python view_results.py test_results/20260226_123456_results.yaml

# List all tests
python view_results.py --list

# View latest test
python view_results.py test_results/*.yaml | tail -1

Test Metrics

  • Latency: Round-trip delay between input and output channels (ms)
  • THD: Total Harmonic Distortion for input and output (%)
  • SNR: Signal-to-Noise Ratio for input and output (dB)

Tests run at multiple frequencies: 100 Hz, 250 Hz, 500 Hz, 1 kHz, 2 kHz, 4 kHz, 8 kHz

Output Format

Results are saved as YAML files in test_results/:

metadata:
  test_id: 20260226_123456
  timestamp: '2026-02-26T12:34:56.789012'
  pcb_version: v2.1
  pcb_revision: A
  software_version: a3f2b1c
  notes: Replaced capacitor C5
test_results:
  - frequency_hz: 1000
    latency_ms: 2.345
    thd_input_percent: 0.012
    thd_output_percent: 0.034
    snr_input_db: 92.5
    snr_output_db: 89.2

Configuration

Edit config.yaml to customize:

  • Audio device settings
  • Test frequencies
  • Test duration
  • Output options

Hardware Setup

Laptop <-> Audio Interface (Scarlett) <-> DUT <-> Audio Interface (Scarlett) <-> Laptop
         Output Channels 1&2         Input Channels 1&2

The system auto-detects Focusrite Scarlett audio interfaces.

File Structure

closed_loop_audio_test_suite/
├── config.yaml              # Test configuration
├── run_test.py              # Main test runner
├── view_results.py          # Results viewer
├── src/
│   └── audio_tests.py       # Core test functions
└── test_results/            # YAML output files
    └── YYYYMMDD_HHMMSS_results.yaml

Tips

  • Each test run creates a timestamped YAML file
  • Results are self-contained with full metadata
  • Compare tests by opening multiple YAML files
  • Archive old tests by moving YAML files to subdirectories