C library for audio noise reduction and other spectral effects
  • C 96.3%
  • Meson 3.2%
  • Shell 0.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Luciano Dato 52660fa1db
Overflow and null pointers fixes (#77)
* Overflow and null pointers fixes

* Addressing codecov issues

* Enhance actions to consider these issues in the future

* Addressing CI issues

* refactor: improve code readability and consistency by adding parentheses, `U` suffixes, and curly braces, and fixing a struct member access.

* Attempt to fix CI errors

* fix: pass sanitizer flags to linker for shared library and tests

The sanitizer flags (-fsanitize=address, -fsanitize=undefined) were only
being passed to the compiler, causing undefined reference errors for
ASan/UBSan runtime symbols during linking. This fix adds lib_link_args
to pass the same flags to the linker for both the shared library and
test executables.

* fix: disable clang-format for compound literal macro to avoid version differences

Different clang-format versions (14 on CI vs 21 locally) format the
relative_thresholds compound literal macro differently. Using clang-format
off/on comments ensures consistent behavior across all versions.

* test: add edge case tests for improved patch coverage

- Add NULL pointer and zero-size edge case tests to test_utils.c
- Add FFT edge case tests for NULL pointer handling
- Test BLACKMAN and VORBIS window types
- Fix lint warnings: add braces, cast M_PI to float

* Remove not needed comment
2026-01-20 20:51:09 +01:00
.github/workflows Overflow and null pointers fixes (#77) 2026-01-20 20:51:09 +01:00
examples refactor: Simplify header paths and rename denoiser parameter structs for clarity. (#74) 2026-01-05 21:14:28 +01:00
include refactor: Simplify header paths and rename denoiser parameter structs for clarity. (#74) 2026-01-05 21:14:28 +01:00
src Overflow and null pointers fixes (#77) 2026-01-20 20:51:09 +01:00
tests Overflow and null pointers fixes (#77) 2026-01-20 20:51:09 +01:00
.agents.md Overflow and null pointers fixes (#77) 2026-01-20 20:51:09 +01:00
.clang-format Start modernizing code (#57) 2025-12-17 22:17:38 +01:00
.clang-tidy Overflow and null pointers fixes (#77) 2026-01-20 20:51:09 +01:00
.clangd Start modernizing code (#57) 2025-12-17 22:17:38 +01:00
.editorconfig Start modernizing code (#57) 2025-12-17 22:17:38 +01:00
.gitignore Small refactors and correct post filter module to use a moving averag… (#67) 2025-12-26 22:45:47 +01:00
CHANGELOG.md build: configure library versioning and update project documentation (#63) 2025-12-21 12:01:19 +01:00
codecov.yml feat: Refine Codecov configuration by explicitly including source files and expanding ignore patterns for tests and examples 2025-12-19 14:15:55 +01:00
CONTRIBUTING.md Overflow and null pointers fixes (#77) 2026-01-20 20:51:09 +01:00
LICENSE Initial commit 2022-04-02 18:43:55 +02:00
meson.build Overflow and null pointers fixes (#77) 2026-01-20 20:51:09 +01:00
meson_options.txt feat: Add static_deps meson option and apply it to the fftw3f dep… (#72) 2026-01-03 13:50:24 +01:00
README.md feat: Add static_deps meson option and apply it to the fftw3f dep… (#72) 2026-01-03 13:50:24 +01:00

libspecbleach

build codecov License: LGPL v2.1

C library for audio noise reduction and other spectral effects

Table of Contents

Background

This library is based on the algorithms that were used in noise-repellent. These were extracted into a standalone library to remove the lv2 dependency. It was designed to be extensible and modular. It uses the concept of a spectral processor which itself uses a short time Fourier transform (STFT) to process the audio. There are two initial processors in place, one which uses the adaptive part of noise repellent and one that uses the manual capturing profile based denoising. The library could be extended with more spectral processors using any STFT-based algorithm such as de-crackle, de-click and other audio restoration algorithms.

De-noise Algorithms

There are several techniques implemented in the library that are being used in the denoisers, such as masking thresholds estimation, onset detectors, etc. All these are being used in conjunction to improve the very basic spectral subtraction algorithm. Most of the papers used are listed in the wiki of the project. Also a block diagram is provided to explain the reduction architecture.

Build

If you wish to compile yourself and install the library you will need:

  • A C compiling toolchain (GCC or Clang)
  • Meson build system (0.60.0 or newer)
  • Ninja build tool
  • FFTW3 library (float version)
  • libsndfile (optional, for examples)

Installation

git clone https://github.com/lucianodato/libspecbleach.git
cd libspecbleach
meson setup build --buildtype=release
meson compile -C build
sudo meson install -C build

Build Options

You can configure the build using -Doption=value:

  • enable_examples: Build example applications (default: false). Requires libsndfile.
  • enable_tests: Build unit and integration tests (default: false). Requires libsndfile.
  • static_deps: Link internal dependencies (like FFTW3) statically (default: false). Useful for creating self-contained libraries.
  • custom_warning_level: 0-3 (default: 2). Controls compiler warning verbosity.
  • treat_warnings_as_errors: Treat compiler warnings as errors (default: false).
  • enable_sanitizers: Enable sanitizers in debug builds (default: false).
  • sanitize_address: Enable AddressSanitizer (default: false).
  • sanitize_undefined: Enable UndefinedBehaviorSanitizer (default: false).

Example for a static build with examples:

meson setup build -Dstatic_deps=true -Denable_examples=true
meson compile -C build

Usage Examples

Simple console apps examples are provided to demonstrate how to use the library. It needs libsndfile to compile successfully. You can build them with:

meson setup build --buildtype=release -Denable_examples=true
meson compile -C build

Adaptive noise reduction

./build/example/adenoiser_demo <input file name> <output file name>

Manual noise reduction

./build/example/denoiser_demo <input file name> <output file name>

It will recognize any libsndfile supported format.

Development

Building for Development

For development builds with debugging symbols:

meson setup build --buildtype=debug
meson compile -C build

Code Formatting

The project uses clang-format for code formatting. To format the code:

meson compile format -C build

Running Tests

If tests are enabled:

meson setup build -Denable_tests=true
meson test -C build

Coverage

To generate coverage reports locally, you will need gcovr or lcov installed.

meson setup build --buildtype=debug -Db_coverage=true
meson compile -C build
meson test -C build
ninja -C build coverage-html

The report will be available in build/meson-logs/coveragereport/index.html.

License

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

See LICENSE for more details.