diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index 4a1b3e9b..b064f5b6 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -270,7 +270,7 @@ static void Cable_step(Cable* that) { } -static void Engine_step(Engine* that) { +static void Engine_stepModules(Engine* that) { Engine::Internal* internal = that->internal; // Param smoothing @@ -296,6 +296,12 @@ static void Engine_step(Engine* that) { // Step cables for (Cable* cable : that->internal->cables) { + // // Check that the output is finite + // float v = cable->outputModule->outputs[cable->outputId].getVoltage(); + // if (!std::isfinite(v)) { + // // Automatically disable module + // that->disableModule(cable->outputModule, true); + // } Cable_step(cable); } @@ -422,6 +428,7 @@ void Engine::clear() { void Engine::step(int frames) { initMXCSR(); + random::init(); // Set sample rate if (internal->sampleRate != settings::sampleRate) { @@ -451,7 +458,7 @@ void Engine::step(int frames) { // Step modules for (int i = 0; i < frames; i++) { - Engine_step(this); + Engine_stepModules(this); } } else { diff --git a/src/random.cpp b/src/random.cpp index 2c37b39d..d24e902a 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -30,6 +30,10 @@ static uint64_t xoroshiro128plus_next(void) { } void init() { + // Do nothing if already initialized + if (xoroshiro128plus_state[0] || xoroshiro128plus_state[1]) + return; + struct timeval tv; gettimeofday(&tv, NULL); xoroshiro128plus_state[0] = tv.tv_sec;