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

Lock BPM updates #3012

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open

Lock BPM updates #3012

wants to merge 30 commits into from

Conversation

poelzi
Copy link
Contributor

@poelzi poelzi commented Aug 11, 2020

This patchset fixes some long time annoyances of mine.

  • Currently, it is not possible to change the bpm lock from the track dialog. Instead of disabling the BPM tab, add a checkbox to disable the appropriate controls.
  • Add a controlobject so controllers are able to set the bpm lock of a deck [ChannelN],beatgrid_lock
  • Add a optional bpm lock symbol next to the bpm display (currently deere only).

lock_updates

Copy link
Contributor

@uklotzde uklotzde left a comment

Choose a reason for hiding this comment

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

Some technical issues

src/track/track.cpp Outdated Show resolved Hide resolved
src/library/dlgtrackinfo.cpp Outdated Show resolved Hide resolved
src/library/dlgtrackinfo.h Outdated Show resolved Hide resolved
src/library/dlgtrackinfo.h Outdated Show resolved Hide resolved
src/library/dlgtrackinfo.cpp Outdated Show resolved Hide resolved
src/engine/enginebuffer.cpp Outdated Show resolved Hide resolved
src/engine/controls/enginecontrol.h Show resolved Hide resolved
src/engine/controls/bpmcontrol.h Outdated Show resolved Hide resolved
src/engine/controls/bpmcontrol.h Outdated Show resolved Hide resolved
src/engine/controls/bpmcontrol.cpp Outdated Show resolved Hide resolved
@Holzhaus
Copy link
Member

What exactly does the BPM lock do? Is is a way to lock the beatgrid? Or does it prevent the BPM sliders from being used?

@poelzi
Copy link
Contributor Author

poelzi commented Aug 12, 2020

It's the normal lock bpm function from the library and prevents the analyzer from changing the beatgrid. When I have fixed the beatgrid alignment I usually try to lock it. Having this mapped on the controller makes my life easier, seeing if the lock is enabled on the deck helps me not to forget to check it before mixing it in.

@Holzhaus
Copy link
Member

Ok, then we should probably pick a more fitting name, like "beatgrid_locked" and also rename the existing function. What do you think?

@uklotzde
Copy link
Contributor

Ping. Still unresolved review comments.

@poelzi
Copy link
Contributor Author

poelzi commented Aug 27, 2020

@Holzhaus I renamed the new everything to beatgrid lock or appropriate variations.
I also found one major bug in 0cf5668 that should be cherry-picked into 2.3 and maybe even 2.2 ?

I polished the whole dialog. There is still one old bug left I can't figure out. In the BPM tab, everything has Alt+Key shortcuts.
Alt+n works, but Alt+p doesn't. I just can't figure out why this is broken.

@ronso0
Copy link
Member

ronso0 commented Aug 28, 2020

Alt+n works, but Alt+p doesn't. I just can't figure out why this is broken.

Works here. Do you have other shortcuts set in a custom keyboard mapping?
(I see Alt is only used for Left/Right button to eject decks with the default mapping)

@poelzi
Copy link
Contributor Author

poelzi commented Aug 31, 2020

@uklotzde I'm pretty sure I have addressed all your and @Holzhaus comments.

@uklotzde
Copy link
Contributor

uklotzde commented Sep 1, 2020

@uklotzde I'm pretty sure I have addressed all your and @Holzhaus comments.

Thanks. Maybe I got confused by GitHub's various views.

src/track/beats.h Outdated Show resolved Hide resolved
src/track/beats.h Outdated Show resolved Hide resolved
src/library/dlgtrackinfo.h Show resolved Hide resolved
src/track/beatgrid.cpp Outdated Show resolved Hide resolved
src/engine/controls/bpmcontrol.cpp Outdated Show resolved Hide resolved
src/engine/controls/bpmcontrol.cpp Outdated Show resolved Hide resolved
src/library/basetracktablemodel.cpp Outdated Show resolved Hide resolved
@poelzi
Copy link
Contributor Author

poelzi commented Sep 16, 2020

I incorporated the suggestions. The remaining comments where deliberate design decisions

@poelzi
Copy link
Contributor Author

poelzi commented Oct 12, 2020

please merge

@ywwg
Copy link
Member

ywwg commented Oct 12, 2020

@daschuer @uklotzde ping on this pr?

