mirror of
https://github.com/mikeoliphant/neural-amp-modeler-lv2.git
synced 2026-05-10 04:30:14 +02:00
Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0649b4a822 | |||
| 61bbce1e2a | |||
| 1dc54bc5f9 | |||
| 40bae2bd87 | |||
| 1ff6dab119 | |||
| baff908f93 | |||
| 72fd4a1e3d | |||
| 1626e74d0e | |||
| d1794e1bbd | |||
| b8c6333955 | |||
| 02256b4349 | |||
| f07c40c16f | |||
| 5605b03acc | |||
| 43fb036706 | |||
| b40df0945c | |||
| 24f03afd69 | |||
| db3603e134 | |||
| 97cff04114 | |||
| 067b3236ea | |||
| 191ae3786e | |||
| 2b5a4c9912 | |||
| 23200eb566 | |||
| 3434ba0b7d | |||
| 3e9ffee4e7 | |||
| 3cff8ca37a | |||
| fcec78fa0f | |||
| 34be69df6d | |||
| 34c7628202 | |||
| 8384827981 | |||
| e3c5b6bd4f | |||
| eb46377d71 | |||
| b22f02c84e | |||
| 52810a3f9c |
@@ -24,6 +24,18 @@ jobs:
|
|||||||
cmake --build . --config $BUILD_TYPE -j4
|
cmake --build . --config $BUILD_TYPE -j4
|
||||||
cpack
|
cpack
|
||||||
|
|
||||||
|
- name: Upload binary
|
||||||
|
uses: actions/upload-artifact@v1
|
||||||
|
with:
|
||||||
|
name: neural_amp_modeler.lv2-linux-amd64
|
||||||
|
path: ${{github.workspace}}/build/neural_amp_modeler.lv2
|
||||||
|
|
||||||
|
# - name: Upload deb
|
||||||
|
# uses: actions/upload-artifact@v1
|
||||||
|
# with:
|
||||||
|
# name: neural_amp_modeler.lv2-linux-deb-amd64
|
||||||
|
# path: ${{github.workspace}}/build/*.deb
|
||||||
|
|
||||||
build-windows:
|
build-windows:
|
||||||
name: Build Windows
|
name: Build Windows
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
@@ -35,5 +47,11 @@ jobs:
|
|||||||
- name: Build Plugin
|
- name: Build Plugin
|
||||||
working-directory: ${{github.workspace}}/build
|
working-directory: ${{github.workspace}}/build
|
||||||
run: |
|
run: |
|
||||||
cmake.exe -G "Visual Studio 17 2022" -A x64 ..
|
cmake.exe -G "Visual Studio 17 2022" -A x64 -T ClangCL ..
|
||||||
cmake --build . --config=release -j4
|
cmake --build . --config=release -j4
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v1
|
||||||
|
with:
|
||||||
|
name: neural_amp_modeler.lv2-win
|
||||||
|
path: ${{github.workspace}}/build/neural_amp_modeler.lv2
|
||||||
|
|||||||
@@ -8,3 +8,6 @@
|
|||||||
path = deps/NeuralAmpModelerCore
|
path = deps/NeuralAmpModelerCore
|
||||||
url = https://github.com/mikeoliphant/NeuralAmpModelerCore
|
url = https://github.com/mikeoliphant/NeuralAmpModelerCore
|
||||||
branch = devel
|
branch = devel
|
||||||
|
[submodule "deps/AudioDSPTools"]
|
||||||
|
path = deps/AudioDSPTools
|
||||||
|
url = https://github.com/sdatkinson/AudioDSPTools
|
||||||
|
|||||||
+2
-3
@@ -1,10 +1,10 @@
|
|||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
|
||||||
project(NeuralAmpModelerLv2 VERSION 0.1.2)
|
project(NeuralAmpModelerLv2 VERSION 0.1.4)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED OFF)
|
set(CMAKE_CXX_STANDARD_REQUIRED OFF)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
@@ -23,7 +23,6 @@ set(NAM_LV2_ID http://github.com/mikeoliphant/neural-amp-modeler-lv2)
|
|||||||
include_directories(SYSTEM deps/eigen)
|
include_directories(SYSTEM deps/eigen)
|
||||||
include_directories(SYSTEM deps/lv2/include)
|
include_directories(SYSTEM deps/lv2/include)
|
||||||
include_directories(SYSTEM deps/NeuralAmpModelerCore)
|
include_directories(SYSTEM deps/NeuralAmpModelerCore)
|
||||||
include_directories(SYSTEM deps/NeuralAmpModelerCore)
|
|
||||||
include_directories(SYSTEM deps/json)
|
include_directories(SYSTEM deps/json)
|
||||||
include_directories(SYSTEM deps/denormal)
|
include_directories(SYSTEM deps/denormal)
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
Bare-bones implementation of [Neural Amp Modeler](https://github.com/sdatkinson/neural-amp-modeler) (NAM) models in an LV2 plugin.
|
Bare-bones implementation of [Neural Amp Modeler](https://github.com/sdatkinson/neural-amp-modeler) (NAM) models in an LV2 plugin.
|
||||||
|
|
||||||
**There is no user interface**. Setting the model to use requires that your LV2 host supports atom:Path parameters. Reaper does as of v6.82. Carla and Ardour do. If your favorite LV2 host does not support atom:Path, let them know you want it.
|
**There is no user interface**. Setting the model to use requires that your LV2 host supports atom:Path parameters. Reaper does as of v6.82. Carla and Ardour do. If your favorite LV2 host does not support atom:Path, let them know you want it.
|
||||||
|
If you are looking for a GUI version, @brummer10 [has one here](https://github.com/brummer10/neural-amp-modeler-ui) that works for Linux and Windows. You may also be interested in the the version shipped with the [MOD Desktop App](https://github.com/moddevices/mod-desktop-app), or my digital pedalboard app [Stompbox](https://github.com/mikeoliphant/StompboxUI).
|
||||||
|
|
||||||
To get the intended behavior, **you must run your audio host at the same sample rate the model was trained at** (usually 48kHz) - no resampling is done by the plugin.
|
To get the intended behavior, **you must run your audio host at the same sample rate the model was trained at** (usually 48kHz) - no resampling is done by the plugin.
|
||||||
|
|
||||||
@@ -44,3 +45,6 @@ Note - you'll have to change the Visual Studio version if you are using a differ
|
|||||||
|
|
||||||
After building, the plugin will be in **build/neural_amp_modeler.lv2**.
|
After building, the plugin will be in **build/neural_amp_modeler.lv2**.
|
||||||
|
|
||||||
|
### Optimization
|
||||||
|
|
||||||
|
If you have a relatively modern x64 processor, you can pass "**‑DUSE_NATIVE_ARCH=ON**" on your cmake command line to enable certain processor-specific optimizations.
|
||||||
|
|||||||
Vendored
+1
-1
Submodule deps/NeuralAmpModelerCore updated: 885a535d29...529a1c8342
Vendored
+1
-1
Submodule deps/eigen updated: 7bf2968fed...f78c37f0af
Vendored
+1
-1
Submodule deps/lv2 updated: dbdbe3e518...e9d9432874
@@ -39,11 +39,11 @@
|
|||||||
opts:supportedOption <http://lv2plug.in/ns/ext/buf-size#maxBlockLength>;
|
opts:supportedOption <http://lv2plug.in/ns/ext/buf-size#maxBlockLength>;
|
||||||
|
|
||||||
rdfs:comment """
|
rdfs:comment """
|
||||||
An LV2 implementation of Neural Amp Modeler.
|
LV2 plugin for Neural Amp Modeler machine learning guitar amplifier simulation models
|
||||||
|
|
||||||
NAM accepts Neural Amp Modeler .nam files.
|
Based on the Neural Amp Modeler Core codebase: https://github.com/sdatkinson/NeuralAmpModelerCore
|
||||||
|
|
||||||
A large collection of .nam files is available at https://tonehunt.org/
|
A large collection of .nam models is available at https://tonehunt.org
|
||||||
""";
|
""";
|
||||||
|
|
||||||
patch:writable <@NAM_LV2_ID@#model>;
|
patch:writable <@NAM_LV2_ID@#model>;
|
||||||
|
|||||||
+9
-8
@@ -17,16 +17,10 @@ set(NAM_SOURCES ../deps/NeuralAmpModelerCore/NAM/activations.h
|
|||||||
../deps/NeuralAmpModelerCore/NAM/convnet.cpp
|
../deps/NeuralAmpModelerCore/NAM/convnet.cpp
|
||||||
../deps/NeuralAmpModelerCore/NAM/convnet.h)
|
../deps/NeuralAmpModelerCore/NAM/convnet.h)
|
||||||
|
|
||||||
set(DSP_SOURCES ../deps/NeuralAmpModelerCore/dsp/dsp.h
|
add_library(neural_amp_modeler MODULE ${SOURCES} ${NAM_SOURCES})
|
||||||
../deps/NeuralAmpModelerCore/dsp/dsp.cpp
|
|
||||||
../deps/NeuralAmpModelerCore/dsp/RecursiveLinearFilter.h
|
|
||||||
../deps/NeuralAmpModelerCore/dsp/RecursiveLinearFilter.cpp)
|
|
||||||
|
|
||||||
add_library(neural_amp_modeler MODULE ${SOURCES} ${NAM_SOURCES} ${DSP_SOURCES})
|
|
||||||
|
|
||||||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES})
|
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 ${NAM_SOURCES})
|
||||||
source_group(dsp ${CMAKE_CURRENT_SOURCE_DIR} FILES ${DSP_SOURCES})
|
|
||||||
|
|
||||||
option(DISABLE_DENORMALS "Disable floating point denormals" ON)
|
option(DISABLE_DENORMALS "Disable floating point denormals" ON)
|
||||||
|
|
||||||
@@ -34,7 +28,14 @@ if(DISABLE_DENORMALS)
|
|||||||
add_definitions(-DDISABLE_DENORMALS)
|
add_definitions(-DDISABLE_DENORMALS)
|
||||||
endif (DISABLE_DENORMALS)
|
endif (DISABLE_DENORMALS)
|
||||||
|
|
||||||
target_compile_features(neural_amp_modeler PUBLIC cxx_std_17)
|
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(amd64)|(AMD64)|(x86_64)")
|
||||||
|
option(USE_NATIVE_ARCH "Enable architecture-specific optimizations" OFF)
|
||||||
|
|
||||||
|
if (USE_NATIVE_ARCH)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=x86-64-v3")
|
||||||
|
message("Enabling -march=x86-64-v3")
|
||||||
|
endif (USE_NATIVE_ARCH)
|
||||||
|
endif ()
|
||||||
|
|
||||||
set_target_properties(neural_amp_modeler
|
set_target_properties(neural_amp_modeler
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
|
|||||||
+1
-1
@@ -96,7 +96,7 @@ LV2_SYMBOL_EXPORT const LV2_Descriptor* lv2_descriptor(uint32_t index)
|
|||||||
{
|
{
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
// Turn on fast tanh approximation
|
// Turn on fast tanh approximation
|
||||||
activations::Activation::enable_fast_tanh();
|
nam::activations::Activation::enable_fast_tanh();
|
||||||
|
|
||||||
return &descriptor;
|
return &descriptor;
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-19
@@ -24,10 +24,6 @@ namespace NAM {
|
|||||||
{
|
{
|
||||||
this->sampleRate = sampleRate;
|
this->sampleRate = sampleRate;
|
||||||
|
|
||||||
const double highPassCutoffFreq = 5.0;
|
|
||||||
const recursive_linear_filter::HighPassParams highPassParams(sampleRate, highPassCutoffFreq);
|
|
||||||
mHighPass.SetParams(highPassParams);
|
|
||||||
|
|
||||||
// for fetching initial options, can be null
|
// for fetching initial options, can be null
|
||||||
LV2_Options_Option* options = nullptr;
|
LV2_Options_Option* options = nullptr;
|
||||||
|
|
||||||
@@ -92,7 +88,7 @@ namespace NAM {
|
|||||||
auto msg = static_cast<const LV2LoadModelMsg*>(data);
|
auto msg = static_cast<const LV2LoadModelMsg*>(data);
|
||||||
auto nam = static_cast<NAM::Plugin*>(instance);
|
auto nam = static_cast<NAM::Plugin*>(instance);
|
||||||
|
|
||||||
::DSP* model = nullptr;
|
nam::DSP* model = nullptr;
|
||||||
LV2SwitchModelMsg response = { kWorkTypeSwitch, {}, {} };
|
LV2SwitchModelMsg response = { kWorkTypeSwitch, {}, {} };
|
||||||
LV2_Worker_Status result = LV2_WORKER_SUCCESS;
|
LV2_Worker_Status result = LV2_WORKER_SUCCESS;
|
||||||
|
|
||||||
@@ -111,10 +107,7 @@ namespace NAM {
|
|||||||
{
|
{
|
||||||
lv2_log_trace(&nam->logger, "Staging model change: `%s`\n", msg->path);
|
lv2_log_trace(&nam->logger, "Staging model change: `%s`\n", msg->path);
|
||||||
|
|
||||||
model = get_dsp(msg->path).release();
|
model = nam::get_dsp(msg->path).release();
|
||||||
|
|
||||||
// Enable model loudness normalization
|
|
||||||
model->SetNormalize(true);
|
|
||||||
|
|
||||||
// Pre-run model to ensure all needed buffers are allocated in advance
|
// Pre-run model to ensure all needed buffers are allocated in advance
|
||||||
if (const int32_t numSamples = nam->maxBufferSize)
|
if (const int32_t numSamples = nam->maxBufferSize)
|
||||||
@@ -122,8 +115,7 @@ namespace NAM {
|
|||||||
float* buffer = new float[numSamples];
|
float* buffer = new float[numSamples];
|
||||||
memset(buffer, 0, numSamples * sizeof(float));
|
memset(buffer, 0, numSamples * sizeof(float));
|
||||||
|
|
||||||
std::unordered_map<std::string, double> params = {};
|
model->process(buffer, buffer, numSamples);
|
||||||
model->process(&buffer, &buffer, 1, numSamples, 1.0, 1.0, params);
|
|
||||||
model->finalize_(numSamples);
|
model->finalize_(numSamples);
|
||||||
|
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
@@ -242,6 +234,7 @@ namespace NAM {
|
|||||||
|
|
||||||
ports.audio_out[i] = ports.audio_in[i] * level;
|
ports.audio_out[i] = ports.audio_in[i] * level;
|
||||||
}
|
}
|
||||||
|
|
||||||
inputLevel = level;
|
inputLevel = level;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -254,30 +247,35 @@ namespace NAM {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float** outputPtrs = &ports.audio_out;
|
float modelLoudnessAdjustmentDB = 0;
|
||||||
|
|
||||||
if (currentModel != nullptr)
|
if (currentModel != nullptr)
|
||||||
{
|
{
|
||||||
currentModel->process(&ports.audio_out, &ports.audio_out, 1, n_samples, 1.0, 1.0, mNAMParams);
|
currentModel->process(ports.audio_out, ports.audio_out, n_samples);
|
||||||
currentModel->finalize_(n_samples);
|
currentModel->finalize_(n_samples);
|
||||||
|
|
||||||
// Apply a high pass filter at 5Hz to eliminate any DC offset
|
if (currentModel->HasLoudness())
|
||||||
outputPtrs = mHighPass.Process(outputPtrs, 1, n_samples);
|
{
|
||||||
|
// Normalize model to -18dB
|
||||||
|
modelLoudnessAdjustmentDB = -18 - currentModel->GetLoudness();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert output level from db
|
// Convert output level from db
|
||||||
float desiredOutputLevel = powf(10, *(ports.output_level) * 0.05f);
|
float desiredOutputLevel = powf(10, (*(ports.output_level) + modelLoudnessAdjustmentDB) * 0.05f);
|
||||||
|
|
||||||
if (fabs(desiredOutputLevel - outputLevel) > SMOOTH_EPSILON)
|
if (fabs(desiredOutputLevel - outputLevel) > SMOOTH_EPSILON)
|
||||||
{
|
{
|
||||||
level = outputLevel;
|
level = outputLevel;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < n_samples; i++)
|
for (unsigned int i = 0; i < n_samples; i++)
|
||||||
{
|
{
|
||||||
// do very basic smoothing
|
// do very basic smoothing
|
||||||
level = (.99f * level) + (.01f * desiredOutputLevel);
|
level = (.99f * level) + (.01f * desiredOutputLevel);
|
||||||
|
|
||||||
ports.audio_out[i] = outputPtrs[0][i] * outputLevel;
|
ports.audio_out[i] = ports.audio_out[i] * outputLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
outputLevel = level;
|
outputLevel = level;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -286,9 +284,22 @@ namespace NAM {
|
|||||||
|
|
||||||
for (unsigned int i = 0; i < n_samples; i++)
|
for (unsigned int i = 0; i < n_samples; i++)
|
||||||
{
|
{
|
||||||
ports.audio_out[i] = outputPtrs[0][i] * level;
|
ports.audio_out[i] = ports.audio_out[i] * level;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float dcBlockCoefficient = 1 - (220.0 / sampleRate);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < n_samples; i++)
|
||||||
|
{
|
||||||
|
float dcInput = ports.audio_out[i];
|
||||||
|
|
||||||
|
// dc blocker
|
||||||
|
ports.audio_out[i] = ports.audio_out[i] - prevDCInput + dcBlockCoefficient * prevDCOutput;
|
||||||
|
|
||||||
|
prevDCInput = dcInput;
|
||||||
|
prevDCOutput = ports.audio_out[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Plugin::options_get(LV2_Handle, LV2_Options_Option*)
|
uint32_t Plugin::options_get(LV2_Handle, LV2_Options_Option*)
|
||||||
|
|||||||
+5
-7
@@ -22,7 +22,6 @@
|
|||||||
#include <lv2/units/units.h>
|
#include <lv2/units/units.h>
|
||||||
|
|
||||||
#include <NAM/dsp.h>
|
#include <NAM/dsp.h>
|
||||||
#include <dsp/RecursiveLinearFilter.h>
|
|
||||||
|
|
||||||
#define PlUGIN_URI "http://github.com/mikeoliphant/neural-amp-modeler-lv2"
|
#define PlUGIN_URI "http://github.com/mikeoliphant/neural-amp-modeler-lv2"
|
||||||
#define MODEL_URI PlUGIN_URI "#model"
|
#define MODEL_URI PlUGIN_URI "#model"
|
||||||
@@ -44,12 +43,12 @@ namespace NAM {
|
|||||||
struct LV2SwitchModelMsg {
|
struct LV2SwitchModelMsg {
|
||||||
LV2WorkType type;
|
LV2WorkType type;
|
||||||
char path[MAX_FILE_NAME];
|
char path[MAX_FILE_NAME];
|
||||||
::DSP* model;
|
nam::DSP* model;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LV2FreeModelMsg {
|
struct LV2FreeModelMsg {
|
||||||
LV2WorkType type;
|
LV2WorkType type;
|
||||||
::DSP* model;
|
nam::DSP* model;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Plugin {
|
class Plugin {
|
||||||
@@ -71,11 +70,10 @@ namespace NAM {
|
|||||||
LV2_Log_Logger logger = {};
|
LV2_Log_Logger logger = {};
|
||||||
LV2_Worker_Schedule* schedule = nullptr;
|
LV2_Worker_Schedule* schedule = nullptr;
|
||||||
|
|
||||||
::DSP* currentModel = nullptr;
|
nam::DSP* currentModel = nullptr;
|
||||||
std::string currentModelPath;
|
std::string currentModelPath;
|
||||||
recursive_linear_filter::HighPass mHighPass;
|
float prevDCInput = 0;
|
||||||
|
float prevDCOutput = 0;
|
||||||
std::unordered_map<std::string, double> mNAMParams = {};
|
|
||||||
|
|
||||||
Plugin();
|
Plugin();
|
||||||
~Plugin();
|
~Plugin();
|
||||||
|
|||||||
Reference in New Issue
Block a user