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

add beats_translate_move ControlEncoder #12376

Merged
merged 2 commits into from
Dec 7, 2023

Conversation

mxmilkiib
Copy link
Contributor

See #12337

@mxmilkiib mxmilkiib marked this pull request as draft November 30, 2023 12:32
Copy link
Member

@ronso0 ronso0 left a 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 Show resolved Hide resolved
src/engine/controls/bpmcontrol.cpp Outdated Show resolved Hide resolved
Comment on lines 211 to 216
const double sampleOffset = frameInfo().sampleRate;
if (v <= 0) {
const double sampleOffset = sampleOffset * 0.01;
} else {
const double sampleOffset = sampleOffset * -0.01;
}
Copy link
Member

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:

Suggested change
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);

Copy link
Contributor Author

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

Copy link
Member

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.

add("beats_translate_move")
<< tr("Adjust Beats")
<< tr("When tapped, moves the beatgrid left or right by a small amount.");

Copy link
Member

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🫡

@ronso0
Copy link
Member

ronso0 commented Nov 30, 2023

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 ;)

@ronso0
Copy link
Member

ronso0 commented Nov 30, 2023

Please also check the CI runners (at the bottom of this page) once they are finished.

Worth reading to avoid cleanup work later on:
https://github.com/mixxxdj/mixxx/wiki/Contribution-Guidelines
and this one about automatic ode checking (pre-commit)
https://github.com/mixxxdj/mixxx/wiki/Using%20Git#set-up-automatic-code-checking

Thanks for signing the CLA!
You'll find your name in the contributor list in the About dialog in the next release.

@mxmilkiib
Copy link
Contributor Author

mxmilkiib commented Nov 30, 2023

Thanks for all the feedback!

On the current build fail due to code style, I'm confused;

image

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).

https://github.com/mxmilkiib/mixxx/blob/beats_translate_move/src/controllers/controlpickermenu.cpp#L232

https://github.com/mxmilkiib/mixxx/blob/beats_translate_move/src/engine/controls/bpmcontrol.cpp#L90

@ronso0
Copy link
Member

ronso0 commented Nov 30, 2023

Yeah, pre-commit only checks changed lines, and the existing lines were created long before we started using pre-commit.
Yep, the green part is how pre-commit wants it to be, but I'm doubtful if that is correct. Actually we want the lines to break at about 80 chars, and the suggestion is much longer.

I propose to break after every comma, that way it's readable in narrow editors and pre-commit should be happy, too.

@mxmilkiib
Copy link
Contributor Author

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?

@ronso0
Copy link
Member

ronso0 commented Nov 30, 2023

I understand this desire, though we try to avoid needless mass-formatting. Usually, after being merged, it creates conflicts in other PRs.

@mxmilkiib
Copy link
Contributor Author

mxmilkiib commented Nov 30, 2023

🙏

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.

@ronso0
Copy link
Member

ronso0 commented Dec 1, 2023

Same for bpmcontrol.cpp I'd say, break after every comma.

@mxmilkiib
Copy link
Contributor Author

Does the code style linter need updating then?

@ronso0 ronso0 changed the title Draft: adding a beats_translate_move add beats_translate_move ControlEncoder Dec 1, 2023
@ronso0
Copy link
Member

ronso0 commented Dec 1, 2023

Actually it's configured well, but every now and then it has a bad day or something and its suggestions are... weird.
We don't obey it 100% but it makes life much easier.

@ronso0
Copy link
Member

ronso0 commented Dec 1, 2023

You can also ignore certain checks locally (once, for the current command) if they keep you from commiting, for example disable clang-format if it insists on the long line after you broke it in pieces:
SKIP=clang-format git [commit|push|whatever]

@mxmilkiib
Copy link
Contributor Author

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?

@mxmilkiib mxmilkiib marked this pull request as ready for review December 1, 2023 02:12
@daschuer
Copy link
Member

daschuer commented Dec 1, 2023

Does the code style linter need updating then?

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.

# A ColumnLimit > 0 causes clang-format to unbreaks all short lines,

@ronso0
Copy link
Member

ronso0 commented Dec 1, 2023

yeah, but it failed here. Its proposal is 126 chars + indentation.

@ronso0
Copy link
Member

ronso0 commented Dec 1, 2023

One more comment.
And the linebreaks please, then I'll take a final look.

@mxmilkiib
Copy link
Contributor Author

mxmilkiib commented Dec 1, 2023

How could I make the line

        const mixxx::audio::FrameDiff_t frameOffset = sampleOffset / mixxx::kEngineChannelCount;

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.

@mxmilkiib
Copy link
Contributor Author

a bad day or something

There's got to be logic behind why it's trying to make a 130 character wide statement.

@ronso0
Copy link
Member

ronso0 commented Dec 1, 2023

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.

# A ColumnLimit > 0 causes clang-format to unbreaks all short lines,

# We recommend a maximum line length of 80, but do allow up to 100 characters

Btw I'm not sure why you keep merging the main branch.

@mxmilkiib
Copy link
Contributor Author

Ok.

I'm not sure why I shouldn't?

@ronso0
Copy link
Member

ronso0 commented Dec 2, 2023

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.
You can do that whenever you like, I was just wondering what you expect from it.

The line-break issue still needs to be resolved, one connect arg per line. If you can't resist just change the calls above and below, as well, I don't mind. Not many (and only trivial) merge conflicts to be expected with this PR.

@ronso0
Copy link
Member

ronso0 commented Dec 2, 2023

The commit messages look like you used the Github web interface.
If yes, do you also work on this branch locally?

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).

@mxmilkiib
Copy link
Contributor Author

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;
Copy link
Member

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 ; )

Copy link
Member

@ronso0 ronso0 Dec 2, 2023

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.

@ronso0
Copy link
Member

ronso0 commented Dec 2, 2023

Okay, I'm sorry to hear that.

I'll adopt this PR then.
Thank you for getting this started and for your work!

@ronso0
Copy link
Member

ronso0 commented Dec 2, 2023

Please don't delete your branch, I'll push to it and someone else needs to do the final review and merge.

@ronso0
Copy link
Member

ronso0 commented Dec 2, 2023

@mixxxdj/developers May someone please take a look?
I adopted this and added another commit, therefore I won't merge myself. Thanks!

pTrack->trySetBeats(*translatedBeats);
}
}
slotTranslateBeatsMove(v);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.

Copy link
Member

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

@@ -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);
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

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

Yep.

@@ -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);
Copy link
Member

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.

@ywwg
Copy link
Member

ywwg commented Dec 7, 2023

looks good, thank you @mxmilkiib and @ronso0 !

@ywwg
Copy link
Member

ywwg commented Dec 7, 2023

@ronso0 and @JoergAtGithub are your notes addressed?

@JoergAtGithub
Copy link
Member

LGTM now! Thank you!

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

Successfully merging this pull request may close these issues.

5 participants