Преглед на файлове

Don't use make threads by default. Change install script to accommodate rnnoise submodule.

Luciano Dato преди 7 години
родител
ревизия
d4c243ecda
променени са 5 файла, в които са добавени 49 реда и са изтрити 42 реда
  1. 0 0
      .gitmodules
  2. 17 31
      install.sh
  3. 13 3
      lv2ttl/sdenoise.ttl
  4. 19 5
      src/sdenoise.c
  5. 0 3
      static_rnnoise.sh

+ 0 - 0
.gitmodules


+ 17 - 31
install.sh

@@ -12,39 +12,25 @@ case $OS in
   *) ;;
 esac
 
-#Remove static rnnoise build
-if [ -d rnnoise ]; then
-    read -p "Do you want to remove previous rnnoise build? (y/n)?" choice
-    case "$choice" in 
-    y|Y ) rm -rf rnnoise && echo "Previous rnnoise build removed";;
-    n|N ) echo "Previous rnnoise build was not removed";;
-    * ) echo "invalid";;
-    esac
+#build rrnoise statically
+git submodule init
+git config submodule.rnnoise.url "rnnoise"
+git submodule update
+cd rnnoise
+git submodule sync
+./autogen.sh
+mv ../ltmain.sh ./ && ./autogen.sh #This is weird but otherwise it won't work (Related to bug #24 in rnnoise)
+
+if [ $OS = "Mac" ]; then
+    CFLAGS="-fvisibility=hidden -fPIC " \ 
+    ./configure --disable-examples --disable-doc --disable-shared --enable-static        
+elif [ $OS = "Linux" ]; then
+    CFLAGS="-fvisibility=hidden -fPIC -Wl,--exclude-libs,ALL" \
+    ./configure --disable-examples --disable-doc --disable-shared --enable-static
 fi
 
-#only rebuild rnnoise if the user prefers to
-if [ ! -d rnnoise ]; then
-    #build rrnoise statically
-    wget https://github.com/xiph/rnnoise/archive/master.zip
-    # When using git or submodule to get rnnoise, the directory will be called
-    # rnnoise, but when using the zip it will be rnnoise-master. Renaming to
-    # rnnoise to keep unity.
-    unzip -o master.zip && mv rnnoise-master rnnoise && rm master.zip
-    cd rnnoise && ./autogen.sh
-    mv ../ltmain.sh ./ && ./autogen.sh #This is weird but otherwise it won't work
-
-    if [ $OS = "Mac" ]; then
-        CFLAGS="-fvisibility=hidden -fPIC " \ 
-        ./configure --disable-examples --disable-doc --disable-shared --enable-static        
-    elif [ $OS = "Linux" ]; then
-        CFLAGS="-fvisibility=hidden -fPIC -Wl,--exclude-libs,ALL" \
-        ./configure --disable-examples --disable-doc --disable-shared --enable-static
-    fi
-
-    # Perhaps best to remove j? Or do:
-    make -j$(nproc)
-    cd ..
-fi
+make
+cd ..
 
 #remove previous builds
 rm -rf build || true

+ 13 - 3
lv2ttl/sdenoise.ttl

@@ -33,10 +33,20 @@
     lv2:portProperty lv2:toggled, pprop:notOnGUI;
     lv2:designation <http://ardour.org/lv2/processing#enable>;
   ], [
+    a lv2:InputPort,
+      lv2:ControlPort ;
+    lv2:name "Mix" ;
+    lv2:index 1 ;
+    lv2:symbol "mix" ;
+    lv2:minimum 0.0 ;
+    lv2:maximum 100.0 ;
+    lv2:default 70.0 ;
+    units:unit units:pc ;
+  ], [
     a lv2:OutputPort,
       lv2:ControlPort ;
     lv2:name "latency" ;
-    lv2:index 1 ;
+    lv2:index 2 ;
     lv2:symbol "latency" ;
     lv2:minimum 0 ;
     lv2:maximum 8192 ;
@@ -45,13 +55,13 @@
   ], [
     a lv2:AudioPort,
       lv2:InputPort ;
-    lv2:index 2 ;
+    lv2:index 3 ;
     lv2:symbol "input" ;
     lv2:name "Input" ;
   ], [
     a lv2:AudioPort,
       lv2:OutputPort ;
-    lv2:index 3 ;
+    lv2:index 4 ;
     lv2:symbol "output" ;
     lv2:name "Output" ;
   ];

