Skip to content

gostonx/DeciBar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeciBar

A lightweight native macOS menu bar utility inspired by the Apple Watch Noise app. DeciBar continuously estimates ambient sound levels using your Mac microphone, logs historical data, and provides insights into weekly noise exposure. It is built to feel like a first party Apple application with a clean architecture and a polished user experience.

Overview

DeciBar lives in your menu bar and shows a live estimate of the ambient sound around your Mac. It tracks daily averages and peaks, records readings efficiently in the background, and surfaces trends through a refined dashboard. All processing happens locally on your Mac.

Estimated values are treated as ambient sound estimates rather than laboratory calibrated SPL measurements.

Features

Live ambient noise meter

  • Current estimated decibel level with smoothing
  • Peak level tracking
  • Daily average
  • Efficient throttled updates

Menu bar

Three display modes:

  • Icon and level
  • Level only
  • Icon only

The menu surfaces the current noise level, today average, today peak, connected audio device, the active warning threshold, and quick access to the dashboard, settings, and quit.

Warning system

  • Configurable thresholds at 75, 80, 85, and 90 decibels
  • Native macOS notification when noise stays above the threshold
  • Cooldown timer to prevent notification spam
  • Exposure duration tracking

Background logging

  • Readings stored every 5 to 15 seconds rather than on every microphone update
  • Each reading captures timestamp, estimated level, peak, and the connected audio device
  • Persistence powered by SwiftData

Audio device detection

Automatic detection of the current default output device using CoreAudio, including AirPods, Bluetooth headphones, Bluetooth speakers, built in speakers, Studio Display, USB audio, HDMI, and AirPlay. The active device updates automatically and every stored reading records it.

Dashboard

A polished native dashboard with a live circular gauge, today statistics, weekly history, device statistics, a weekly heatmap, and a scrollable timeline. Charts are rendered with Swift Charts.

Settings

Configure the warning threshold, sampling interval, notification cooldown, launch at login, menu bar display style, appearance, and data retention. Export history to CSV or clear all history.

Privacy

Everything is processed locally. No analytics, no cloud storage, and no tracking. Audio is never recorded or transmitted. Microphone permission is requested only when needed, and denied permissions are handled gracefully.

Technical details

  • Native SwiftUI application
  • macOS 15 or later
  • MenuBarExtra
  • SwiftData persistence
  • Swift Concurrency with async and await
  • MVVM architecture
  • AVFoundation and CoreAudio
  • Swift Charts

Project structure

The project is organized into focused modules covering models, services, view models, and views.

DecibelBar/
  App/            App entry point, delegate, and window management
  Models/         SwiftData models and value types
  Services/
    AudioEngine/    Microphone metering and permission
    DeviceMonitor/  CoreAudio output device detection
    Notifications/  Threshold warnings and cooldown
    Persistence/    SwiftData store, aggregation, and CSV export
  ViewModels/     Observable coordinators for the UI
  Views/
    MenuBar/        Menu bar label and popover
    Dashboard/      Dashboard window and sections
    Settings/       Settings window
    Components/     Reusable UI building blocks
    Charts/         Swift Charts visualizations
  Utilities/      Settings store, formatters, and helpers
  Resources/      Assets, entitlements, and Info.plist

Building

Open the project in Xcode and run the DeciBar scheme, or build from the command line.

xcodebuild -project DecibelBar.xcodeproj -scheme DecibelBar -configuration Release build

On first launch the app requests microphone access so it can estimate ambient sound levels.

License

Released under the MIT License. See the LICENSE file for details.

About

A lightweight native macOS menu bar utility that estimates ambient noise levels in real time, logs history, and shows weekly exposure insights

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages