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

Beat map assert fix, single beats #3694

Merged
merged 3 commits into from Mar 14, 2021
Merged

Conversation

daschuer
Copy link
Member

This fixed a debug assertion with one of my artificial test tracks which has one beat only.

@@ -269,7 +269,7 @@ QString BeatMap::getSubVersion() const {
}

bool BeatMap::isValid() const {
return m_sampleRate.isValid() && m_beats.size() > 0;
return m_sampleRate.isValid() && m_beats.size() > 1;
Copy link
Member

Choose a reason for hiding this comment

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

Why is a beatgrid invalid if it has one beat?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because it has no tempo.

Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose this is worth a comment. Better: Introduce a constant constexpr int kMinNumberOfBeats = 2 and place the comment there.

Copy link
Contributor

@uklotzde uklotzde Mar 13, 2021

Choose a reason for hiding this comment

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

Verify class invariant?

DEBUG_ASSERT(m_beats.isEmpty() || m_beats.size() >= kMinNumberOfBeats);

@@ -269,7 +270,7 @@ QString BeatMap::getSubVersion() const {
}

bool BeatMap::isValid() const {
return m_sampleRate.isValid() && m_beats.size() > 0;
return m_sampleRate.isValid() && m_beats.size() >= kMinNumberOfBeats);
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
return m_sampleRate.isValid() && m_beats.size() >= kMinNumberOfBeats);
return m_sampleRate.isValid() && m_beats.size() >= kMinNumberOfBeats;

Copy link
Member Author

Choose a reason for hiding this comment

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

Ups.

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.

Now everyone should be able to understand the code :) LGTM

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

Successfully merging this pull request may close these issues.

None yet

3 participants