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
Conversation
src/track/beatmap.cpp
Outdated
@@ -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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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);
src/track/beatmap.cpp
Outdated
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return m_sampleRate.isValid() && m_beats.size() >= kMinNumberOfBeats); | |
return m_sampleRate.isValid() && m_beats.size() >= kMinNumberOfBeats; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ups.
There was a problem hiding this 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
This fixed a debug assertion with one of my artificial test tracks which has one beat only.