8000 feat: support snapped knobs by Ericxgao · Pull Request #507 · 4ms/metamodule · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Ericxgao
Copy link
Collaborator
@Ericxgao Ericxgao commented May 6, 2025

@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

if (el.integral) {
float clamped_value = std::clamp(value, 0.f, 1.f);

unsigned v = (clamped_value >= 1.f) ?
Copy link
Collaborator Author

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);
Copy link
Collaborator Author

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);
Copy link
Collaborator Author

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) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0