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

feat: add support for scaling BPM by different ratios #12934

Merged
merged 3 commits into from
May 18, 2024

Conversation

mxmilkiib
Copy link
Contributor

This change introduces the ability to scale the BPM of a track by different ratios using ControlPushButton objects. Each button is connected to a lambda function that calls the slotScaleBpm method with the corresponding BPM scale factor.

@daschuer
Copy link
Member

daschuer commented Mar 8, 2024

Unfortunately clang-format is still complaining.
I suggest to install pre-commit locally to format every commit automatically. https://github.com/mixxxdj/mixxx/wiki/Using-Git#set-up-automatic-code-checking
It will also install clang-format.
You may format your whole PR
By git clang-format upstream/main
(Make sure not to format the whole code base.)

src/engine/controls/bpmcontrol.cpp Outdated Show resolved Hide resolved
@ronso0 ronso0 added the bpm label Mar 8, 2024
@ronso0 ronso0 added this to the 2.5-beta milestone Mar 8, 2024
@ronso0 ronso0 linked an issue Mar 8, 2024 that may be closed by this pull request
@mxmilkiib
Copy link
Contributor Author

mxmilkiib commented Mar 8, 2024

That syntax gives me this though;

In file included from /home/milk/src/mixxx/src/engine/controls/bpmcontrol.cpp:1:
/home/milk/src/mixxx/src/engine/controls/bpmcontrol.h:149:39: error: template argument 1 is invalid
  149 |     std::unique_ptr<ControlPushButton m_pBeatsHalve;
      |                                       ^~~~~~~~~~~~~
/home/milk/src/mixxx/src/engine/controls/bpmcontrol.h:149:39: error: template argument 2 is invalid
/home/milk/src/mixxx/src/engine/controls/bpmcontrol.h:149:10: error: ‘<expression error>’ in namespace ‘std’ does not name a type
  149 |     std::unique_ptr<ControlPushButton m_pBeatsHalve;
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
/home/milk/src/mixxx/src/engine/controls/bpmcontrol.cpp: In constructor ‘BpmControl::BpmControl(const QString&, UserSettingsPointer)’:
/home/milk/src/mixxx/src/engine/controls/bpmcontrol.cpp:97:5: error: ‘m_pBeatsHalve’ was not declared in this scope; did you mean ‘m_pBeats’?
   97 |     m_pBeatsHalve = std::make_unique<ControlPushButton>(ConfigKey(group, "beats_set_halve"), false);
      |     ^~~~~~~~~~~~~
      |     m_pBeats

@ronso0
Copy link
Member

ronso0 commented Mar 8, 2024

std::unique_ptr<ControlPushButton m_pBeatsHalve;

missing closing >

@mxmilkiib
Copy link
Contributor Author

with closing bracket;

/home/milk/src/mixxx/src/engine/controls/bpmcontrol.cpp: In constructor ‘BpmControl::BpmControl(const QString&, UserSettingsPointer)’:
/home/milk/src/mixxx/src/engine/controls/bpmcontrol.cpp:98:12: error: no matching function for call to ‘BpmControl::connect(std::unique_ptr<ControlPushButton>&, void (ControlObject::*)(double), BpmControl*, BpmControl::BpmControl(const QString&, UserSettingsPointer)::<lambda(int)>)’
   98 |     connect(m_pBeatsHalve,
      |     ~~~~~~~^~~~~~~~~~~~~~~
   99 |             &ControlObject::valueChanged,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  100 |             this,
      |             ~~~~~
  101 |             [this](int value) {
      |             ~~~~~~~~~~~~~~~~~~~
  102 |                 if (value > 0) {
      |                 ~~~~~~~~~~~~~~~~
  103 |                     slotScaleBpm(mixxx::Beats::BpmScale::Halve);
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  104 |                 }
      |                 ~
  105 |             });
      |             ~~
In file included from /usr/include/qt6/QtCore/QObject:1,
                 from /home/milk/src/mixxx/src/control/controlobject.h:3,
                 from /home/milk/src/mixxx/src/engine/controls/bpmcontrol.h:5,
                 from /home/milk/src/mixxx/src/engine/controls/bpmcontrol.cpp:1:
/usr/include/qt6/QtCore/qobject.h:198:9: note: candidate: ‘static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Prototype>::Object*, Func1, const typename QtPrivate::ContextTypeForFunctor<Func2>::ContextType*, Func2&&, Qt::ConnectionType) [with Func1 = void (ControlObject::*)(double); Func2 = BpmControl::BpmControl(const QString&, UserSettingsPointer)::<lambda(int)>; typename QtPrivate::FunctionPointer<Prototype>::Object = ControlObject; typename QtPrivate::ContextTypeForFunctor<Func2>::ContextType = QObject]’
  198 |         connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
      |         ^~~~~~~
