Skip to main content

earshot_level 1.0.0 copy "earshot_level: ^1.0.0" to clipboard
earshot_level: ^1.0.0 copied to clipboard

Pure Dart sound level metering for earshot: A, C and Z weighting, Fast and Slow response, Leq and calibration.

earshot_level #

pub package style: very good analysis License: MIT

Pure Dart sound level metering: A, C and Z weighting, Fast, Slow and Impulse response, Leq and device calibration. Feed it the PCM from earshot_capture.

Part of earshot: on-device ambient listening with no network access, where no audio leaves the device.

Usage #

import 'package:earshot_capture/earshot_capture.dart';
import 'package:earshot_level/earshot_level.dart';

final readings = const EarshotCapture().pcm().transform(
  const LevelMeter(
    options: LevelOptions(
      weighting: FrequencyWeighting.a,
      timeWeighting: TimeWeighting.fast,
      calibration: LevelCalibration(offsetDb: 100),
    ),
  ),
);

readings.listen((reading) {
  print('${reading.db} dB(A), Leq 1 s ${reading.leq1s}, Leq 60 s ${reading.leq60s}');
});

The meter emits one LevelReading per PCM chunk. Each listen starts a new measurement session.

What it measures #

  • Frequency weighting (FrequencyWeighting.a, .c, .z) per IEC 61672-1, within ±0.5 dB of the standard's design goals at ten frequencies from 31.5 Hz to 16 kHz, at 16, 44.1 and 48 kHz. At 16 kHz the Nyquist frequency is 8 kHz, so nothing above it can be measured, and the tested frequencies stop at 6.3 kHz.
  • Time weighting (TimeWeighting.fast, .slow, .impulse): exponential averaging with 125 ms, 1 s, or 35 ms rise and 1.5 s decay. The meter starts from silence, so the first readings rise towards the true level.
  • Leq: over the session (leq), the last second (leq1s) and the last 60 seconds (leq60s). The rolling windows have a 10 ms resolution, and cover the audio heard so far until they fill.
  • LevelCalibration: LevelCalibration.offsetDb is added to every level.

Decibel reference #

Without calibration, 0 dB is the level of a full-scale sine (an RMS of 1/√2), so a full-scale 1 kHz sine reads 0 dB with every weighting. Phone microphones are not measurement microphones: to read dB SPL, measure a known source with a reference sound level meter and set the difference as the calibration offset. Uncalibrated readings are relative estimates.

Digital silence reads LevelReading.floorDb (-200 dB) plus the calibration offset, never negative infinity.

0
likes
160
points
317
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Pure Dart sound level metering for earshot: A, C and Z weighting, Fast and Slow response, Leq and calibration.

Repository (GitHub)
View/report issues
Contributing

Topics

#audio #decibel #sound-level #dsp

License

MIT (license)

Dependencies

earshot_capture_platform_interface, meta

More

Packages that depend on earshot_level