|
1 | 1 | #include <algorithm> // std::clamp
|
2 |
| -#include <cmath> |
| 2 | +#include <cmath> // pow |
3 | 3 | #include <filesystem>
|
4 | 4 | #include <iostream>
|
5 | 5 | #include <utility>
|
@@ -143,7 +143,7 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info)
|
143 | 143 | contentArea.GetFromBottom((2.0f * fileHeight)).GetFromTop(fileHeight).GetMidHPadded(fileWidth).GetVShifted(-1);
|
144 | 144 | const auto modelIconArea = modelArea.GetFromLeft(30).GetTranslated(-40, 10);
|
145 | 145 | const auto irArea = modelArea.GetVShifted(irYOffset);
|
146 |
| - const auto irSwitchArea = irArea.GetFromLeft(30).GetHShifted(-40).GetScaledAboutCentre(0.6); |
| 146 | + const auto irSwitchArea = irArea.GetFromLeft(30.0f).GetHShifted(-40.0f).GetScaledAboutCentre(0.6f); |
147 | 147 |
|
148 | 148 | // Areas for meters
|
149 | 149 | const auto inputMeterArea = contentArea.GetFromLeft(30).GetHShifted(-20).GetMidVPadded(100).GetVShifted(-25);
|
@@ -293,13 +293,15 @@ void NeuralAmpModeler::ProcessBlock(iplug::sample** inputs, iplug::sample** outp
|
293 | 293 |
|
294 | 294 | if (mModel != nullptr)
|
295 | 295 | {
|
296 |
| - mModel->SetNormalize(GetParam(kOutNorm)->Value()); |
297 |
| - // TODO remove input / output gains from here. |
298 |
| - const double inputGain = 1.0; |
299 |
| - const double outputGain = 1.0; |
300 |
| - const int nChans = (int)numChannelsInternal; |
301 |
| - mModel->process(triggerOutput, mOutputPointers, nChans, nFrames, inputGain, outputGain, mNAMParams); |
| 296 | + // TODO multi-channel processing; Issue |
| 297 | + // <ake sure it's multi-threaded or else this won't perform well! |
| 298 | + mModel->process(triggerOutput[0], mOutputPointers[0], nFrames); |
302 | 299 | mModel->finalize_(nFrames);
|
| 300 | + // Normalize loudness |
| 301 | + if (GetParam(kOutNorm)->Value()) |
| 302 | + { |
| 303 | + _NormalizeModelOutput(mOutputPointers, numChannelsInternal, numFrames); |
| 304 | + } |
303 | 305 | }
|
304 | 306 | else
|
305 | 307 | {
|
@@ -592,6 +594,24 @@ void NeuralAmpModeler::_FallbackDSP(iplug::sample** inputs, iplug::sample** outp
|
592 | 594 | mOutputArray[c][s] = mInputArray[c][s];
|
593 | 595 | }
|
594 | 596 |
|
| 597 | +void NeuralAmpModeler::_NormalizeModelOutput(iplug::sample** buffer, const size_t numChannels, const size_t numFrames) |
| 598 | +{ |
| 599 | + if (!mModel) |
| 600 | + return; |
| 601 | + if (!mModel->HasLoudness()) |
| 602 | + return; |
| 603 | + const double loudness = mModel->GetLoudness(); |
| 604 | + const double targetLoudness = -18.0; |
| 605 | + const double gain = pow(10.0, (targetLoudness - loudness) / 20.0); |
| 606 | + for (size_t c = 0; c < numChannels; c++) |
| 607 | + { |
| 608 | + for (size_t f = 0; f < numFrames; f++) |
| 609 | + { |
| 610 | + buffer[c][f] *= gain; |
| 611 | + } |
| 612 | + } |
| 613 | +} |
| 614 | + |
595 | 615 | void NeuralAmpModeler::_ResampleModelAndIR()
|
596 | 616 | {
|
597 | 617 | const auto sampleRate = GetSampleRate();
|
|
0 commit comments