浏览代码

Fix glitch sound when bypassing. Adding the option to preserve rrnoise build to avoid downloading every time while developing.

Luciano Dato 7 年之前
父节点
当前提交
fb9a966b4c
共有 2 个文件被更改,包括 32 次插入24 次删除
  1. 30 21
      install.sh
  2. 2 3
      src/sdenoise.c

+ 30 - 21
install.sh

@@ -12,25 +12,38 @@ case $OS in
   *) ;;
 esac
 
-#remove previous builds
-rm -rf build || true
+#Remove static rnnoise build
+if [ -d rnnoise-master ]; then
+    read -p "Do you want to remove previous rnnoise build? (y/n)?" choice
+    case "$choice" in 
+    y|Y ) rm -rf rnnoise-master && echo "Previous rnnoise build removed";;
+    n|N ) echo "Previous rnnoise build was not removed";;
+    * ) echo "invalid";;
+    esac
+fi
 
-#build rrnoise statically
-wget https://github.com/xiph/rnnoise/archive/master.zip
-unzip -o master.zip && rm master.zip
-cd rnnoise-master && ./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
+#only rebuild rnnoise if the user prefers to
+if [ ! -d rnnoise-master ]; then
+    #build rrnoise statically
+    wget https://github.com/xiph/rnnoise/archive/master.zip
+    unzip -o master.zip && rm master.zip
+    cd rnnoise-master && ./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
+
+    make -j2
+    cd ..
 fi
 
-make -j2
-cd ..
+#remove previous builds
+rm -rf build || true
 
 #build the plugin in the new directory
 if [ $OS = "Linux" ]; then
@@ -43,8 +56,4 @@ cd build
 ninja -v
 
 #install the plugin in the system
-sudo ninja install
-
-#Remove static rnnoise build
-cd ..
-rm -rfv rnnoise-master
+sudo ninja install

+ 2 - 3
src/sdenoise.c

@@ -211,8 +211,7 @@ run(LV2_Handle instance, uint32_t n_samples)
 				//Scaling down to float values
 				for (k = 0; k < self->frame_size; k++)
 				{
-					self->rnnoise_output_frame[k] /= SHRT_MAX;
-					self->rnnoise_input_frame[k] /= SHRT_MAX;
+					self->rnnoise_input_frame[k] = self->rnnoise_output_frame[k] / SHRT_MAX;
 				}
 			}
 
@@ -221,7 +220,7 @@ run(LV2_Handle instance, uint32_t n_samples)
 			//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->rnnoise_input_frame[k] + self->wet_dry*self->rnnoise_output_frame[k];
+				self->out_fifo[k] = (1.f - self->wet_dry) * self->in_fifo[k] + self->wet_dry * self->rnnoise_input_frame[k];
 			}
 
 			//-------------------------------