shichao-an / soundmeter

Simple real-time sound meter
https://soundmeter.shichao.io
BSD 2-Clause "Simplified" License
82 stars 27 forks source link

USB microphone causes error #1

Closed npearson72 closed 10 years ago

npearson72 commented 10 years ago

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??

shichao-an commented 10 years ago

Hi, I think maybe your USB microphone is single-channel. The default config sets channels = 2. Try to create a local config file: ~/.soundmeter/config with the following settings and see if it still crashes:

[soundmeter]
channels = 1
npearson72 commented 10 years ago

Yeah, afraid so. I had to create my own config file btw. Does it need anything other than these permission: -rw-r--r—

On Jan 19, 2014, at 10:34 PM, Shichao An notifications@github.com wrote:

Hi, I think maybe your USB microphone is single-channel. The default config sets channels = 2. Try to create a local config file: ~/.soundmeter/config with the following settings and see if it still crashes:

[soundmeter] channels = 1 — Reply to this email directly or view it on GitHub.

shichao-an commented 10 years ago

No. -rw-r--r-- will be just fine.

npearson72 commented 10 years ago

BTW, maybe this isn’t the right forum for this, but I’ll tell you what I want to use your app for. I have super noisy neighbors. I’d like to monitor their noise level and when it reaches a certain level, trigger itunes or some mp3 player to turn on. I’ll have a speaker connected as output and place it to the wall. After 30-60 seconds.. I will shut the player down and reset it to listen for noise again.

This way I can train them to keep the noise down while I’m at away from the apartment.

I don’t know much about python, but am a ruby developer. Would you know a way in python to start and stop a desktop app? If you find this idea useful, I’d be open to collaboration.

On Jan 19, 2014, at 10:40 PM, Shichao An notifications@github.com wrote:

No. -rw-r--r-- will be just fine.

— Reply to this email directly or view it on GitHub.

shichao-an commented 10 years ago

I not very familiar with GUI programming (seems irrelevant), but as far as your case mentioned, I think you just need to find a way to control desktop apps from command-line since soundmeter can be triggered to run shell scripts.

I just did a search and found an iTunes controlling script: https://gist.github.com/rkumar/503162

You can put your commands (which runs the above itunes.sh) in ~/.soundmeter/trigger.sh and make sure it is executable and has a correct shebang. And then use something like the following to listen and trigger:

$ soundmeter --trigger +211 --action exec

You may also need some extra shell scripting to ensure the trigger.sh is not executed by soundmeter within the 30-60-seconds music playing time.

npearson72 commented 10 years ago

Sounds good. I’ll give it a try. Thanks a lot!

On Jan 19, 2014, at 11:11 PM, Shichao An notifications@github.com wrote:

I not very familiar with GUI programming, but as far as your case mentioned, I think you just need to find a way to control desktop apps from command-line since soundmeter can be triggered to run shell scripts.

I just did a search and found an iTunes controlling script: https://gist.github.com/rkumar/503162

You can put your commands (which runs the above itunes.sh) in ~/.soundmeter/trigger.sh and make sure it is executable and has a correct shebang. And then use something like the following to listen and trigger:

$ soundmeter --trigger +211 --action exec You may also need some extra shell scripting to ensure the trigger.sh is not executed by soundmeter within the 30-60-seconds music playing time.

— Reply to this email directly or view it on GitHub.

shichao-an commented 10 years ago

No problem.