From 0aad7c32b6806c826848b21bb1d2699eb79de29b Mon Sep 17 00:00:00 2001 From: Mike Oliphant Date: Mon, 19 Jun 2023 10:58:05 -0700 Subject: [PATCH] Add CMake option for denormal disabling --- src/CMakeLists.txt | 6 ++++++ src/nam_lv2.cpp | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8f7ac77..6ca6c97 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,6 +22,12 @@ add_library(neural_amp_modeler MODULE ${SOURCES} ${NAM_SOURCES}) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES}) source_group(NAM ${CMAKE_CURRENT_SOURCE_DIR} FILES ${NAM_SOURCES}) +option(DISABLE_DENORMALS "Disable floating point denormals" ON) + +if(DISABLE_DENORMALS) + add_definitions(-DDISABLE_DENORMALS) +endif(DISABLE_DENORMALS) + target_compile_features(neural_amp_modeler PUBLIC cxx_std_17) set_target_properties(neural_amp_modeler diff --git a/src/nam_lv2.cpp b/src/nam_lv2.cpp index b836438..50ef348 100644 --- a/src/nam_lv2.cpp +++ b/src/nam_lv2.cpp @@ -43,15 +43,17 @@ static void activate(LV2_Handle) {} static void run(LV2_Handle instance, uint32_t n_samples) { - // Disable floating point denormals +#ifdef DISABLE_DENORMALS // Disable floating point denormals std::fenv_t fe_state; std::feholdexcept(&fe_state); disable_denormals(); +#endif static_cast(instance)->process(n_samples); - // restore previous floating point state +#ifdef DISABLE_DENORMALS // restore previous floating point state std::feupdateenv(&fe_state); +#endif } static void deactivate(LV2_Handle) {}