skip to navigation
skip to content

Not Logged In

soundmeter 0.1.2

Simple real-time sound meter.

SoundMeter is a command-line tool to obtain sound power in real time. It basically turns the audio recording functionality into a sound meter for machines that ship with microphones. It currently reveals the root-mean-square (RMS) of sound fragments, which is a measure of the power in an audio signal.

Features

  • A command-line meter that supports triggering upon events
  • Monitor API for backend module programming

Dependencies

System packages

On Debian/Ubuntu:

$ sudo apt-get install portaudio19-dev python-dev alsa-utils

On Fedora/RHEL:

$ sudo yum install portaudio-devel python-devel alsa-utils

On OS X:

$ brew install portaudio

PyPI packages

  • argparse
  • pyaudio
  • pydub
  • python-daemon

Installation

You can install with pip:

$ pip install soundmeter

Or, you can download a source distribution and install with these commands:

$ python setup.py install

Usage

The simplest usage is to run soundmeter from command-line without any options:

$ soundmeter

Collect RMS values for 10 seconds so that you will know the sound level in the current environment:

$ soundmeter --collect --seconds 10
Collecting RMS values...
   154  Timeout
Collected result:
    min:        152
    max:        211
    avg:        156

You can set trigger and action for soundmeter.

Stop the soundmeter if RMS is greater than 211 consecutively for 3 times:

$ soundmeter --trigger +211 3 --action stop

Execute trigger.sh if RMS is greater than 211:

$ soundmeter --trigger +211 --action exec --exec trigger.sh

Execute trigger.sh and stop soundmeter if RMS is less than 152 consecutively for 3 times:

$ soundmeter --trigger -152 3 --action exec-stop --exec trigger.sh

Run the soundmeter with trigger and action in the background:

$ soundmeter --trigger +211 3 --action exec --exec trigger.sh --daemonize

Run the soundmeter for 2 minutes and log to meter.log:

$ soundmeter --seconds 120 --log meter.log

Command-line Options

The “soundmeter” command accepts the following options:

<kbd>-c, --collect</kbd> collect RMS values to determine thresholds
<kbd>-s <var>SECS</var>, --seconds <var>SECS</var></kbd>
 time in seconds to run the meter (default forever)
<kbd>-a <var>ACTION_TYPE</var>, --action <var>ACTION_TYPE</var></kbd>
 triggered action (stop, exec-stop and exec)
<kbd>-t <var>THRESHOLD</var>, --trigger <var>THRESHOLD</var></kbd>
 trigger condition (threshold RMS and an optional number of consecutive triggering times, which defaults 1)
<kbd>-e <var>FILE</var>, --execute <var>FILE</var></kbd>
 shell script to execute upon trigger (defaults to ~/.soundmeter/trigger.sh)
<kbd>-d, --daemonize</kbd>
 run the meter in the background
<kbd>--log <var>LOGFILE</var></kbd> log the meter (defaults to ~/.soundmeter/log)
<kbd>-v, --verbose</kbd> verbose mode
<kbd>--segment <var>SECONDS</var></kbd>
 audio segment length recorded in seconds (defaults to 0.5)

Config

Some “dependency-required” parameters can be configured at ~/.soundmeter/config. The default configuration is:

[soundmeter]
frames_per_buffer = 2048
format = 8
channels = 2
rate = 44100
audio_segment_length = 0.5
 
File Type Py Version Uploaded on Size
soundmeter-0.1.2.tar.gz (md5) Source 2014-01-10 10KB
  • Downloads (All Versions):
  • 7 downloads in the last day
  • 60 downloads in the last week
  • 219 downloads in the last month