Skip to content

Commit

Permalink
FEAT(client): Restore RNNoise for version 0.2
Browse files Browse the repository at this point in the history
Reverted the merge which added ReNameNoise as an RNNoise replacement.
Added the git submodule from xiph/rnnoise after removing ReNameNoise.
Chose to go with rnnoise's `main` here.

Resolves #6395
Reverts #6364
  • Loading branch information
guillermofbriceno committed Oct 14, 2024
1 parent cb01bfa commit b4024b0
Show file tree
Hide file tree
Showing 15 changed files with 290 additions and 67 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
[submodule "3rdparty/speexdsp"]
path = 3rdparty/speexdsp
url = https://github.com/xiph/speexdsp.git
[submodule "3rdparty/rnnoise-src"]
path = 3rdparty/rnnoise-src
url = https://github.com/xiph/rnnoise.git
[submodule "3rdparty/FindPythonInterpreter"]
path = 3rdparty/FindPythonInterpreter
url = https://github.com/Krzmbrzl/FindPythonInterpreter.git
Expand All @@ -25,9 +28,6 @@
[submodule "3rdparty/cmake-compiler-flags"]
path = 3rdparty/cmake-compiler-flags
url = https://github.com/Krzmbrzl/cmake-compiler-flags.git
[submodule "3rdparty/renamenoise"]
path = 3rdparty/renamenoise
url = https://github.com/mumble-voip/ReNameNoise.git
[submodule "3rdparty/flag-icons"]
path = 3rdparty/flag-icons
url = https://github.com/lipis/flag-icons.git
Expand Down
1 change: 0 additions & 1 deletion 3rdparty/renamenoise
Submodule renamenoise deleted from 2a551a
74 changes: 74 additions & 0 deletions 3rdparty/rnnoise-build/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright 2005-2019 The Mumble Developers. All rights reserved.
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file at the root of the
# Mumble source tree or at <https://www.mumble.info/LICENSE>.

