Refactoring and minor improvents.

This commit is contained in:
Pbopbo
2026-03-23 13:52:27 +01:00
parent 39bcd072c0
commit 5d5a131b77
6 changed files with 238 additions and 124 deletions

View File

@@ -4,8 +4,8 @@ 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
- **Automated Testing**: Latency measurements with configurable iterations
- **Metadata Tracking**: Serial number, software version, timestamps, comments
- **YAML Output**: Human-readable structured results
- **Simple Workflow**: Run tests, view results, compare versions
@@ -19,13 +19,22 @@ pip install -r requirements.txt
### 2. Run a Test
**Latency Test:**
```bash
python run_test.py \
python test_latency.py \
--serial-number "SN001234" \
--software-version "a3f2b1c" \
--comment "Replaced capacitor C5"
```
**Artifact Detection Test:**
```bash
python test_artifact_detection.py \
--serial-number "SN001234" \
--software-version "a3f2b1c" \
--comment "Baseline test"
```
### 3. View Results
```bash
@@ -42,10 +51,8 @@ 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
- Average, minimum, maximum, and standard deviation across measurements
- Uses chirp signal for accurate cross-correlation measurement
## Output Format
@@ -55,27 +62,35 @@ 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
serial_number: SN001234
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
comment: Replaced capacitor C5
latency_test:
avg: 2.345
min: 2.201
max: 2.489
std: 0.087
```
## Configuration
Edit `config.yaml` to customize:
- Audio device settings
- Test frequencies
- Test duration
- Output options
```yaml
audio:
sample_rate: 44100
channels: 2
device_name: "Scarlett"
output:
results_dir: "test_results"
save_plots: true
```
The system auto-detects Focusrite Scarlett audio interfaces.
## Hardware Setup
```
@@ -83,19 +98,19 @@ Laptop <-> Audio Interface (Scarlett) <-> DUT <-> Audio Interface (Scarlett) <->
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
├── test_latency.py # Latency test runner
├── test_artifact_detection.py # Artifact detection test
├── view_results.py # Results viewer
├── src/
│ └── audio_tests.py # Core test functions
└── test_results/ # YAML output files
── YYYYMMDD_HHMMSS_results.yaml
── YYYYMMDD_HHMMSS_latency/
└── YYYYMMDD_HHMMSS_artifact_detection/
```
## Tips