easyeffects icon indicating copy to clipboard operation
easyeffects copied to clipboard

[RNNoise plugin] Cracking & performance loss when microphone is disabled by button

Open Lubieerror opened this issue 1 month ago • 1 comments

EasyEffects Version

7.2.5, latest GTK4, latest master

What package are you using?

Other (specify below)

Distribution

CachyOS (cachyos-extra-v3/easyeffects and compiled from git)

Describe the bug

I'm using CachyOS on a modern but not powerful laptop with the GentleDynamics preset on audio and the jtrv preset on microphone.

I noticed that when I disable my microphone (Yeti X) physically (with a button - it's still connected and powered on), I'm getting horrible cracking in my headphones and some performance losses. It only happens when there's an application that captures input and something playing sound and only when Noise Reduction is enabled.

Expected Behavior

No cracking.

Debug Log

Debug Log
Paste your log here

Additional Information

I did some digging, tests, cloned repos, and replicated it both on the latest GTK4 (gtk4-legacy) and the latest QT version (master).

From the digging, seems like the problem happens when the microphone sends zeros (left_in and right_in in remove_noise in rnnoise.hpp). First I put dropped early in the RNNoise::process on zeros. This fixed the cracking but broke some visuals, so I moved it to the remove_noise function. This worked better without breaking anything, but I started to have microphone cracking.

I'm little tired and out of time to test it properly right now. I can come back to this later when I have a while, but since you know the system better, I thought maybe you want to also look at it (since there are few other issues with cracking, maybe it could solve some of them).

There's not much code I added, so I just share the one I used to detect a disabled microphone. I'm also not a C++ developer, so perhaps something I'm doing is sub-optimal.

// used it twice on right_in and left_in at the start of remove_noise in rnnoise.hpp and just return early.
  template<typename T>
  auto input_is_zero(const T& data) -> bool {
    return std::all_of(data.begin(), data.end(), [](float v) {
      return v == 0.0F;
    });
  }

My other idea is there might be something in calculations that takes too much power when inputs are 0.

Btw. really, really great software <3 I miss it so much when I have to come back to windows and LGHub 😭

Lubieerror avatar Oct 30 '25 13:10 Lubieerror

My other idea is there might be something in calculations that takes too much power when inputs are 0.

It is possible the rnnoise library has something like that. I think I never looked at its implementation. At least on our side there is not much being done that would make this plugin cause a huge CPU load. We do have to force resampling when the sampling rate is different from 48 kHz because the rnnoise library requires 48 kHz for it to work.

I'm also not a C++ developer, so perhaps something I'm doing is sub-optimal.

The c++ there is fine. But based on my experience a plain for loop has better performance in this case. The main issue is if taking action based on the values being equal to zero is a good idea.

As none of my microphone work this way trying to fix this on my side will be tough.

wwmm avatar Oct 30 '25 23:10 wwmm