shithub: pt2-clone

Download patch

ref: 75aa4a93bffee44e010ebd8277752ed51752a4d9
parent: 6155437096ad7fd125b8cde49c1c344d7bb6f312
author: Olav Sørensen <olav.sorensen@live.no>
date: Sat Jul 4 11:39:11 EDT 2020

Prevent denormalized numbers in RC filter routine

--- a/src/pt2_audio.c
+++ b/src/pt2_audio.c
@@ -245,7 +245,11 @@
 // aciddose: input 0 is resistor side of capacitor (low-pass), input 1 is reference side (high-pass)
 static inline double getLowpassOutput(rcFilter_t *f, const double input_0, const double input_1, const double buffer)
 {
-	return buffer * f->g + input_0 * f->cg + input_1 * (1.0 - f->cg);
+	double dOutput = DENORMAL_OFFSET;
+
+	dOutput += buffer * f->g + input_0 * f->cg + input_1 * (1.0 - f->cg);
+
+	return dOutput;
 }
 
 void RCLowPassFilter(rcFilter_t *f, const double *in, double *out)
--- a/src/pt2_audio.h
+++ b/src/pt2_audio.h
@@ -4,8 +4,8 @@
 #include <stdbool.h>
 #include "pt2_header.h" // AMIGA_VOICES
 
-// adding this forces the FPU to enter slow mode
-#define DENORMAL_OFFSET 1e-10
+// adding this prevents denormalized numbers, which is slow
+#define DENORMAL_OFFSET 1e-15
 
 typedef struct rcFilter_t
 {
--- a/src/pt2_keyboard.c
+++ b/src/pt2_keyboard.c
@@ -30,7 +30,6 @@
 #include "pt2_config.h"
 #include "pt2_sampling.h"
 
-
 #if defined _WIN32 && !defined _DEBUG
 extern bool windowsKeyIsDown;
 extern HHOOK g_hKeyboardHook;