Page - Ambient Noise

Screen: AppRoute.ambientNoise File: Utiliship/Features/AmbientNoise/AmbientNoiseView.swift ViewModel: Utiliship/Features/AmbientNoise/AmbientNoiseViewModel.swift

Purpose

Real-time ambient noise meter using the device microphone. Displays current dB level, a noise classification badge (Quiet / Moderate / Loud / Very Loud), and running min/max/average statistics. The ViewModel consumes an async stream of NoiseLevel values from NoiseMeterService.

Component Tree

AmbientNoiseView
└── VStack
    ├── decibelGauge         — large display of state.currentDecibels
    ├── classificationBadge  — state.noiseClassification label + colour
    ├── statisticsRow
    │   ├── minLabel         — state.minDecibels
    │   ├── avgLabel         — state.averageDecibels
    │   └── maxLabel         — state.maxDecibels
    ├── startStopButton      — viewModel.startMeasuring() / stopMeasuring()
    ├── resetButton          — viewModel.resetStatistics()
    └── permissionDeniedCard — shown when state.permissionDenied
    └── .withBannerAd(placement: .ambientNoise)

ViewModel State

FieldTypeDescription
currentDecibelsDoubleLatest sample from NoiseMeterService stream
noiseClassificationNoiseClassificationDerived from current dB level
isMeasuringBoolTrue while measurementTask is active
permissionDeniedBoolTrue if microphone access was refused
errorMessageString?Session or permission error description
minDecibelsDoubleRunning minimum across current session
maxDecibelsDoubleRunning maximum
averageDecibelsDoubleMean of all samples this session

Data Flow