From 3f5872cc783a2e5d85c1278f39a7c4291068a2b7 Mon Sep 17 00:00:00 2001 From: Mike Oliphant Date: Thu, 14 Nov 2024 07:47:52 -0800 Subject: [PATCH] CMake options for forcing use of NAM Core for LSTM or WaveNet --- src/CMakeLists.txt | 13 +++++++++++++ src/nam_lv2.cpp | 4 ++-- src/nam_plugin.cpp | 8 ++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index db43747..0251c9a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,6 +23,19 @@ if (DISABLE_DENORMALS) add_definitions(-DDISABLE_DENORMALS) endif (DISABLE_DENORMALS) +option(LSTM_PREFER_NAM "Always use NAM Core for NAM LSTM models" OFF) + +if (LSTM_PREFER_NAM) + add_definitions(-DLSTM_PREFER_NAM) +endif (LSTM_PREFER_NAM) + +option(WAVENET_PREFER_NAM "Always use NAM Core for NAM WaveNet models" OFF) + +if (WAVENET_PREFER_NAM) + add_definitions(-DWAVENET_PREFER_NAM) +endif (WAVENET_PREFER_NAM) + + if (CMAKE_SYSTEM_PROCESSOR MATCHES "(amd64)|(AMD64)|(x86_64)") option(USE_NATIVE_ARCH "Enable architecture-specific optimizations" OFF) diff --git a/src/nam_lv2.cpp b/src/nam_lv2.cpp index e8856a3..d0538b9 100644 --- a/src/nam_lv2.cpp +++ b/src/nam_lv2.cpp @@ -14,8 +14,8 @@ #include "nam_plugin.h" // LV2 Functions -static LV2_Handle instantiate(const LV2_Descriptor*, double rate, const char*, const LV2_Feature* const* features -) { +static LV2_Handle instantiate(const LV2_Descriptor*, double rate, const char*, const LV2_Feature* const* features) +{ try { auto nam = std::make_unique(); diff --git a/src/nam_plugin.cpp b/src/nam_plugin.cpp index 94c27c0..ef53984 100644 --- a/src/nam_plugin.cpp +++ b/src/nam_plugin.cpp @@ -12,6 +12,14 @@ namespace NAM { { // prevent allocations on the audio thread currentModelPath.reserve(MAX_FILE_NAME+1); + +#ifdef LSTM_PREFER_NAM // Use NAM Core for NAM LSTM models + NeuralAudio::NeuralModel::SetLSTMLoadMode(NeuralAudio::PreferNAMCore); +#endif + +#ifdef WAVENET_PREFER_NAM // Use NAM Core for NAM WaveNet models + NeuralAudio::NeuralModel::SetWaveNetLoadMode(NeuralAudio::PreferNAMCore); +#endif } Plugin::~Plugin()