mirror of
https://github.com/mikeoliphant/neural-amp-modeler-lv2.git
synced 2026-05-06 19:50:11 +02:00
Do 5Hz high pass filter to clean up any DC offset created by the model
This commit is contained in:
+3
-1
@@ -22,11 +22,13 @@ 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/NAM)
|
||||
include_directories(SYSTEM deps/NeuralAmpModelerCore)
|
||||
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
-1
Submodule deps/NeuralAmpModelerCore updated: accaa16ef3...de9cf22b0d
+7
-1
@@ -17,10 +17,16 @@ set(NAM_SOURCES ../deps/NeuralAmpModelerCore/NAM/activations.h
|
||||
../deps/NeuralAmpModelerCore/NAM/convnet.cpp
|
||||
../deps/NeuralAmpModelerCore/NAM/convnet.h)
|
||||
|
||||
add_library(neural_amp_modeler MODULE ${SOURCES} ${NAM_SOURCES})
|
||||
set(DSP_SOURCES ../deps/NeuralAmpModelerCore/dsp/dsp.h
|
||||
../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(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)
|
||||
|
||||
|
||||
+16
-5
@@ -1,10 +1,10 @@
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
|
||||
#include "nam_plugin.h"
|
||||
#include "activations.h"
|
||||
#include <cassert>
|
||||
#include <NAM/activations.h>
|
||||
|
||||
#define SMOOTH_EPSILON .0001f
|
||||
|
||||
@@ -20,8 +20,14 @@ namespace NAM {
|
||||
delete currentModel;
|
||||
}
|
||||
|
||||
bool Plugin::initialize(double rate, const LV2_Feature* const* features) noexcept
|
||||
bool Plugin::initialize(double sampleRate, const LV2_Feature* const* features) noexcept
|
||||
{
|
||||
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
|
||||
LV2_Options_Option* options = nullptr;
|
||||
|
||||
@@ -243,10 +249,15 @@ namespace NAM {
|
||||
}
|
||||
}
|
||||
|
||||
float** outputPtrs = &ports.audio_out;
|
||||
|
||||
if (currentModel != nullptr)
|
||||
{
|
||||
currentModel->process(&ports.audio_out, &ports.audio_out, 1, n_samples, 1.0, 1.0, mNAMParams);
|
||||
currentModel->finalize_(n_samples);
|
||||
|
||||
// Apply a high pass filter at 5Hz to eliminate any DC offset
|
||||
outputPtrs = mHighPass.Process(outputPtrs, 1, n_samples);
|
||||
}
|
||||
|
||||
// convert output level from db
|
||||
@@ -259,7 +270,7 @@ namespace NAM {
|
||||
// do very basic smoothing
|
||||
outputLevel = (.99f * outputLevel) + (.01f * desiredOutputLevel);
|
||||
|
||||
ports.audio_out[i] *= outputLevel;
|
||||
ports.audio_out[i] = outputPtrs[0][i] * outputLevel;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -268,7 +279,7 @@ namespace NAM {
|
||||
|
||||
for (unsigned int i = 0; i < n_samples; i++)
|
||||
{
|
||||
ports.audio_out[i] *= outputLevel;
|
||||
ports.audio_out[i] = outputPtrs[0][i] * outputLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -21,7 +21,8 @@
|
||||
#include <lv2/state/state.h>
|
||||
#include <lv2/units/units.h>
|
||||
|
||||
#include "dsp.h"
|
||||
#include <NAM/dsp.h>
|
||||
#include <dsp/RecursiveLinearFilter.h>
|
||||
|
||||
#define PlUGIN_URI "http://github.com/mikeoliphant/neural-amp-modeler-lv2"
|
||||
#define MODEL_URI PlUGIN_URI "#model"
|
||||
@@ -64,12 +65,15 @@ namespace NAM {
|
||||
|
||||
Ports ports = {};
|
||||
|
||||
double sampleRate;
|
||||
|
||||
LV2_URID_Map* map = nullptr;
|
||||
LV2_Log_Logger logger = {};
|
||||
LV2_Worker_Schedule* schedule = nullptr;
|
||||
|
||||
::DSP* currentModel = nullptr;
|
||||
std::string currentModelPath;
|
||||
recursive_linear_filter::HighPass mHighPass;
|
||||
|
||||
std::unordered_map<std::string, double> mNAMParams = {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user