Resurrect pipedalProfilePlugin, and amd64 benchmarks.

This commit is contained in:
Robin E.R. Davies
2026-04-21 00:36:13 -04:00
parent ca50da5630
commit 8ade50a3ac
5 changed files with 110 additions and 11 deletions
+32 -1
View File
@@ -328,6 +328,37 @@
"ignoreFailures": true "ignoreFailures": true
} }
] ]
} },
{
"name": "(gdb) pipedalProfilePlugin",
"type": "cppdbg",
"request": "launch",
// Resolved by CMake Tools:
"program": "${command:cmake.launchTargetPath}",
"args": [
"--no-profile",
"--preset-file", "/home/robin/Downloads/NAM Profiling.piPreset",
"--seconds", "100",
"-w"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [
{
"name": "PATH",
"value": "$PATH:${command:cmake.launchTargetDirectory}"
}
],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
] ]
} }
+3
View File
@@ -546,6 +546,9 @@ bool Lv2Pedalboard::Run(float **inputBuffers, float **outputBuffers, uint32_t sa
float volume = outputVolume.Tick(); float volume = outputVolume.Tick();
for (size_t c = 0; c < this->pedalboardOutputBuffers.size(); ++c) for (size_t c = 0; c < this->pedalboardOutputBuffers.size(); ++c)
{ {
if (outputBuffers[c] == nullptr) {
break;
}
outputBuffers[c][i] = this->pedalboardOutputBuffers[c][i] * volume; outputBuffers[c][i] = this->pedalboardOutputBuffers[c][i] * volume;
} }
} }
+1
View File
@@ -18,6 +18,7 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "WebServerConfig.hpp" #include "WebServerConfig.hpp"
#include "PresetBundle.hpp"
#include "WebServer.hpp" #include "WebServer.hpp"
#include <boost/system/error_code.hpp> #include <boost/system/error_code.hpp>
#include <filesystem> #include <filesystem>
+57 -10
View File
@@ -7,6 +7,7 @@
#include <thread> #include <thread>
#include <chrono> #include <chrono>
#include "ss.hpp" #include "ss.hpp"
#include "PresetBundle.hpp"
// apt install google-perftools // apt install google-perftools
#include <gperftools/profiler.h> #include <gperftools/profiler.h>
@@ -78,6 +79,22 @@ private:
std::unique_ptr<std::thread> thread; std::unique_ptr<std::thread> thread;
WriterRingbuffer &writerRingbuffer; WriterRingbuffer &writerRingbuffer;
}; };
static bool IsZipFile(const std::filesystem::path &path)
{
std::ifstream f(path);
if (!f.is_open())
return false;
char c[4];
memset(c, 0, sizeof(c));
f >> c[0] >> c[1] >> c[2] >> c[3];
// official file header according to PKware documetnation.
return c[0] == 0x50 && c[1] == 0x4B && c[2] == 0x03 && c[3] == 0x04;
}
struct ProfileOptions struct ProfileOptions
{ {
std::string presetName; std::string presetName;
@@ -127,6 +144,7 @@ void profilePlugin(const ProfileOptions &profileOptions)
if (profileOptions.presetName.length() != 0) if (profileOptions.presetName.length() != 0)
{ {
PresetIndex presetIndex; PresetIndex presetIndex;
model.GetPresets(&presetIndex); model.GetPresets(&presetIndex);
@@ -149,26 +167,50 @@ void profilePlugin(const ProfileOptions &profileOptions)
} }
else if (profileOptions.presetFileName.length() != 0) else if (profileOptions.presetFileName.length() != 0)
{ {
std::ifstream f(profileOptions.presetFileName); std::filesystem::path filePath = profileOptions.presetFileName;
if (!f.is_open())
if (IsZipFile(filePath))
{ {
throw std::runtime_error(SS("Unable to load preset file " << profileOptions.presetFileName << ".")); auto presetReader = PresetBundleReader::LoadPresetsFile(model, filePath);
} presetReader->ExtractMediaFiles();
try
{ std::stringstream ss(presetReader->GetPresetJson());
json_reader reader(f); json_reader reader(ss);
BankFile bankFile; BankFile bankFile;
reader.read(&bankFile); reader.read(&bankFile);
if (bankFile.presets().size() != 1) if (bankFile.presets().size() != 1)
{ {
throw new std::runtime_error(SS("Invalid preset file. Expection one preset, but " << bankFile.presets().size() << " presets were found.")); throw new std::runtime_error(SS("Invalid preset file. Expection one preset, but " << bankFile.presets().size() << " presets were found."));
} }
Pedalboard pedalboard = (bankFile.presets()[0]->preset()); Pedalboard pedalboard = (bankFile.presets()[0]->preset());
model.SetPedalboard(-1,pedalboard); model.SetPedalboard(-1, pedalboard);
} }
catch (const std::exception &e) else
{ {
throw std::runtime_error(SS("Invalid file format: " << profileOptions.presetFileName << ". " << e.what() ));
std::ifstream f(profileOptions.presetFileName);
if (!f.is_open())
{
throw std::runtime_error(SS("Unable to load preset file " << profileOptions.presetFileName << "."));
}
try
{
json_reader reader(f);
BankFile bankFile;
reader.read(&bankFile);
if (bankFile.presets().size() != 1)
{
throw new std::runtime_error(SS("Invalid preset file. Expection one preset, but " << bankFile.presets().size() << " presets were found."));
}
Pedalboard pedalboard = (bankFile.presets()[0]->preset());
model.SetPedalboard(-1, pedalboard);
}
catch (const std::exception &e)
{
throw std::runtime_error(SS("Invalid file format: " << profileOptions.presetFileName << ". " << e.what()));
}
} }
} }
else else
@@ -197,6 +239,7 @@ void profilePlugin(const ProfileOptions &profileOptions)
RingBufferSink ringBufferSink(writerRingbuffer); RingBufferSink ringBufferSink(writerRingbuffer);
// run once to get memory allocations in NAM and ML out of the way. // run once to get memory allocations in NAM and ML out of the way.
lv2Pedalboard->ResetAtomBuffers();
lv2Pedalboard->Run(inputBuffers, outputBuffers, nFrames, &ringBufferWriter); lv2Pedalboard->Run(inputBuffers, outputBuffers, nFrames, &ringBufferWriter);
/* *** Pump the plugin for a bit if it is expected to do work on the scheduler thread when initializing */ /* *** Pump the plugin for a bit if it is expected to do work on the scheduler thread when initializing */
@@ -210,6 +253,7 @@ void profilePlugin(const ProfileOptions &profileOptions)
while (true) while (true)
{ {
lv2Pedalboard->ResetAtomBuffers();
lv2Pedalboard->Run(inputBuffers, outputBuffers, nFrames, &ringBufferWriter); lv2Pedalboard->Run(inputBuffers, outputBuffers, nFrames, &ringBufferWriter);
auto elapsed = clock::now() - waitStart; auto elapsed = clock::now() - waitStart;
@@ -235,6 +279,7 @@ void profilePlugin(const ProfileOptions &profileOptions)
size_t repetitions = static_cast<size_t>(48000 * profileOptions.benchmark_seconds / nFrames); size_t repetitions = static_cast<size_t>(48000 * profileOptions.benchmark_seconds / nFrames);
for (size_t i = 0; i < repetitions; ++i) for (size_t i = 0; i < repetitions; ++i)
{ {
lv2Pedalboard->ResetAtomBuffers();
lv2Pedalboard->Run(inputBuffers, outputBuffers, nFrames, &ringBufferWriter); lv2Pedalboard->Run(inputBuffers, outputBuffers, nFrames, &ringBufferWriter);
} }
@@ -298,6 +343,8 @@ int main(int argc, char **argv)
cout << "Options:" << endl; cout << "Options:" << endl;
cout << " --no-profile:" << endl; cout << " --no-profile:" << endl;
cout << " do NOT generate a perf file." << endl; cout << " do NOT generate a perf file." << endl;
cout << " --nam-core:" << endl;
cout << " Force use of NAM Core models." << endl;
cout << " -p, --preset-file filename:" << endl; cout << " -p, --preset-file filename:" << endl;
cout << " Load the specified preset file. " << endl; cout << " Load the specified preset file. " << endl;
cout << " -o, --output filename:" << endl; cout << " -o, --output filename:" << endl;
+17
View File
@@ -1,3 +1,20 @@
Benchmark Results:
amd64 (Ubuntu 24.04)
NeuralAudio x64: 5.416s
Neural Modeler Core: 7.965s
CPU: AMD Ryzen 7 7735HS with Radeon Graphics
OS: Ubuntu 24.04 (amd64)
/home/robin/Downloads/NAM Test/media/NeuralAmpModels/Fender Deluxe Reverb %2765 Reissue %7c Clean %7c SM57 %2b Royer R-121 %2b Room/
summaries for Mono audio adapaters. summaries for Mono audio adapaters.
Check PWA on windows, edge and chrome. Check PWA on windows, edge and chrome.
Make sure Pi 4 default audio device is still hidden when selecting devices! Make sure Pi 4 default audio device is still hidden when selecting devices!