Description
Microphone-powered popcorn timer that detects pop rate in real time, tracks cooking phases, and tells you when to stop the microwave to avoid burnt bags and improve consistency.
Prompt
Build a "Perfect Popcorn" mobile-first web app that listens to microphone audio to detect popcorn pops and tells the user when to stop the microwave.... Core requirements: - Request microphone with echoCancellation: false, noiseSuppression: false, autoGainControl: false Detection logic: - Use Web Audio API with AnalyserNode, calculate RMS from getByteTimeDomainData - 2-second calibration period to establish baseline noise level - Pop detection: RMS > adaptive threshold (max of 0.08 or baseline×2) OR RMS > rolling average × 1.5, AND RMS > 0.02 - No debounce between pops - Track pops in rolling 5-second window to calculate pops-per-second (PPS) State machine: - idle → listening (calibrating) → waiting (heard some pops) → popping (PPS ≥ 0.3) → slowing (PPS drops, after 3 slow intervals and peak PPS ≥ 0.5) → done (PPS < 0.15) Time phases** (visual timeline indicator): - Early: 0-60s (green) - Peak: 60-90s (yellow) - Late: 90-120s (orange) - Danger: 120s+ (red) - show warning Important UI elements: - Slim volume meter bar (shows mic is working) - 3-column stats: total pops, current PPS, peak PPS - Phase timeline bar (highlights current phase) - Warning banner when in danger zone - "Perfect! Remove your popcorn now" celebration when done - Start/Stop button always at bottom