src/library/dlgtrackinfo.cpp Outdated Show resolved Hide resolved
src/track/bpm.h Outdated Show resolved Hide resolved
src/track/bpm.h Outdated Show resolved Hide resolved
src/widget/wtrackmenu.cpp Outdated Show resolved Hide resolved
@uklotzde
Copy link
Contributor

Please enable the pre-commit hooks. I will not review any new PRs as long as the pre-commit build fails.

@uklotzde
Copy link
Contributor

@poelzi Explicitly requesting to merge while the CI builds are obviously failing doesn't speed up the process.

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

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

LGTM, Thank you.

@uklotzde: merge?

@uklotzde
Copy link
Contributor

@daschuer All CI builds are failing!

@poelzi
Copy link
Contributor Author

poelzi commented Oct 13, 2020

@uklotzde sorry, I somehow missed the introduction of the pre-commit hook. I fixed my setup and squished all commits together so the hooks are run correctly and formatting of all files is nice.
Only addition is a fix to the qsscheck script I discovered while testing. I had a LTR locale set and it failed decoding unicode without reporting which file. Enforcing the correct encoding on file open fixed the problem.

@Holzhaus
Copy link
Member

There are some merge conflicts.

@Holzhaus Holzhaus marked this pull request as draft October 18, 2020 13:30
@Be-ing Be-ing changed the base branch from master to main October 23, 2020 23:14
@poelzi poelzi marked this pull request as ready for review October 27, 2020 15:29
@daschuer
Copy link
Member

Can you remember which track you modify? Where they analyzed with the fixed analyzer?

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

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

Thank you. This is now in a merge-able state.

To issue that can be improved: We have no two entries for the lock in the context menu.
It would be nice to have one with a checkbox. This requires to gray out the other entries on the fly with is some extra work.

In case the bpm is locked we may hide the beat grid edit tools.

@uklotzde: Are your issues fixed?

@daschuer
Copy link
Member

daschuer commented Apr 14, 2021

I have skimmed through my tracks, but I have not yet found a one where the analyzer rounding not works. I am really interested in your samples to have a chance to improve the analyzer.

For my understanding these remaining Tracks must be one with two different beat instruments, where Mixxx is able to find a non integer beat that is not more than 20 ms of any of those beats. Can you confirm that?

How about add the rounding feature into the beat_adjust_slower/beat_adjust_faster controls? This can also snap to all fractionals, that are useful for multiplying BPM later.

For my understanding this covers both of our use cases:

  • Easy/Fast way to get full integer bpm
  • Adjustment is done in the deck, not blindly in the library
  • No rounding of big fractions like 0.3 bpm which is IMHO never desired.

@daschuer
Copy link
Member

I have implemented that in #3790
What do you think?

@poelzi
Copy link
Contributor Author

poelzi commented Apr 16, 2021

@daschuer https://sanatonrecords.bandcamp.com/track/already-maged-circle-dance-of-cold-constellations detected as 151.03 for example.
I gave #3790 a spin and even tho it is much better then the current behaviour, I find it quite hard to get 180 bpm exact and then stop at exactly that bpm number and not press any more. The rounding button works every time.

@poelzi
Copy link
Contributor Author

poelzi commented Apr 16, 2021

@poelzi
Copy link
Contributor Author

poelzi commented Apr 16, 2021

@Holzhaus
Copy link
Member

Can we make a wiki page for those analyzer test tracks, so that they don't get lost?

@daschuer
Copy link
Member

We have: https://github.com/mixxxdj/mixxx/wiki/Iconic-Tracks but I must admit I have not updated frequently.

@daschuer
Copy link
Member

I have just checked
https://badgersrecords.bandcamp.com/track/auraka-creeping-inspiration-148-bpm
in mp3 and in the flac version.
both are analyzed to a clean 98,666667 BPM value using const beat grid analyzer setting.
The 3/2 value is 148.00000000000001 which is an issue that double can't express the 98 2/3 value exactly.
I will add rounding to the scale function as well, to fix that.
https://github.com/mixxxdj/mixxx/pull/3790/files

How do you get:
3/2 -> 147.99733777 bpm

@daschuer
Copy link
Member

https://sanatonrecords.bandcamp.com/track/procs-frigolitpuffens-magiska-trampdyna is exactly 140.000 BPM here.