+ 19 - 5
src/sdenoise.c

@@ -51,9 +51,10 @@ along with this program.  If not, see <http://www.gnu.org/licenses/
 typedef enum
 {
 	NREPEL_ENABLE = 0,
-	NREPEL_LATENCY = 1,
-	NREPEL_INPUT = 2,
-	NREPEL_OUTPUT = 3,
+	NREPEL_MIX = 1,
+	NREPEL_LATENCY = 2,
+	NREPEL_INPUT = 3,
+	NREPEL_OUTPUT = 4,
 } PortIndex;
 
 /**
@@ -68,6 +69,7 @@ typedef struct
 	//Parameters for the algorithm (user input)
 	float* enable; //For soft bypass (click free bypass)
 	float* report_latency; //Latency necessary
+	float* mix; //Mix between wet and dry signal
 
 	//Parameters values for RNNoise libray
 	int frame_size; //RNNOISE frame input size
@@ -84,6 +86,7 @@ typedef struct
 	float* out_fifo; //internal output buffer
 	float* rnnoise_input_frame;
 	float* rnnoise_output_frame;
+	float* processed_frame;
 	int read_ptr; //buffers read pointer
 
 } SDenoise;
@@ -110,6 +113,7 @@ instantiate(const LV2_Descriptor* descriptor, double rate, const char* bundle_pa
 	self->out_fifo = (float*)calloc(self->frame_size, sizeof(float));
 	self->rnnoise_input_frame = (float*)calloc(self->frame_size, sizeof(float));
 	self->rnnoise_output_frame = (float*)calloc(self->frame_size, sizeof(float));
+	self->processed_frame = (float*)calloc(self->frame_size, sizeof(float));
 	self->input_latency = self->frame_size;
 	self->read_ptr = 0; //the initial position because we are that many samples ahead
 
@@ -133,6 +137,9 @@ connect_port(LV2_Handle instance, uint32_t port, void* data)
 		case NREPEL_ENABLE:
 		self->enable = (float*)data;
 		break;
+		case NREPEL_MIX:
+		self->mix = (float*)data;
+		break;
 		case NREPEL_LATENCY:
 		self->report_latency = (float*)data;
 		break;
@@ -211,16 +218,23 @@ run(LV2_Handle instance, uint32_t n_samples)
 				//Scaling down to float values
 				for (k = 0; k < self->frame_size; k++)
 				{
-					self->rnnoise_input_frame[k] = self->rnnoise_output_frame[k] / SHRT_MAX;
+					self->rnnoise_input_frame[k] = self->rnnoise_input_frame[k] / SHRT_MAX;
+					self->rnnoise_output_frame[k] = self->rnnoise_output_frame[k] / SHRT_MAX;
 				}
 			}
 
 			//-----------------------------------
 
+			//Mix wet and dry signal using the parameter
+			for (k = 0; k < self->frame_size; k++)
+			{
+				self->processed_frame[k] = (1.f - (*(self->mix) / 100.f)) * self->rnnoise_input_frame[k] + (*(self->mix) / 100.f) * self->rnnoise_output_frame[k];
+			}
+
 			//Output processed samples from RNNoise to output fifo considering soft bypass
 			for (k = 0; k < self->frame_size; k++)
 			{
-				self->out_fifo[k] = (1.f - self->wet_dry) * self->in_fifo[k] + self->wet_dry * self->rnnoise_input_frame[k];
+				self->out_fifo[k] = (1.f - self->wet_dry) * self->in_fifo[k] + self->wet_dry * self->processed_frame[k];
 			}
 
 			//-------------------------------

+ 0 - 3
static_rnnoise.sh

@@ -1,8 +1,5 @@
 #!/usr/bin/env bash
 
-# No need for these with submodule
-# rm -rf rnnoise || true
-# git clone https://github.com/xiph/rnnoise.git
 cd rnnoise/
 ./autogen.sh
 mv ../ltmain.sh ./ && ./autogen.sh # Dang, what with this thing