rbn42 / panon

An Audio Visualizer Widget in KDE Plasma
GNU General Public License v3.0
192 stars 30 forks source link

[BUG] Does not use specified audio device (Always uses `default`) #58

Closed second2050 closed 3 years ago

second2050 commented 3 years ago

Desktop (please complete the following information):

Describe the bug While using the PulseAudio backend the plasmoid only uses the default audio device regardless of what's set in the config window.

Plasmoid Viewer Log panon.log

rbn42 commented 3 years ago

How did you know it only uses the default audio device? Is it shown in pgrep -af panon

second2050 commented 3 years ago

Okay my bad, I said default audio device because it seemed like it only used the default.

Output of pgrep if set to: "Monitor of Current device":

14936 python3 -m panon.backend.client ws://127.0.0.1:34729 --backend=soundcard --device-index=smart --fps=75 --reduce-bass --bass-resolution-level=4 --enable-spectrum-data

"Monitor of EMU20K2 [SoundBlaster X-Fi Titanium Series]…":

15515 python3 -m panon.backend.client ws://127.0.0.1:34729 --backend=soundcard --device-index=alsa_output.pci-0000_05_00.0.analog-stereo.monitor --fps=75 --reduce-bass --bass-resolution-level=4 --enable-spectrum-data

"Monitor of Family 17h (Models 00h-0fh) HD Audio Controller…":

15606 python3 -m panon.backend.client ws://127.0.0.1:34729 --backend=soundcard --device-index=alsa_output.pci-0000_0b_00.3.analog-stereo.monitor --fps=75 --reduce-bass --bass-resolution-level=4 --enable-spectrum-data

In all cases it shows the input of my microphone instead of the what's playing on these devices though.

rbn42 commented 3 years ago

Please install python-soundcard, and try this standalone python script. I want to know could this script record audio data from your other devices, or only from your microphone.

import soundcard as sc
_id="alsa_output.pci-0000_0b_00.3.analog-stereo.monitor"
mic=sc.get_microphone(_id)
stream = mic.recorder(44100,2,44100)
stream.__enter__()
while True:
  data=stream.record(44100)
  if sum(data)==0:
    print('muted',sum(data))
  else:
    print('activated',sum(data))
second2050 commented 3 years ago

Output of the script:

Traceback (most recent call last):
  File "/home/second2050/rbn42-test.py", line 3, in <module>
    mic=sc.get_microphone(_id)
  File "/usr/lib/python3.9/site-packages/soundcard/pulseaudio.py", line 317, in get_microphone
    return _Microphone(id=_match_soundcard(id, microphones, include_loopback)['id'])
  File "/usr/lib/python3.9/site-packages/soundcard/pulseaudio.py", line 345, in _match_soundcard
    raise IndexError('no soundcard with id {}'.format(id))
IndexError: no soundcard with id alsa_output.pci-0000_0b_00.3.analog-stereo.monitor
rbn42 commented 3 years ago

Oh, sorry, I made a mistake at line 3. please try this script again

import soundcard as sc
_id="alsa_output.pci-0000_0b_00.3.analog-stereo.monitor"
mic=sc.get_microphone(_id,exclude_monitors=False)
stream = mic.recorder(44100,2,44100)
stream.__enter__()
while True:
  data=stream.record(44100)
  if sum(data)==0:
    print('muted',sum(data))
  else:
    print('activated',sum(data))
second2050 commented 3 years ago

Output of the new script was:

Traceback (most recent call last):
  File "/home/second2050/rbn42-test.py", line 8, in <module>
    if sum(data)==0:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
second2050 commented 3 years ago

I just did a system update, pipewire-pulse in particular got an update, and it's working again as it should. My guess is that this was a bug introduced by Pipewire and not Panon, therefore I will close this issues for the time being.