From 5ee86c519f6c81b121a1d47ada0cff1742a20708 Mon Sep 17 00:00:00 2001 From: "Robin E.R. Davies" Date: Wed, 20 May 2026 09:30:55 -0400 Subject: [PATCH] A2 UI --- .vscode/launch.json | 4 +- PiPedalCommon/src/DBusDispatcher.cpp | 3 +- PiPedalCommon/src/include/DBusDispatcher.hpp | 2 +- src/PiPedalModel.cpp | 10 ++++- src/PiPedalModel.hpp | 3 +- src/profilePluginMain.cpp | 2 + vite/src/pipedal/ToobNamView.tsx | 43 +++++++++++--------- 7 files changed, 42 insertions(+), 25 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index ccadb2a..dac42b7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -337,8 +337,8 @@ "program": "${command:cmake.launchTargetPath}", "args": [ "--no-profile", - "--preset-file", "/home/robin/Downloads/NAM Profiling.piPreset", - "--seconds", "100", + "--preset-file", "/home/robin/Downloads/A1 Profiling.piPreset", + "--seconds", "1", "-w" ], "stopAtEntry": false, diff --git a/PiPedalCommon/src/DBusDispatcher.cpp b/PiPedalCommon/src/DBusDispatcher.cpp index 412db24..e440552 100644 --- a/PiPedalCommon/src/DBusDispatcher.cpp +++ b/PiPedalCommon/src/DBusDispatcher.cpp @@ -208,8 +208,9 @@ void DBusDispatcher::WaitForClose() serviceThread.join(); } } - catch (const std::exception &) + catch (const std::exception &e) { + std::cout << "DBusDispatcher: " << e.what() << std::endl; } if (eventFd != -1) { diff --git a/PiPedalCommon/src/include/DBusDispatcher.hpp b/PiPedalCommon/src/include/DBusDispatcher.hpp index 1da5414..9bc7299 100644 --- a/PiPedalCommon/src/include/DBusDispatcher.hpp +++ b/PiPedalCommon/src/include/DBusDispatcher.hpp @@ -78,7 +78,7 @@ private: std::atomic stopping; std::vector postedEvents; - bool threadStarted; + bool threadStarted = false; std::thread serviceThread; std::mutex postMutex; }; \ No newline at end of file diff --git a/src/PiPedalModel.cpp b/src/PiPedalModel.cpp index f7834a0..f3188ad 100644 --- a/src/PiPedalModel.cpp +++ b/src/PiPedalModel.cpp @@ -80,7 +80,6 @@ PiPedalModel::PiPedalModel() atomConverter(pluginHost.GetMapFeature()) { this->updater = Updater::Create(); - this->updater->Start(); this->currentUpdateStatus = updater->GetCurrentStatus(); this->pedalboard = Pedalboard::MakeDefault(); @@ -211,6 +210,10 @@ PiPedalModel::~PiPedalModel() void PiPedalModel::Init(const PiPedalConfiguration &configuration) { std::lock_guard lock(mutex); // prevent callbacks while we're initializing. + if (updaterEnabled) + { + this->updater->Start(); + } this->configuration = configuration; pluginHost.SetConfiguration(configuration); @@ -3452,3 +3455,8 @@ std::string PiPedalModel::Tone3000ThumbnailDirectory() } +void PiPedalModel::EnableUpdater(bool enable) +{ + this->updaterEnabled = enable; +} + diff --git a/src/PiPedalModel.hpp b/src/PiPedalModel.hpp index d62d84b..df7661a 100644 --- a/src/PiPedalModel.hpp +++ b/src/PiPedalModel.hpp @@ -119,6 +119,7 @@ namespace pipedal using NetworkChangedListener = std::function; private: + bool updaterEnabled = true; PedalboardItem *GetPedalboardItemForFileProperty(const UiFileProperty &fileProperty); // Tone3000Downloader::Listener implementation @@ -296,7 +297,7 @@ namespace pipedal Decrease }; - + void EnableUpdater(bool enable); Storage &GetStorage() { return storage; } diff --git a/src/profilePluginMain.cpp b/src/profilePluginMain.cpp index 215db9d..4c89cef 100644 --- a/src/profilePluginMain.cpp +++ b/src/profilePluginMain.cpp @@ -132,7 +132,9 @@ void profilePlugin(const ProfileOptions &profileOptions) throw std::runtime_error(s.str()); } + model.EnableUpdater(false); model.Init(configuration); + model.GetPluginHost().asIHost()->SetMaxAudioBufferSize(64); model.LoadLv2PluginInfo(); diff --git a/vite/src/pipedal/ToobNamView.tsx b/vite/src/pipedal/ToobNamView.tsx index dfa2677..03701f0 100644 --- a/vite/src/pipedal/ToobNamView.tsx +++ b/vite/src/pipedal/ToobNamView.tsx @@ -38,9 +38,23 @@ import { CustomPluginControl } from './PluginControl'; const TOOB_NAM__MODEL_METADATA_URI = "http://two-play.com/plugins/toob-nam#model_metadata"; const TOOB_NAM__MODEL_WEIGHT_URI = "http://two-play.com/plugins/toob-nam#modelWeight"; + +enum NamModelType { + None = 0, + A1 = 1, + A2 = 2 +}; + +function floatToModelType(value: number): NamModelType { + switch (value) { + case 0: return NamModelType.None; + case 1: return NamModelType.A1; + case 2: return NamModelType.A2; + default: return NamModelType.None; + } +} // offset 0: an integer with the folloing bits set. // Must match ToobAmp/src/NeuralAmpModeler_Lv2Extensions.hpp enum TOOB_NAM_METADATA_OFFSETS -const MAX_SLIMMABLE_WEIGHTS = 16; class TOOB_NAM_METADATA_OFFSETS { static readonly flags = 0; static readonly preset_version = 1; @@ -48,11 +62,10 @@ class TOOB_NAM_METADATA_OFFSETS { static readonly gain = 3; static readonly input_level_dbu = 4; static readonly output_level_dbu = 5; - static readonly is_a2 = 6; + static readonly has_slimmable_weights = 6; static readonly model_weight = 7; - static readonly slimmable_weights_size = 8; - static readonly slimmable_weights = 9; - static readonly max_medatadata = TOOB_NAM_METADATA_OFFSETS.slimmable_weights + MAX_SLIMMABLE_WEIGHTS; + static readonly model_type = 8; + static readonly max_medatadata = 9; }; @@ -81,12 +94,9 @@ class ModelMetadata { this.inputlevelDBU = metadataValues[TOOB_NAM_METADATA_OFFSETS.input_level_dbu]; this.outputlevelDBU = metadataValues[TOOB_NAM_METADATA_OFFSETS.output_level_dbu]; this.preset_version = metadataValues[TOOB_NAM_METADATA_OFFSETS.preset_version]; - this.isA2 = metadataValues[TOOB_NAM_METADATA_OFFSETS.is_a2] !== 0; + this.hasSlimmableWeights = metadataValues[TOOB_NAM_METADATA_OFFSETS.has_slimmable_weights] !== 0; this.modelWeight = metadataValues[TOOB_NAM_METADATA_OFFSETS.model_weight]; - let slimmableWeightsSize = metadataValues[TOOB_NAM_METADATA_OFFSETS.slimmable_weights_size]; - for (let i = 0; i < slimmableWeightsSize && i < 16; ++i) { - this.slimmable_weights.push(metadataValues[TOOB_NAM_METADATA_OFFSETS.slimmable_weights + i]); - } + this.modelType = floatToModelType(metadataValues[TOOB_NAM_METADATA_OFFSETS.model_type]); } else { this.hasModel = false; this.hasLoudness = false; @@ -96,19 +106,18 @@ class ModelMetadata { this.loudness = 0; this.gain = 0; + this.hasSlimmableWeights = false; this.inputlevelDBU = 0; this.outputlevelDBU = 0; this.preset_version = 1; this.modelWeight = -1; - this.isA2 = false; - this.slimmable_weights = []; } } preset_version: number; - isA2: boolean = false; + hasSlimmableWeights: boolean = false; modelWeight: number = 1.0; - slimmable_weights: number[] = []; + modelType: NamModelType; hasModel: boolean; hasLoudness: boolean; hasGain: boolean; @@ -120,10 +129,6 @@ class ModelMetadata { inputlevelDBU: number; outputlevelDBU: number; - hasSlimmableWeights(): boolean { - return this.slimmable_weights.length > 0; - } - } @@ -255,7 +260,7 @@ const ToobNamView = if (!this.state.showEqSection) { controls.splice(EqPos, 1); } - if (this.state.modelMetadata.hasSlimmableWeights()) { + if (this.state.modelMetadata.hasSlimmableWeights) { controls.splice(3, 0, this.MakeModelWeightSelector(host)); } return controls;