My pipewire seems to have issues with crackling audio and severely dampening my mic and I have no clue why.
Pipewire’s default quantum (buffer size, effectively) is incredibly low, this is good for low latency audio but anytime your system is too busy to keep the buffers filled you get crackling.
If you look at pw-top you’ll see all of your devices and nodes. The quant column is probably 1 or a very small number for the devices.
You can increase the quantum with this command. This only lasts until pipewire restarts:
pw-metadata -n settings 0 clock.min-quantum 512
At a sample rate of 48000, this is roughly a 10ms buffer. 1024 is 20ms, etc. You want it as low as possible without getting crackling. Start with 512 and adjust from there (you don’t have to use a power of 2, a quantum of 1234 works just as well).
severely dampening my mic and I have no clue why.
By default pipewire doesn’t do any ‘mic boost’, as Windows calls it. You can get the same effect by raising the maximum volume.
In your sound control panel you should be able to turn the mic up higher than 100%. In KDE Plasma, you can do this in System Settings -> Sound -> Configure Volume Controls… [top right button] -> Raise maximum volume.
Alternatively, you can use EasyEffects to add a compressor. This will boost your mic volume and also prevent it from getting too loud
Compressors basically reduce the dynamic range of an audio signal by attenuating loud sounds and boosting quieter ones, this would provide a better mix.
Other useful plug-ins are noise canceling, (kills background noise) and echo canceling (lets you play sound out of your speakers which won’t get picked up by your mic). Sometimes apps, like Discord, will do this signal processing for you while others, like Signal, do no signal processing.
I absolutely wasn’t expecting a helpful response under a meme, so thank you very much for taking the time to write it!
anytime your system is too busy to keep the buffers filled you get crackling
I’d have to test that more thoroughly, but I do think that lines up with the timing of the issues.
You can increase the quantum with this command. This only lasts until pipewire restarts:
Can I put that in some config to make it stick?
I’m admittedly very junior to pipewire config, so most of what I have is copied from the internet, tweaked for node names / descriptions, but I generally like working with config files and slowly learning what all that stuff in there means.
I have two loopbacks (I like having music and games each grouped separately from other audio), an echo-cancel and a noise cancel (filter-chain with a single rnnoise node), all configured via .conf files. As an aside, is there a “best order” to chain echo cancel and noise cancel?
Echo cancel seems to have a quantum/rate of 480/48000 across the board. Loopbacks, rnnoise and alsa_output (my headset) all have 0/0. I imagine it makes sense for the Loopbacks and rnnoise, but should it be something else for the main output?
By default pipewire doesn’t do any ‘mic boost’, as Windows calls it. You can get the same effect by raising the maximum volume.
Well, it seemed to work just fine without echo cancel, if I capture the mic directly, but putting it through echo cancel (with or without noise cancel) seems to reduce the gain significantly.
I’m gonna mess with the volume sliders and see which ones I can crank up to fix that issue.
But I’m confused why that issue would occur in the first place and if I have something misconfigured.
Alternatively, you can use EasyEffects to add a compressor. This will boost your mic volume and also prevent it from getting too loud
Sounds like a compressor would be a good idea to have anyway. Is that also doable through the config? I’m not opposed to graphical tools, I just feel like working with the config directly is more educational. It’s also more prone to screwing things up, but that’s just bonus lessons on what not to do.
Sometimes apps, like Discord, will do this signal processing for you
Curiously, the reason I looked at echo-cancel in the first place is that Discord’s own echo fucks with things, cutting me out at times while also not cancelling the echo at others.
Sorry @luciferofastora@feddit.org, I got out of bed and completely forgot to actually go check what I did. My issue was under high load the audio would crackle, I could never quite establish if it was GPU or CPU, but at least it was during intenser moments in games. I played around a lot with the quantization that people in here have already suggested but it never fixed the crackling.
What finally solved it for me was to enable threadirqs. You can do this with sudo kernelstub -a threadirqs. I don’t entirely understand it, but I believe it makes the interrupted handler execute in threads.
I need it to automate fishing in Minecraft, and the normal way to take screenshots in Python (which is one line with PIL) on Linux went from at least 30 possible fps on X11 to 2 on Wayland. The only way to do it fast enough then is to use Pipewire. Which is one hell of a convoluted mess. (The next part of this whole mess will be finding a way to send mouse clicks without having Minecraft registering a mouse move too in case xdotools stop working)
I’m writing a script that automatically take screenshots of the desktop (in particular the Minecraft game window) and then use OpenCV to do template matching to recognize if I’ve caught a fish or not.
If I use any usual screenshot capabilities of any python library, I simply cannot take pictures fast enough (at least 10 images per second) to have the script work (under Wayland the usual system top out at 2 images per second).
The only way fast enough I’ve found so far is to use Pipewire to create a livestream of the desktop and get frames of it to do the job.
And it is a complex mess. (At least I’ve found a (very basic and badly documented) library to do most of the work instead of having to work it all through Dbus myself.)
It’s just that what once was a single line in my previous X11 script is now a full on script by itself, and I understand almost nothing of it.
My pipewire seems to have issues with crackling audio and severely dampening my mic and I have no clue why.
Still better than Windows.
Pipewire’s default quantum (buffer size, effectively) is incredibly low, this is good for low latency audio but anytime your system is too busy to keep the buffers filled you get crackling.
If you look at
pw-topyou’ll see all of your devices and nodes. The quant column is probably 1 or a very small number for the devices.You can increase the quantum with this command. This only lasts until pipewire restarts:
At a sample rate of 48000, this is roughly a 10ms buffer. 1024 is 20ms, etc. You want it as low as possible without getting crackling. Start with 512 and adjust from there (you don’t have to use a power of 2, a quantum of 1234 works just as well).
By default pipewire doesn’t do any ‘mic boost’, as Windows calls it. You can get the same effect by raising the maximum volume.
In your sound control panel you should be able to turn the mic up higher than 100%. In KDE Plasma, you can do this in System Settings -> Sound -> Configure Volume Controls… [top right button] -> Raise maximum volume.
Alternatively, you can use EasyEffects to add a compressor. This will boost your mic volume and also prevent it from getting too loud
Compressors basically reduce the dynamic range of an audio signal by attenuating loud sounds and boosting quieter ones, this would provide a better mix.
Other useful plug-ins are noise canceling, (kills background noise) and echo canceling (lets you play sound out of your speakers which won’t get picked up by your mic). Sometimes apps, like Discord, will do this signal processing for you while others, like Signal, do no signal processing.
I absolutely wasn’t expecting a helpful response under a meme, so thank you very much for taking the time to write it!
I’d have to test that more thoroughly, but I do think that lines up with the timing of the issues.
Can I put that in some config to make it stick?
I’m admittedly very junior to pipewire config, so most of what I have is copied from the internet, tweaked for node names / descriptions, but I generally like working with config files and slowly learning what all that stuff in there means.
I have two loopbacks (I like having music and games each grouped separately from other audio), an echo-cancel and a noise cancel (filter-chain with a single rnnoise node), all configured via
.conffiles. As an aside, is there a “best order” to chain echo cancel and noise cancel?Echo cancel seems to have a quantum/rate of 480/48000 across the board. Loopbacks, rnnoise and alsa_output (my headset) all have 0/0. I imagine it makes sense for the Loopbacks and rnnoise, but should it be something else for the main output?
Well, it seemed to work just fine without echo cancel, if I capture the mic directly, but putting it through echo cancel (with or without noise cancel) seems to reduce the gain significantly.
I’m gonna mess with the volume sliders and see which ones I can crank up to fix that issue.
But I’m confused why that issue would occur in the first place and if I have something misconfigured.
Sounds like a compressor would be a good idea to have anyway. Is that also doable through the config? I’m not opposed to graphical tools, I just feel like working with the config directly is more educational. It’s also more prone to screwing things up, but that’s just bonus lessons on what not to do.
Curiously, the reason I looked at echo-cancel in the first place is that Discord’s own echo fucks with things, cutting me out at times while also not cancelling the echo at others.
Oh I had this issue and it drove me bonkers trying to fix it! I have to go digging a not to try and remember what fixed it in the end.
Sorry @luciferofastora@feddit.org, I got out of bed and completely forgot to actually go check what I did. My issue was under high load the audio would crackle, I could never quite establish if it was GPU or CPU, but at least it was during intenser moments in games. I played around a lot with the quantization that people in here have already suggested but it never fixed the crackling.
What finally solved it for me was to enable
threadirqs. You can do this withsudo kernelstub -a threadirqs. I don’t entirely understand it, but I believe it makes the interrupted handler execute in threads.Thanks for remembering, checking and getting back to me! I’ll look into that
threadirqsthing, thanks for the pointer!Bluetooth headphones by any chance?
Nope, wired. Separate ports for input / output on the front of the case.
Read the arch wiki on troubleshooting pulse audio. I remember having this issue long ago.
The issue occurred yesterday gaming with friends and I didn’t have time to troubleshoot yet, but I’ll keep that in mind, thanks!
I’m still trying to figure out why the only real way of taking screenshots fast in Wayland is to do a video capture of the desktop with pipewire…
I don’t know what you mean. I can just hit the print screen key on my keyboard and have a screenshot in my clipboard.
I need it to automate fishing in Minecraft, and the normal way to take screenshots in Python (which is one line with PIL) on Linux went from at least 30 possible fps on X11 to 2 on Wayland. The only way to do it fast enough then is to use Pipewire. Which is one hell of a convoluted mess. (The next part of this whole mess will be finding a way to send mouse clicks without having Minecraft registering a mouse move too in case xdotools stop working)
You need the print screen key for something else is what you’re saying (I had trouble following your reply)?
Can only speak for KDE, but you can easily change the screenshot shortcut to something else in settings.
I’m writing a script that automatically take screenshots of the desktop (in particular the Minecraft game window) and then use OpenCV to do template matching to recognize if I’ve caught a fish or not.
If I use any usual screenshot capabilities of any python library, I simply cannot take pictures fast enough (at least 10 images per second) to have the script work (under Wayland the usual system top out at 2 images per second).
The only way fast enough I’ve found so far is to use Pipewire to create a livestream of the desktop and get frames of it to do the job.
And it is a complex mess. (At least I’ve found a (very basic and badly documented) library to do most of the work instead of having to work it all through Dbus myself.)
It’s just that what once was a single line in my previous X11 script is now a full on script by itself, and I understand almost nothing of it.