[x] The code must enumerate audio devices and prefer pulse if present, since neither default device nor first device (index 0, typically named according to the actual model of the hardware) work with PyAudio (probably due to historical changes in Linux audio, as described more below).
As discussed at PR #33
Hey, thanks for the pull request!
Before I merge it, I would like to ask a few questions because I'm too well versed in this.
Firstly, are you on linux? I don't have a linux machine right now and am unable to test pyvidplayer2 there. If so, how was the experience? Did everything work properly?
Yes, it is tested on:
Linux Mint 21.3 (PulseAudio + Pipewire)
Ubuntu Studio 24.04 Noble Numbat (PipeWire+Jack, but still runs pulse server for compatibility)
Windows 10
Second, why did you make a custom logger instead of using the default warnings logger?
That was mostly for having info messages shown conditionally. It operated similarly to Python's own logging module, but for backward compatibility I didn't import that. I didn't notice until I was finished that you use the warnings module, which I never used before. Anyway:
[x] I removed the custom logging module from the PR and instead now use the warnings module there in response to your message.
And lastly, I'm still confused about the features you've added.
The separate_wave feature was mostly for testing, so I could play audio samples without video. However, after seeing your comments and questions, I looked at the code further, and much more code would be necessary to actually synchronize the separate audio file and to get it working with pygame audio (I only tested it with PyAudio mode, and didn't test it with rewind etc. which wouldn't have worked). Therefore:
[x] I've removed the separate_wave feature from the PR as well.
Can you explain a little bit more what pulse is?
pulse is the name of the PulseAudio server present on (probably most) linux systems.
Unfortunately, if PulseAudio and/or Pipewire are installed, the old code will not work. Finding the default will not be the right one, probably due to PyAudio not accounting for recent changes in linux distros:
The development system that works well for everyone was rocky, going from [OSS several years ago to] ALSA to PulseAudio and finally to Pipewire which seems to solve latency issues and work well with both with PulseAudio and with jack. As noted in the new docstring for the new preferred_device_names attribute:
jack which is used for audio production but is tied to a specific sample rate when it is started, so generally should not be in the preferred_device_names (has stuttering and may freeze).
also, trying to use the pipewire device with PyAudio causes severe stuttering and freezes as well (reason unknown, probably PyAudio just doesn't talk to pipewire correctly, or pipewire is piped into jack and the input sample rate may not match jack, the default being 48000 Hz).
If pulse (or preferred_device_names) is not found in the list of devices returned by PyAudio, the code in the PR will run the old code (The first device will be selected).
Again, thanks for your contribution. I would love to collaborate!
I'm very glad to help! I have been searching for fast and accurate video scrubbing in Python for a long time, and look forward to using it to make applications.
pulse
if present, since neitherdefault
device nor first device (index0
, typically named according to the actual model of the hardware) work with PyAudio (probably due to historical changes in Linux audio, as described more below).As discussed at PR #33
Yes, it is tested on:
pulse
server for compatibility)That was mostly for having info messages shown conditionally. It operated similarly to Python's own logging module, but for backward compatibility I didn't import that. I didn't notice until I was finished that you use the warnings module, which I never used before. Anyway:
logging
module from the PR and instead now use thewarnings
module there in response to your message.The
separate_wave
feature was mostly for testing, so I could play audio samples without video. However, after seeing your comments and questions, I looked at the code further, and much more code would be necessary to actually synchronize the separate audio file and to get it working with pygame audio (I only tested it with PyAudio mode, and didn't test it with rewind etc. which wouldn't have worked). Therefore:separate_wave
feature from the PR as well.pulse
is the name of the PulseAudio server present on (probably most) linux systems.jack
. As noted in the new docstring for the newpreferred_device_names
attribute:jack
which is used for audio production but is tied to a specific sample rate when it is started, so generally should not be in thepreferred_device_names
(has stuttering and may freeze).pipewire
device with PyAudio causes severe stuttering and freezes as well (reason unknown, probably PyAudio just doesn't talk topipewire
correctly, orpipewire
is piped into jack and the input sample rate may not match jack, the default being 48000 Hz).pulse
(orpreferred_device_names
) is not found in the list of devices returned by PyAudio, the code in the PR will run the old code (The first device will be selected).I'm very glad to help! I have been searching for fast and accurate video scrubbing in Python for a long time, and look forward to using it to make applications.