https://sanatonrecords.bandcamp.com/track/already-maged-circle-dance-of-cold-constellations is here 151,01485970 BPM
To fix it, I have corrected the offset at the beginning "!" and adjust the speed to match beats at the end.
This is a single click on "< >" and works also in the 151,03 case. With https://github.com/mixxxdj/mixxx/pull/3790/files. Which is OK IMHO.
The non const detection of this track is a whole mess.
For my understanding we need a at least 250 const beats region (100 s), to rectify not rounding to 150.
I don't see it when skimming through the track. So I think we have discovered a bug. I will have a look.

@poelzi
Copy link
Contributor Author

poelzi commented Apr 16, 2021

@daschuer maybe a compiler difference:
[nix-shell:~/Projects/mixxx-upstream]$ clang --version
clang version 10.0.1
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/6pzqj9q656vc1msa675k75hmhsrfizsy-clang-10.0.1/bin

[----------] Global test environment tear-down
[==========] 671 tests from 92 test suites ran. (58975 ms total)
[ PASSED ] 662 tests.
[ FAILED ] 9 tests, listed below:
[ FAILED ] ControllerScriptEngineLegacyTest.commonScriptHasNoErrors
[ FAILED ] TrackExporterTest.SimpleListExport
[ FAILED ] TrackExporterTest.OverwriteSkip
[ FAILED ] TrackExporterTest.OverwriteAll
[ FAILED ] TrackExporterTest.SkipAll
[ FAILED ] TrackExporterTest.Cancel
[ FAILED ] TrackExporterTest.DedupeList
[ FAILED ] TrackExporterTest.MungeFilename
[ FAILED ] TrackExporterTest.PatternExport

(TrackExporter failures are from merged export branch)

@daschuer
Copy link
Member

I have testes the "creeping-inspiration" with various Machines:

  • Ubuntu Bionic: 148.00000001
  • Ubuntu Focal: 148.00000001
  • Ubuntu Hirsute: 148.00000001
  • Win10: 148.00000001
  • Fedora 34: 147.99733778

So there must be an imprecise issue on Fedora and NixOs.
@uklotzde Can this be related to the test failures with Rubberband? Or gcc 11?

@poelzi
Copy link
Contributor Author

poelzi commented Apr 17, 2021

@daschuer I just recompiled #3790 with gcc instead of clang and got on "creeping-inspiration":

  • Nixos 20.09 with gcc: 148.00000000

Does fedora 34 use clang as default ?

@daschuer
Copy link
Member

I have just tested the mp3 version with Fedora 34 and It works correctly. So only the FLAC version is affected.

This is the mp3 track output:

