lucianodato / libspecbleach

C library for audio noise reduction and other spectral effects
GNU Lesser General Public License v2.1
68 stars 12 forks source link

Memory issue, Windows #34

Closed SimonG4ELI closed 2 years ago

SimonG4ELI commented 2 years ago

I have compiled this in a 64-Bit Windows MFC DLL, works superbly but I believe the heap is being corrupted. I am so impressed with libspecbleach that I'm spending considerable time trying to try this down. Available via e-mail as simon@sdr-radio.com .

SimonG4ELI commented 2 years ago

Same problem with 32-bit. My audio sample rates are 8k and 24k. I can initialise then free, that is OK, But if I initialise, run then free my heap is corrupted.

SimonG4ELI commented 2 years ago

FWIW this may be my code, I'll let you know if I can't fix it.

lucianodato commented 2 years ago

Hey Simon! Many thanks for your input. The issue has been reported already. I'm dealing with it as fast as I can. Checkout the dev branch if you are interested in the latest changes. Also as you remarked in the other issue let me know if any code documentation is not clear. This is my first c lib so no expert here.

SimonG4ELI commented 2 years ago

Ah - I thought I had seen a reference to a memory issue but couldn't find it. The problem is still present with the development branch. The reduction is excellent, it'll be great when you find this problem. As for documentation - smoothing factor and noise rescale aren't clear to me. I can't find documentation for these.

lucianodato commented 2 years ago

Hey Simon! Sorry for the long delay but I think I've got it now. Would you mind testing current master? Also I've written better explanation on the header file for the parameters. Let me know if that clarifies your questions.

SimonG4ELI commented 2 years ago

Hi,

Thanks - will test early tomorrow morning and let you know.

SimonG4ELI commented 2 years ago

Hi,

No - the processing in specbleach_adaptive_process() is corrupting the heap somewhere. This doesn't cause a crash, but the heap check when running in debug mode generates diagnostics. I'll maybe step through the code myself, it could also be a Windows thing with the compilation.

The noise reduction is excellent.

lucianodato commented 2 years ago

You are right and actually looking at my meson command in my tasks I found that I had not enable all warnings and from what I've looked quickly there's some stuff that I need to fix. No need to dig the code. I'll let you know soon.

SimonG4ELI commented 2 years ago

OK, great. I'll get a video on my website today showing your code cleaning up shortwave transmissions.

SimonG4ELI commented 2 years ago

So,

What I'll do in a few days is add diagnostics and bound checks:

lucianodato commented 2 years ago

@SimonG4ELI Ok so the issue is basically that whenever you use different samplerates that are less than 20k in their nyquist the critical bands are trying to use the full spectrum which is not available. My bad in not testing with lowersample rates. I'm going to include some heuristics to consider these special cases. Sorry for all the trouble and thanks for the help!! Will keep you posted here,,,

SimonG4ELI commented 2 years ago

Hi,

I can always resample to 48k but would appreciate some work for 8k sample rates as this is the one I use most. As this is live audio I'm always running adaptively. Anything you can do is really appreciated, many thanks for this excellent software.

lucianodato commented 2 years ago

Hi,

I can always resample to 48k but would appreciate some work for 8k sample rates as this is the one I use most. As this is live audio I'm always running adaptively. Anything you can do is really appreciated, many thanks for this excellent software.

Not at all, actually this is not a big deal to fix. I think I've already got it. It is uploaded to the development branch if you want to give it a quick test. I'm very glad that you find it useful

lucianodato commented 2 years ago

I've tried 8k, 16k, 44.1k, 48k and 96k and all seem to be working but let me know your findings

SimonG4ELI commented 2 years ago

I've tried 8k, 16k, 44.1k, 48k and 96k and all seem to be working but let me know your findings

Looks good, no problem with my sample rates.

lucianodato commented 2 years ago

Should I mark this as resolved and do a release?

SimonG4ELI commented 2 years ago

Yes, works 100%