diff --git a/NeuralAmpModeler/NeuralAmpModeler.cpp b/NeuralAmpModeler/NeuralAmpModeler.cpp index 0642bc8d..c7af79da 100644 --- a/NeuralAmpModeler/NeuralAmpModeler.cpp +++ b/NeuralAmpModeler/NeuralAmpModeler.cpp @@ -320,22 +320,31 @@ void NeuralAmpModeler::ProcessBlock(iplug::sample** inputs, iplug::sample** outp mModel->process(newInputs[0], newOutputs[0], newNFrames); mModel->finalize_(newNFrames); }); + + auto outputGain = GetParam(kOutputLevel)->DBToAmp(); + + // Apply loudness normalization and output level gain + if (mModel->HasLoudness()) + { + const auto loudness = mModel->GetLoudness(); + const auto targetLoudness = -18.0; + const auto loudnessGain = pow(10.0, (targetLoudness - loudness) / 20.0); + outputGain *= loudnessGain; + } + + for (auto s=0; sDBToAmp(); - - for (auto s=0; s