Skip to main content
2 of 6
added 891 characters in body
klanomath
  • 67k
  • 10
  • 135
  • 204

Using command line tools you can do the following:

  • Install brew

  • Update and doctor brew

  • Install portaudio, ffmpeg and all dependencies with brew

      brew install portaudio
      brew install ffmpeg
    
  • Install pip by downloading get-pip.py (direct link) and executing

      sudo python ~/Downloads/get-pip.py
    
  • Install soundmeter

      sudo pip install soundmeter
    
  • Run soundmeter. To get help use the -h switch:

      soundmeter -h
      optional arguments:
        -h, --help            show this help message and exit
        -c, --collect         collect RMS values to determine thresholds
        -s SECONDS, --seconds SECONDS
                              time in seconds to run the meter (default forever)
        -a {stop,exec-stop,exec}, --action {stop,exec-stop,exec}
                              triggered action
        -t [+|-]THRESHOLD [NUM ...], --trigger [+|-]THRESHOLD [NUM ...]
                              trigger condition (threshold RMS and number of times)
        -e SCRIPT, --exec SCRIPT
                              shell script to execute upon trigger
        -d, --daemonize       run the meter in the background
        --log [LOGFILE]       log the meter (default to ~/.soundmeter/log)
        -v, --verbose         verbose mode
        --segment SECONDS     audio segment length recorded in seconds (defaults to
                              0.5)
    

Simply running soundmeter will output an RMS value. After defining a threshold you can trigger a shell script action (which may itself trigger an AppleScript script) with the -e switch.

Entering soundmeter --segment 0.1 --log watching online TV (climate change and coffee farming in Colombia - the end of Arabica beans) will show something like:

2017-01-25 18:16:02,289 24
2017-01-25 18:16:02,665 24
2017-01-25 18:16:03,037 31
2017-01-25 18:16:03,399 3
2017-01-25 18:16:03,769 15
2017-01-25 18:16:04,142 11
2017-01-25 18:16:04,524 9
2017-01-25 18:16:04,891 7
2017-01-25 18:16:05,257 7
2017-01-25 18:16:05,632 0
2017-01-25 18:16:06,001 7
2017-01-25 18:16:06,384 0
2017-01-25 18:16:06,745 2
2017-01-25 18:16:07,113 10
2017-01-25 18:16:07,491 14
2017-01-25 18:16:07,860 6
2017-01-25 18:16:08,223 0
2017-01-25 18:16:08,609 13
2017-01-25 18:16:08,973 16
2017-01-25 18:16:09,347 7
2017-01-25 18:16:09,720 26
2017-01-25 18:16:10,091 1
2017-01-25 18:16:10,464 38 ← an Arabica bean died here
2017-01-25 18:16:10,835 13
2017-01-25 18:16:11,204 Stopped
klanomath
  • 67k
  • 10
  • 135
  • 204