Hacker News new | ask | show | jobs
by ArsenArsen 1965 days ago
Ever since I got a new microphone I've been having issues with large quantities of background noise, primarily typing sounds, leaking in through my microphone. A friend of mine had told me about rnnoise, describing it as "very good" at removing noise, so I decided to test it. My initial testing started by me piping raw PCM from arecord through rnnoises denoiser demo into aplay. The results frankly shocked me. When not speaking, there was no noise (or sound) at all (this is due to rnnoises voice detection system, which essentially mutes the microphone when there's no voice), and when I was talking, the sound of my keyboard was a lot quieter without it affecting my voice, this lead me to decide to develop alsa_rnnoise to have good real time noise cancellation.

alsa_rnnoise is a very simple ALSA filter plugin that runs its input through rnnoise before outputting it back to ALSA. It operates in real time, adds very little latency (the amount depends on what size frames ALSA delivers, but is nominally less than 10ms). After enabling it, any annoying background sounds were gone. My intended use cases for this were VoIP, screencasting and streaming, and, as far as I can tell, it works great for all three.

3 comments

A few weeks ago, I tried doing this with the LADSPA version of RNNoise and ALSA, but couldn't get it to work reliably.

I have also experimented with NoiseTorch which routes the microphone through LADSPA using Pulseaudio but it didn't work reliably either. The biggest problem with this is that Pulseaudio will load one CPU thread 100% even when no audio input. This makes it a deal breaker for laptops.

I will definitely check this out. RNNoise is truly amazing tech, but it is not as accessible as I would like. The best use if it is in the Mumble client where it is an optional setting.

It is a shame Nvidia has taken over this space completely with RTX voice. RNNoise does a comparable job without the need for an Nvidia GPU. But I guess it is because RNNoise is just not as easy to setup.

I believe Pulse also has a LADSPA module that you could try.
Hey, thanks for building this! There are multiple options like this for Pulseaudio, but last I researched it nothing for pure ALSA. On a system without Pulseaudio this is obviously better, great to have.

The pulseaudio plugins like noisetorch have the issue of significant system load even without current sound input (something about how the loopback works iirc), will this alsa plugin share that issue or will the system load be lower when currently there is no sound input?

The plugin uses very little CPU, and is entirely inactive when not in use (i.e. when data isn't being pulled => the transfer function isn't being called) due to how ALSA works

EDIT: Do note, though, that each process pulling audio will be denoising independently, so the usage scales linearly with the amount of clients. This is due to how ALSA plugins work, but regardless of that, on a Ryzen 5 1600x (the only CPU I can test on), the plugin uses 2.5% of a single core when recording mono 48k

Excellent.

I'm testing this right now and am noticing that some more info about the installation could be helpful. Specifically, when installing rnnoise as shown in the readme it of course goes to /usr/local/lib, but /usr/local/lib/pkgconfig was not in the PKG_CONFIG_PATH of my distro. Maybe there could be a hint to set that when calling `meson build` if rnnoise can't be found?

Packaging software is always annoying, sorry for dragging you into that mud. Ideally distros will pick it up and compiling manually unnecessary. I would have left this as an issue but saw no issue tracker on the project page.

There's an issue tracker on that page, under tickets, but I'd prefer if you took a discussion to the attached mailing list first before it hits the official tracker.

As for packaging, that's my field of work for some projects I'm working on so it's not unfamiliar to me, the only problem is that the RNNoise upstream lacks releases, although there's discussion about something happening about that.

Okay. To also mention the result: Installation worked, alsa plugin worked and the filter does work. Nice, thanks again.

With extreme sounds (vacuum) in the background the voice gets a bit more distorted than ideal, but something like a keyboard gets filtered nicely to be less noisy. I assumed that's just how RNNoise behaves, I'm just mentioning it because of the sound quality discussion above. Maybe also to that: Just activating the alsa_rnnoise filter does not significantly lower recording quality, at least not that I can notice.

> There are multiple options like this for Pulseaudio,

Mind sharing? I didn't manage to find any that was easy to install/configure, so it would help me a lot. Thanks!

NoiseTorch is the one I use on my Pulseaudio-enabled laptop, https://github.com/lawl/NoiseTorch. It has a GUI and is very easy to install, seems to work well. Significant cpu usage when active, so I only load it when it's needed, but that's okay for me.
I'm intrigued by this. I've never been really satisfied with any software noise reduction system, but this sounds like a phenomenal improvement.

Tried installing it on Ubuntu LTS via latest pulseeffects, but it seems like it switched to pipewire 0.3 which is not available yet so I can't really run it.

My solution so far has been a headset with a boom microphone, like the CoolerMaster MH630 (one of the better boom mics, see https://www.rtings.com/headphones/reviews/cooler-master/mh63... for a sound demo at the "Recording quality" section). When it comes to noise reduction, bringing the microphone as close to the mouth as possible is a really good way to get an amazing SNR boost immediately (even for omnidirectional mics). Unfortunately that's a pain with large capsule condenser microphones (unless you're ready to have a large boom arm hanging about on your desk and accept view obstruction, and you add postprocessing to remove the very bassy proximity effect)

Another benefit of headsets with boom mics is consistency (without DSP). No matter how you move, the distance and angle to the microphone is always identical, and therefore the sound is very consistent (save for your own personal loudness)

You can of course add DSP (limiter, noise reduction etc) to that, but the better input you provide, the better output you get.