From 71fc534a786af23ff3c51551c74161ae326683fa Mon Sep 17 00:00:00 2001 From: "Robin E. R. Davies" Date: Sat, 19 Jul 2025 13:26:53 -0400 Subject: [PATCH] Control Zooming disabled. --- src/Pedalboard.cpp | 1 + src/Pedalboard.hpp | 3 ++ src/PiPedalModel.cpp | 12 +++++++ src/PiPedalModel.hpp | 2 ++ src/PiPedalSocket.cpp | 21 +++++++++++ todo.txt | 2 ++ vite/src/pipedal/MainPage.tsx | 50 ++++++++++++++++---------- vite/src/pipedal/Pedalboard.tsx | 2 ++ vite/src/pipedal/PedalboardView.tsx | 4 ++- vite/src/pipedal/PiPedalModel.tsx | 15 ++++++++ vite/src/pipedal/PluginControl.tsx | 18 +++++----- vite/src/pipedal/PluginControlView.tsx | 5 +-- vite/src/pipedal/PresetSelector.tsx | 2 +- vite/src/pipedal/ZoomedUiControl.tsx | 5 ++- 14 files changed, 109 insertions(+), 33 deletions(-) diff --git a/src/Pedalboard.cpp b/src/Pedalboard.cpp index 9296906..6093736 100644 --- a/src/Pedalboard.cpp +++ b/src/Pedalboard.cpp @@ -537,6 +537,7 @@ JSON_MAP_BEGIN(Pedalboard) JSON_MAP_REFERENCE(Pedalboard,nextInstanceId) JSON_MAP_REFERENCE(Pedalboard,snapshots) JSON_MAP_REFERENCE(Pedalboard,selectedSnapshot) + JSON_MAP_REFERENCE(Pedalboard,selectedPlugin) JSON_MAP_END() JSON_MAP_BEGIN(SnapshotValue) diff --git a/src/Pedalboard.hpp b/src/Pedalboard.hpp index 8ef6fd9..cb65855 100644 --- a/src/Pedalboard.hpp +++ b/src/Pedalboard.hpp @@ -197,6 +197,8 @@ class Pedalboard { std::vector> snapshots_; int64_t selectedSnapshot_ = -1; + int64_t selectedPlugin_ = -1; + public: // deep copy, breaking shared pointers. Pedalboard DeepCopy(); @@ -224,6 +226,7 @@ public: GETTER_SETTER(output_volume_db) GETTER_SETTER_VEC(snapshots) GETTER_SETTER(selectedSnapshot) + GETTER_SETTER(selectedPlugin) DECLARE_JSON_MAP(Pedalboard); diff --git a/src/PiPedalModel.cpp b/src/PiPedalModel.cpp index fcc8eb5..5049cb9 100644 --- a/src/PiPedalModel.cpp +++ b/src/PiPedalModel.cpp @@ -2595,6 +2595,16 @@ std::shared_ptr PiPedalModel::GetLv2Pedalboard() } return lv2Pedalboard; } + +void PiPedalModel::SetSelectedPedalboardPlugin(uint64_t clientId, uint64_t pedalboardId) +{ + // Thinking on this: + // 1) do NOT mark the pedalboard as changed. This shouldn't set a change flag. + // 2) do NOT broadcast the change. Whoever set it last controls what happens when the plugin is reloaded. Meh. + // 3) Clients must be able to save a non-changed pedalboard. + pedalboard.selectedPlugin(pedalboardId); +} + bool PiPedalModel::LoadCurrentPedalboard() { if (previousPedalboardLoaded && pedalboard.IsStructureIdentical(previousPedalboard)) @@ -3075,3 +3085,5 @@ bool PiPedalModel::HasTone3000Auth() const return storage.GetTone3000Auth() != ""; } + + diff --git a/src/PiPedalModel.hpp b/src/PiPedalModel.hpp index 0a54af1..9145be4 100644 --- a/src/PiPedalModel.hpp +++ b/src/PiPedalModel.hpp @@ -489,6 +489,8 @@ namespace pipedal void SetTone3000Auth(const std::string &apiKey); bool HasTone3000Auth() const; + void SetSelectedPedalboardPlugin(uint64_t clientId, uint64_t pedalboardId); + }; } // namespace pipedal. \ No newline at end of file diff --git a/src/PiPedalSocket.cpp b/src/PiPedalSocket.cpp index f54c14f..83d1bfe 100644 --- a/src/PiPedalSocket.cpp +++ b/src/PiPedalSocket.cpp @@ -472,6 +472,21 @@ JSON_MAP_REFERENCE(SetSnapshotsBody, snapshots) JSON_MAP_REFERENCE(SetSnapshotsBody, selectedSnapshot) JSON_MAP_END() +class SetSelectedPedalboardPluginBody +{ +public: + uint64_t clientId_; + uint64_t pluginInstanceId_; + + DECLARE_JSON_MAP(SetSelectedPedalboardPluginBody); +}; + +JSON_MAP_BEGIN(SetSelectedPedalboardPluginBody) +JSON_MAP_REFERENCE(SetSelectedPedalboardPluginBody, clientId) +JSON_MAP_REFERENCE(SetSelectedPedalboardPluginBody, pluginInstanceId) +JSON_MAP_END() + + class SnapshotModifiedBody { public: @@ -1300,6 +1315,12 @@ public: int64_t result = this->model.SaveCurrentPresetAs(this->clientId, body.name_, body.saveAfterInstanceId_); Reply(replyTo, "saveCurrentPresetsAs", result); } + else if (message == "setSelectedPedalboardPlugin") + { + SetSelectedPedalboardPluginBody body; + pReader->read(&body); + this->model.SetSelectedPedalboardPlugin(body.clientId_,body.pluginInstanceId_); + } else if (message == "savePluginPresetAs") { SavePluginPresetAsBody body; diff --git a/todo.txt b/todo.txt index 2e6706f..5776346 100644 --- a/todo.txt +++ b/todo.txt @@ -1,3 +1,5 @@ +Crash-proofing: do not reload pedalboard if the previous run crashed before normal shutdown. + Persist and reconnect IP addresses in client. Zeroconv crash assert. /var/pipedal/audio_uploads/ReverbImpulseFiles/ diff --git a/vite/src/pipedal/MainPage.tsx b/vite/src/pipedal/MainPage.tsx index 8d3f3e9..a1ea987 100644 --- a/vite/src/pipedal/MainPage.tsx +++ b/vite/src/pipedal/MainPage.tsx @@ -82,7 +82,7 @@ const styles = ({ palette }: Theme) => { }), pedalboardScroll: css({ position: "relative", width: "100%", - flex: "0 0 auto", overflow: "auto", maxHeight: 220, + flex: "0 0 auto", overflow: "auto", maxHeight: 220, }), pedalboardScrollSmall: css({ position: "relative", width: "100%", @@ -158,7 +158,10 @@ export const MainPage = super(props); this.model = PiPedalModelFactory.getInstance(); let pedalboard = this.model.pedalboard.get(); - let selectedPedal = pedalboard.getFirstSelectableItem(); + let selectedPedal = pedalboard.selectedPlugin; + if (selectedPedal === -1) { + selectedPedal = pedalboard.getFirstSelectableItem(); + } this.state = { selectedPedal: selectedPedal, @@ -243,12 +246,16 @@ export const MainPage = this.model.loadPluginPreset(instanceId, presetInstanceId); } onPedalboardChanged(value: Pedalboard) { - let selectedItem = -1; - if (this.state.selectedPedal === Pedalboard.START_CONTROL || this.state.selectedPedal === Pedalboard.END_CONTROL) { - selectedItem = this.state.selectedPedal; - } else if (value.hasItem(this.state.selectedPedal)) { - selectedItem = this.state.selectedPedal; - } else { + // let selectedItem = -1; + // if (this.state.selectedPedal === Pedalboard.START_CONTROL || this.state.selectedPedal === Pedalboard.END_CONTROL) { + // selectedItem = this.state.selectedPedal; + // } else if (value.hasItem(this.state.selectedPedal)) { + // selectedItem = this.state.selectedPedal; + // } else { + // selectedItem = value.getFirstSelectableItem(); + // } + let selectedItem = value.selectedPlugin; + if (selectedItem === -1 || !value.hasItem(selectedItem)) { selectedItem = value.getFirstSelectableItem(); } this.setState({ @@ -265,9 +272,10 @@ export const MainPage = } onDeletePedal(instanceId: number): void { + // ok. let result = this.model.deletePedalboardPedal(instanceId); - if (result != null) { - this.setState({ selectedPedal: result }); + if (result != null) + this.setSelection(result); { } } @@ -284,9 +292,9 @@ export const MainPage = componentDidUpdate(prevProps: MainProps, prevState: MainState) { if (prevState.selectedPedal !== this.state.selectedPedal - || prevState.pedalboard !== this.state.pedalboard + || prevState.pedalboard !== this.state.pedalboard ) { - this.setState({showModUi: this.state.pedalboard.maybeGetItem(this.state.selectedPedal)?.useModUi??false}); + this.setState({ showModUi: this.state.pedalboard.maybeGetItem(this.state.selectedPedal)?.useModUi ?? false }); } } updateResponsive() { @@ -305,6 +313,10 @@ export const MainPage = setSelection(selectedId_: number): void { this.setState({ selectedPedal: selectedId_ }); + if (this.state.pedalboard.selectedPlugin !== selectedId_) { + this.model.setPedalboardSelectedPlugin(selectedId_); + this.state.pedalboard.selectedPlugin = selectedId_; + } } onSelectionChanged(selectedId: number): void { @@ -335,7 +347,7 @@ export const MainPage = this.setState({ loadDialogOpen: false }); let itemId = this.state.selectedPedal; let newSelectedItem = this.model.loadPedalboardPlugin(itemId, selectedUri); - this.setState({ selectedPedal: newSelectedItem }); + this.setSelection(newSelectedItem); } onSnapshotDialogOk(): void { this.setState({ snapshotDialogOpen: false }); @@ -621,12 +633,12 @@ export const MainPage =
- +
diff --git a/vite/src/pipedal/Pedalboard.tsx b/vite/src/pipedal/Pedalboard.tsx index a5129ba..34c54a3 100644 --- a/vite/src/pipedal/Pedalboard.tsx +++ b/vite/src/pipedal/Pedalboard.tsx @@ -372,6 +372,7 @@ export class Pedalboard implements Deserializable { this.snapshots = input.snapshots ? Snapshot.deserializeArray(input.snapshots): []; this.selectedSnapshot = input.selectedSnapshot; this.pathProperties = input.pathProperties; + this.selectedPlugin = input.selectedPlugin??-1; return this; } @@ -387,6 +388,7 @@ export class Pedalboard implements Deserializable { snapshots: (Snapshot | null)[] = []; selectedSnapshot: number = -1; pathProperties: {[Name: string]: string} = {}; + selectedPlugin: number = -1; *itemsGenerator(): Generator { let it = itemGenerator_(this.items); diff --git a/vite/src/pipedal/PedalboardView.tsx b/vite/src/pipedal/PedalboardView.tsx index ffd73f1..4b25517 100644 --- a/vite/src/pipedal/PedalboardView.tsx +++ b/vite/src/pipedal/PedalboardView.tsx @@ -540,7 +540,9 @@ withStyles( } onPedalboardChanged(value?: Pedalboard) { - this.setState({ pedalboard: value }); + this.setState({ + pedalboard: value, + }); } componentDidMount() { diff --git a/vite/src/pipedal/PiPedalModel.tsx b/vite/src/pipedal/PiPedalModel.tsx index 4c30cc8..97ac43e 100644 --- a/vite/src/pipedal/PiPedalModel.tsx +++ b/vite/src/pipedal/PiPedalModel.tsx @@ -1820,6 +1820,7 @@ export class PiPedalModel //implements PiPedalModel let result = newPedalboard.deleteItem(instanceId); if (result !== null) { + newPedalboard.selectedPlugin = result; this.setModelPedalboard(newPedalboard); this.updateServerPedalboard(); } @@ -3505,6 +3506,20 @@ export class PiPedalModel //implements PiPedalModel this.androidHost?.setScreenOrientation(value as number); } } + + setPedalboardSelectedPlugin(pluginId: number): void { + let pedalboard = this.pedalboard.get(); + if (!pedalboard) { + throw new PiPedalStateError("Pedalboard not loaded."); + } + if (pedalboard.selectedPlugin === pluginId) { + return; // no change. + } + pedalboard.selectedPlugin = pluginId; // naughty, because it doesn't broadcast. + // notify the server. + this.webSocket?.send("setSelectedPedalboardPlugin", { clientId: this.clientId, pluginInstanceId: pluginId }); + + } }; let instance: PiPedalModel | undefined = undefined; diff --git a/vite/src/pipedal/PluginControl.tsx b/vite/src/pipedal/PluginControl.tsx index 3aa0c33..9374188 100644 --- a/vite/src/pipedal/PluginControl.tsx +++ b/vite/src/pipedal/PluginControl.tsx @@ -367,15 +367,15 @@ const PluginControl = } } - if (this.isTouchDevice()) { - if (this.props.uiControl - && (this.props.uiControl.isDial() || this.props.uiControl.isGraphicEq()) - ) { - this.isTap = false; - this.showZoomedControl(); - return; - } - } + // if (this.isTouchDevice()) { + // if (this.props.uiControl + // && (this.props.uiControl.isDial() || this.props.uiControl.isGraphicEq()) + // ) { + // this.isTap = false; + // this.showZoomedControl(); + // return; + // } + // } ++this.pointersDown; diff --git a/vite/src/pipedal/PluginControlView.tsx b/vite/src/pipedal/PluginControlView.tsx index 2fc820f..073fd86 100644 --- a/vite/src/pipedal/PluginControlView.tsx +++ b/vite/src/pipedal/PluginControlView.tsx @@ -81,10 +81,11 @@ function makeIoPluginInfo(name: string, uri: string): UiPlugin { return result; } -let startPluginInfo: UiPlugin = +export const startPluginInfo: UiPlugin = makeIoPluginInfo("Input", Pedalboard.START_PEDALBOARD_ITEM_URI); -let endPluginInfo: UiPlugin = + +export const endPluginInfo: UiPlugin = makeIoPluginInfo("Output", Pedalboard.END_PEDALBOARD_ITEM_URI); diff --git a/vite/src/pipedal/PresetSelector.tsx b/vite/src/pipedal/PresetSelector.tsx index 5491519..a903f79 100644 --- a/vite/src/pipedal/PresetSelector.tsx +++ b/vite/src/pipedal/PresetSelector.tsx @@ -304,7 +304,7 @@ const PresetSelector = }}>
{ this.handleSave(); }} size="large"> diff --git a/vite/src/pipedal/ZoomedUiControl.tsx b/vite/src/pipedal/ZoomedUiControl.tsx index 3d21ffe..1432c86 100644 --- a/vite/src/pipedal/ZoomedUiControl.tsx +++ b/vite/src/pipedal/ZoomedUiControl.tsx @@ -96,7 +96,10 @@ const ZoomedUiControl = withTheme(withStyles( } else { let uiControl = this.props.controlInfo.uiControl; let instanceId = this.props.controlInfo.instanceId; - if (instanceId === -1) return 0; + if (instanceId === -2 && uiControl.symbol === "volume_db") { + return this.model.pedalboard.get()?.input_volume_db??0; + } + let pedalboardItem = this.model.pedalboard.get()?.getItem(instanceId); let value: number = pedalboardItem?.getControlValue(uiControl.symbol) ?? 0; return value;