Skip to content
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

obs-filters: Add RNNoise to noise suppression filter #3263

Merged
merged 1 commit into from
Aug 18, 2020

Conversation

remjey
Copy link
Contributor

@remjey remjey commented Aug 8, 2020

Description

This commit adds support to using Xiph and Mozilla RNNoise library for
noise reduction.

RNNoise is a small library using an AI approach to noise reduction
using a pre-trained model like RTX Voice. But unlike RTX Voice, it is
very tiny, use CPU instead of GPU and only use little resources.
Obviously it is not as efficient but will effectively remove background
noise. It uses more CPU than the existing libspeex-based noise
reduction but it also sounds sounds way better.

RNNoise support is added to the noise reduction effect. It can be
enabled with a checkbox in the effect configuration. RNNoise has no
settings.

Motivation and Context

RTX Voice isn’t available to everybody and libspeex noise reduction introduces
sound artifacts that are sometimes annoying. RNNoise works better than libspeex
while requiring no special hardware and uses only a little more CPU.

RNNoise support will only compile if the library is available on the system.

How Has This Been Tested?

This change is completely incremental. I tested it myself on my main computer
running Linux, Devuan Beowulf (based on Debian Buster). It doesn’t affect any
other area of code, however I had to add some cmake scripts to detect RNNoise.

2020-08-08-202353_861x726_scrot

2020-08-08-202400_861x726_scrot

Types of changes

  • New feature: add RNNoise support in the Noise Reduction sound effect.

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@WizardCM WizardCM added the Enhancement Improvement to existing functionality label Aug 9, 2020
@jp9000
Copy link
Member

jp9000 commented Aug 18, 2020

This thing is legit amazing. Also it does not use that much more CPU usage at all.

@dodgepong
Copy link
Member

dodgepong commented Aug 18, 2020

A few demos:

No noise suppression: https://streamable.com/g3i6sf
RNNoise (using this build): https://streamable.com/qilnq1
Speex (existing OBS noise suppression, -30db): https://streamable.com/m0e2ff
RTX Voice: https://streamable.com/0c026f

@dodgepong
Copy link
Member

I feel like this UI behavior is a bit strange.: https://streamable.com/cjs73p

Maybe a dropdown to choose noise suppression algorithm would be better?

@jp9000
Copy link
Member

jp9000 commented Aug 18, 2020

I can add the dropdown.

@dodgepong
Copy link
Member

If a dropdown is added, you can move the text inside the current tooltip to be where the settings would otherwise be for RNNoise.

Are there any worthwhile settings for RNNoise? I saw another person had an implementation for RNNoise here (demo) with several options but I don't know if they are actually useful to expose in practice.

Comment on lines +47 to +51
#define RNNOISE_SAMPLE_RATE 48000
#define RNNOISE_FRAME_SIZE 480
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be configurable? Does it make sense to have this sample rate fixed to 48 kHz when I want to output a different sample rate?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these just match OBS sample rate settings? Adding settings is a double-edged sword for usability if we can select reasonable defaults or set things automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned near those constants, these can’t be changed. The sample rate is the one used by the samples used to train the standard model of RNNoise, and the frame size is fixed in the library. Feeding non-resampled 44100Hz audio in the model will yield bad results.

This commit adds support to using Xiph and Mozilla RNNoise library for
noise reduction.

RNNoise is a small library using an AI approach to noise reduction
using a pre-trained model like RTX Voice. But unlike RTX Voice, it is
very tiny, use CPU instead of GPU and only use little resources.
Obviously it is not as efficient but will effectively remove background
noise. It uses more CPU than the existing libspeex-based noise
reduction but it also sounds sounds way better.

RNNoise support is added to the noise reduction effect. It can be
enabled with a checkbox in the effect configuration. RNNoise has no
settings.
@jp9000 jp9000 changed the title obs-filters: add option to use RNNoise for noise reduction obs-filters: Add option to use RNNoise for noise reduction Aug 18, 2020
@jp9000 jp9000 changed the title obs-filters: Add option to use RNNoise for noise reduction obs-filters: Add RNNoise to noise suppression filter Aug 18, 2020
@jp9000 jp9000 merged commit 076baa3 into obsproject:master Aug 18, 2020
@remjey
Copy link
Contributor Author

remjey commented Aug 19, 2020

I feel like this UI behavior is a bit strange.: https://streamable.com/cjs73p
Maybe a dropdown to choose noise suppression algorithm would be better?

I was inspired by the layout of the noise reduction settings in Mumble, which use the two same libraries.

@remjey
Copy link
Contributor Author

remjey commented Aug 19, 2020

Are there any worthwhile settings for RNNoise? I saw another person had an implementation for RNNoise here (demo) with several options but I don't know if they are actually useful to expose in practice.

This filter seems to be using an old fork of RNNoise. The parameters being used are not available in the current official library. Actually there are no settings at all, except for a way to use a custom model.

I can add a way to reduce noise reduction by mixing the RNNoise output with its input if you wish.

@dodgepong
Copy link
Member

I'm a fan of fewer settings if they aren't needed. I was just wondering what was going on there. If we don't need settings, then there shouldn't be settings.

@mufunyo
Copy link

mufunyo commented Aug 19, 2020

A "dry mix" option could be useful in lieu of the ability to set the denoising strength.

@tt2468
Copy link
Member

tt2468 commented Aug 20, 2020

After testing this filter with some IRL streams, I think that an option to blend part of the original audio would be incredibly useful. RNNoise is incredibly decisive I've found.

@remjey
Copy link
Contributor Author

remjey commented Aug 20, 2020

After testing this filter with some IRL streams, I think that an option to blend part of the original audio would be incredibly useful. RNNoise is incredibly decisive I've found.

A "dry mix" option could be useful in lieu of the ability to set the denoising strength.

I have created a patch that unmasks the denoiser strengh slider when RNNoise is selected and uses its value as the gain with which the input of RNNoise is mixed into its output. At 0dB the result is only input audio, at -60dB there is virtually only RNNoise output.

https://github.com/remjey/obs-studio/tree/rnnoise-drymix

Here is a demo with a sample from the RNNoise demo page.

https://streamable.com/4696fq

I’ll create a pull request if you think it’s good.

@dodgepong
Copy link
Member

That looks pretty cool! Definitely worth a PR I think.

My only thought on both this slider and the Speex slider is that it's probably not obvious to lay users that the higher the slider is, the less powerful the noise suppression is, especially with a label like "Suppression Level". My UX gut tells me that the dB spinners should be hidden and the slider effectively reversed such that 100% to the right is -60dB ("full") and 0% to the left is 0dB ("None"), i.e. "more slider = stronger noise suppression". I could be wrong though, curious to hear others' thoughts.

@remjey
Copy link
Contributor Author

remjey commented Aug 20, 2020

Done: #3299

I’d say the slider makes sense in this orientation for me but I’m used to sound software. I think maybe to a regular user that design seems strange and the dB unit pretty opaque. On the other hand, this slider is coherent with the ones that can be found in the compressor, noise gate, expander and gain effects, which are more complex.

I’d just add that from a user’s point of view, the noise reduction filter is a very easy yet very effective way to improve one’s stream’s sound quality. It is important that this filter is easy to understand and use.

In my opinion the question is about whether it’s better to have a coherent interface for all effects, or invite the novice user to use the effects that bring the most improvement to the stream for the least amount of work by making their interface more intuitive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Improvement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants