Prune snapshot values
This commit is contained in:
@@ -514,7 +514,7 @@ export class Pedalboard implements Deserializable<Pedalboard> {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
deleteItem_(instanceId: number,items: PedalboardItem[]): number | null
|
private deleteItem_(instanceId: number,items: PedalboardItem[]): number | null
|
||||||
{
|
{
|
||||||
for (let i = 0; i < items.length; ++i)
|
for (let i = 0; i < items.length; ++i)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1538,15 +1538,39 @@ export class PiPedalModel //implements PiPedalModel
|
|||||||
selectSnapshot(index: number) {
|
selectSnapshot(index: number) {
|
||||||
this.webSocket?.send("setSnapshot", index);
|
this.webSocket?.send("setSnapshot", index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private pruneSnapshotValues(pedalboard: Pedalboard)
|
||||||
|
{
|
||||||
|
let validPluginIds: Set<number> = new Set<number>();
|
||||||
|
|
||||||
|
for (let item of pedalboard.items) {
|
||||||
|
validPluginIds.add(item.instanceId);
|
||||||
|
}
|
||||||
|
for (let snapshot of pedalboard.snapshots) {
|
||||||
|
if (snapshot) {
|
||||||
|
let ix = 0;
|
||||||
|
while (ix < snapshot.values.length) {
|
||||||
|
let value = snapshot.values[ix];
|
||||||
|
if (validPluginIds.has(value.instanceId)) {
|
||||||
|
ix++;
|
||||||
|
} else {
|
||||||
|
snapshot.values.splice(ix, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
setSnapshots(snapshots: (Snapshot | null)[], selectedSnapshot: number) {
|
setSnapshots(snapshots: (Snapshot | null)[], selectedSnapshot: number) {
|
||||||
let pedalboard = this.pedalboard.get().clone();
|
let pedalboard = this.pedalboard.get().clone();
|
||||||
pedalboard.snapshots = snapshots;
|
pedalboard.snapshots = snapshots;
|
||||||
if (selectedSnapshot !== -1) {
|
if (selectedSnapshot !== -1) {
|
||||||
pedalboard.selectedSnapshot = selectedSnapshot;
|
pedalboard.selectedSnapshot = selectedSnapshot;
|
||||||
}
|
}
|
||||||
|
this.pruneSnapshotValues(pedalboard);
|
||||||
|
|
||||||
this.setModelPedalboard(pedalboard);
|
this.setModelPedalboard(pedalboard);
|
||||||
|
|
||||||
this.webSocket?.send("setSnapshots", { snapshots: snapshots, selectedSnapshot: selectedSnapshot });
|
this.webSocket?.send("setSnapshots", { snapshots: pedalboard.snapshots, selectedSnapshot: selectedSnapshot });
|
||||||
}
|
}
|
||||||
|
|
||||||
setInputVolume(volume_db: number): void {
|
setInputVolume(volume_db: number): void {
|
||||||
@@ -1841,6 +1865,7 @@ export class PiPedalModel //implements PiPedalModel
|
|||||||
let result = newPedalboard.deleteItem(instanceId);
|
let result = newPedalboard.deleteItem(instanceId);
|
||||||
if (result !== null) {
|
if (result !== null) {
|
||||||
newPedalboard.selectedPlugin = result;
|
newPedalboard.selectedPlugin = result;
|
||||||
|
this.pruneSnapshotValues(newPedalboard);
|
||||||
this.setModelPedalboard(newPedalboard);
|
this.setModelPedalboard(newPedalboard);
|
||||||
this.updateServerPedalboard();
|
this.updateServerPedalboard();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user