/usr/include/qt6/QtCore/qobject.h:198:75: note:   no known conversion for argument 1 from ‘std::unique_ptr<ControlPushButton>’ to ‘const QtPrivate::FunctionPointer<void (ControlObject::*)(double)>::Object*’ {aka ‘const ControlObject*’}
  198 |         connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
/usr/include/qt6/QtCore/qobject.h:246:9: note: candidate: ‘template<class Func1, class Func2> static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Prototype>::Object*, Func1, Func2&&)’
  246 |         connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 &&slot)
      |         ^~~~~~~
/usr/include/qt6/QtCore/qobject.h:246:9: note:   template argument deduction/substitution failed:
/home/milk/src/mixxx/src/engine/controls/bpmcontrol.cpp:98:12: note:   candidate expects 3 arguments, 4 provided
   98 |     connect(m_pBeatsHalve,
      |     ~~~~~~~^~~~~~~~~~~~~~~
   99 |             &ControlObject::valueChanged,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  100 |             this,
      |             ~~~~~
  101 |             [this](int value) {
      |             ~~~~~~~~~~~~~~~~~~~
  102 |                 if (value > 0) {
      |                 ~~~~~~~~~~~~~~~~
  103 |                     slotScaleBpm(mixxx::Beats::BpmScale::Halve);
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  104 |                 }
      |                 ~
  105 |             });
      |             ~~
