shichao-an / soundmeter

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

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

Open ytokusho opened 7 years ago

ytokusho commented 7 years ago

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,

stevenbaur commented 7 years ago

Hey, I have the exact same problem here with my Raspberry 3, with the exact same error-message.

For the first warning about ffmpeg you can easily install libav-tools to get rid of the warning, works fine for me so far.

but the for the rest (connect(2) call to /tmp/jack-1000/default/jack_0 failed (err=No such file or directory) (..) I'd be happy to read a solution here =)

thanks! :)

shichao-an commented 6 years ago

Hi, you can change the channels in the config file.

Check the number of channels of your default input device:

>>> import pyaudio
>>> p = pyaudio.PyAudio()
>>> p.get_default_input_device_info()['maxInputChannels']
1L

Then change your config file's channel to that value:

[soundmeter]
frames_per_buffer = 2048
format = 8
channels = 1
rate = 44100
audio_segment_length = 0.5
rms_as_trigger_arg = False