Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #118

Open
wants to merge 12 commits into
base: DEVELOPMENT
Choose a base branch
from
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# noise-repellent
# noise-repellent-DEV-Efenstor-fork

A suite of lv2 plugins for noise reduction that uses [libspecbleach](https://github.com/lucianodato/libspecbleach) C library.
### This is the fixed development branch of the original noise-repellent, probably not quite stable but tested and useable.

[![build](https://github.com/lucianodato/noise-repellent/actions/workflows/build.yml/badge.svg)](https://github.com/lucianodato/noise-repellent/actions/workflows/build.yml)
A suite of lv2 plugins for noise reduction that uses [libspecbleach](https://github.com/lucianodato/libspecbleach) C library.

## Features

Expand All @@ -15,24 +15,20 @@ A suite of lv2 plugins for noise reduction that uses [libspecbleach](https://git

## Install

Binaries for most platforms are built using [PawPaw](https://github.com/DISTRHO/PawPaw) and provided with each Github release. Just extract the adequate zip file for your platform to your [lv2 plugins folder](https://lv2plug.in/pages/filesystem-hierarchy-standard.html)

If you wish to compile yourself and install this plug-in you will need the a C compiling toolchain, LV2 SDK, Meson build system, ninja compiler, git and libspecbleach library (if it doesn't find it it will download and compile it. In this case make sure to have libspecbleach dependencies installed).
To compile yourself and install this plug-in you will need the a C compiling toolchain, LV2 SDK, Meson build system, ninja compiler, git and libspecbleach library (if it doesn't find it it will download and compile it. In this case make sure to have libspecbleach dependencies installed).

Installation:

```bash
git clone https://github.com/lucianodato/noise-repellent.git
cd noise-repellent
meson build --buildtype=release --prefix=/usr --libdir=lib (your-os-appropriate-location-fullpath)
meson compile -C build -v
sudo meson install -C build
git clone https://github.com/Efenstor/noise-repellent-DEV-Efenstor-fork.git --branch=DEVELOPMENT
cd noise-repellent-DEV-Efenstor-fork
mkdir build
cd build
meson .. --buildtype=release
meson compile -v
sudo meson install
```

Noise-repellent is on Arch community at <https://www.archlinux.org/packages/community/x86_64/noise-repellent/>.

Noise-repellent is also available in KXStudios repositories <https://kx.studio/Repositories:Plugins>

## Use Instuctions

Please refer to project's wiki <https://github.com/lucianodato/noise-repellent/wiki>
3 changes: 3 additions & 0 deletions lv2ttl/nrepellent.ttl.in
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
lv2:default 10.0 ;
lv2:designation lv2:threshold ;
units:unit units:db ;
units:conversion [
units:to units:coef;
];
], [
a lv2:ControlPort,
lv2:InputPort ;
Expand Down
24 changes: 13 additions & 11 deletions plugins/nrepellent-adaptive.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ typedef enum PortIndex {
NOISEREPELLENT_POSTFILTER = 3,
NOISEREPELLENT_NOISE_SMOOTHING = 4,
NOISEREPELLENT_WHITENING = 5,
NOISEREPELLENT_RESIDUAL_LISTEN = 6,
NOISEREPELLENT_RESIDUAL_LISTEN = 6,
NOISEREPELLENT_ENABLE = 7,
NOISEREPELLENT_LATENCY = 8,
NOISEREPELLENT_INPUT_1 = 9,
Expand Down Expand Up @@ -133,7 +133,7 @@ static LV2_Handle instantiate(const LV2_Descriptor *descriptor,
return NULL;
}

if (strstr(descriptor->URI, NOISEREPELLENT_ADAPTIVE_URI)) {
if (!strcmp(descriptor->URI, NOISEREPELLENT_ADAPTIVE_STEREO_URI)) {
self->plugin_uri = (char *)calloc(
strlen(NOISEREPELLENT_ADAPTIVE_STEREO_URI) + 1, sizeof(char));
strcpy(self->plugin_uri, descriptor->URI);
Expand Down Expand Up @@ -161,7 +161,7 @@ static LV2_Handle instantiate(const LV2_Descriptor *descriptor,
return NULL;
}

if (strstr(self->plugin_uri, NOISEREPELLENT_ADAPTIVE_STEREO_URI)) {
if (!strcmp(self->plugin_uri, NOISEREPELLENT_ADAPTIVE_STEREO_URI)) {
self->lib_instance_2 =
specbleach_adaptive_initialize((uint32_t)self->sample_rate, FRAME_SIZE);

Expand Down Expand Up @@ -259,11 +259,12 @@ static void run(LV2_Handle instance, uint32_t number_of_samples) {

specbleach_adaptive_load_parameters(self->lib_instance_1, self->parameters);

specbleach_adaptive_process(self->lib_instance_1, number_of_samples,
self->input_1, self->output_1);
if(*self->enable)
specbleach_adaptive_process(self->lib_instance_1, number_of_samples,
self->input_1, self->output_1);

signal_crossfade_run(self->soft_bypass, number_of_samples, self->input_1,
self->output_1, (bool)*self->enable);
/*signal_crossfade_run(self->soft_bypass, number_of_samples, self->input_1,
self->output_1, (bool)*self->enable);*/
}

static void run_stereo(LV2_Handle instance, uint32_t number_of_samples) {
Expand All @@ -273,11 +274,12 @@ static void run_stereo(LV2_Handle instance, uint32_t number_of_samples) {

specbleach_adaptive_load_parameters(self->lib_instance_2, self->parameters);

specbleach_adaptive_process(self->lib_instance_2, number_of_samples,
self->input_2, self->output_2);
if(*self->enable)
specbleach_adaptive_process(self->lib_instance_2, number_of_samples,
self->input_2, self->output_2);

signal_crossfade_run(self->soft_bypass, number_of_samples, self->input_2,
self->output_2, (bool)*self->enable);
/*signal_crossfade_run(self->soft_bypass, number_of_samples, self->input_2,
self->output_2, (bool)*self->enable);*/
}

// clang-format off
Expand Down
52 changes: 17 additions & 35 deletions plugins/nrepellent.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static void map_uris(LV2_URID_Map *map, URIs *uris, const char *uri) {
}

static void map_state(LV2_URID_Map *map, State *state, const char *uri) {
if (!strcmp(uri, NOISEREPELLENT_URI)) {
if (!strcmp(uri, NOISEREPELLENT_STEREO_URI)) {
state->property_noise_profile_1 =
map->map(map->handle, NOISEREPELLENT_STEREO_URI "#noiseprofile");
state->property_noise_profile_2 =
Expand All @@ -71,7 +71,6 @@ static void map_state(LV2_URID_Map *map, State *state, const char *uri) {
map->map(map->handle, NOISEREPELLENT_STEREO_URI "#noiseprofilesize");
state->property_averaged_blocks = map->map(
map->handle, NOISEREPELLENT_STEREO_URI "#noiseprofileaveragedblocks");

} else {
state->property_noise_profile_1 =
map->map(map->handle, NOISEREPELLENT_URI "#noiseprofile");
Expand Down Expand Up @@ -193,15 +192,8 @@ static LV2_Handle instantiate(const LV2_Descriptor *descriptor,
return NULL;
}

if (strstr(descriptor->URI, NOISEREPELLENT_STEREO_URI)) {
self->plugin_uri =
(char *)calloc(strlen(NOISEREPELLENT_STEREO_URI) + 1U, sizeof(char));
strcpy(self->plugin_uri, descriptor->URI);
} else {
self->plugin_uri =
(char *)calloc(strlen(NOISEREPELLENT_URI) + 1U, sizeof(char));
strcpy(self->plugin_uri, descriptor->URI);
}
self->plugin_uri = (char *)calloc(strlen(descriptor->URI) + 1U, sizeof(char));
strcpy(self->plugin_uri, descriptor->URI);

map_uris(self->map, &self->uris, self->plugin_uri);
map_state(self->map, &self->state, self->plugin_uri);
Expand Down Expand Up @@ -231,7 +223,7 @@ static LV2_Handle instantiate(const LV2_Descriptor *descriptor,

self->noise_profile_1 = (float *)calloc(self->profile_size, sizeof(float));

if (strstr(self->plugin_uri, NOISEREPELLENT_STEREO_URI)) {
if (!strcmp(self->plugin_uri, NOISEREPELLENT_STEREO_URI)) {
self->lib_instance_2 =
specbleach_initialize((uint32_t)self->sample_rate, FRAME_SIZE);

Expand Down Expand Up @@ -296,18 +288,6 @@ static void connect_port(LV2_Handle instance, uint32_t port, void *data) {
case NOISEREPELLENT_OUTPUT_1:
self->output_1 = (float *)data;
break;
default:
break;
}
}

static void connect_port_stereo(LV2_Handle instance, uint32_t port,
void *data) {
NoiseRepellentPlugin *self = (NoiseRepellentPlugin *)instance;

connect_port(instance, port, data);

switch ((PortIndex)port) {
case NOISEREPELLENT_INPUT_2:
self->input_2 = (const float *)data;
break;
Expand Down Expand Up @@ -348,11 +328,12 @@ static void run(LV2_Handle instance, uint32_t number_of_samples) {
specbleach_reset_noise_profile(self->lib_instance_1);
}

specbleach_process(self->lib_instance_1, number_of_samples, self->input_1,
self->output_1);
if(*self->enable)
specbleach_process(self->lib_instance_1, number_of_samples, self->input_1,
self->output_1);

signal_crossfade_run(self->soft_bypass, number_of_samples, self->input_1,
self->output_1, (bool)*self->enable);
/*signal_crossfade_run(self->soft_bypass, number_of_samples, self->input_1,
self->output_1, (bool)*self->enable);*/
}

static void run_stereo(LV2_Handle instance, uint32_t number_of_samples) {
Expand All @@ -366,11 +347,12 @@ static void run_stereo(LV2_Handle instance, uint32_t number_of_samples) {
specbleach_reset_noise_profile(self->lib_instance_2);
}

specbleach_process(self->lib_instance_2, number_of_samples, self->input_2,
self->output_2);
if(*self->enable)
specbleach_process(self->lib_instance_2, number_of_samples, self->input_2,
self->output_2);

signal_crossfade_run(self->soft_bypass, number_of_samples, self->input_2,
self->output_2, (bool)*self->enable);
/*signal_crossfade_run(self->soft_bypass, number_of_samples, self->input_2,
self->output_2, (bool)*self->enable);*/
}

static LV2_State_Status save(LV2_Handle instance,
Expand Down Expand Up @@ -401,7 +383,7 @@ static LV2_State_Status save(LV2_Handle instance,
(void *)self->noise_profile_state_1, noise_profile_get_size(),
self->uris.atom_Vector, LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);

if (strstr(self->plugin_uri, NOISEREPELLENT_STEREO_URI)) {
if (!strcmp(self->plugin_uri, NOISEREPELLENT_STEREO_URI)) {
memcpy(noise_profile_get_elements(self->noise_profile_state_2),
specbleach_get_noise_profile(self->lib_instance_2),
sizeof(float) * self->profile_size);
Expand Down Expand Up @@ -449,7 +431,7 @@ static LV2_State_Status restore(LV2_Handle instance,
specbleach_load_noise_profile(self->lib_instance_1, self->noise_profile_1,
*fftsize, *averagedblocks);

if (strstr(self->plugin_uri, NOISEREPELLENT_STEREO_URI)) {
if (!strcmp(self->plugin_uri, NOISEREPELLENT_STEREO_URI)) {
const void *saved_noise_profile_2 = retrieve(
handle, self->state.property_noise_profile_2, &size, &type, &valflags);
if (!saved_noise_profile_2 || size != noise_profile_get_size() ||
Expand Down Expand Up @@ -490,7 +472,7 @@ static const LV2_Descriptor descriptor = {
static const LV2_Descriptor descriptor_stereo = {
NOISEREPELLENT_STEREO_URI,
instantiate,
connect_port_stereo,
connect_port,
activate,
run_stereo,
NULL,
Expand Down
2 changes: 1 addition & 1 deletion src/signal_crossfade.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ bool signal_crossfade_run(SignalCrossfade *self,
}

return true;
}
}
2 changes: 1 addition & 1 deletion src/signal_crossfade.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ SignalCrossfade *signal_crossfade_initialize(uint32_t sample_rate);
void signal_crossfade_free(SignalCrossfade *self);
bool signal_crossfade_run(SignalCrossfade *self, uint32_t number_of_samples,
const float *input, float *output, bool enable);
#endif
#endif