/usr/include/qt6/QtCore/qobject.h:177:36: note: candidate: ‘static QMetaObject::Connection QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)’
  177 |     static QMetaObject::Connection connect(const QObject *sender, const char *signal,
      |                                    ^~~~~~~
...

@mxmilkiib
Copy link
Contributor Author

mxmilkiib commented Mar 8, 2024

Aah cmake cache again.. edit: nope..

@ronso0
Copy link
Member

ronso0 commented Mar 8, 2024

Yes, it's a unique_ptr now so we need to get() the value first (the ControlPushButton in this case).
This should work:

connect(m_pBeatsHalve.get(),
       &ControlObject::valueChanged,
       this,
       [this](int value) {
           if (value > 0) {
               slotScaleBpm(mixxx::Beats::BpmScale::Halve);
           }
       });

@mxmilkiib
Copy link
Contributor Author

The style changes mentioned are inconsistent, I could do the extra line breaks, but it's not asking for them in all cases..?

@ronso0
Copy link
Member

ronso0 commented Mar 8, 2024

Builds are currently failing because the explicit delete calls are still in the destructor BpmControl::~BpmControl but not applicable to the now unique_ptr.
Please remove those and amend to the respective commits (each commit must build in order to allow git bisect).

In case you still can't build locally I can provide fixups and push to your branch.

@mxmilkiib
Copy link
Contributor Author

Can do, will be afk for a couple of days tho

@mxmilkiib mxmilkiib force-pushed the Add-bpm-scaling-controls branch 3 times, most recently from d95620f to 63278a4 Compare March 11, 2024 22:51
@ronso0
Copy link
Member

ronso0 commented Mar 11, 2024

ping clang-format wants to break some long lines.

Unfortunately clang-format is still complaining. I suggest to install pre-commit locally to format every commit automatically. https://github.com/mixxxdj/mixxx/wiki/Using-Git#set-up-automatic-code-checking It will also install clang-format. You may format your whole PR By git clang-format upstream/main (Make sure not to format the whole code base.)

@@ -1,4 +1,4 @@
#include "engine/controls/bpmcontrol.h"
#include "bpmcontrol.h"
Copy link
Member

Choose a reason for hiding this comment

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

Why did you change this?
We use the full path for all other includes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah that was me trying reacting to the red squiggly lines the MS IntelliSense extension in VSCodium put under the path saying the file could not be found.

It's frustrating because I tried the other Clang based debugger mentioned on Zulip a while back and it sucks compared to the MS IntelliSense extension re advising what the cause of and solution for most a true problems are.

I'll fix and force push again in a bit.

@mxmilkiib
Copy link
Contributor Author

ping clang-format wants to break some long lines.

"The style changes mentioned are inconsistent, I could do the extra line breaks, but it's not asking for them in all cases..?"

Unless I misread then, and I havn't relooked yet - I'll do so after I've done the other thing - it was wanting me to remove line breaks, and for some reason only wanting me to add line breaks to some of the code I'd added thus I assumed that adding further linebreaks would hit me with a requirement to remove those new line breaks too. Maybe I was wrong. I'll suffer trying to fix it multiple times again and it continually giving me inconsistent output until I rage quit and go to bed.

Also, running locally give no problematic output. I guess either I'm doing something wrong or the instructions are inadequate.

image

Well, it is giving a silly number of "skipped", obviously part of the problem, given it should be giving me an error, but I'm not sure how I've fluffed the process.

@mxmilkiib mxmilkiib force-pushed the Add-bpm-scaling-controls branch from 63278a4 to b2160ef Compare March 12, 2024 01:45
@ronso0
Copy link
Member

ronso0 commented Mar 12, 2024

It's skipping because you have no file changes for pre-commit to check.
clang-format has a line length threshold above which it proposes line-breaks (which may sometimes look rather strange to humans).

You can do
git log -1 (just to note the commit message)
git reset HEAD^1
git add --all
git commit
Then pre-commit should run again on the changeset.

(by the way I very much recommend the zsh git plugin, it has many useful shortkeys)

@ronso0
Copy link
Member

ronso0 commented Mar 12, 2024

now it wants to move the header include...

please revert and re-commit as described above, actually pre-commit should only act on changed lines.
then force-push.

@mxmilkiib mxmilkiib force-pushed the Add-bpm-scaling-controls branch 2 times, most recently from 5ffcb02 to f607409 Compare March 12, 2024 02:10
@ronso0
Copy link
Member

ronso0 commented Mar 12, 2024

...and trailing whitespaces 😆
You can also download the pre-commit patch from the CI summary (at the bottm of the Summary page https://github.com/mixxxdj/mixxx/actions/runs/8242566098?pr=12934), apply that (git commit --amend) and push again.

@mxmilkiib mxmilkiib force-pushed the Add-bpm-scaling-controls branch from f607409 to 5ad8971 Compare March 12, 2024 02:23
@ronso0
Copy link
Member

ronso0 commented Mar 24, 2024

I'm the only reviewer until now and I'm fine with cherry-picking / rebasing and amend the commit of #12941.

@mxmilkiib
Copy link
Contributor Author

Cool cool.

I was using Git Butler to "undo" and force push the PR commits, now it has stopped working, as I made a mess trying to get multiple feature PRs into the same branch so removed the repo dir and recloned but apparently broke some part of a workflow. I learnt some git years ago but have forgotten most, and never rebased nor force pushed back then, let alone cherry picked commits, so am rather lost in how to explain to myself what I need to do.

image

I also retrieved both my PRs with gh pr checkout then tried git cherry [sha of main commit in first PR], but that just returned another SHA looking string, and I can't tell if anything changed.

@mxmilkiib
Copy link
Contributor Author

Ah, git cherry-pick not git cherry.

Lets see how wrong I get this..

@mxmilkiib
Copy link
Contributor Author

A strange sort order;
image

Needs a new issue?

@ronso0
Copy link
Member

ronso0 commented Apr 2, 2024

I assume this is the MIDI Input table. Actions are sorted by control, and IIRC that is
D ouble
F our thirds
H alf
T hree fourths
T wo thirds etc

Yeah please file a new issue!

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.

LGTM, except one tiny yet significant character

src/engine/controls/bpmcontrol.cpp Show resolved Hide resolved
@mxmilkiib
Copy link
Contributor Author

Please take this off my hands, I don't have the capacity to focus on fixing and finishing this PR. Thanks.

@daschuer daschuer marked this pull request as draft May 1, 2024 19:58
@daschuer daschuer removed this from the 2.5-beta milestone May 1, 2024
@ronso0 ronso0 force-pushed the Add-bpm-scaling-controls branch from 213fb90 to 5daa61c Compare May 11, 2024 12:14
@ronso0 ronso0 marked this pull request as ready for review May 11, 2024 12:14
@ronso0
Copy link
Member

ronso0 commented May 11, 2024

I have just rebased, fixed and force-pushed to your branch.
Hopefully also clang-tidy is happy now.

@ronso0 ronso0 requested a review from daschuer May 11, 2024 12:16
@ronso0
Copy link
Member

ronso0 commented May 11, 2024

I have just rebased, fixed and force-pushed to your branch. Hopefully also clang-tidy is happy now.

Since I worked on this, too, someone else needs to review and merge.

@ronso0
Copy link
Member

ronso0 commented May 11, 2024

I've split the commit into the std::unique_ptr changes and the actual feature commit.

@ronso0 ronso0 force-pushed the Add-bpm-scaling-controls branch from 5daa61c to 1fa0c48 Compare May 11, 2024 19:49
@ronso0 ronso0 added this to the 2.5-beta milestone May 16, 2024
@daschuer
Copy link
Member

We have a conflict unfortunately

@ronso0
Copy link
Member

ronso0 commented May 18, 2024

We have a conflict unfortunately

resolved. There'll be some more #12104 when this is merged 💦

@daschuer
Copy link
Member

Thank you.

@daschuer daschuer merged commit de2b3ec into mixxxdj:main May 18, 2024
13 checks passed
@ronso0
Copy link
Member

ronso0 commented May 18, 2024

Thanks @mxmilkiib for starting this, and their patience.

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

Successfully merging this pull request may close these issues.

add controls to manipulate the bpm via skin/midi controller
3 participants