-
8000
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: support snapped knobs #507
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
base: main
Are you sure you want to change the base?
Conversation
if (el.integral) { | ||
float clamped_value = std::clamp(value, 0.f, 1.f); | ||
|
||
unsigned v = (clamped_value >= 1.f) ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this. But since knob positions span from 0-1 inclusive, the math required to get an index from the state is a little wonky - you can't do a naive round/floor operation because it will be missing states.
@@ -184,6 +184,9 @@ private: | |||
if (pot.display_mult > 1 && pot.display_mult != 100 && pot.display_base == 0 && pot.units == "") { | |||
lv_arc_set_range(ui_ControlArc, 0, pot.display_mult); | |||
hide_resolution_text(); | |||
} else if (pot.integral) { | |||
lv_arc_set_range(ui_ControlArc, pot.min_value, pot.max_value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This worked like you said.
@@ -100,6 +100,17 @@ static Knob create_base_knob(rack::app::Knob *widget) { | |||
element.display_offset = pq->displayOffset; | |||
element.integral = pq->snapEnabled; | |||
element.display_precision = pq->displayPrecision; | |||
|
|||
if (element.integral) { | |||
auto switchPq = dynamic_cast<rack::engine::SwitchQuantity*>(pq); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this normal? I have to casxt the param quantity to a switchQuantity to properly get access to the labels array?
element.pos_names[i] = pq->labels[i]; | ||
// Check if pq is 86DB actually a SwitchQuantity with labels | ||
auto switchPq = dynamic_cast<rack::engine::SwitchQuantity*>(pq); | ||
if (switchPq) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@danngreen
Updated with your suggestions, not sure why the old PR is gone.
Adding a few comments/questions below
Corresponding PR requests
4ms/metamodule-core-interface#2
4ms/metamodule-plugin-sdk#7