Giter Site home page Giter Site logo

soundmeter's Introduction

SoundMeter

https://img.shields.io/pypi/v/soundmeter.png

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 audio input devices (e.g. microphone). It currently reveals the root-mean-square (RMS) of sound fragments, which is a measure of the power in an audio signal. The actual values also depend on the system settings of sound input.

https://asciinema.org/a/RdNCvGdsdvxdu8O9nLqkhhgaT.png

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 the package with pip using the following command to allow externally hosted packages:

$ pip install soundmeter --allow-all-external --allow-unverified pyaudio

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:

-p PROFILE, --profile PROFILE
 config profile (section name)
-c, --collect collect RMS values to determine thresholds
-s SECS, --seconds SECS
 time in seconds to run the meter (default forever)
-a ACTION_TYPE, --action ACTION_TYPE
 triggered action (stop, exec-stop and exec)
-t THRESHOLD, --trigger THRESHOLD
 trigger condition (threshold RMS and an optional number of consecutive triggering times, which defaults 1)
-e FILE, --execute FILE
 shell script to execute upon trigger (defaults to ~/.soundmeter/trigger.sh), can be configured to pass the "last triggering" RMS value as argument by setting rms_as_trigger_arg to True in ~/.soundmeter/config
-d, --daemonize
 run the meter in the background
--log LOGFILE log the meter (defaults to ~/.soundmeter/log)
-v, --verbose verbose mode
--segment SECONDS
 audio segment length recorded in seconds (defaults to 0.5); when specified, it overrides audio_segment_length in ~/.soundmeter/config

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
rms_as_trigger_arg = False

You can have multiple sections in the config file and specify the one to use with the --profile command-line options. The default profile name is soundmeter. For example:

[soundmeter]
frames_per_buffer = 2048
format = 8
channels = 2

[test]
frames_per_buffer = 1024
format = 8
channels = 1

To use the test profile:

$ soundmeter --profile test ...

There is also an input_device_index parameter, which specifies the index of input device to use. If unspecified, it uses the default input device.

soundmeter's People

Contributors

johnschimmel avatar shichao-an avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

soundmeter's Issues

real time sound sampling.

I am working on a project. I need to write algorithm to do real time sampling the sound (about 5s) which is picked up from microphone. the code will return the plot (time vs. amplitude), and also the numpy array of the sound. Can you guys help me with the code? thank you

[Errno -9981] Input overflowed

Hi,

I'm trying to run soundmeter indefinitely on my Mac Mini using the command soundmeter -t +XXX 2 -a exec-stop -e xyz.sh
When I started this last night and checked on it this morning, soundmeter seemed to have crashed and executed the script although the trigger was never reached. I got the following error in terminal:

1549 Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/soundmeter", line 11, in
load_entry_point('soundmeter==0.1.5', 'console_scripts', 'soundmeter')()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/soundmeter/meter.py", line 322, in main
m.start()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/soundmeter/meter.py", line 124, in start
record.send(True) # Record stream `AUDIO_SEGMENT_LENGTH' long
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/soundmeter/meter.py", line 95, in record
data = self.stream.read(self.config.FRAMES_PER_BUFFER)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyaudio.py", line 608, in read
return pa.read_stream(self._stream, num_frames, exception_on_overflow)
OSError: [Errno -9981] Input overflowed

Any idea what could be causing that and how to prevent it?

My intention is to run soundmeter to detect input from a record player and then automatically configure the sound output to play on my speakers (done in the shell script). The script works, but due to the failure, the speakers got misconfigured and the automation stops...

maxChans failed

Hi there,

I'm trying to get your soundmeter working on a Raspberry Pi Zero W.

I'm getting the following error when I try do anything:

