Skip to content

Commit 4d2a939

Browse files
authored
Add rnnoise module for background noise reduction (#1249)
* Add rnnoise module for background noise reduction * Update workflows for rnnoise * Improve link_rnnoise to have zero delay * Resolve review comments
1 parent 8631c07 commit 4d2a939

14 files changed

Lines changed: 1182 additions & 9 deletions

.github/workflows/build-distros.yml

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,42 +35,79 @@ jobs:
3535
sed -i 's/^Types: deb/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources
3636
DEBIAN_FRONTEND=noninteractive apt-get -qq update
3737
DEBIAN_FRONTEND=noninteractive apt-get -yqq build-dep mlt
38-
DEBIAN_FRONTEND=noninteractive apt-get -yqq install cmake qt6-base-dev libqt6svg6-dev
38+
DEBIAN_FRONTEND=noninteractive apt-get -yqq install autoconf automake git libtool pkg-config wget cmake qt6-base-dev libqt6svg6-dev
39+
git clone --depth 1 --branch v0.2 https://github.com/xiph/rnnoise.git /tmp/rnnoise
40+
cd /tmp/rnnoise
41+
./autogen.sh
42+
./configure --prefix=/usr/local --enable-shared --disable-static
43+
make -j"$(nproc)"
44+
make install
3945
- name: ubuntu-24.04
4046
image: ubuntu:24.04
4147
setup_script: |
4248
sed -i 's/^Types: deb/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources
4349
DEBIAN_FRONTEND=noninteractive apt-get -qq update
4450
DEBIAN_FRONTEND=noninteractive apt-get -yqq build-dep mlt
45-
DEBIAN_FRONTEND=noninteractive apt-get -yqq install cmake qt6-base-dev libqt6svg6-dev
51+
DEBIAN_FRONTEND=noninteractive apt-get -yqq install autoconf automake git libtool pkg-config wget cmake qt6-base-dev libqt6svg6-dev
52+
git clone --depth 1 --branch v0.2 https://github.com/xiph/rnnoise.git /tmp/rnnoise
53+
cd /tmp/rnnoise
54+
./autogen.sh
55+
./configure --prefix=/usr/local --enable-shared --disable-static
56+
make -j"$(nproc)"
57+
make install
4658
- name: ubuntu-22.04
4759
image: ubuntu:22.04
4860
setup_script: |
4961
sed -i '/^#\sdeb-src /s/^#//' "/etc/apt/sources.list"
5062
DEBIAN_FRONTEND=noninteractive apt-get -qq update
5163
DEBIAN_FRONTEND=noninteractive apt-get -yqq build-dep mlt
52-
DEBIAN_FRONTEND=noninteractive apt-get -yqq install cmake qt6-base-dev libqt6svg6-dev libqt6core5compat6-dev
64+
DEBIAN_FRONTEND=noninteractive apt-get -yqq install autoconf automake git libtool pkg-config wget cmake qt6-base-dev libqt6svg6-dev libqt6core5compat6-dev
65+
git clone --depth 1 --branch v0.2 https://github.com/xiph/rnnoise.git /tmp/rnnoise
66+
cd /tmp/rnnoise
67+
./autogen.sh
68+
./configure --prefix=/usr/local --enable-shared --disable-static
69+
make -j"$(nproc)"
70+
make install
5371
- name: debian-unstable
5472
image: debian:unstable
5573
setup_script: |
5674
echo 'deb-src http://deb.debian.org/debian unstable main' >> /etc/apt/sources.list
5775
apt-get -qq update
5876
apt-get -yqq build-dep mlt
77+
apt-get -yqq install autoconf automake git libtool pkg-config wget
78+
git clone --depth 1 --branch v0.2 https://github.com/xiph/rnnoise.git /tmp/rnnoise
79+
cd /tmp/rnnoise
80+
./autogen.sh
81+
./configure --prefix=/usr/local --enable-shared --disable-static
82+
make -j"$(nproc)"
83+
make install
5984
- name: debian-testing
6085
image: debian:testing
6186
setup_script: |
6287
echo 'deb-src http://deb.debian.org/debian testing main' >> /etc/apt/sources.list
6388
apt-get -qq update
6489
apt-get -yqq build-dep mlt
65-
apt-get -yqq install cmake qt6-base-dev libqt6svg6-dev
90+
apt-get -yqq install autoconf automake git libtool pkg-config wget cmake qt6-base-dev libqt6svg6-dev
91+
git clone --depth 1 --branch v0.2 https://github.com/xiph/rnnoise.git /tmp/rnnoise
92+
cd /tmp/rnnoise
93+
./autogen.sh
94+
./configure --prefix=/usr/local --enable-shared --disable-static
95+
make -j"$(nproc)"
96+
make install
6697
- name: debian-stable
6798
image: debian:stable
6899
setup_script: |
69100
echo 'deb-src http://deb.debian.org/debian stable main\ndeb-src http://deb.debian.org/debian stable-updates main' >> /etc/apt/sources.list
70101
echo 'deb http://deb.debian.org/debian bookworm-backports main' >> /etc/apt/sources.list
71102
apt-get -qq update
72103
apt-get -yqq build-dep mlt
73-
apt-get -yqq install cmake qt6-base-dev libqt6svg6-dev
104+
apt-get -yqq install autoconf automake git libtool pkg-config wget cmake qt6-base-dev libqt6svg6-dev
105+
git clone --depth 1 --branch v0.2 https://github.com/xiph/rnnoise.git /tmp/rnnoise
106+
cd /tmp/rnnoise
107+
./autogen.sh
108+
./configure --prefix=/usr/local --enable-shared --disable-static
109+
make -j"$(nproc)"
110+
make install
74111
- name: fedora-44
75112
image: fedora:44
76113
setup_script: |
@@ -83,7 +120,7 @@ jobs:
83120
libtheora-devel libvorbis-devel libvdpau-devel \
84121
libsoup-devel liboil-devel python-devel alsa-lib \
85122
pulseaudio-libs-devel gcc-c++ cmake ffmpeg-free-devel \
86-
movit-devel rubberband-devel vid.stab-devel
123+
movit-devel rubberband-devel vid.stab-devel rnnoise-devel
87124
- name: fedora-38
88125
image: fedora:38
89126
setup_script: |
@@ -96,7 +133,7 @@ jobs:
96133
libtheora-devel libvorbis-devel libvdpau-devel \
97134
libsoup-devel liboil-devel python-devel alsa-lib \
98135
pulseaudio-libs-devel gcc-c++ cmake ffmpeg-free-devel \
99-
movit-devel rubberband-devel vid.stab-devel
136+
movit-devel rubberband-devel vid.stab-devel rnnoise-devel
100137
101138
container:
102139
image: ${{ matrix.image }}

.github/workflows/build-linux.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ jobs:
3838
sudo sed -i '/^#\sdeb-src /s/^#//' "/etc/apt/sources.list"
3939
sudo apt-get -qq update
4040
sudo apt-get -yqq build-dep mlt
41-
sudo apt-get -yqq install qt6-base-dev libqt6svg6-dev libqt6core5compat6-dev
41+
sudo apt-get -yqq install autoconf automake git libtool pkg-config wget qt6-base-dev libqt6svg6-dev libqt6core5compat6-dev
42+
git clone --depth 1 --branch v0.2 https://github.com/xiph/rnnoise.git /tmp/rnnoise
43+
pushd /tmp/rnnoise
44+
./autogen.sh
45+
./configure --prefix=/usr/local --enable-shared --disable-static
46+
make -j"$(nproc)"
47+
sudo make install
48+
popd
4249
sudo apt-get -yqq install cmake ninja-build kwalify
4350
cmake -D CMAKE_BUILD_TYPE=Debug -D BUILD_TESTING=ON -D SWIG_PYTHON=ON -S . -B build -G Ninja
4451
cmake --build build

.github/workflows/build-msys2-mingw64.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ jobs:
6565
- name: Build C/C++ with CMake
6666
shell: msys2 {0}
6767
run: |
68+
git clone --depth 1 --branch v0.2 https://github.com/xiph/rnnoise.git /tmp/rnnoise
69+
pushd /tmp/rnnoise
70+
./autogen.sh
71+
./configure --prefix=/mingw64 --enable-shared --disable-static
72+
make -j"$(nproc)"
73+
make install
74+
popd
6875
cmake -D CMAKE_BUILD_TYPE=Debug -D MOD_MOVIT=OFF -D SWIG_PYTHON=ON -S . -B build -G Ninja
6976
cmake --build build
7077
cmake --install build

.github/workflows/static-code-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
sudo apt-get -yqq install clang-format-14
3636
- name: Run CMake
3737
run: |
38-
cmake -S . -B build -D CLANG_FORMAT=ON -D MOD_SDL2=OFF -D MOD_QT6=OFF -D MOD_AVFORMAT=OFF -D MOD_DECKLINK=OFF -D MOD_FREI0R=OFF -D MOD_GDK=OFF -D MOD_JACKRACK=OFF -D USE_LV2=OFF -D USE_VST2=OFF -D MOD_KDENLIVE=OFF -D MOD_NORMALIZE=OFF -D MOD_OLDFILM=OFF -D MOD_MOVIT=OFF -D MOD_PLUS=OFF -D MOD_PLUSGPL=OFF -D MOD_RESAMPLE=OFF -D MOD_RTAUDIO=OFF -D MOD_RUBBERBAND=OFF -D MOD_SOX=OFF -D MOD_VIDSTAB=OFF -D MOD_VORBIS=OFF -D MOD_XINE=OFF -D MOD_XML=OFF
38+
cmake -S . -B build -D CLANG_FORMAT=ON -D MOD_SDL2=OFF -D MOD_QT6=OFF -D MOD_AVFORMAT=OFF -D MOD_DECKLINK=OFF -D MOD_FREI0R=OFF -D MOD_GDK=OFF -D MOD_JACKRACK=OFF -D USE_LV2=OFF -D USE_VST2=OFF -D MOD_KDENLIVE=OFF -D MOD_NORMALIZE=OFF -D MOD_OLDFILM=OFF -D MOD_MOVIT=OFF -D MOD_PLUS=OFF -D MOD_PLUSGPL=OFF -D MOD_RESAMPLE=OFF -D MOD_RNNOISE=OFF -D MOD_RTAUDIO=OFF -D MOD_RUBBERBAND=OFF -D MOD_SOX=OFF -D MOD_VIDSTAB=OFF -D MOD_VORBIS=OFF -D MOD_XINE=OFF -D MOD_XML=OFF
3939
- name: Run clang-format
4040
run: |
4141
cd build

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ option(MOD_QT6 "Enable Qt6 module (GPL)" ON)
4040
option(MOD_RESAMPLE "Enable Resample module (GPL)" ON)
4141
option(MOD_RTAUDIO "Enable RtAudio module" ON)
4242
option(MOD_RUBBERBAND "Enable Rubberband module (GPL)" ON)
43+
option(MOD_RNNOISE "Enable RNNoise noise-reduction module" ON)
44+
if(WIN32 AND MSVC)
45+
set(MOD_RNNOISE OFF CACHE BOOL "Enable RNNoise noise-reduction module" FORCE)
46+
endif()
4347
option(MOD_SDL1 "Enable SDL1 module" OFF)
4448
option(MOD_SDL2 "Enable SDL2 module" ON)
4549
option(MOD_SOX "Enable SoX module" ON)
@@ -368,6 +372,11 @@ if(MOD_RUBBERBAND)
368372
list(APPEND MLT_SUPPORTED_COMPONENTS rubberband)
369373
endif()
370374

375+
if(MOD_RNNOISE)
376+
pkg_check_modules(rnnoise REQUIRED IMPORTED_TARGET rnnoise)
377+
list(APPEND MLT_SUPPORTED_COMPONENTS rnnoise)
378+
endif()
379+
371380
if(MOD_SDL1)
372381
pkg_check_modules(sdl REQUIRED IMPORTED_TARGET sdl)
373382
list(APPEND MLT_SUPPORTED_COMPONENTS sdl)
@@ -589,6 +598,7 @@ add_feature_info("Module: Qt6" MOD_QT6 "")
589598
add_feature_info("Module: Resample" MOD_RESAMPLE "")
590599
add_feature_info("Module: RtAudio" MOD_RTAUDIO "")
591600
add_feature_info("Module: Rubberband" MOD_RUBBERBAND "")
601+
add_feature_info("Module: RNNoise" MOD_RNNOISE "")
592602
add_feature_info("Module: SDL1" MOD_SDL1 "")
593603
add_feature_info("Module: SDL2" MOD_SDL2 "")
594604
add_feature_info("Module: SoX" MOD_SOX "")

CMakePresets.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"MOD_RESAMPLE": "ON",
3333
"MOD_RTAUDIO": "ON",
3434
"MOD_RUBBERBAND": "ON",
35+
"MOD_RNNOISE": "OFF",
3536
"MOD_SDL2": "ON",
3637
"MOD_SPATIALAUDIO": "OFF",
3738
"MOD_VIDSTAB": "OFF",

src/modules/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ if(MOD_RUBBERBAND)
7272
add_subdirectory(rubberband)
7373
endif()
7474

75+
if(MOD_RNNOISE)
76+
add_subdirectory(rnnoise)
77+
endif()
78+
7579
if(MOD_SDL1)
7680
add_subdirectory(sdl)
7781
endif()

src/modules/rnnoise/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
add_library(mltrnnoise MODULE factory.c filter_rnnoise.c link_rnnoise.c)
2+
3+
file(GLOB YML "*.yml")
4+
add_custom_target(Other_rnnoise_Files SOURCES ${YML})
5+
6+
include(GenerateExportHeader)
7+
generate_export_header(mltrnnoise)
8+
9+
target_compile_options(mltrnnoise PRIVATE ${MLT_COMPILE_OPTIONS})
10+
target_include_directories(mltrnnoise PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
11+
target_link_libraries(mltrnnoise PRIVATE mlt PkgConfig::rnnoise)
12+
13+
set_target_properties(mltrnnoise PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${MLT_MODULE_OUTPUT_DIRECTORY}")
14+
15+
install(TARGETS mltrnnoise LIBRARY DESTINATION ${MLT_INSTALL_MODULE_DIR})
16+
install(FILES filter_rnnoise.yml link_rnnoise.yml DESTINATION ${MLT_INSTALL_DATA_DIR}/rnnoise)

src/modules/rnnoise/factory.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* factory.c -- the factory method interfaces for the rnnoise module
3+
* Copyright (C) 2026 Meltytech, LLC
4+
*
5+
* This library is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU Lesser General Public
7+
* License as published by the Free Software Foundation; either
8+
* version 2.1 of the License, or (at your option) any later version.
9+
*
10+
* This library is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this library; if not, write to the Free Software
17+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18+
* 02110-1301 USA
19+
*/
20+
21+
#include "mltrnnoise_export.h"
22+
#include <framework/mlt.h>
23+
#include <limits.h>
24+
#include <string.h>
25+
26+
extern mlt_filter filter_rnnoise_init(mlt_profile profile,
27+
mlt_service_type type,
28+
const char *id,
29+
char *arg);
30+
extern mlt_link link_rnnoise_init(mlt_profile profile,
31+
mlt_service_type type,
32+
const char *id,
33+
char *arg);
34+
35+
static mlt_properties metadata(mlt_service_type type, const char *id, void *data)
36+
{
37+
char file[PATH_MAX];
38+
snprintf(file, PATH_MAX, "%s/rnnoise/%s", mlt_environment("MLT_DATA"), (char *) data);
39+
return mlt_properties_parse_yaml(file);
40+
}
41+
42+
MLTRNNOISE_EXPORT MLT_REPOSITORY
43+
{
44+
MLT_REGISTER(mlt_service_filter_type, "rnnoise", filter_rnnoise_init);
45+
MLT_REGISTER(mlt_service_link_type, "rnnoise", link_rnnoise_init);
46+
MLT_REGISTER_METADATA(mlt_service_filter_type, "rnnoise", metadata, "filter_rnnoise.yml");
47+
MLT_REGISTER_METADATA(mlt_service_link_type, "rnnoise", metadata, "link_rnnoise.yml");
48+
}

0 commit comments

Comments
 (0)