From 368e47e12ee048db886d08919945bd0514981985 Mon Sep 17 00:00:00 2001 From: Mike Oliphant Date: Wed, 27 Nov 2024 09:17:49 -0800 Subject: [PATCH] Update NeuralAudio (better RTNeural NAM performance) --- CMakeLists.txt | 2 +- deps/NeuralAudio | 2 +- src/CMakeLists.txt | 10 ++++++++-- src/nam_plugin.cpp | 9 ++++++++- src/nam_plugin.h | 3 ++- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93567f4..683c439 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(NeuralAmpModelerLv2 VERSION 0.1.5) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED OFF) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/deps/NeuralAudio b/deps/NeuralAudio index 8678eff..8b6a831 160000 --- a/deps/NeuralAudio +++ b/deps/NeuralAudio @@ -1 +1 @@ -Subproject commit 8678eff6ab428156ae79a329936f7cf217c38bbd +Subproject commit 8b6a83169a41914fc7d5c67651cc2aa36ebe0326 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8c106b2..2b9ffe3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,16 +48,22 @@ if (DISABLE_DENORMALS) add_definitions(-DDISABLE_DENORMALS) endif (DISABLE_DENORMALS) -option(LSTM_PREFER_NAM "Always use NAM Core for NAM LSTM models" OFF) +option(LSTM_PREFER_NAM "Always use NAM Core for NAM LSTM models" ON) if (LSTM_PREFER_NAM) add_definitions(-DLSTM_PREFER_NAM) + message("Using NAM Core for LSTM models") +else() + message("Using RTNeural for LSTM models") endif (LSTM_PREFER_NAM) -option(WAVENET_PREFER_NAM "Always use NAM Core for NAM WaveNet models" ON) +option(WAVENET_PREFER_NAM "Always use NAM Core for NAM WaveNet models" OFF) if (WAVENET_PREFER_NAM) add_definitions(-DWAVENET_PREFER_NAM) + message("Using NAM Core for WaveNet models") +else() + message("Using RTNeural for WaveNet models") endif (WAVENET_PREFER_NAM) set_target_properties(neural_amp_modeler diff --git a/src/nam_plugin.cpp b/src/nam_plugin.cpp index 20c784b..9af0d01 100644 --- a/src/nam_plugin.cpp +++ b/src/nam_plugin.cpp @@ -190,6 +190,13 @@ namespace NAM { return LV2_WORKER_SUCCESS; } + void Plugin::set_max_buffer_size(int size) noexcept + { + maxBufferSize = size; + + NeuralAudio::NeuralModel::SetDefaultMaxAudioBufferSize(size); + } + void Plugin::process(uint32_t n_samples) noexcept { lv2_atom_forge_set_buffer(&atom_forge, (uint8_t*)ports.notify, ports.notify->atom.size); @@ -326,7 +333,7 @@ namespace NAM { { if (options[i].key == nam->uris.bufSize_maxBlockLength && options[i].type == nam->uris.atom_Int) { - nam->maxBufferSize = *(const int32_t*)options[i].value; + nam->set_max_buffer_size(*(const int32_t*)options[i].value); break; } } diff --git a/src/nam_plugin.h b/src/nam_plugin.h index 9967593..15a03a4 100644 --- a/src/nam_plugin.h +++ b/src/nam_plugin.h @@ -79,6 +79,7 @@ namespace NAM { ~Plugin(); bool initialize(double rate, const LV2_Feature* const* features) noexcept; + void set_max_buffer_size(int size) noexcept; void process(uint32_t n_samples) noexcept; void write_current_path(); @@ -118,6 +119,6 @@ namespace NAM { float inputLevel = 0; float outputLevel = 0; - int32_t maxBufferSize = 0; + int32_t maxBufferSize = 512; }; }