un-global noise variables

This commit is contained in:
maksw committed 2025-04-08 08:13:11 +02:00
1 parent 4078eacfbd
commit 1896471e1a
1 file changed
+3 -2
+3 -2
View File
@@ -8,8 +8,6 @@
const int SAMPLE_RATE = 44100;
const double M_TAU = 6.283185307179586476925286766559;
uint16_t lfsr = 0xACE1u;
unsigned bit;
// Enum for waveform types
enum Waveform {
@@ -253,6 +251,9 @@ double applyEnvelope(double time, double startTime, double duration, double volu
}
double noiseWave() {
static uint16_t lfsr = 0xACE1u;
static unsigned bit;
// 16-bit Galois LFSR
bit = ((lfsr >> 0) ^ (lfsr >> 2) ^ (lfsr >> 3) ^ (lfsr >> 5)) & 1;
lfsr = (lfsr >> 1) | (bit << 15);