set(RNNOISE_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../rnnoise-src")

if(NOT EXISTS "${RNNOISE_SRC_DIR}/COPYING")
message(FATAL_ERROR
"${RNNOISE_SRC_DIR} was not found.\n"
"Please checkout the submodule:\n"
"git submodule update --init --recursive"
)
endif()

if(WIN32)
add_library(rnnoise SHARED)
set_target_properties(rnnoise PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
if(MINGW)
# Remove "lib" prefix.
set_target_properties(rnnoise PROPERTIES PREFIX "")
endif()
target_compile_definitions(rnnoise
PRIVATE
"WIN32"
"DLL_EXPORT"
)
else()
add_library(rnnoise STATIC)
endif()

target_compile_definitions(rnnoise PRIVATE "HAVE_CONFIG_H")

target_include_directories(rnnoise
PRIVATE SYSTEM
${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC SYSTEM
"${RNNOISE_SRC_DIR}/include"
"${RNNOISE_SRC_DIR}/src"
)

if(MSVC)
# Use malloc() and free() instead of variable length arrays (unsupported)
target_compile_definitions(rnnoise PRIVATE "USE_MALLOC")
# Define M_PI
target_compile_definitions(rnnoise PRIVATE "_USE_MATH_DEFINES")
endif()

add_custom_command(
OUTPUT
"${RNNOISE_SRC_DIR}/src/rnnoise_data.c"
"${RNNOISE_SRC_DIR}/src/rnnoise_data.h"
"${RNNOISE_SRC_DIR}/src/rnnoise_data_little.c"
"${RNNOISE_SRC_DIR}/src/rnnoise_data_little.h"

WORKING_DIRECTORY "${RNNOISE_SRC_DIR}"
COMMAND "${RNNOISE_SRC_DIR}/download_model.sh"
COMMENT "Downloading RNNoise model files"
)

target_sources(rnnoise PRIVATE
"${RNNOISE_SRC_DIR}/src/rnnoise_data.c"
"${RNNOISE_SRC_DIR}/src/rnnoise_tables.c"
"${RNNOISE_SRC_DIR}/src/rnn.c"
"${RNNOISE_SRC_DIR}/src/pitch.c"
"${RNNOISE_SRC_DIR}/src/nnet.c"
"${RNNOISE_SRC_DIR}/src/nnet_default.c"
"${RNNOISE_SRC_DIR}/src/parse_lpcnet_weights.c"
"${RNNOISE_SRC_DIR}/src/kiss_fft.c"
"${RNNOISE_SRC_DIR}/src/denoise.c"
"${RNNOISE_SRC_DIR}/src/celt_lpc.c"
)

target_disable_warnings(rnnoise)
122 changes: 122 additions & 0 deletions 3rdparty/rnnoise-build/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */

/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1

/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1

/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1

/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1

/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1

/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1

/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1

/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1

/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1

/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1

/* Define to the sub-directory where libtool stores uninstalled libraries. */
#define LT_OBJDIR ".libs/"

/* Enable assertions in code */
/* #undef OP_ENABLE_ASSERTIONS */

/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "[email protected]"

/* Define to the full name of this package. */
#define PACKAGE_NAME "rnnoise"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "rnnoise unknown"

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "rnnoise"

/* Define to the home page for this package. */
#define PACKAGE_URL ""

/* Define to the version of this package. */
#define PACKAGE_VERSION "unknown"

/* This is a build of the library */
#define RNNOISE_BUILD /**/

/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1

/* Define this if the compiler supports __attribute__((
ifelse([visibility("default")], , [visibility_default],
[visibility("default")]) )) */
#define SUPPORT_ATTRIBUTE_VISIBILITY_DEFAULT 1

/* Define this if the compiler supports the -fvisibility flag */
#define SUPPORT_FLAG_VISIBILITY 1

/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# define _ALL_SOURCE 1
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# define _POSIX_PTHREAD_SEMANTICS 1
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# define _TANDEM_SOURCE 1
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# define __EXTENSIONS__ 1
#endif


/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif

/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS */

/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */

/* Define to 1 if on MINIX. */
/* #undef _MINIX */

/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
/* #undef _POSIX_1_SOURCE */

/* Define to 1 if you need to in order for `stat' and other things to work. */
/* #undef _POSIX_SOURCE */

/* We need at least WindowsXP for getaddrinfo/freeaddrinfo */
/* #undef _WIN32_WINNT */

/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef inline */
#endif
1 change: 1 addition & 0 deletions 3rdparty/rnnoise-src
Submodule rnnoise-src added at d98345
16 changes: 8 additions & 8 deletions docs/dev/build-instructions/cmake_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ Use the bundled GSL version instead of looking for one on the system
Build the included version of nlohmann_json instead of looking for one on the system
(Default: ON)

### bundled-renamenoise
### bundled-rnnoise

Build the included version of ReNameNoise instead of looking for one on the system.
(Default: ${renamenoise})
Build the included version of RNNoise instead of looking for one on the system.
(Default: ${rnnoise})

### bundled-speex

Expand Down Expand Up @@ -189,16 +189,16 @@ Build support for custom Diffie-Hellman parameters.
Use Qt's text-to-speech system (part of the Qt Speech module) instead of Mumble's own OS-specific text-to-speech implementations.
(Default: OFF)

### renamenoise

Use ReNameNoise for machine learning noise reduction.
(Default: ON)

### retracted-plugins

Build redacted (outdated) plugins as well
(Default: OFF)

### rnnoise

Use RNNoise for machine learning noise reduction.
(Default: ON)

### server

Build the server (Murmur)
Expand Down
15 changes: 13 additions & 2 deletions installer/ClientInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
public struct Features {
public bool overlay;
public bool g15;
public bool rnnoise;
}

public class ClientInstaller : MumbleInstall {
Expand Down Expand Up @@ -86,11 +87,14 @@ public ClientInstaller(string version, string arch, Features features) {
// 64 bit
this.Platform = WixSharp.Platform.x64;
binaries = new List<string>() {
"renamenoise.dll",
"speexdsp.dll",
"mumble.exe",
};

if (features.rnnoise) {
binaries.Add("rnnoise.dll");
}

if (features.overlay) {
binaries.Add("mumble_ol.dll");
binaries.Add("mumble_ol_helper.exe");
Expand All @@ -105,11 +109,14 @@ public ClientInstaller(string version, string arch, Features features) {
// 32 bit
this.Platform = WixSharp.Platform.x86;
binaries = new List<string>() {
"renamenoise.dll",
"speexdsp.dll",
"mumble.exe",
};

if (features.rnnoise) {
binaries.Add("rnnoise.dll");
}

if (features.overlay) {
binaries.Add("mumble_ol.dll");
binaries.Add("mumble_ol_helper.exe");
Expand Down Expand Up @@ -214,6 +221,10 @@ public static void Main(string[] args) {
if (args[i] == "--overlay") {
features.overlay = true;
}

if (args[i] == "--rnnoise") {
features.rnnoise = true;
}
}

if (version != null && arch != null) {
Expand Down
26 changes: 13 additions & 13 deletions src/mumble/AudioConfigDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ AudioInputDialog::AudioInputDialog(Settings &st) : ConfigWidget(st) {
// Hide the slider by default
showSpeexNoiseSuppressionSlider(false);

#ifndef USE_RENAMENOISE
// Hide options related to ReNameNoise
qrbNoiseSupReNameNoise->setVisible(false);
#ifndef USE_RNNOISE
// Hide options related to RNNoise
qrbNoiseSupRNNoise->setVisible(false);
qrbNoiseSupBoth->setVisible(false);
#endif
}
Expand Down Expand Up @@ -143,12 +143,12 @@ void AudioInputDialog::load(const Settings &r) {
loadSlider(qsSpeexNoiseSupStrength, 14);
}

bool allowReNameNoise = SAMPLE_RATE == 48000;
bool allowRNNoise = SAMPLE_RATE == 48000;

if (!allowReNameNoise) {
if (!allowRNNoise) {
const QString tooltip = QObject::tr("RNNoise is not available due to a sample rate mismatch.");
qrbNoiseSupReNameNoise->setEnabled(false);
qrbNoiseSupReNameNoise->setToolTip(tooltip);
qrbNoiseSupRNNoise->setEnabled(false);
qrbNoiseSupRNNoise->setToolTip(tooltip);
qrbNoiseSupBoth->setEnabled(false);
qrbNoiseSupBoth->setToolTip(tooltip);
}
Expand All @@ -161,9 +161,9 @@ void AudioInputDialog::load(const Settings &r) {
loadCheckBox(qrbNoiseSupSpeex, true);
break;
case Settings::NoiseCancelRNN:
#ifdef USE_RENAMENOISE
if (allowReNameNoise) {
loadCheckBox(qrbNoiseSupReNameNoise, true);
#ifdef USE_RNNOISE
if (allowRNNoise) {
loadCheckBox(qrbNoiseSupRNNoise, true);
} else {
// We have to switch to speex as a fallback
loadCheckBox(qrbNoiseSupSpeex, true);
Expand All @@ -174,8 +174,8 @@ void AudioInputDialog::load(const Settings &r) {
#endif
break;
case Settings::NoiseCancelBoth:
#ifdef USE_RENAMENOISE
if (allowReNameNoise) {
#ifdef USE_RNNOISE
if (allowRNNoise) {
loadCheckBox(qrbNoiseSupBoth, true);
} else {
// We have to switch to speex as a fallback
Expand Down Expand Up @@ -233,7 +233,7 @@ void AudioInputDialog::save() const {
s.noiseCancelMode = Settings::NoiseCancelOff;
} else if (qrbNoiseSupBoth->isChecked()) {
s.noiseCancelMode = Settings::NoiseCancelBoth;
} else if (qrbNoiseSupReNameNoise->isChecked()) {
} else if (qrbNoiseSupRNNoise->isChecked()) {
s.noiseCancelMode = Settings::NoiseCancelRNN;
} else {
s.noiseCancelMode = Settings::NoiseCancelSpeex;
Expand Down
Loading

0 comments on commit b4024b0

Please sign in to comment.