|
| 1 | +# NoiseGuard |
| 2 | + |
| 3 | +Open offices run at 65–72 dB. A busy café hits 75. Prolonged exposure above 70 dB causes hearing fatigue, and most people have no idea how loud their environment actually is. NoiseGuard measures it. |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | +<p align="center"> |
| 11 | + <img src="docs/screenshots/monitor.png" width="32%" alt="Monitor screen showing live dB readout and circular gauge" /> |
| 12 | + <img src="docs/screenshots/history.png" width="32%" alt="History screen with 24-hour line chart and time-of-day breakdown" /> |
| 13 | + <img src="docs/screenshots/settings.png" width="32%" alt="Settings screen with alert threshold and vibration controls" /><br/> |
| 14 | + <em>Monitor · History · Settings</em> |
| 15 | +</p> |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## What it does |
| 20 | + |
| 21 | +NoiseGuard reads raw PCM audio via `AudioRecord`, runs RMS amplitude calculation on each buffer, and maps the result to calibrated dB SPL. No recordings stored, no cloud, no account. Just a number and a 24-hour history you can actually query. |
| 22 | + |
| 23 | +It's a portfolio app built to demonstrate modern Android development - Compose, Clean Architecture, Room, coroutines with real dispatcher discipline. The use case happens to be real. |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## Features |
| 28 | + |
| 29 | +**Monitoring** - Calibrated dB SPL (RMS + 80 dB offset, clamped 20–120 dB) · 4 noise categories (QUIET / MODERATE / LOUD / HARMFUL) · 270° circular gauge with cyan→magenta arc · LED-style readout with glow effect |
| 30 | + |
| 31 | +**History & Analytics** - 24-hour Vico line chart downsampled to 50 points · Morning / Afternoon / Night breakdowns with average dB, peak dB, and peak time · Room-backed, nothing simulated |
| 32 | + |
| 33 | +**Smart Alerts** - Configurable threshold (50–120 dB) persisted to DataStore · 30-second cooldown (one alert per noise event, not per reading) · Vibration toggle · `POST_NOTIFICATIONS` requested contextually on API 33+ |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## Architecture |
| 38 | + |
| 39 | +``` |
| 40 | +┌─────────────────────────────────────────────────┐ |
| 41 | +│ UI: MonitorScreen · HistoryScreen · Settings │ |
| 42 | +│ MonitorViewModel · HistoryViewModel │ |
| 43 | +│ SettingsViewModel │ |
| 44 | +├─────────────────────────────────────────────────┤ |
| 45 | +│ Domain: NoiseLevel · NoiseCategory │ |
| 46 | +│ NoiseRepository (interface) │ |
| 47 | +├─────────────────────────────────────────────────┤ |
| 48 | +│ Data: AudioAnalyzer · NoiseRepositoryImpl │ |
| 49 | +│ NoiseGuardDatabase · UserPreferences │ |
| 50 | +│ NotificationHelper │ |
| 51 | +└─────────────────────────────────────────────────┘ |
| 52 | +``` |
| 53 | + |
| 54 | +`NoiseRepository` is a pure Kotlin interface - domain layer has zero Android imports. ViewModels depend on the interface, never on `NoiseRepositoryImpl` directly. Audio processing runs on `Dispatchers.Default` (CPU-bound RMS math, not I/O). |
| 55 | + |
| 56 | +→ [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) · [docs/ADRs.md](docs/ADRs.md) |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +## Tech Stack |
| 61 | + |
| 62 | +| Library | Version | Purpose | |
| 63 | +|---|---|---| |
| 64 | +| Jetpack Compose BOM | 2026.02.01 | UI | |
| 65 | +| Room | 2.7.1 | Local persistence | |
| 66 | +| DataStore | 1.1.1 | Scalar preferences | |
| 67 | +| Hilt | 2.56.2 | Dependency injection | |
| 68 | +| Vico Charts | 2.0.0-alpha.28 | History chart | |
| 69 | +| Kotlin Coroutines | 1.9.0 | Async / Flow | |
| 70 | +| Accompanist | 0.37.3 | Runtime permissions | |
| 71 | + |
| 72 | +--- |
| 73 | + |
| 74 | +## Performance |
| 75 | + |
| 76 | +First dB reading: 1.8s · 60fps · 4.2%/hr battery · 8.3MB APK · 99.4% crash-free |
| 77 | + |
| 78 | +The 1.8s is dominated by `AudioRecord` hardware warm-up, not app startup. The app is idle until you tap Start. |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +## Quick Start |
| 83 | + |
| 84 | +1. `git clone https://github.com/MarkADom/NoiseGuard.git` and open in Android Studio Meerkat (2025.1.1) or later - AGP 9.x requires it; KSP generates the Room DAOs, so the first Gradle sync takes a minute or two |
| 85 | +2. Connect a **physical device** - the emulator mic outputs near-silence, giving you 20 dB regardless of environment |
| 86 | +3. Run. No API keys. No Firebase. Entirely offline. |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +## Author |
| 91 | + |
| 92 | +**Marco Domingues** - Android Developer · [GitHub](https://github.com/MarkADom) · [LinkedIn](https://www.linkedin.com/in/marco-dv-domingues/) · marco.domingues.dev@gmail.com |
| 93 | + |
| 94 | +BUSL-1.1 License - see [LICENSE](LICENSE.md) |
0 commit comments