diff --git a/synthetizer.cpp b/synthetizer.cpp index df25861..e89c446 100644 --- a/synthetizer.cpp +++ b/synthetizer.cpp @@ -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);