Expression 'parameters->channelCount <= maxChans' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1514
Expression 'ValidateParameters( inputParameters, hostApi, StreamDirection_In )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2818
Traceback (most recent call last):
File "/usr/local/bin/soundmeter", line 11, in
load_entry_point('soundmeter==0.1.5', 'console_scripts', 'soundmeter')()
File "/usr/local/lib/python2.7/dist-packages/soundmeter/meter.py", line 321, in main
m = Meter(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/soundmeter/meter.py", line 66, in init
frames_per_buffer=self.config.FRAMES_PER_BUFFER)
File "/usr/local/lib/python2.7/dist-packages/pyaudio.py", line 750, in open
stream = Stream(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pyaudio.py", line 441, in init
self._stream = pa.open(**arguments)
IOError: [Errno -9998] Invalid number of channels

I have no experience with Python, so not sure what I'm looking at here.

IOError: [Errno -9996] Invalid input device (no default output device)

I'm getting the following error with osx 10.11 python 2.7.10

$ soundmeter --collect --seconds 10 -v
Traceback (most recent call last):
  File "/usr/local/bin/soundmeter", line 9, in <module>
    load_entry_point('soundmeter==0.1.3', 'console_scripts', 'soundmeter')()
  File "/Library/Python/2.7/site-packages/soundmeter/meter.py", line 310, in main
    m = Meter(**kwargs)
  File "/Library/Python/2.7/site-packages/soundmeter/meter.py", line 66, in __init__
    frames_per_buffer=FRAMES_PER_BUFFER)
  File "/Library/Python/2.7/site-packages/pyaudio.py", line 750, in open
    stream = Stream(self, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/pyaudio.py", line 441, in __init__
    self._stream = pa.open(**arguments)
IOError: [Errno -9996] Invalid input device (no default output device)

Complains about jack server not running on Raspbian

I tried using soundmeter today on a Raspberry Pi running Raspbian. It's a Debian like distribution and installation worked without any problems by following the normal Debian/Ubuntu installation instructions. The soundmeter functionality I expect seems to work fine. However, it always complains about jack server not running. Specifically, here's an example:

$ soundmeter --collect --seconds 10
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
Collecting RMS values...
        19  Timeout
Collected result:
    min:         18
    max:         27
    avg:         19

I can make that warning go away if I run jackd with the dummy driver:

terminal1$ jackd -d dummy
jackdmp 1.9.10
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2014 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"

terminal2$ soundmeter --collect --seconds 10
Collecting RMS values...
        17  Timeout
Collected result:
    min:         16
    max:         20
    avg:         17

I'm filing this issue because I'm not sure what the implications are of running an instance of jackd with the dummy driver. Since it seems like soundmeter doesn't actually need a jack server to function, is it possible to add a fix somewhere in soundmeter itself?

Exec format error

When I tried to run a script I made, I got this message:
cannot execute binary file: Exec format error
I can run the script without any problem directly from the console, but the trigger function always get that error.
I am using raspbian if that helps.

Deprecation Warning (Carbon Component Manager) on OS X El Capitan‎

On OS X 10.10 El Capitan, the following warnings will show up when running soundmeter:

2016-01-09 22:21:11.616 python2.7[2268:35440] 22:21:11.614 WARNING:  140: This application, or a library it uses, is using the deprecated Carbon Component Manager for hosting Audio Units. Support for this will be removed in a future release. Also, this makes the host incompatible with version 3 audio units. Please transition to the API's in AudioComponent.h.

some problem with php

hello
thank you for this open-software it's really nice
I Work on Raspberry Pi and his Apache server but i have an issue when i launch soundmeter using a php script, the program runs but i don't have the display of the RMS value, i tried a lot of things; like changing permission, groups ... and nothing works. Do you what could be the issue ?

No section named in config

Hi there,
I am using your script for the first time and I have connected a USB webcam, when using alsa I can record from the mic without any issues but when I try using your script I get an error saying that there is an invalid number of channels. So I am trying to overwrite the config, I created the config file and added a section but I get the following error:

Traceback (most recent call last):
File "/usr/local/bin/soundmeter", line 11, in
load_entry_point('soundmeter==0.1.5', 'console_scripts', 'soundmeter')()
File "/usr/local/lib/python2.7/dist-packages/soundmeter-0.1.5-py2.7.egg/soundmeter/meter.py", line 321, in main
m = Meter(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/soundmeter-0.1.5-py2.7.egg/soundmeter/meter.py", line 56, in init
self.config = Config(profile)
File "/usr/local/lib/python2.7/dist-packages/soundmeter-0.1.5-py2.7.egg/soundmeter/settings.py", line 59, in init
raise Exception('No section named "%s" in config' % section)
Exception: No section named "test" in config

I added the config file in ~/.soundmeter/ but it doesn't work. Any idea why?

Soundmeter returning 0

Hi,

I'm trying to use Soundmeter with a USB mic on Raspberry pi. If I run arecord -l I get the following output:

**** List of CAPTURE Hardware Devices ****
card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

I can record from the USB mic fine, but when I run Soundmeter I just get "0" as the output. I've tried creating a script to select the input as per issue #15 modified to the following:

from soundmeter.meter import Meter
from soundmeter.cli import get_meter_kwargs, setup_user_dir
import pyaudio

def main():
    pyaudio.paALSA = 0
    setup_user_dir()
    kwargs = get_meter_kwargs()
    meter = Meter(**kwargs)
    meter.start()

if __name__ == '__main__':
    main()

But I'm now stuck! Grateful for any suggestions.

non-exclusive access for alsa

Please would it be possible to allow other applications still use the same microphone when soundmeter is running
Currently it seems it's having exclusive access to audio input it's working on:

arecord -f S16_LE -d 20 -r 44100 -D hw:1,0 /dev/shm/test2.wav
arecord: main:828: audio open error: Device or resource busy

When I stop soundmeter , acrecord works just fine.

Raspbian 10 / alsa-base 1.0.27+1 / alsa-utils 1.1.8-2

lsusb | grep Audio
Bus 001 Device 004: ID 0d8c:0014 C-Media Electronics, Inc. Audio Adapter (Unitek Y-247A)

arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: Device [USB Audio Device], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0

OSError: [Errno Input overflowed]

I get the below error when running soundmeter on my raspberry pi.
It doesn't take long to get the error (a few seconds up to a few minutes).

pi@pi3three:~ $ soundmeter
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
123 Traceback (most recent call last):
File "/usr/local/bin/soundmeter", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.4/dist-packages/soundmeter/meter.py", line 320, in main
m.start()
File "/usr/local/lib/python3.4/dist-packages/soundmeter/meter.py", line 122, in start
record.send(True) # Record stream 'AUDIO_SEGMENT_LENGTH' long
File "/usr/local/lib/python3.4/dist-packages/soundmeter/meter.py", line 94, in record
data = self.stream.read(FRAMES_PER_BUFFER)
File "/usr/lib/python3/dist-packages/pyaudio.py", line 605, in read
return pa.read_stream(self._stream, num_frames)
OSError: [Errno Input overflowed] -9981

Workaround for installing some dependencies on OS X

If you encounter issues when installing Python dependencies, the following may help:

Trouble installing pyaudio

If you see the following error:

    src/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found
    #include "portaudio.h"
             ^
    1 error generated.
    error: command 'cc' failed with exit status 1

After installing portaudio with Homebrew:

brew install portaudio

Try the following command to install pyaudio:

pip install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio

See https://stackoverflow.com/a/33821084 for details.

Trouble installing python-daemon

If you see such error while installing-daemon:

    i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'

Try this:

pip install docutils

Then install python-daemon:

pip install python-daemon

See https://stackoverflow.com/a/44539260 for details.

"Invalid number of channel" error occured on Raspberry Pi 3 model B

I tried to use SoundMeter on Raspberry Pi 3 model B with external UBS microphone.
Installation was completed without any problems. But, when executioned, I faced following error.
Probably, this error occured due to my Raspberry Pi 3 board's sound input channel is '1' for external USB microphone and no sound channel on channel number '0' which supporsed to be default number.
So please anyone help me to use soundmeter by changing audio input channel number to the appropriate one ('1')?


pi@raspberrypi:~/work $ soundmeter
/usr/local/lib/python2.7/dist-packages/pydub/utils.py:165: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
connect(2) call to /tmp/jack-1000/default/jack_0 failed (err=No such file or directory)
attempt to connect to server failed
Expression 'parameters->channelCount <= maxChans' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1514
Expression 'ValidateParameters( inputParameters, hostApi, StreamDirection_In )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2818
Traceback (most recent call last):
File "/usr/local/bin/soundmeter", line 9, in
load_entry_point('soundmeter==0.1.3', 'console_scripts', 'soundmeter')()
File "/usr/local/lib/python2.7/dist-packages/soundmeter/meter.py", line 310, in main
m = Meter(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/soundmeter/meter.py", line 66, in init
frames_per_buffer=FRAMES_PER_BUFFER)
File "/usr/local/lib/python2.7/dist-packages/pyaudio.py", line 750, in open
stream = Stream(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pyaudio.py", line 441, in init
self._stream = pa.open(**arguments)
IOError: [Errno -9998] Invalid number of channels

thank you,

Set input by name? Or otherwise consistent input_device_index?

I created profiles to set a input_device_index - The issue I'm having is that that number seems to change frequently, presumably every time I plug/unplug different inputs.

My entire need in the profile is consistency, so I can just run soundmeter --profile mic1 and know it's listening to that input. But since sometimes Mic1 is on index 3 and sometimes it's on index 5, it requires me to manually find the index and change the profile every time.

Am I missing something?

Daemon Quits

I currently have the daemon running (soundmeter -d --segment 5 --log sound.csv) on a Raspberry Pi 3b. The program logs every 5 (or 4.9?) seconds to the log file. Great! However, I haven't gotten it to be able to run for more then a few hours at a time. I'd like it to run indefinitely.

My thoughts: I download the log file to my web server (I use my server to pull the file from my Pi using lftp sftp://user:pass@home-ip:1234 -e "get sound.csv; bye") periodically. It seems that it is at that time that the soundmeter daemon quits. There is no log showing any errors that I can find. (/var/log - messages, syslog, error, etc.)

I'm guessing that when I pull the file, soundmeter cannot access the log to write the new data and it quits.

My thoughts were to quick copy the file on the Pi (cp sound.csv sound1.csv), and then download that new file via sftp, but I think even that stopped soundmeter from logging!

Question: Am I correct in thinking that this is why the program quits? (Because I am accessing the log file when it might be trying to write to it?) Can you think of any solutions that might work? Is there a way that the program can debug this for me and show me a log as to why it quits?

(My next plan .. set up a cron job to run the logger for 6 hours with the --seconds 21600 switch, download the log file at that time, delete the log file and start the daemon again .. but that seems to be a little overkill)

Great program -- I'm having fun experimenting with it!

python---IOError: No Default Input Device Available

~# python -m speech_recognition
ALSA lib pcm_dsnoop.c:638:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1099:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dsnoop.c:638:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1099:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm_dmix.c:1099:(snd_pcm_dmix_open) unable to open slave
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/dist-packages/speech_recognition/main.py", line 4, in
m = sr.Microphone()
File "/usr/local/lib/python2.7/dist-packages/speech_recognition/init.py", line 86, in init
device_info = audio.get_device_info_by_index(device_index) if device_index is not None else audio.get_default_input_device_info()
File "/usr/local/lib/python2.7/dist-packages/pyaudio.py", line 949, in get_default_input_device_info
device_index = pa.get_default_input_device()
IOError: No Default Input Device Available


what to do ?anyone can fix this

loop recording

I want to adjust this code to to loop recording. saying, it will record for 5s, then sleep for 5s, and then it will start to record again. Can you guys help me to adjust the code? thank you

import pyaudio
import wave
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
CHUNK = 1024
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "file.wav"

audio = pyaudio.PyAudio()

start Recording

stream = audio.open(format=FORMAT, channels=CHANNELS,
rate=RATE, input=True,
frames_per_buffer=CHUNK)
print "recording..."
frames = []

for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
data = stream.read(CHUNK)
frames.append(data)
print "finished recording"

stop Recording

stream.stop_stream()
stream.close()
audio.terminate()

waveFile = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
waveFile.setnchannels(CHANNELS)
waveFile.setsampwidth(audio.get_sample_size(FORMAT))
waveFile.setframerate(RATE)
waveFile.writeframes(b''.join(frames))
waveFile.close()

trigger options

I'm using soundmeter running on a raspberry pi to monitor my smoke detector and so need to set up the trigger to distinguish the loud intermittent noise of the smoke detector. It is working well and much more stable than my previous attempts attaching a sound sensor to the GPIO. However, I haven't got the triggering parameters optimised yet.

If I set up something to detect a few consecutive events with a suitable threshold and audio_segment_length it will work but it will also be triggered by a similar intensity (or louder) short noise above the threshold (eg a door slamming).

It I set it up to detect a longer run of consecutive events it will not be triggered by the door slam but will not be triggered by the smoke alarm (due to the intermittent beeping)

If I set up something to detect a few consecutive events with a lower threshold and a longer segment it will work but it will also be triggered by a continuous noise above the threshold (eg the spin cycle on my washer)

I can't get a compromise between the two to work that avoids the false triggers.

What would be ideal would be if the trigger logic could be set to determine x out of y events that were above the threshold. Would that be easy to implement within soundmeter?

with thanks

parallelize RMS capture and audio recording

Hello,
I'm working on a project that starts two scripts using cronjob at the same time. One should record the audio while the other take the RMS values. Is it possible parallelize RMS capture using soundmeter and recording audio at the same time with the same input audio device?

USB microphone causes error

Great software! My built in mic in my MacBook Pro works just fine, but when I plug in a USB mic, I get this error:

Traceback (most recent call last):
File "/usr/local/bin/soundmeter", line 8, in
load_entry_point('soundmeter==0.1.2', 'console_scripts', 'soundmeter')()
File "/Library/Python/2.7/site-packages/soundmeter-0.1.2-py2.7.egg/soundmeter/meter.py", line 304, in main
m = Meter(**kwargs)
File "/Library/Python/2.7/site-packages/soundmeter-0.1.2-py2.7.egg/soundmeter/meter.py", line 65, in init
frames_per_buffer=FRAMES_PER_BUFFER)
File "build/bdist.macosx-10.9-intel/egg/pyaudio.py", line 747, in open
File "build/bdist.macosx-10.9-intel/egg/pyaudio.py", line 442, in init
IOError: [Errno Invalid number of channels] -9998

Any idea??

Re-enable KeyboardInterrupt on Ctrl+C?

Hi, when I import soundmeter into my flask app, I believe it's breaking the default Ctrl+C behaviour because the sigint_handler doesn't raise KeyboardInterrupt. I believe if you simply adding raise KeyboardInterrupt to the end of sigint_handler, this would work correctly again. However, not sure if this was intentional or if it'll mess up daemonized mode.

Am I correct? Is this something worth fixing? If so, I can make the PR if it helps

Not working with Python3

I tried this with python3 on osx 10.11 and ran into a few errors, here they are in received order:

  • SyntaxError: Missing parentheses in call to 'print'
  • ImportError: No module named 'StringIO'
  • ImportError: No module named 'ConfigParser'
  • TypeError: object() takes no parameters
  • NameError: name 'xrange' is not defined

all standard python2 -> python3 conversion issues, which I worked through with some quick fixes, and finally got to this attempt:

$ soundmeter --collect --seconds 10
2016-06-03 20:24:59.760 Python[6027:183774] 20:24:59.759 WARNING:  140: This application, or a library it uses, is using the deprecated Carbon Component Manager for hosting Audio Units. Support for this will be removed in a future release. Also, this makes the host incompatible with version 3 audio units. Please transition to the API's in AudioComponent.h.
Collecting RMS values...
Traceback (most recent call last):
  File "/usr/local/bin/soundmeter", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/site-packages/soundmeter/meter.py", line 311, in main
    m.start()
  File "/usr/local/lib/python3.5/site-packages/soundmeter/meter.py", line 116, in start
    self.record()  # Record stream in `AUDIO_SEGMENT_LENGTH' long
  File "/usr/local/lib/python3.5/site-packages/soundmeter/meter.py", line 90, in record
    data = self.stream.read(FRAMES_PER_BUFFER)
  File "/usr/local/lib/python3.5/site-packages/pyaudio.py", line 608, in read
    return pa.read_stream(self._stream, num_frames, exception_on_overflow)
OSError: [Errno -9981] Input overflowed

Which didn't seem like a standard error, so I moved to another osx to try python2, and ran in to issue #7, but that is a separate issue...

API and integration with a nodeJS app

Hi,

I'd like to integrate the readout from soundmeter into a nodeJS app I'm building.
I'm actually not very familiar with Python so I wasn't able to figure exactly how to query which file in soundmeter using python-shell for example to retrieve the RMS value.

Right now I'm running soundmeter straight from the terminal. But ultimately I'd be calling it from my nodeJS app and use the value there.

Any advice ?
Thanks

Can't run shell script [Errno 2] No such file or directory

Hi everyone,

I have created a Python script to launch notifications with Pushover.
The script is called "pushover.py" and is located in the /home/pi folder.

It works well when I type :
$ sudo python pushover.py

But when I try to launch :
$ soundmeter --trigger +300 --action exec --exec pushover.py

I receive the following error message when the 300 threshold is reached :
"Can't run shell script [Errno 2] No such file or directory"

What am I missing here ?
Where should I put the 'pushover.py" file to solve this ?

Many thanks in advance for your help.

Selecting another input

Hi,
Sorry this is more a question than an issue really, I can't seem to find how you specify which input the program is listening to ?
I wanted to specify an entrance like "pyaudio.paJACK = 12" but I couldn't even find where you call pyaudio from...
Best regards

Unit of RMS

Hi, I want to get the value of RMS in decibels, any idea of the formula to use ?

Question on accuracy

Hi, thanks for creating this -- I have a problem I'm trying to solve and it seems this may be a perfect solution. One question though.

Have you done at work to see how precisely soundmeter can detect two audio peaks, e.g. to what what precision in time?

The problem I'm trying to solve is to measure audio latency as audio travels from one cell phone to another. I've done this so far by using audacity to record and measure the audio peaks and determine the time between them. I'm trying to determine with a precision down to about 50ms as I measure different audio routing options.

I did a quick test (which I realize isn't optimal) and I'm seeing there is about a 650ms between executions. Before I dig into how much I can reduce this, I wanted to see if you had any experience with this.

Here's what I tried so far:

I'm running soundmeter as follows:

soundmeter --trigger +3000 1 --action exec --exec ./measure

Measure is a script that does this:

!/bin/sh

cd /Users/brooksc/grid/latency
TIME=$(gdate +%s.%N)
LAST=$(cat last)
echo $TIME > last
echo $TIME - $LAST | bc

So it calculates the time from the last execution to now.

My next step is to capture the timecode in python and avoid the time to execute the external program.

FYI - the shortest delay I've heard between two cell phones is about 500ms. But as I'm trying to measure whether a particular call is 700ms or 850ms between audio peaks -- the accuracy of measuring time between peaks is critical.

Thanks again for creating this!

Please support XDG Base Directory Configuration

hi,
I'd like to use something like ${XDG_CONFIG_HOME}/soundmeter/rc.conf as the configuration folder/file. Could you please check that path fist?

thanks for this tool! I use it to control mpd in a woodworking shop to have some music now and then, only when there's little noise.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.