====== PicoMic — Noise-Cancelling USB Microphone ======
Noise-cancelling USB microphone built on the Raspberry Pi Pico 2 (RP2350). Multiple I2S MEMS mics + adaptive filtering = clean voice on a €12 budget.
===== Concept =====
[INMP441 #1 (voice)] ──┐
├── PIO I2S RX (1 state machine, stereo)
[INMP441 #2 (noise ref)]┘ │
DMA → Audio Buffer
│
Core 0: LMS adaptive filter (5% CPU!)
│
TinyUSB UAC → appears as USB mic
LMS (Least Mean Squares) adaptive filter uses the reference mic to model ambient noise, then subtracts it from the voice mic signal in real-time. 10-15 dB noise reduction with 2 mics.
===== Why RP2350? =====
* **Cortex-M33 with DSP extension** — single-cycle MAC, SIMD for 16-bit math
* **CMSIS-DSP** built-in: ''arm_lms_f32'', ''arm_lms_norm_f32'', FFT, FIR filters
* **PIO** handles I2S with zero CPU overhead
* At 16kHz / 256-tap LMS: **5.5% of one core**. Absurd headroom.
* RP2040 (Cortex-M0+) works too at ~41% of one core, but no hardware MAC
===== Parts List =====
^ Part ^ Price ^ Notes ^
| Pico 2 (RP2350) | €5 | Or Pico 2 W for wireless monitoring |
| 2-4x INMP441 breakout | €3-6 | I2S MEMS mic, 61 dB SNR |
| PCM5102A DAC (optional) | €3 | I2S output for monitoring processed audio |
| **Total** | **~€12-14** | |
Alternative mics: ICS-43434 (65 dB SNR, better linearity), SPH0645LM4H (Adafruit breakout).
===== Mic Placement =====
The hard part is not computation — it's **physical placement**.
=== 2-mic ANC (recommended start) ===
* Voice mic: pointing at mouth, ~30 cm away
* Reference mic: **pointing opposite direction**, back-to-back
* Spacing: doesn't matter much for LMS — **orientation** and **acoustic isolation** matter
* A foam barrier or PCB between mics helps
* LMS filter adapts to any delay
=== 3-mic hybrid (ANC + beamforming) ===
* Voice mic: center, facing user
* 2 reference mics: flanking at **40-60 mm** spacing
* Gives both adaptive NC AND spatial rejection
* 40-60 mm avoids spatial aliasing up to ~4 kHz
=== Reference spacing from products ===
^ Device ^ Mics ^ Spacing ^ Application ^
| ReSpeaker 2-Mic HAT | 2 | 58 mm | Voice capture |
| ReSpeaker 4-Mic Linear | 4 | 65 mm | Far-field beamforming |
| Amazon Echo | 7 | ~35 mm circular | Far-field 360° |
| AirPods Pro | 3/ear | ~8 mm | Feedforward + feedback ANC |
| Laptop built-in | 2 | 60-80 mm | Near-field beamforming |
=== Rules ===
* For beamforming: spacing must be < λ/2 at highest frequency (4 kHz → < 4.25 cm)
* For ANC/LMS: spacing barely matters, orientation and shielding matter
* More reference mics = diminishing returns. Sweet spot: 1 voice + 3 reference (covers 3 noise axes)
===== Computational Budget =====
LMS at 16kHz, N=256 taps:
Per sample: 2*256+1 = 513 MACs
Per second: 8.2 million MACs/s
RP2350: 5.5% of one core
RP2040: 41% of one core
LMS at 48kHz, N=512 taps:
Per second: 49.2 million MACs/s
RP2350: 33% of one core — still comfortable
Memory: ~16 KB total (audio buffers + filter coefficients + FFT workspace). Non-issue on either chip.
===== Key Resources =====
* [[https://github.com/ArmDeveloperEcosystem/microphone-library-for-pico|microphone-library-for-pico]] — Arm's I2S/PDM mic library, includes USB mic example
* [[https://arm-software.github.io/CMSIS-DSP/latest/|CMSIS-DSP]] — LMS, FIR, FFT functions for Cortex-M33
* PineBuds Pro — open-source TWS earbuds with ANC (VM ''pinebuds'' on data has the dev environment)
===== Wiring =====
Two INMP441s on one I2S bus (3 wires + power):
Pico GPIO → INMP441 #1 (L/R=GND) + INMP441 #2 (L/R=VDD)
SCK → pin X ──┬── BCLK #1
└── BCLK #2
WS → pin Y ──┬── WS #1
└── WS #2
SD → pin Z ──┬── SD #1
└── SD #2
3V3 → VDD both
GND → GND both
One PIO state machine, one DMA channel. Samples arrive interleaved L(voice)/R(noise).
===== Status =====
**Phase:** Backlog. Synergizes with [[picoshell|PicoShell]] (same Pico 2 platform) and turing voice satellite.