diff --git a/Delay.cpp b/Delay.cpp index fa0b4ea..00ee1dd 100644 --- a/Delay.cpp +++ b/Delay.cpp @@ -1,6 +1,8 @@ // Delay.cpp: implementation of the CDelay class. // ( also performs Hilbert Real to complex I/Q 3KHz filtering ) +#include + #include "Delay.h" #include "FilterTables.h" diff --git a/NoiseGen.cpp b/NoiseGen.cpp index a01a1a4..d5a9268 100644 --- a/NoiseGen.cpp +++ b/NoiseGen.cpp @@ -56,8 +56,13 @@ void NoiseGen::add_band_limited_noise(int bufsize, double *pInOut, double siggai m_queue_pos = HILBPFIR_LENGTH - 1; } else acc = noise[j]; - // Add BP filtered noise to signal - pInOut[i] = siggain * pInOut[i ++] + acc; + // Add BP filtered noise to signal. + // NB: this must not be written as pInOut[i] = ... pInOut[i++] ...: + // since C++17 the RHS (including i++) is sequenced BEFORE the + // left-hand subscript, so the store lands at pInOut[i+1] and + // destroys the next input sample before it is read. + pInOut[i] = siggain * pInOut[i] + acc; + ++ i; } } } diff --git a/Path.cpp b/Path.cpp index 7c5244a..006721a 100644 --- a/Path.cpp +++ b/Path.cpp @@ -1,6 +1,7 @@ #include "Path.h" #include +#include #define _USE_MATH_DEFINES #include