Skip to content

Commit

Permalink
Merge v1.6-dev into main (Fundamental:quant uses presets)
Browse files Browse the repository at this point in the history
  • Loading branch information
danngreen committed Dec 12, 2024
2 parents 0c62950 + 84256e2 commit 29dc5c0
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion VCV-Fundamental/quant.cc
Original file line number Diff line number Diff line change
@@ -171,7 +171,32 @@ void Quant::load_state(std::string_view state_data) {
return;
}

dataFromJson(root);
// we need to check if the incoming state data is a preset or patch
// occasionally presets use params, and other times they use the data node.
// the params node is always present, however the data node is not.
const auto is_preset = [root]() {
std::array<std::string_view, 4> nodes = {
"plugin",
"model",
"version",
"params",
};

for (const auto i : nodes) {
if (!json_object_get(root, i.data())) {
return false;
}
}
return true;
}();

if (is_preset) {
if (auto node = json_object_get(root, "data"); node) {
dataFromJson(node);
}
} else {
dataFromJson(root);
}

json_decref(root);
}

0 comments on commit 29dc5c0

Please sign in to comment.