Debug [AnalyzerThread 0 #1]: adjusting phase by -186.362
Debug [AnalyzerThread 0 #1]: AnalyzerBeats plugin detected 842 beats. Average BPM: 98.6667

And this the flac track output

Debug [AnalyzerThread 0 #1]: adjusting phase by -113.557
Debug [AnalyzerThread 0 #1]: AnalyzerBeats plugin detected 840 beats. Average BPM: 98.6667

both versions are starting with the same beats when using non const and shift apart at 39 s

An Ubuntu Focal I have exactly the same log:

mp3

Debug [AnalyzerThread 0 #2]: adjusting phase by -186.362
Debug [AnalyzerThread 0 #2]: AnalyzerBeats plugin detected 842 beats. Average BPM: 98.6667

Flac

Debug [AnalyzerThread 1 #1]: adjusting phase by -113.557
Debug [AnalyzerThread 1 #1]: AnalyzerBeats plugin detected 840 beats. Average BPM: 98.6667

And judged by eye the same non const beat grid with the same shifting point between mp3 and flac at 39 s.

I am curious where the compiler sensitive part is hidden.

@daschuer
Copy link
Member

@uklotzde I have now build Mixxx with the instructions on our wiki, and the build is working. It is using gcc and based on these: https://github.com/rpmfusion/mixxx/blob/f34/mixxx.spec but I am not able to reproduce the issue that happens with the rpmfusion version. Do I miss something?

@uklotzde
Copy link
Contributor

@uklotzde I have now build Mixxx with the instructions on our wiki, and the build is working. It is using gcc and based on these: https://github.com/rpmfusion/mixxx/blob/f34/mixxx.spec but I am not able to reproduce the issue that happens with the rpmfusion version. Do I miss something?

Last f34 builds: https://koji.rpmfusion.org/koji/buildinfo?buildID=18678

Logs x86_64 build.log: https://koji.rpmfusion.org/kojifiles/packages/mixxx/2.3.0/0.20.beta.20210322git25f342e.fc34/data/logs/x86_64/build.log

@daschuer
Copy link
Member

Strange, I have just build the exact same commit with clang and gcc, but I cannot reproduce the issue with these. Only the rpmfusion version is affected. It is 2.3.0-beta (build beta r20210322git25f342e)
Did something change to the used libraries or compiler?

@uklotzde
Copy link
Contributor

Floating-point rounding may depend on register allocations and optimization settings, i.e. internal 80-bit (long double) vs. 64-bit (double).

https://en.wikipedia.org/wiki/Extended_precision#IEEE_754_extended_precision_formats

@uklotzde
Copy link
Contributor

The behavior might differ depending on compiler versions. It's floating-point, just deal with it. I experienced this behavior >20 years ago when writing rasterization algorithms in C.

@daschuer
Copy link
Member

This can only hardly explained with a double optimization issue. I have the impression there is something more serious going on. Now I cannot reproduce the issue even with the RpmFusion version. To sort out updates, I have cross checked with a fresh installation and and there the issue is gone as well.

@daschuer
Copy link
Member

It looks like we are hunting a phantom. The not updated Fedora version has mixxx build beta r20210126gitf009e06 which has not yet the ironing pr merged. I think that was the original state in my other Fedora reported in #3012 (comment). Than it was auto updated and now it has the ironing PR so I cannot reproduce the issue.

@poelzi: Can you still reproduce the issue if you build the current 2.3 branch with clang?

@poelzi
Copy link
Contributor Author

poelzi commented Jul 8, 2021

@daschuer I merged main, and this is mergeable now.
I just ran main for some days and really miss this changeset, it really improves workflow a lot

@daschuer
Copy link
Member

daschuer commented Jul 8, 2021

Thank you, @uklotzde merge?

Copy link
Contributor

@uklotzde uklotzde left a comment

Choose a reason for hiding this comment

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

Sorry, but this is not ready and contains serious issues.

// called from an engine worker thread
void BpmControl::trackUnloaded(TrackPointer pOldTrack) {
if (pOldTrack) {
disconnect(
Copy link
Contributor

Choose a reason for hiding this comment

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

pOldTrack->disconnect(this)

m_value = std::round(m_value);
}

QString displayString() {
Copy link
Contributor

Choose a reason for hiding this comment

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

const

static double valueFromString(const QString& str, bool* pValid = nullptr);
static QString valueToString(double value);
static int valueToInteger(double value) {
return static_cast<int>(std::round(value));
}

/// Returns a string depending on non zero decimal placess.
Copy link
Contributor

Choose a reason for hiding this comment

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

typo

/// Returns a string depending on non zero decimal placess.
/// If the value is round enough, use 1 decimal places, otherwise 2
/// @param {value} bpm value
static QString displayString(double value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Using the same name for both a static and a non-static function is confusing.

/// If the value is round enough, use 1 decimal places, otherwise 2
/// @param {value} bpm value
static QString displayString(double value) {
if (fabs(round(value * 10) / 10 - value) < 0.001) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Calculate the precision beforehand and then use a single, parameterized QString formatting expression. To reduce redundancy.

// unlock the bpmLock in case force is requested
if (forceBpm) {
wasLocked = isBpmLocked();
setBpmLocked(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Invoking mutating, public functions of Track while the object is locked is forbidden! This could result in deadlocks when emitting signals.

@@ -290,6 +299,10 @@ bool Track::replaceRecord(
bpmUpdatedFlag = trySetBpmWhileLocked(
newRecord.getMetadata().getTrackInfo().getBpm().value());
}

if (forceBpm) {
setBpmLocked(wasLocked);
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, this is not permissible. The object is in an inconsistent state and locked.

@@ -515,48 +555,92 @@ void DlgTrackInfo::clear() {
m_pBeatsClone.clear();

txtLocation->setText("");
txtBitrate->setText("");
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed? Doesn't resetTrackRecord() reset all those fields implicitly? We should check that.

@github-actions
Copy link

github-actions bot commented Oct 7, 2021

This PR is marked as stale because it has been open 90 days with no activity.

@github-actions github-actions bot added the stale Stale issues that haven't been updated for a long time. label Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
library skins stale Stale issues that haven't been updated for a long time. ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants