mirror of
https://github.com/mikeoliphant/neural-amp-modeler-lv2.git
synced 2026-05-06 19:50:11 +02:00
Switch to NeuralAudio for model handling
This commit is contained in:
-10
@@ -1,16 +1,6 @@
|
||||
[submodule "lv2"]
|
||||
path = deps/lv2
|
||||
url = https://github.com/lv2/lv2
|
||||
[submodule "eigen"]
|
||||
path = deps/eigen
|
||||
url = https://gitlab.com/libeigen/eigen
|
||||
[submodule "NeuralAmpModelerCore"]
|
||||
path = deps/NeuralAmpModelerCore
|
||||
url = https://github.com/mikeoliphant/NeuralAmpModelerCore
|
||||
branch = devel
|
||||
[submodule "deps/AudioDSPTools"]
|
||||
path = deps/AudioDSPTools
|
||||
url = https://github.com/sdatkinson/AudioDSPTools
|
||||
[submodule "deps/NeuralAudio"]
|
||||
path = deps/NeuralAudio
|
||||
url = https://github.com/mikeoliphant/NeuralAudio
|
||||
|
||||
@@ -20,15 +20,6 @@ endif()
|
||||
|
||||
set(NAM_LV2_ID http://github.com/mikeoliphant/neural-amp-modeler-lv2)
|
||||
|
||||
include_directories(SYSTEM deps/eigen)
|
||||
include_directories(SYSTEM deps/lv2/include)
|
||||
include_directories(SYSTEM deps/NeuralAmpModelerCore)
|
||||
include_directories(SYSTEM deps/json)
|
||||
include_directories(SYSTEM deps/denormal)
|
||||
|
||||
add_definitions(-DNAM_SAMPLE_FLOAT)
|
||||
add_definitions(-DDSP_SAMPLE_FLOAT)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
|
||||
|
||||
Vendored
-1
Submodule deps/NeuralAmpModelerCore deleted from 529a1c8342
Vendored
+1
-1
Submodule deps/NeuralAudio updated: 4c5b7d3e1f...92e1b9136d
Vendored
-1
Submodule deps/eigen deleted from f78c37f0af
Vendored
-22875
File diff suppressed because it is too large
Load Diff
+11
-16
@@ -1,26 +1,21 @@
|
||||
add_subdirectory(../deps/NeuralAudio NeuralAudio)
|
||||
|
||||
include_directories(SYSTEM ../deps/NeuralAudio)
|
||||
include_directories(SYSTEM ../deps/lv2/include)
|
||||
include_directories(SYSTEM ../deps/denormal)
|
||||
|
||||
set(SOURCES nam_lv2.cpp
|
||||
nam_plugin.cpp
|
||||
nam_plugin.h)
|
||||
|
||||
set(NAM_SOURCES ../deps/NeuralAmpModelerCore/NAM/activations.h
|
||||
../deps/NeuralAmpModelerCore/NAM/activations.cpp
|
||||
../deps/NeuralAmpModelerCore/NAM/version.h
|
||||
../deps/NeuralAmpModelerCore/NAM/lstm.h
|
||||
../deps/NeuralAmpModelerCore/NAM/lstm.cpp
|
||||
../deps/NeuralAmpModelerCore/NAM/dsp.h
|
||||
../deps/NeuralAmpModelerCore/NAM/dsp.cpp
|
||||
../deps/NeuralAmpModelerCore/NAM/get_dsp.cpp
|
||||
../deps/NeuralAmpModelerCore/NAM/util.cpp
|
||||
../deps/NeuralAmpModelerCore/NAM/util.h
|
||||
../deps/NeuralAmpModelerCore/NAM/wavenet.cpp
|
||||
../deps/NeuralAmpModelerCore/NAM/wavenet.h
|
||||
../deps/NeuralAmpModelerCore/NAM/convnet.cpp
|
||||
../deps/NeuralAmpModelerCore/NAM/convnet.h)
|
||||
set(NA_SOURCES ../deps/NeuralAudio/NeuralAudio/NeuralModel.h)
|
||||
|
||||
add_library(neural_amp_modeler MODULE ${SOURCES} ${NAM_SOURCES})
|
||||
add_library(neural_amp_modeler MODULE ${SOURCES} ${NA_SOURCES})
|
||||
|
||||
target_link_libraries(neural_amp_modeler PRIVATE NeuralAudio)
|
||||
|
||||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES})
|
||||
source_group(NAM ${CMAKE_CURRENT_SOURCE_DIR} FILES ${NAM_SOURCES})
|
||||
source_group(NAM ${CMAKE_CURRENT_SOURCE_DIR} FILES ${NA_SOURCES})
|
||||
|
||||
option(DISABLE_DENORMALS "Disable floating point denormals" ON)
|
||||
|
||||
|
||||
@@ -95,9 +95,6 @@ static const LV2_Descriptor descriptor =
|
||||
LV2_SYMBOL_EXPORT const LV2_Descriptor* lv2_descriptor(uint32_t index)
|
||||
{
|
||||
if (index == 0) {
|
||||
// Turn on fast tanh approximation
|
||||
nam::activations::Activation::enable_fast_tanh();
|
||||
|
||||
return &descriptor;
|
||||
}
|
||||
|
||||
|
||||
+14
-18
@@ -4,7 +4,6 @@
|
||||
#include <cassert>
|
||||
|
||||
#include "nam_plugin.h"
|
||||
#include <NAM/activations.h>
|
||||
|
||||
#define SMOOTH_EPSILON .0001f
|
||||
|
||||
@@ -88,7 +87,7 @@ namespace NAM {
|
||||
auto msg = static_cast<const LV2LoadModelMsg*>(data);
|
||||
auto nam = static_cast<NAM::Plugin*>(instance);
|
||||
|
||||
nam::DSP* model = nullptr;
|
||||
NeuralAudio::NeuralModel* model = nullptr;
|
||||
LV2SwitchModelMsg response = { kWorkTypeSwitch, {}, {} };
|
||||
LV2_Worker_Status result = LV2_WORKER_SUCCESS;
|
||||
|
||||
@@ -107,19 +106,19 @@ namespace NAM {
|
||||
{
|
||||
lv2_log_trace(&nam->logger, "Staging model change: `%s`\n", msg->path);
|
||||
|
||||
model = nam::get_dsp(msg->path).release();
|
||||
model = NeuralAudio::NeuralModel::CreateFromFile(msg->path);
|
||||
|
||||
// Pre-run model to ensure all needed buffers are allocated in advance
|
||||
if (const int32_t numSamples = nam->maxBufferSize)
|
||||
{
|
||||
float* buffer = new float[numSamples];
|
||||
memset(buffer, 0, numSamples * sizeof(float));
|
||||
//if (const int32_t numSamples = nam->maxBufferSize)
|
||||
//{
|
||||
// float* buffer = new float[numSamples];
|
||||
// memset(buffer, 0, numSamples * sizeof(float));
|
||||
|
||||
model->process(buffer, buffer, numSamples);
|
||||
model->finalize_(numSamples);
|
||||
// model->Process(buffer, buffer, numSamples);
|
||||
// //model->finalize_(numSamples);
|
||||
|
||||
delete[] buffer;
|
||||
}
|
||||
// delete[] buffer;
|
||||
//}
|
||||
}
|
||||
|
||||
response.model = model;
|
||||
@@ -251,14 +250,11 @@ namespace NAM {
|
||||
|
||||
if (currentModel != nullptr)
|
||||
{
|
||||
currentModel->process(ports.audio_out, ports.audio_out, n_samples);
|
||||
currentModel->finalize_(n_samples);
|
||||
std::vector<float> inout( + n_samples);
|
||||
|
||||
if (currentModel->HasLoudness())
|
||||
{
|
||||
// Normalize model to -18dB
|
||||
modelLoudnessAdjustmentDB = -18 - currentModel->GetLoudness();
|
||||
}
|
||||
currentModel->Process(ports.audio_out, ports.audio_out, n_samples);
|
||||
|
||||
modelLoudnessAdjustmentDB = currentModel->GetRecommendedOutputDBAdjustment();
|
||||
}
|
||||
|
||||
// Convert output level from db
|
||||
|
||||
+4
-4
@@ -21,7 +21,7 @@
|
||||
#include <lv2/state/state.h>
|
||||
#include <lv2/units/units.h>
|
||||
|
||||
#include <NAM/dsp.h>
|
||||
#include <NeuralAudio/NeuralModel.h>
|
||||
|
||||
#define PlUGIN_URI "http://github.com/mikeoliphant/neural-amp-modeler-lv2"
|
||||
#define MODEL_URI PlUGIN_URI "#model"
|
||||
@@ -43,12 +43,12 @@ namespace NAM {
|
||||
struct LV2SwitchModelMsg {
|
||||
LV2WorkType type;
|
||||
char path[MAX_FILE_NAME];
|
||||
nam::DSP* model;
|
||||
NeuralAudio::NeuralModel* model;
|
||||
};
|
||||
|
||||
struct LV2FreeModelMsg {
|
||||
LV2WorkType type;
|
||||
nam::DSP* model;
|
||||
NeuralAudio::NeuralModel* model;
|
||||
};
|
||||
|
||||
class Plugin {
|
||||
@@ -70,7 +70,7 @@ namespace NAM {
|
||||
LV2_Log_Logger logger = {};
|
||||
LV2_Worker_Schedule* schedule = nullptr;
|
||||
|
||||
nam::DSP* currentModel = nullptr;
|
||||
NeuralAudio::NeuralModel* currentModel = nullptr;
|
||||
std::string currentModelPath;
|
||||
float prevDCInput = 0;
|
||||
float prevDCOutput = 0;
|
||||
|
||||
Reference in New Issue
Block a user