Skip to content

agnivon/sound_meter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”Š Sound Meter

A professional-grade sound level meter built with Flutter, providing real-time decibel monitoring, acoustic weighting filters, and recording capabilities β€” all from your phone's microphone.

Flutter Dart License: MIT


✨ Features

🎯 Real-Time Monitoring

  • Live dB readings from the device microphone at ~30 FPS polling rate
  • Radial gauge with animated needle powered by Syncfusion Flutter Gauges
  • Min / Avg / Max tracking with exponential moving average (EMA) smoothing
  • Environment classification β€” contextual labels like "Whisper", "Busy Traffic", "Thunder" based on current noise level

πŸ“Š Multi-View Charts

Cycle through three real-time visualization modes:

Chart Description
Timeline Rolling ~24-second dB history graph
Waveform Raw PCM amplitude from the microphone membrane
FFT Spectrum Logarithmic frequency spectrum (20 Hz – 20 kHz) with peak frequency annotation

πŸŽ›οΈ Acoustic Weighting Filters

Professional frequency and time weighting based on IEC 61672-1:2003:

  • Frequency Weighting: A (dBA), C (dBC), Z (dBZ)
  • Time Weighting: Fast (125 ms), Slow (1 s), Impulse (35 ms rise / 1.5 s decay)

πŸ”§ Calibration

  • Adjustable dB offset for hardware calibration against a known reference source

πŸ’Ύ Recording & History

  • Save sessions with full metadata (min/max/avg dB, duration, dB history, weighting unit)
  • Audio file recording (WAV) via native 32-bit float PCM capture
  • Persistent history powered by hydrated_bloc β€” recordings survive app restarts
  • Detail screen with stats card, area chart replay, and built-in audio playback (SoLoud)
  • Rename, share, and delete recordings

πŸŒ— Theme Support

  • Light and dark mode with automatic system detection
  • Manual toggle from the app bar
  • Material 3 design system with a warm coral (#E85A3F) primary palette

πŸ—οΈ Architecture

The app follows BLoC (Business Logic Component) architecture with a clean separation of concerns:

lib/
β”œβ”€β”€ main.dart                    # App entry point, theme config, BLoC providers
β”œβ”€β”€ blocs/
β”‚   β”œβ”€β”€ sound_meter/             # Core audio state management
β”‚   β”‚   β”œβ”€β”€ sound_meter_bloc.dart
β”‚   β”‚   β”œβ”€β”€ sound_meter_event.dart
β”‚   β”‚   └── sound_meter_state.dart
β”‚   β”œβ”€β”€ history/                 # Persistent recording history (HydratedBloc)
β”‚   β”‚   β”œβ”€β”€ history_bloc.dart
β”‚   β”‚   β”œβ”€β”€ history_event.dart
β”‚   β”‚   └── history_state.dart
β”‚   └── theme/                   # Light/dark mode toggle
β”‚       β”œβ”€β”€ theme_bloc.dart
β”‚       β”œβ”€β”€ theme_event.dart
β”‚       └── theme_state.dart
β”œβ”€β”€ models/
β”‚   └── recording_model.dart     # SoundRecording data model with serialization
β”œβ”€β”€ screens/
β”‚   β”œβ”€β”€ main_screen.dart         # Primary meter + charts UI
β”‚   β”œβ”€β”€ history_screen.dart      # Saved recordings list
β”‚   └── detail_screen.dart       # Recording detail + audio player
β”œβ”€β”€ utils/
β”‚   └── sound_utils.dart         # Frequency/time weighting math, dB references
└── widgets/
    β”œβ”€β”€ db_meter.dart            # Radial gauge + digital display
    β”œβ”€β”€ charts.dart              # Timeline, Waveform, FFT chart widgets
    β”œβ”€β”€ calibration_dialog.dart  # dB offset calibration UI
    β”œβ”€β”€ db_legend_dialog.dart    # dB reference table dialog
    └── weighting_dialog.dart    # Frequency/time weighting picker

Key Design Principles

  • Utility-First Logic β€” All domain math (weighting filters, EMA calculations) lives in lib/utils/ as static, pure functions for easy unit testing
  • Semantic Theming β€” All colors are resolved via Theme.of(context).colorScheme; no hardcoded color constants in widgets
  • Reactive State β€” BLoC pattern with flutter_bloc for predictable, testable state transitions

πŸ› οΈ Tech Stack

Category Package Purpose
State Management flutter_bloc / hydrated_bloc Reactive BLoC pattern with persistence
Audio Capture flutter_recorder Native microphone access (PCM / WAV)
Audio Playback flutter_soloud Low-latency audio playback engine
Signal Processing fftea Fast Fourier Transform for spectrum analysis
Gauges syncfusion_flutter_gauges Radial gauge visualization
Charts syncfusion_flutter_charts Timeline, waveform, and FFT charts
Permissions permission_handler Runtime microphone permission
File System path_provider / path App documents directory management
Formatting intl Date/time formatting
Sharing share_plus Share recordings externally
IDs uuid Unique recording identifiers

πŸš€ Getting Started

Prerequisites

  • Flutter SDK >= 3.11.1
  • Android SDK (API 21+)
  • A physical device with a microphone (emulators have limited audio support)

Installation

# Clone the repository
git clone https://github.com/agnivon/sound_meter.git
cd sound_meter

# Install dependencies
flutter pub get

# Run on a connected device
flutter run

Building for Release

# Android APKs (split by ABI for smaller downloads)
flutter build apk --split-per-abi

# Android App Bundle
flutter build appbundle

πŸ§ͺ Testing

The project includes a comprehensive test suite covering unit, BLoC, and widget tests:

# Run all tests
flutter test

# Run with coverage
flutter test --coverage

Test Structure

test/
β”œβ”€β”€ blocs/
β”‚   β”œβ”€β”€ history_bloc_test.dart
β”‚   β”œβ”€β”€ sound_meter_bloc_test.dart
β”‚   └── theme_bloc_test.dart
β”œβ”€β”€ screens/
β”‚   β”œβ”€β”€ detail_screen_test.dart
β”‚   β”œβ”€β”€ history_screen_test.dart
β”‚   └── main_screen_test.dart
β”œβ”€β”€ utils/
β”‚   └── sound_utils_test.dart
└── widgets/
    β”œβ”€β”€ calibration_dialog_test.dart
    β”œβ”€β”€ db_meter_test.dart
    └── weighting_dialog_test.dart

πŸ“‹ Permissions

| RECORD_AUDIO | Android | Microphone access for sound measurement |

The app requests microphone permission at startup. All audio processing is performed on-device β€” no data is transmitted externally.


πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


πŸ™ Acknowledgements

  • Syncfusion for their excellent Flutter gauge and chart libraries
  • flutter_recorder for native audio capture
  • SoLoud for high-performance audio playback
  • IEC 61672-1:2003 standard for acoustic weighting filter formulae

About

A professional-grade sound level meter built with Flutter. Features real-time dB monitoring, acoustic weighting filters (A, C, Z / Fast, Slow, Impulse), multi-view charting (waveform, FFT spectrum), and audio recording with persistent offline history.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors