mirror of
https://github.com/mikeoliphant/neural-amp-modeler-lv2.git
synced 2026-05-06 19:50:11 +02:00
only do smoothing if we need to, and keep db conversion out of the sampe loop
This commit is contained in:
+42
-10
@@ -6,6 +6,8 @@
|
||||
#include "activations.h"
|
||||
#include <cassert>
|
||||
|
||||
#define SMOOTH_EPSILON .0001f
|
||||
|
||||
namespace NAM {
|
||||
Plugin::Plugin()
|
||||
{
|
||||
@@ -186,12 +188,27 @@ namespace NAM {
|
||||
if (dblData.size() != n_samples)
|
||||
dblData.resize(n_samples);
|
||||
|
||||
for (unsigned int i = 0; i < n_samples; i++)
|
||||
{
|
||||
// Convert input level from db and do very basic smoothing
|
||||
inputLevel = (.99f * inputLevel) + (.01f * powf(10, *(ports.input_level) * 0.05f));
|
||||
// convert input level from db
|
||||
float desiredInputLevel = powf(10, *(ports.input_level) * 0.05f);
|
||||
|
||||
dblData[i] = ports.audio_in[i] * inputLevel;
|
||||
if (fabs(desiredInputLevel - inputLevel) > SMOOTH_EPSILON)
|
||||
{
|
||||
for (unsigned int i = 0; i < n_samples; i++)
|
||||
{
|
||||
// do very basic smoothing
|
||||
inputLevel = (.99f * inputLevel) + (.01f * desiredInputLevel);
|
||||
|
||||
dblData[i] = ports.audio_in[i] * inputLevel;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
inputLevel = desiredInputLevel;
|
||||
|
||||
for (unsigned int i = 0; i < n_samples; i++)
|
||||
{
|
||||
dblData[i] = ports.audio_in[i] * inputLevel;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentModel == nullptr)
|
||||
@@ -205,12 +222,27 @@ namespace NAM {
|
||||
currentModel->finalize_(n_samples);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < n_samples; i++)
|
||||
{
|
||||
// Convert output level from db and do very basic smoothing
|
||||
outputLevel = (.99f * outputLevel) + (.01f * powf(10, *(ports.output_level) * 0.05f));
|
||||
// convert output level from db
|
||||
float desiredOutputLevel = powf(10, *(ports.output_level) * 0.05f);
|
||||
|
||||
ports.audio_out[i] = (float)(dblData[i] * outputLevel);
|
||||
if (fabs(desiredOutputLevel - outputLevel) > SMOOTH_EPSILON)
|
||||
{
|
||||
for (unsigned int i = 0; i < n_samples; i++)
|
||||
{
|
||||
// do very basic smoothing
|
||||
outputLevel = (.99f * outputLevel) + (.01f * desiredOutputLevel);
|
||||
|
||||
ports.audio_out[i] = (float)(dblData[i] * outputLevel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
outputLevel = desiredOutputLevel;
|
||||
|
||||
for (unsigned int i = 0; i < n_samples; i++)
|
||||
{
|
||||
ports.audio_out[i] = (float)(dblData[i] * outputLevel);
|
||||
}
|
||||
}
|
||||
|
||||
if (stateChanged)
|
||||
|
||||
Reference in New Issue
Block a user