diff --git a/docs/nightlychangelog.md b/docs/nightlychangelog.md index d04d80d..32019bc 100644 --- a/docs/nightlychangelog.md +++ b/docs/nightlychangelog.md @@ -38,4 +38,6 @@ you just gotta fix it! - Modulating a frequncy-style surge parameter gets a 'set to 1oct/v' menu item in the RMB. -- Cache the WT conversion for saving into your patch in the WT/Window VCO \ No newline at end of file +- Cache the WT conversion for saving into your patch in the WT/Window VCO +- In rare cases the SpringReverb could NaN. Reset the effect automatically if + these occur as a workaround. \ No newline at end of file diff --git a/src/FX.h b/src/FX.h index 6555945..0b49c7a 100644 --- a/src/FX.h +++ b/src/FX.h @@ -19,6 +19,7 @@ #ifndef SURGE_XT_RACK_SRC_FX_H #define SURGE_XT_RACK_SRC_FX_H +#include #include "SurgeXT.h" #include "dsp/Effect.h" #include "XTModule.h" @@ -75,6 +76,7 @@ template struct FXConfig static constexpr float rescaleInputFactor() { return 1.0; } static constexpr bool softclipOutput() { return false; } + static constexpr bool nanCheckOutput() { return false; } }; template @@ -435,6 +437,7 @@ struct FX : modules::XTModule, sst::rackhelpers::module_connector::NeighborConne std::string getName() override { return std::string("FX<") + fx_type_names[fxType] + ">"; } int bufferPos{0}; + uint32_t lastNanCheck{0}; float bufferL alignas(16)[MAX_POLY][BLOCK_SIZE], bufferR alignas(16)[MAX_POLY][BLOCK_SIZE]; float modulatorL alignas(16)[MAX_POLY][BLOCK_SIZE], modulatorR alignas(16)[MAX_POLY][BLOCK_SIZE]; @@ -567,6 +570,25 @@ struct FX : modules::XTModule, sst::rackhelpers::module_connector::NeighborConne FXConfig::populateExtraOutputs(this, 0, surge_effect.get()); + if constexpr (FXConfig::nanCheckOutput()) + { + if (lastNanCheck == 0) + { + bool isNumber{true}; + for (int ns = 0; ns < BLOCK_SIZE; ++ns) + { + isNumber = isNumber && std::isfinite(processedL[0][ns]); + isNumber = isNumber && std::isfinite(processedR[0][ns]); + } + + if (!isNumber) + { + reinitialize(); + } + } + lastNanCheck = (lastNanCheck + 1) % 32; + } + bufferPos = 0; } @@ -581,6 +603,7 @@ struct FX : modules::XTModule, sst::rackhelpers::module_connector::NeighborConne outl = outl - 4.0 / 27.0 * outl * outl * outl; outr = outr - 4.0 / 27.0 * outr * outr * outr; } + outl *= SURGE_TO_RACK_OSC_MUL; outr *= SURGE_TO_RACK_OSC_MUL; if (outputs[OUTPUT_L].isConnected() && !outputs[OUTPUT_R].isConnected()) @@ -604,6 +627,7 @@ struct FX : modules::XTModule, sst::rackhelpers::module_connector::NeighborConne void reinitialize() { surge_effect->init(); + halfbandIN.reset(); for (const auto &s : surge_effect_poly) if (s) s->init(); diff --git a/src/fxconfig/SpringReverb.h b/src/fxconfig/SpringReverb.h index 5569998..b7fbde2 100644 --- a/src/fxconfig/SpringReverb.h +++ b/src/fxconfig/SpringReverb.h @@ -30,6 +30,7 @@ template <> constexpr int FXConfig::numParams() { return 8; } template <> constexpr int FXConfig::extraInputs() { return 1; } template <> constexpr int FXConfig::extraSchmidtTriggers() { return 2; } template <> constexpr int FXConfig::specificParamCount() { return 1; } +template <> constexpr bool FXConfig::nanCheckOutput() { return true; } template <> FXConfig::layout_t FXConfig::getLayout() { const auto col = FXLayoutHelper::standardColumns_MM();