Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defensive param streaming in FX #963

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/FX.h
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,34 @@ struct FX : modules::XTModule, sst::rackhelpers::module_connector::NeighborConne
{
json_object_set_new(fx, "polyphonicMode", json_boolean(polyphonicMode));
}

// A little bit of defensive code I added in 2.2 in case we change int bounds in the
// future. I don't read this yet but I do write it
auto *paramNatural = json_array();
for (int i = 0; i < n_fx_params; ++i)
{
const auto &p = fxstorage->p[i];
auto *parJ = json_object();

json_object_set(parJ, "index", json_integer(i));
json_object_set(parJ, "valtype", json_integer(p.valtype));
switch (p.valtype)
{
case vt_float:
json_object_set(parJ, "val_f", json_real(p.val.f));
break;
case vt_int:
json_object_set(parJ, "val_i", json_integer(p.val.i));
break;
case vt_bool:
json_object_set(parJ, "val_b", json_boolean(p.val.b));
break;
}
json_array_append_new(paramNatural, parJ);
}

json_object_set_new(fx, "paramNatural", paramNatural);

return fx;
}

Expand Down
26 changes: 26 additions & 0 deletions src/VCO.h
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,32 @@ struct VCO : public modules::XTModule, sst::rackhelpers::module_connector::Neigh
wtT = nullptr;
}

// A little bit of defensive code I added in 2.2 in case we change int bounds in the
// future. I don't read this yet but I do write it
auto *paramNatural = json_array();
for (int i = 0; i < n_osc_params; ++i)
{
const auto &p = oscstorage->p[i];
auto *parJ = json_object();

json_object_set(parJ, "index", json_integer(i));
json_object_set(parJ, "valtype", json_integer(p.valtype));
switch (p.valtype)
{
case vt_float:
json_object_set(parJ, "val_f", json_real(p.val.f));
break;
case vt_int:
json_object_set(parJ, "val_i", json_integer(p.val.i));
break;
case vt_bool:
json_object_set(parJ, "val_b", json_boolean(p.val.b));
break;
}
json_array_append_new(paramNatural, parJ);
}
json_object_set_new(vco, "paramNatural", paramNatural);

json_object_set_new(vco, "halfbandM", json_integer(halfbandM));
json_object_set_new(vco, "halfbandSteep", json_boolean(halfbandSteep));
json_object_set_new(vco, "doDCBlock", json_boolean(doDCBlock));
Expand Down