-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
add beats_translate_move ControlEncoder #12376
Conversation
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.
Thanks for working on this, adn congratulations for your first PR!
For every code change to be included in Mixxx we need contributor's permissions.
Please sign the Mixxx Contributor Agreement and comment here when you have done so. It gives us permission to distribute your contribution under the GPL v2 or later license and the Apple Mac App Store. It is also helpful for us to have contact information for contributors in case we may need it in the future.
I've left some comments / suggestions.
src/engine/controls/bpmcontrol.cpp
Outdated
const double sampleOffset = frameInfo().sampleRate; | ||
if (v <= 0) { | ||
const double sampleOffset = sampleOffset * 0.01; | ||
} else { | ||
const double sampleOffset = sampleOffset * -0.01; | ||
} |
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.
A variable must only be declared once.
Also if you declare it const
(constant) it can't be altered later on.
One way:
const double sampleOffset = frameInfo().sampleRate; | |
if (v <= 0) { | |
const double sampleOffset = sampleOffset * 0.01; | |
} else { | |
const double sampleOffset = sampleOffset * -0.01; | |
} | |
double sampleOffset = frameInfo().sampleRate; | |
if (v < 0) { | |
sampleOffset *= -0.01; | |
} else { | |
sampleOffset *= 0.01; | |
} |
and another, more compact with Short Hand If...Else (Ternary Operator) (initialized with
const double sampleOffset = frameInfo().sampleRate * (v < 0 ? -0.01 : 0.01);
But actually we're not only interested in the direction but also want the value of the input v
, in case the controller accumulated multiple ticks internally and sent 61 or 68 for example.
const double sampleOffset = frameInfo().sampleRate * v * 0.01);
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.
Nice compactification, I'll switch to that
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.
Oh, superfluous )
at the end.
src/skin/legacy/tooltips.cpp
Outdated
add("beats_translate_move") | ||
<< tr("Adjust Beats") | ||
<< tr("When tapped, moves the beatgrid left or right by a small amount."); | ||
|
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.
Good you thought about that, though tooltips are only for GUI controls, and since this new control is made for controllers we don't need a need a tooltip (there are no GUI encoders, only pots with absoute values).
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.
🫡
About code reviews: please keep them open, it's up to the reviewer to check and mark as resolved (besides no one will see your reply if you resolve a conversation ;) |
Please also check the CI runners (at the bottom of this page) once they are finished. Worth reading to avoid cleanup work later on: Thanks for signing the CLA! |
Thanks for all the feedback! On the current build fail due to code style, I'm confused; https://github.com/mixxxdj/mixxx/actions/runs/7051273531/job/19194088455?pr=12376#step:6:133 Should I change the code to the format in green? But that would make it different from the rest of the formatting (well, in the first case, the formatting of all the related lines above). |
Yeah, pre-commit only checks changed lines, and the existing lines were created long before we started using pre-commit. I propose to break after every comma, that way it's readable in narrow editors and pre-commit should be happy, too. |
I concur. My desire would be to format the entire file the same in fell swoop. Does this need to be thirded or go throiugh a consensus process? |
I understand this desire, though we try to avoid needless mass-formatting. Usually, after being merged, it creates conflicts in other PRs. |
🙏 What should I do re the second (given it goes over 80 chars)? There is an irony, in that the suggested style for both is the opposite of the other. |
Same for bpmcontrol.cpp I'd say, break after every comma. |
Does the code style linter need updating then? |
Actually it's configured well, but every now and then it has a bad day or something and its suggestions are... weird. |
You can also ignore certain checks locally (once, for the current command) if they keep you from commiting, for example disable |
Cool beans. Well, sorry for such an ugly git commit history. What might the next step be? I take it the failing Windows build isn't related? |
We apply clang-format twice, to respect user line breaks. First run: Unbreak lines with breaks not following the rules. Second Run: break all lines the exceeds 100 at <80. Line 7 in 0f0deb1
|
yeah, but it failed here. Its proposal is 126 chars + indentation. |
One more comment. |
How could I make the line
not be 97 characters wide? Assuming that's the main offender. Edit: it's not, given it doesn't show as diffed, it's just "shifted". The other longer line I cna break on a comma. |
There's got to be logic behind why it's trying to make a 130 character wide statement. |
Sure. However, these nonsense suggestions are so rare that obviously nobody is motivated enough to debug the script. Not worth spending time on it atm, manual fixing is... snap.. done. Or just ignore and merge anyway. Line 7 in 0f0deb1
Line 15 in 6acfe63
Btw I'm not sure why you keep merging the main branch. |
Ok. I'm not sure why I shouldn't? |
IME we only do that to get code that was merged since opeing a PR / starting a branch, especially for long-standing PRs, in order to get other fixes and/or fix merge conflicts. The line-break issue still needs to be resolved, one |
The commit messages look like you used the Github web interface. I'm asking because now would be a good moment to squash all commits, and that's not possible in the web UI, only via command line or desktop client (never used that). |
Yes. I'm having a mental health crisis atm, various things and a dream of a dead sometime lover. Please take over this, I can't deal with it anymore. |
@@ -141,6 +142,7 @@ class BpmControl : public EngineControl { | |||
ControlPushButton* m_pAdjustBeatsSlower; | |||
ControlPushButton* m_pTranslateBeatsEarlier; | |||
ControlPushButton* m_pTranslateBeatsLater; | |||
ControlEncoder* m_pTranslateBeatsMove; |
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.
Interesting that CI can build this at all.
Locally, I can't because ControlEncoder is an unknown type, it's neither forward-declared here (preferred) nor is its header included via #include "control/controlencoder.h"
here or in the bpmcontrol.cpp.
Btw, I now remember I touched a lot this code in #12104 incl. the formatting of the connect
calls ; )
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.
@daschuer could that be a side effect of PCH (which I have disabled locally)?
Anyhow, CI should catch this.
Okay, I'm sorry to hear that. I'll adopt this PR then. |
Please don't delete your branch, I'll push to it and someone else needs to do the final review and merge. |
a69215e
to
67d2daa
Compare
@mixxxdj/developers May someone please take a look? |
src/engine/controls/bpmcontrol.cpp
Outdated
pTrack->trySetBeats(*translatedBeats); | ||
} | ||
} | ||
slotTranslateBeatsMove(v); |
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.
slotTranslateBeatsMove(v); | |
if (v <= 0) { | |
return; | |
} | |
slotTranslateBeatsMove(-1.0); |
Otherwise the code is identical to slotTranslateBeatsLater
and the behavior of the function would be different, than before.
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.
🤦
Thank you. I pushed the fix:
later: +1
earlier: -1
67d2daa
to
97c1596
Compare
@@ -127,7 +134,6 @@ BpmControl::BpmControl(const QString& group, | |||
// Measures distance from last beat in percentage: 0.5 = half-beat away. | |||
m_pThisBeatDistance = new ControlProxy(group, "beat_distance", this); | |||
m_pSyncMode = new ControlProxy(group, "sync_mode", this); | |||
m_pSyncEnabled = new ControlProxy(group, "sync_enabled", this); |
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.
was this dropped because it's unused?
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.
Yep.
src/engine/controls/bpmcontrol.cpp
Outdated
@@ -87,6 +87,13 @@ BpmControl::BpmControl(const QString& group, | |||
connect(m_pTranslateBeatsLater, &ControlObject::valueChanged, | |||
this, &BpmControl::slotTranslateBeatsLater, | |||
Qt::DirectConnection); | |||
m_pTranslateBeatsMove = new ControlEncoder(ConfigKey(group, "beats_translate_move"), false); | |||
m_pTranslateBeatsMove->setKbdRepeatable(true); |
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.
oh, that's useless with ControlEncoder. I'll remove it.
Co-authored-by: ronso0 <ronso0@mixxx.org>
97c1596
to
63602be
Compare
looks good, thank you @mxmilkiib and @ronso0 ! |
@ronso0 and @JoergAtGithub are your notes addressed? |
LGTM now! Thank you! |
See #12337