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

Sync: Use mixxx::Bpm class #4071

Merged
merged 3 commits into from
Aug 8, 2021
Merged

Conversation

Holzhaus
Copy link
Member

@Holzhaus Holzhaus commented Jul 7, 2021

Marked as draft until @ywwg sync PRs are merged.

@Holzhaus Holzhaus requested a review from ywwg July 7, 2021 20:03
@Holzhaus Holzhaus force-pushed the sync-bpm-refactor branch 2 times, most recently from 5088610 to 8faf04d Compare August 6, 2021 11:39
@Holzhaus Holzhaus marked this pull request as ready for review August 6, 2021 11:39
@Holzhaus
Copy link
Member Author

Holzhaus commented Aug 6, 2021

Except for the leader renaming there were barely any merge conflicts, and all of them were trivial. I think this is ready to merge.

@coveralls
Copy link

coveralls commented Aug 6, 2021

Pull Request Test Coverage Report for Build 1105872166

  • 90 of 96 (93.75%) changed or added relevant lines in 4 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.03%) to 26.027%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/engine/sync/internalclock.cpp 22 23 95.65%
src/engine/sync/enginesync.cpp 25 27 92.59%
src/engine/sync/synccontrol.cpp 40 43 93.02%
Files with Coverage Reduction New Missed Lines %
src/engine/sync/enginesync.cpp 2 85.11%
Totals Coverage Status
Change from base Build 1104640684: 0.03%
Covered Lines: 20036
Relevant Lines: 76981

💛 - Coveralls

Holzhaus added a commit to Holzhaus/mixxx that referenced this pull request Aug 6, 2021
Use `mixxx::audio::SampleRate` instead of `int` in the `EngineMaster`,
`EngineSync` and `InternalClock` code.

The type was not applied to the channel mixer and effects code to reduce
potential merge conflicts with mixxxdj#1966 and mixxxdj#2618.

Based on PR mixxxdj#4071.
Holzhaus added a commit to Holzhaus/mixxx that referenced this pull request Aug 6, 2021
Use `mixxx::audio::SampleRate` instead of `int` in the `EngineMaster`,
`EngineSync` and `InternalClock` code.

The type was not applied to the channel mixer and effects code to reduce
potential merge conflicts with mixxxdj#1966 and mixxxdj#2618.

Based on PR mixxxdj#4071.
Copy link
Member

@ywwg ywwg left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for making this change! Some minor comments.

@@ -12,16 +12,17 @@

namespace {
const mixxx::Logger kLogger("InternalClock");
constexpr mixxx::Bpm kDefaultBpm(124.0);
Copy link
Member

Choose a reason for hiding this comment

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

we've talked about having a mixxx-wide default bpm, have we established one yet? (not needed for this PR)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not aware we have. We can probably add it later on.

mixxx::Bpm SyncControl::getBaseBpm() const {
const mixxx::Bpm bpm = getLocalBpm();
if (!bpm.isValid()) {
return {};
Copy link
Member

@ywwg ywwg Aug 6, 2021

Choose a reason for hiding this comment

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

does {} result in an invalid bpm getting returned? It would be clearer to explicitly return kInvalidBpm.

Copy link
Member Author

@Holzhaus Holzhaus Aug 6, 2021

Choose a reason for hiding this comment

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

Yes, this returns a default constructed Bpm which is invalid (it's the same as mixxx::Bpm(), but repeating the return type is not that nice).

There is no kInvalidBpm. We could add it if you think itvs necessary.

<< bpm << "/" << m_leaderBpmAdjustFactor;
}
if (!bpm.isValid()) {
return {};
Copy link
Member

Choose a reason for hiding this comment

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

as elsewhere, rather than returning "empty" I would prefer to explicitly return the Invalid value

Copy link
Contributor

Choose a reason for hiding this comment

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

That would require to introduce a named constant for default constructed instances of Bpm.

@@ -484,11 +491,14 @@ void SyncControl::updateAudible() {
}

void SyncControl::slotRateChanged() {
double bpm = m_pLocalBpm ? m_pLocalBpm->get() * m_pRateRatio->get() : 0.0;
mixxx::Bpm bpm = getLocalBpm();
if (bpm.isValid()) {
Copy link
Member

Choose a reason for hiding this comment

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

it looks like it would be simpler to early-return if bpm is invalid.

Copy link
Member Author

Choose a reason for hiding this comment

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

Unsure if the rate ratio could be NaN/infinity. Is this a read-only CO? Otherwise Bpm may become invalid due to the multiplication. I restructured the code a bit.

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.

Straightforward refactoring that should be save to merge.

@ywwg Ping.

@uklotzde
Copy link
Contributor

uklotzde commented Aug 8, 2021

Already approved by two of use, will merge now. LGTM

@uklotzde uklotzde merged commit 98262c2 into mixxxdj:main Aug 8, 2021
Holzhaus added a commit to Holzhaus/mixxx that referenced this pull request Aug 8, 2021
Use `mixxx::audio::SampleRate` instead of `int` in the `EngineMaster`,
`EngineSync` and `InternalClock` code.

The type was not applied to the channel mixer and effects code to reduce
potential merge conflicts with mixxxdj#1966 and mixxxdj#2618.

Based on PR mixxxdj#4071.
ronso0 pushed a commit to ronso0/mixxx that referenced this pull request Sep 24, 2021
Use `mixxx::audio::SampleRate` instead of `int` in the `EngineMaster`,
`EngineSync` and `InternalClock` code.

The type was not applied to the channel mixer and effects code to reduce
potential merge conflicts with mixxxdj#1966 and mixxxdj#2618.

Based on PR mixxxdj#4071.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

4 participants