-
-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Audible stutter, crackle or pops occur when an application changes volume or state #350
Comments
This is a known problem we have had since forever. Recently I asked in Pulseaudio's mailing list about this and I found out this is a problem in Pulseaudio. You can read their answer here https://lists.freedesktop.org/archives/pulseaudio-discuss/2018-October/030553.html. Unfortunately it seems there is no one looking at this bug at this moment. So we may have to live with this for a while. For now I suggest we let this issue opened for people noticing this bug to find the link above easily. But there is nothing we can do in PulseEffects that could fix this. |
I see, so it only occurs via pa monitoring as a result of buffer overlapping, which makes sense. Fixing the bug could involve either disabling rewind (first thing I looked for prior to reporting) or using a buffer copy-through akin to running a virtual device loop, the later adding additional latency but effectively sandboxing pa-effects. I'll look at pa's code anyway to see what can be done, might only need some interpolation. |
The PulseAudio's ML answer is a bit depressing, especially when you see that the problem has been known for 4 years. Is there anything we can do to help, besides actually fixing the bug (I don't know enough about PulseAudio to try). |
I don't know. At this moment I do not have any idea :-( |
And I just wanted to say that the equalizer kicks ass, much better than the PulseAudio LADSPA equalizer. I own a ThinkPad X1 and the Dolby driver does not exists on Linux, so the sound is garbage by default, but I managed to salvage a lot of depth and clarity using the many bands available in PulseEffects. Thanks a lot for making this tool available! |
Found this really good explanation of how rewinding works in PulseAudio. It also mentions several known bugs (none of which seem to have ever been addressed) any one of which could be causing the crackling we hear when rewinds occur in PA. The one mentioned at the end of the "buffers" section seems suspiciously capable of being the culprit (but the whole page is a good read on rewinding in PA and how it all works). PulseAudio Rewinding Developer Documentation
|
Does this crackle also occur when pausing/playing a file? @edit: Changing the active profile of pulseeffects to my "all off profile" and then back to my "Sennheiser" profile which has EQ enabled, fixes the issue. |
The source of the noise are the rewinds done by Pulseaudio while we are recording from the sink monitor. So any action that can cause a rewind will generate noise. If I am not mistaken playing/pausing may cause rewinds too because when you have only 1 audio app running and you pause/unpause it PulseEffects will alternate its pipeline between the playing and paused state in order to save cpu usage. Something to have in mind is that the intensity of the noise seems to be dependent on factors like the audio buffer size. So there are rewinds that do not cause audible noises and others that do... I think that this sampling rate change must have happened for other reason. It does not depend on the equalizer. When PulseEffects starts it reads the rate of the default output device and the whole pipeline is locked to this value while PulseEffects is running. Just take a look at the values in our headerbar |
The crackles when enabling/disabling are intense? I can listen to a very small noise when the eq is enabled. It is not related to the eq but to the fact that the pipeline has to be "cut" on the fly so that we can insert the eq there. And as it is being done now some audio buffers may be lost a long the way... What is probably causing this noise. There is a better way to insert/remove the plugins from the pipeline on the fly and I tried it a long time ago. Introduced so many problems I gave up. Dynamic GStreamer pipelines can be hard to get right when they are large as the ones we have. Maybe one day I will take a look at this again... |
Yes, play-pausing will trigger rewinds, and the crackle will vary in intensity simply by whatever the last bits in the stream were. PA is the only library with this fault as it's the only one that does rewinding (for reasons still unknown to me...). The only real solution is to disable/remove rewinding from PA, but I'm not aware of any [proper] ways to do that... |
Oh, it'd also vary in intensity based on the user's balance between physical speaker/head volume and mixing volume. I tend to have my physical volume at a fixed, high value, so that each application gets a high volume range to chose from. This of course makes small crackles and stutter very predominant, often as a loud crack or thump. |
To me the cracks only happen when pause/playing/rewinding/changing track or audio/video files. If it is a fault from PA-side, why does it not occur when using only PA without pulseeffects? |
Because without PE there is nothing recording audio from a sink monitor. But in order to apply effects we have to record from the sink monitor we redirect apps output to |
I almost can not listen these cracklings unless I change the app volume. I definitely do not have a noticeable noise when just alternating between the playing and paused state. What values are you using for buffer and latency in the settings menu? |
It feels like this can get worse on some hardwares. 99% of the time I forget we have this problem |
Maybe the reason why I do not notice them is because I never have the system volume at its highest value. I set each app volume to it's maximum and control the system volume through my keyboard multimedia keys |
Using low latency and buffer values may help. This the most that can be done on our side. Some months ago I really tried everything I could do to no avail. This has to be fixed in Pulseaudio. This is happening deep inside its code and here on PE we are coding from a high level API. My hands are tied =/ |
I also use the system volume and have everything else set to about 70% to avoid clipping and hardly notice this issue during normal use. @Utini2000 it might be worth lowering the volume of the application playing audio and see if that helps. I do sometimes get the crackle when a new stream starts to play, even if it's not going through pulseeffects but that's rare. |
Buffer: 200000 My DAC vendor (Meier Audio Daccord FF) recommend in the manual to have the system volume at 100% and use the DAC/AMP to change the volume level. This is also how the driver works in its default state. As soon as I plug in my DAC, the volume will go to 100%. I just want to re-try it with a lower system/app volume but ofcourse I can't reproduce the error now :D |
Okay, I will give it a try tonight :) |
I'm on 500000 for buffer which I found makes the audio much more stable - although there is a noticeable delay, which doesn't bother me. Something else to consider, pulseeffects will amplify the sound slightly too, which can be seen here The system volume (as in what's controlled with the media keys or volume thing in the system tray) is applied after pulseeffects so turning that down has no effect - the damage is already done by the puleeffects stream clipping. It works in the same way as video or image encoding, once it's been compressed and the detail is lost there is no way to get it back. Analogue amplifiers will normally say you need the source volume at max because if it's too quiet you'll have to turn the volume way up which will add a horrible buzzing noise from electrical noise being amplified. @Utini2000 If the sounds is very loud with the amp on a low setting I'd say try turning the app volume down to about 40% and leave system at 100%. That should eliminate any clipping that might be happeneing and you could turn the amp up a bit so the volume control on it would actually be usable :) |
Also just btw, @wwmm Pulseeffects is awesome :D |
Thanks @betterphp! :-) The volume amplification will depend on which plugins are enabled and on how they are being used. Let's consider as an example that the equalizer is the only plugin enabled. If you use subtractive equalization(all gains are below zero) the output level will be smaller than the one in the input. But if you boost weak frequencies instead of cutting the strongest ones it will happen what you described. When boosting I suggest using the input or the output gain controls to reduce the signal level. Based on your image you are using a bluetooth device as output. For some reason I do not know bluetooth devices need more buffering. My bluetooth headphone does not work with anything less than 200000 or 250000. |
@Utini2000 the section |
@wwmm thanks for that link. It would make sense because the wikie mentions the problems especially in connection with KDE4. I switched from XFCE to KDE-Plasma pretty much at the same time when I installed pulseeffects. That might make me believe it is a pulseeffects fault. So I tried what the wiki states and it doesnt really work for me. If I add both lines then my system becomes unresponsive and I have to force off the system. Also I already have that file on my Arch installation with lots of content. |
I just noticed that my problem could be related to what the wiki mentions because I just had cracks when opening a window (twice in a row). Now I just need to figure out how to apply that fix in a way that it works for me :o |
I have good news for you! Although the rewind bug is still there I was able to submit a few patches to Pulseaudio that helped me to workaround it. It was already merged as you can see here https://gitlab.freedesktop.org/pulseaudio/pulseaudio/merge_requests/93. I have already updated PulseEffects so that rewinds are disabled when Pulseaudio 13(not released yet) or its development branch is being used. People willing to try it now will have to install both Pulseaudio and PulseEffects from sources. Pulseaudio can be installed this way
You have to kill the current instance before running the new one
Now you can start the Pulseaudio version you compiled
After that you can open PulseEffects and the other audio apps. To go back to the Pulseaudio installed in your system kill the one you compiled from sources and run
I know. Doing tests with Pulseaudio compiled from sources is a pain. But it would be nice to know if the issue is fixed for everybody. At least for me it is :-) |
Small notice: I need to run it by
(Arch Linux) After all operations, there are still lags, described here: #222 (comment) (when I change volume of application in PE). |
I had this error too. It makes no difference. Pulseaudio runs even if this file is not installed. Honestly I don't know why Pulseaudio is trying to put stuff in /etc when the prefix is in /tmp. It may be better to not run as root |
Did you update PE too? |
Yes, but I don't know how, if
Sorry, no. I'll try a little bit later. |
I installed both pulseaudio-git and pulseeffects-git from the AUR and it works like a charm! I didn't think this would get fixed any time soon, good work! |
@AlexWayfer install as normal user. These errors are not relevant to us. Good to know @ferreum! I tried to use pulseaudio-git from aur but for some reason it fails to compile on my Arch install. Strange. |
Right, the PKGBUILD contained a patch command that I had to comment out. I figured it was not needed any more because it complained about already having been applied. |
Oh! I did not think about that. @AlexWayfer in this case it is better to do the same as @ferreum and install the aur package |
Thank you! I did that. There are no more lags when I change volume of application in PE. I'll look if it resolves #222 too. |
I am not able to test and verify this right now (+the next 2 weeks) but given by the effort you put into fixing this and actually fixing PulseAudio, you are simply awesome! |
I think we can close this. |
If I cherry-pick those patches to PulseAudio in ppa:milkhailnov/pulseeffects, will pulseeffects be able to detect that to disable rewinds? |
Only if you also compile PulseEffects from git. PE |
You would also need to make Pulseaudio identify itself as something newer than |
Let's wait for the next version of PulseEffects and prepare Pulseaudio now.
I think it will be easier and more reliable to patch PulseEffects when building in the PPA, please give a link to the code that checks it. |
Hm, if doing like this, if PulseEffects is installed from the PPA and Pulseaudio is not, then PE will try to use this new option and fail, will it lead to a crash? |
If I do like this
will pulseeffects understand it? (PA_MICRO seems to be used only in |
This is where Pulseaudio version is checked https://github.com/wwmm/pulseeffects/blob/57d1811011c9b229e7d4d889a3101dbd8b72184b/src/pulse_manager.cpp#L542 As PulseEffects is right now it works for all Pulseaudio versions. But if you force the new null sink option |
I don't know if patching Pulseaudio this way will work. Whatever you do you can test by running the command |
I've packported the fix to Pulseaudio 12.2 and it did fix crackling when changing sound volume via Pulseeffects for me. Have commited the updated PulseAudio into the PulseEffects PPA for Ubuntu 18.04, 18.10, 19.04 and 19.10.
|
Archlinux has 12.2-2 (although the terminal reports back 12.2) which still has the crackling issue :( |
Just install |
You will have to do what @AlexWayfer said. Pulseaudio 12.2 in Arch Linux repository does not have the patches I sent to Pulseaudio devs. Until Pulseaudio 13 is released(what may take a while) |
Whenever an application changes audio volume in some way, usually via the user, or if an application changes state or its media is skipped ahead or behind, also usually via the user; an audible crack or pop, or occasionally a stutter/glitch, is heard.
The displayed buffer latency for that application also changes erratically each time the above event occurs.
This does not occur with regular pulseaudio, or if 'pulseaudio -k' is called to reset PA, in turn disabling pulseaudio-effects.
The text was updated successfully, but these errors were encountered: