Technical

For those who want
to understand the engine

The deep dive. Architecture, algorithms, and validation.

Signal Processing

FFT: Iterative radix-2 Cooley-Tukey, 2048-sample frames, 512-sample hop, Hann window.

STFT: Power spectrum with log-frequency binning (50 Hz – 12 kHz, 48 bins).

Spectral Subtraction: 1.5× oversubtraction, 5% floor to prevent musical noise.

Adaptive LMS: 64-tap normalized filter, 48-sample delay (~1 ms at 48 kHz).

Feature Extraction

YIN-lite pitch: Autocorrelation with parabolic interpolation, 60–600 Hz range.

HNR (Harmonic Comb): Independent harmonic-to-noise measurement. Sums energy at harmonic bins, compares to inter-harmonic gaps. Tracks true SNR 0–20 dB.

LPC Formants: Levinson-Durbin recursion, order 16, grid peak-picking.

MFCCs: 13 coefficients + 7 spectral contrast bands + 12 chroma bins via Essentia.js.

Classification Architecture

Stage 1 — k-NN Pattern Recognition: Euclidean distance on normalized MFCC fingerprints. k=5, distance-weighted voting. Reference database: 17 datasets (Barkopedia, AudioSet, DCASE, YouTube, self-generated).

Stage 2 — Deterministic Validator: 3-level decision tree. Level 1: periodicity (strength ≥0.6). Level 2: tonal branch (HNR ≥6 dB, or relaxed to ≥0.85 periodicity when HNR null). Level 3: breed-scaled spectral rules (Kraman & Wang 1990 anchor).

Disagreement Handler: Margin-based arbitration. k-NN leads when clearly ahead (>0.1 margin). Tree leads when clearly ahead. Close calls: higher score wins with confidence penalty proportional to disagreement strength.

Context Multipliers: Soft priors per recording context. Sleeping boosts breath_normal 1.5×, penalizes cough 0.5×. Post-exercise boosts panting 1.5×.

The Four Defensible Contributions

1. Harshness Index Normalized for Respiratory Rate: Restores a clinical resolution veterinary medicine abandoned because the ear cannot compute conditionals.

2. Species-Scaled CORSA Taxonomy: Human respiratory standard adapted for canine anatomy with breed-specific spectral thresholds.

3. Self-Referential Baseline: Microphone transfer function cancels mathematically when comparing current to baseline on the same device. No calibrated hardware required.

4. Synthetic Validation Suite: 14 tests with known inputs. F0 precision ±2 Hz at 440 Hz. HNR precision ±1 dB at known SNR.

Tech Stack
React 18 TypeScript Vite Supabase Essentia.js (WASM) Web Workers Vercel