Skip to content

Commit

Permalink
Add LADSPA support, add instructions for linux, fix compilation on li…
Browse files Browse the repository at this point in the history
…nux.

- Add LADSPA support to load plugin into pulseaudio.
- Add instructions for working with pulseaudio.
- Fix compilation on linux.
- Updated readme.
  • Loading branch information
werman committed Feb 21, 2018
1 parent ec67b2c commit 4a3d557
Show file tree
Hide file tree
Showing 17 changed files with 1,813 additions and 23 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ add_subdirectory(src/rnnoise)
add_subdirectory(src/common)
add_subdirectory(src/vst_plugin)
add_subdirectory(src/lv2_plugin)
add_subdirectory(src/ladspa_plugin)
61 changes: 52 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# VST Noise Suppression Plugin
# Real-time Noise Suppression Plugin (VST2, LV2, LADSPA)

A real-time noise suppression VST and LV2 plugin for voice based on [Xiph's RNNoise](https://github.com/xiph/rnnoise). [More info about the base library](https://people.xiph.org/~jm/demo/rnnoise/).
A real-time noise suppression plugin for voice based on [Xiph's RNNoise](https://github.com/xiph/rnnoise). [More info about the base library](https://people.xiph.org/~jm/demo/rnnoise/).

## About

Expand All @@ -12,32 +12,75 @@ The plugin is made to work with 1 channel, 16 bit, 48000 Hz audio input. Other s

## How-to

### Windows + Equalizer APO
### Windows + Equalizer APO (VST2)

To check or change mic settings go to "Recording devices" -> "Recording" -> "Properties" of the target mic -> "Advanced".

To enable the plugin in Equalizer APO select "Plugins" -> "VST Plugin" and specify the plugin dll.

### Linux

Testing required.
#### Pulseaudio

The idea is:

- Create a sink from which apps will take audio later and which will be the end think in the chain.
- Load the plugin which outputs to already created sink ('sink_master' parameter) and has input sink ('sink_name' parameter, sink will be created).
- Create loopback from microphone ('source') to input sink of plugin ('sink') with 1 channel.


```
pacmd load-module module-null-sink sink_name=mic_denoised_out
pacmd load-module module-ladspa-sink sink_name=mic_raw_in sink_master=mic_denoised_out label=noise_suppressor plugin=librnnoise_ladspa_x64.so
pacmd load-module module-loopback source=your_mic_name sink=mic_raw_in channels=1
```

This should be executed every time pulse audio is launched. This can be done by creating file in ~/.config/pulse/default.pa with:

```
.include /etc/pulse/default.pa
load-module module-null-sink sink_name=mic_denoised_out
load-module module-ladspa-sink sink_name=mic_raw_in sink_master=mic_denoised_out label=noise_suppressor plugin=librnnoise_ladspa_x64.so
load-module module-loopback source=your_mic_name sink=mic_raw_in channels=1
set-default-source mic_denoised_out.monitor
```

Your mic name can be found by:

```
pacmd list-sources
```

You may still need to set correct input for application, this can be done in audio mixer panel (if you have one) in 'Recording' tab where you should set 'Monitor of Null Output' as source.

Useful detailed info about pulseaudio logic [toadjaune/pulseaudio-config](https://github.com/toadjaune/pulseaudio-config).

The [thread](https://bugs.freedesktop.org/show_bug.cgi?id=101043) which helped me with how to post-process mic output and make it available to applications.

## Status

The plugin is tested with Equalizer APO v1.2 x64 (open source system-wide equalizer for Windows). It is a minimal proof-of-concept work.
The plugin is tested with Equalizer APO v1.2 x64 (open source system-wide equalizer for Windows) and tested with pulse audio on arch linux.

I'm not associated with the original work in any way and have only superficial understanding of it. The original author will probably create something better out of their work but for now I don't see any analogs with similar capabilities so I have created a usable one.

## Developing

The plugin is built with gcc in mingw environment for x32 and x64 architectures, the current cmake project is made for such environment and may need changes in order to support other ones.

VST sdk files aren't shipped here due to their license. You need to download VST sdk and copy several files to src/pluginterfaces/vst2.x/ and to src/vst2.x/. You can find sdk [here](https://www.steinberg.net/en/company/developers.html).

LV2 sdk files are
LV2 and LADSPA sdk files are in repository.

All improvements are welcomed!

## ☑ TODO

- [X] Create LV2 plugin.
- [X] Create LV2 plugin. (Untested)
- [X] Create LADSPA plugin.
- [X] Create correct setup with pulseaudio.
- [ ] Create package for linux distros (I don't here experience here so help is highly appreciated).
- [ ] Try to train the net with data for specific cases and see if will do better for them.

## License
Expand Down
2 changes: 2 additions & 0 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ project(RnNoisePluginCommon LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 14)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(COMMON_SRC
include/common/RnNoiseCommonPlugin.h
src/RnNoiseCommonPlugin.cpp)
Expand Down
42 changes: 42 additions & 0 deletions src/ladspa_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
cmake_minimum_required(VERSION 3.6)
project(rnnoise_ladspa_plugin LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 14)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

include_directories(${CMAKE_CURRENT_SOURCE_DIR})

set(PROJECT_ROOT ../../../)

set(LADSPA_INTERFACE_SRC
ladspa.h
ladspa++.h)

set(LADSPA_IMPL_SRC
RnNoiseLadspaPlugin.h
RnNoiseLadspaPlugin.cpp)

set(LADSPA_PLUGIN_SOURCES
${LADSPA_INTERFACE_SRC}
${LADSPA_IMPL_SRC})

function(build bit)
set(LADSPA_TARGET_X${bit} rnnoise_ladspa_x${bit})

add_library(${LADSPA_TARGET_X${bit}} SHARED ${LADSPA_PLUGIN_SOURCES})

target_link_libraries(${LADSPA_TARGET_X${bit}} RnNoisePluginCommon "-static-libgcc -static-libstdc++ -m${bit}")

set(X${bit}_COMPILE_OPTIONS
"-m${bit};"
"$<$<CONFIG:RELEASE>:-O3;>")

target_compile_options(${LADSPA_TARGET_X${bit}} PRIVATE ${X${bit}_COMPILE_OPTIONS})

set_target_properties(${LADSPA_TARGET_X${bit}} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_ROOT}/bin/x${bit}/ladspa")
endfunction()

build(32)
build(64)
2 changes: 2 additions & 0 deletions src/ladspa_plugin/RnNoiseLadspaPlugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "RnNoiseLadspaPlugin.h"

65 changes: 65 additions & 0 deletions src/ladspa_plugin/RnNoiseLadspaPlugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#pragma once

#include "ladspa++.h"
#include "common/RnNoiseCommonPlugin.h"

using namespace ladspa;

struct RnNoise {
enum class port_names {
in_1,
out_1,
size
};

static constexpr port_info_t port_info[] =
{
port_info_common::audio_input,
port_info_common::audio_output,
port_info_common::final_port
};

static constexpr info_t info =
{
9354877, // unique id
"noise_suppressor",
properties::realtime,
"Noise Suppressor for Voice",
"werman",
"Removes wide range of noises from voice in real time, based on Xiph's RNNoise library.",
{"voice", "noise suppression", "de-noise"},
strings::copyright::gpl3,
nullptr // implementation data
};

RnNoise() {
m_rnNoisePlugin.init();
}

~RnNoise() {
m_rnNoisePlugin.deinit();
}

void run(port_array_t<port_names, port_info> &ports) {

const_buffer in_buffer = ports.get<port_names::in_1>();
buffer out_buffer = ports.get<port_names::out_1>();

m_rnNoisePlugin.process(in_buffer.data(), out_buffer.data(), in_buffer.size());
}

RnNoiseCommonPlugin m_rnNoisePlugin;
};

/*
* to be called by ladspa
*/

void _init() {}

void _fini() {}

const LADSPA_Descriptor *
ladspa_descriptor(plugin_index_t index) {
return collection<RnNoise>::get_ladspa_descriptor(index);
}
Loading

0 comments on commit 4a3d557

Please sign in to comment.