From 6acf45a909ed61d7168ef82f40b6c5ac68e39451 Mon Sep 17 00:00:00 2001 From: "J.A. de Jong - Redu-Sone B.V., ASCEE V.O.F" Date: Mon, 9 Mar 2020 15:49:25 +0100 Subject: [PATCH] Some minor fixes in siggen and ln to also work with (untested) 32-bit floats --- lasp/c/lasp_math_raw.h | 2 ++ lasp/c/lasp_siggen.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lasp/c/lasp_math_raw.h b/lasp/c/lasp_math_raw.h index 376aec6..c707cd7 100644 --- a/lasp/c/lasp_math_raw.h +++ b/lasp/c/lasp_math_raw.h @@ -35,6 +35,7 @@ #define d_cos cos #define d_pow pow #define d_log10 log10 +#define d_ln log #define d_epsilon (DBL_EPSILON) #else // LASP_DOUBLE_PRECISION not defined @@ -51,6 +52,7 @@ #define d_cos cosf #define d_pow powf #define d_log10 log10f +#define d_ln logf #define d_epsilon (FLT_EPSILON) #endif // LASP_DOUBLE_PRECISION diff --git a/lasp/c/lasp_siggen.c b/lasp/c/lasp_siggen.c index 7be2d56..2e07746 100644 --- a/lasp/c/lasp_siggen.c +++ b/lasp/c/lasp_siggen.c @@ -83,7 +83,7 @@ Siggen* Siggen_Noise_create(const d fs, const d level_dB, Sosfilterbank* colorfi fsTRACE(15); Siggen* noise = Siggen_create(NOISE, fs, level_dB); - dbgassert(sizeof(noiseSpecific) <= sizeof(noise->private_data), + dbgassert(sizeof(NoiseSpecific) <= sizeof(noise->private_data), "Allocated memory too small"); NoiseSpecific* wn = (NoiseSpecific*) noise->private_data; wn->phase = 0; @@ -264,9 +264,9 @@ static void noise_genSignal(Siggen* siggen, NoiseSpecific* wn, vd* samples) { S = V1 * V1 + V2 * V2; } while(S >= 1 || S == 0); - X = V1 * sqrt(-2 * d_log(S) / S); + X = V1 * sqrt(-2 * d_ln(S) / S); } else - X = V2 * sqrt(-2 * d_log(S) / S); + X = V2 * sqrt(-2 * d_ln(S) / S); phase = 1 - phase;